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
        image: gcr.io/tfx-oss-public/ml_metadata_store_server:0.21.1
        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: mysql-configmap
              key: mlmd_db
        - name: MYSQL_HOST
          valueFrom:
            configMapKeyRef:
              name: mysql-configmap
              key: host
        - name: MYSQL_PORT
          valueFrom:
            configMapKeyRef:
              name: mysql-configmap
              key: port
        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)"
               ]
        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
