apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: ml-pipeline
  name: ml-pipeline
spec:
  selector:
    matchLabels:
      app: ml-pipeline
  template:
    metadata:
      labels:
        app: ml-pipeline
      annotations:
        cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
    spec:
      securityContext:
        seccompProfile:
          type: RuntimeDefault
      containers:
        - env:
            # Whether or not to publish component logs to the object store.
            - name: PUBLISH_LOGS
              value: "true"
            - name: LOG_LEVEL
              value: "info"
            # Driver / launcher log level during pipeline execution
            - name: PIPELINE_LOG_LEVEL
              value: "1"
            - name: AUTO_UPDATE_PIPELINE_DEFAULT_VERSION
              valueFrom:
                configMapKeyRef:
                  name: pipeline-install-config
                  key: autoUpdatePipelineDefaultVersion
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: OBJECTSTORECONFIG_SECURE
              value: "false"
            - name: OBJECTSTORECONFIG_BUCKETNAME
              valueFrom:
                configMapKeyRef:
                  name: pipeline-install-config
                  key: bucketName
            # relic variables
            - name: DBCONFIG_USER
              valueFrom:
                secretKeyRef:
                  name: mysql-secret
                  key: username
            - name: DBCONFIG_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: mysql-secret
                  key: password
            - name: DBCONFIG_DBNAME
              valueFrom:
                configMapKeyRef:
                  name: pipeline-install-config
                  key: pipelineDb
            - name: DBCONFIG_HOST
              valueFrom:
                configMapKeyRef:
                  name: pipeline-install-config
                  key: dbHost
            - name: DBCONFIG_PORT
              valueFrom:
                configMapKeyRef:
                  name: pipeline-install-config
                  key: dbPort
            # end of relic variables
            - name: DBCONFIG_CONMAXLIFETIME
              valueFrom:
                configMapKeyRef:
                  name: pipeline-install-config
                  key: ConMaxLifeTime
            - name: DB_DRIVER_NAME
              valueFrom:
                configMapKeyRef:
                  name: pipeline-install-config
                  key: dbType
            # MySQL Config
            - name: DBCONFIG_MYSQLCONFIG_USER
              valueFrom:
                secretKeyRef:
                  name: mysql-secret
                  key: username
            - name: DBCONFIG_MYSQLCONFIG_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: mysql-secret
                  key: password
            - name: DBCONFIG_MYSQLCONFIG_DBNAME
              valueFrom:
                configMapKeyRef:
                  name: pipeline-install-config
                  key: pipelineDb
            - name: DBCONFIG_MYSQLCONFIG_HOST
              valueFrom:
                configMapKeyRef:
                  name: pipeline-install-config
                  key: mysqlHost
            - name: DBCONFIG_MYSQLCONFIG_PORT
              valueFrom:
                configMapKeyRef:
                  name: pipeline-install-config
                  key: mysqlPort
            # end of MySQL Config
            - name: OBJECTSTORECONFIG_ACCESSKEY
              valueFrom:
                secretKeyRef:
                  name: mlpipeline-minio-artifact
                  key: accesskey
            - name: OBJECTSTORECONFIG_SECRETACCESSKEY
              valueFrom:
                secretKeyRef:
                  name: mlpipeline-minio-artifact
                  key: secretkey
            - name: V2_DRIVER_IMAGE
              value: ghcr.io/kubeflow/kfp-driver:2.5.0
            - name: V2_LAUNCHER_IMAGE
              value: ghcr.io/kubeflow/kfp-launcher:2.5.0
          image: ghcr.io/kubeflow/kfp-api-server:dummy
          imagePullPolicy: IfNotPresent
          name: ml-pipeline-api-server
          ports:
            - name: http
              containerPort: 8888
            - name: grpc
              containerPort: 8887
          readinessProbe:
            exec:
              command:
                - wget
                - -q # quiet
                - -S # show server response
                - -O
                - "-" # Redirect output to stdout
                - http://localhost:8888/apis/v1beta1/healthz
            initialDelaySeconds: 3
            periodSeconds: 5
            timeoutSeconds: 2
          livenessProbe:
            exec:
              command:
                - wget
                - -q # quiet
                - -S # show server response
                - -O
                - "-" # Redirect output to stdout
                - http://localhost:8888/apis/v1beta1/healthz
            initialDelaySeconds: 3
            periodSeconds: 5
            timeoutSeconds: 2
          # This startup probe provides up to a 60 second grace window before the
          # liveness probe takes over to accomodate the occasional database
          # migration.
          startupProbe:
            exec:
              command:
                - wget
                - -q # quiet
                - -S # show server response
                - -O
                - "-" # Redirect output to stdout
                - http://localhost:8888/apis/v1beta1/healthz
            failureThreshold: 12
            periodSeconds: 5
            timeoutSeconds: 2
          securityContext:
            allowPrivilegeEscalation: false
            runAsNonRoot: true
            runAsUser: 1000
            runAsGroup: 0
            capabilities:
              drop:
                - ALL
          resources:
            requests:
              cpu: 250m
              memory: 500Mi
      serviceAccountName: ml-pipeline
