apiVersion: apps/v1
kind: Deployment
metadata:
  name: mlflow
  namespace: geocrop
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mlflow
  template:
    metadata:
      labels:
        app: mlflow
    spec:
      nodeName: vmi3045103.contaboserver.net
      containers:
      - name: mlflow
        image: ghcr.io/mlflow/mlflow:v2.10.2
        command:
          - sh
          - -c
          - |
            pip install psycopg2-binary
            export ENCODED_PASS=$(python3 -c "import urllib.parse; print(urllib.parse.quote_plus('$DB_PASSWORD'))")
            mlflow server --host=0.0.0.0 --port=5000 --backend-store-uri=postgresql://postgres:$ENCODED_PASS@geocrop-db:5433/geocrop_gis --default-artifact-root=s3://geocrop-models/mlflow-artifacts
        env:
        - name: DB_PASSWORD
          valueFrom:
            secretKeyRef:
              name: geocrop-db-secret
              key: password
        - name: AWS_ACCESS_KEY_ID
          valueFrom:
            secretKeyRef:
              name: geocrop-secrets
              key: minio-access-key
        - name: AWS_SECRET_ACCESS_KEY
          valueFrom:
            secretKeyRef:
              name: geocrop-secrets
              key: minio-secret-key
        - name: MLFLOW_S3_ENDPOINT_URL
          value: http://minio.geocrop.svc.cluster.local:9000
        ports:
        - containerPort: 5000
