# TODO: Rename this from study-meta-data to study-server.
apiVersion: apps/v1 
kind: Deployment 
metadata: 
  name: study-meta-data 
  labels: 
    app: study-meta-data 
spec: 
  replicas: 1 
  selector: 
    matchLabels: 
      app: study-meta-data 
  template: 
    metadata: 
      labels: 
        app: study-meta-data 
    spec: 
      containers: 
        - name: study-meta-data 
          image: gcr.io/heroes-hat-dev/study-meta-data:latest
          env: 
            - name: DB_USER 
              valueFrom: 
                secretKeyRef: 
                  name: study-meta-data-db-credentials 
                  key: username 
            - name: DB_PASS 
              valueFrom: 
                secretKeyRef: 
                  name: study-meta-data-db-credentials 
                  key: password 
            - name: DB_NAME 
              valueFrom: 
                secretKeyRef: 
                  name: study-meta-data-db-credentials 
                  key: dbname 
            - name: CLIENT_ID 
              valueFrom: 
                secretKeyRef: 
                  name: study-meta-data-secrets
                  key: CLIENT_ID
            - name: SECRET_KEY 
              valueFrom: 
                secretKeyRef: 
                  name: study-meta-data-secrets
                  key: SECRET_KEY
            - name: BASE_URL
              valueFrom:
                secretKeyRef:
                  name: study-meta-data-secrets
                  key: BASE_URL
            - name: RESPONSE_SERVER
              value: "response-server-np:50000"
            - name: USER_REGISTRATION_SERVER
              value: "user-registration-server-np:50000"
          ports:
          - containerPort: 8080
          readinessProbe:
            httpGet:
              path: /StudyMetaData/ping
              port: 8080
        - name: cloudsql-proxy 
          image: gcr.io/cloudsql-docker/gce-proxy:latest 
          command: ["/cloud_sql_proxy", 
            "-instances=heroes-hat-dev:us-east1:my-studies2=tcp:3306", 
            "-credential_file=/secrets/cloudsql/key.json"] 
          volumeMounts: 
            - name: gcloud-key-volume
              mountPath: /secrets/cloudsql
              readOnly: true 
      volumes: 
        - name: gcloud-key-volume
          secret: 
            secretName: study-meta-data-gcloud-key
