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:
      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: uhub.service.ucloud.cn/mirrors/ml_metadata_store_server:1.0.0
        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

