apiVersion: apps/v1
kind: Deployment
metadata:
  name: metadata-grpc-deployment
  labels:
    component: metadata-grpc-server
spec:
  replicas: 1
  selector:
    matchLabels:
      component: metadata-grpc-server
  template:
    metadata:
      labels:
        component: metadata-grpc-server
    spec:
      securityContext:
        seccompProfile:
          type: RuntimeDefault
      containers:
      - name: container
        # ! Sync to the same MLMD version:
        # * backend/metadata_writer/requirements.in and requirements.txt
        # * @kubeflow/frontend/src/mlmd/generated
        # * .cloudbuild.yaml and .release.cloudbuild.yaml
        # * manifests/kustomize/base/metadata/base/metadata-grpc-deployment.yaml
        # * test/tag_for_hosted.sh
        image: gcr.io/tfx-oss-public/ml_metadata_store_server:1.14.0
        securityContext:
          allowPrivilegeEscalation: false
          seccompProfile:
            type: RuntimeDefault
          runAsNonRoot: true
          runAsUser: 1000
          runAsGroup: 0
          capabilities:
            drop:
            - ALL
        env:
        - name: DBCONFIG_USER
          valueFrom:
            secretKeyRef:
              name: mysql-secret
              key: username
        - name: DBCONFIG_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mysql-secret
              key: password
        - name: MYSQL_DATABASE
          valueFrom:
            configMapKeyRef:
              name: pipeline-install-config
              key: mlmdDb
        - name: MYSQL_HOST
          valueFrom:
            configMapKeyRef:
              name: pipeline-install-config
              key: dbHost
        - name: MYSQL_PORT
          valueFrom:
            configMapKeyRef:
              name: pipeline-install-config
              key: dbPort
        command: ["/bin/metadata_store_server"]
        args: ["--grpc_port=8080",
               "--mysql_config_database=$(MYSQL_DATABASE)",
               "--mysql_config_host=$(MYSQL_HOST)",
               "--mysql_config_port=$(MYSQL_PORT)",
               "--mysql_config_user=$(DBCONFIG_USER)",
               "--mysql_config_password=$(DBCONFIG_PASSWORD)",
               "--enable_database_upgrade=true"
               ]
        ports:
        - name: grpc-api
          containerPort: 8080
        livenessProbe:
          tcpSocket:
            port: grpc-api
          initialDelaySeconds: 3
          periodSeconds: 5
          timeoutSeconds: 2
        readinessProbe:
          tcpSocket:
            port: grpc-api
          initialDelaySeconds: 3
          periodSeconds: 5
          timeoutSeconds: 2
      serviceAccountName: metadata-grpc-server

