apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: triggers-pubsub-deployment
  name: triggers-pubsub-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: triggers-pubsub-deployment
  template:
    metadata:
      labels:
        app: triggers-pubsub-deployment
    spec:
      containers:
      - name: triggers-pubsub-subscriber
        image: gcr.io/heroes-hat-dev/triggers-pubsub-subscriber:latest
        env:
            - name: DB_USER
              valueFrom:
                secretKeyRef:
                  name: triggers-handler-db-credentials
                  key: username
            - name: DB_PASS
              valueFrom:
                secretKeyRef:
                  name: triggers-handler-db-credentials
                  key: password
            - name: DB_NAME
              valueFrom:
                secretKeyRef:
                  name: triggers-handler-db-credentials
                  key: dbname
            - name: EMAIL_ADDRESS
              valueFrom:
                secretKeyRef:
                  name: triggers-handler-email-credentials
                  key: email_address
            - name: EMAIL_PASS
              valueFrom:
                secretKeyRef:
                  name: triggers-handler-email-credentials
                  key: email_password
            - name: CLOUD_SQL_CONNECTION_NAME
              value: heroes-hat-dev:us-east1:my-studies2
            - name: PROJECT_ID
              value: heroes-hat-dev
            - name: SURVEYS_COLLECTION_PREFIX
              value: SurveyTeamfood-RESPONSES/SurveyTeamfood/Activities
            - name: PYTHONUNBUFFERED
              value: "1"
      - 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/sql_credentials.json"]
        volumeMounts:
          - name: secrets-volume
            mountPath: /secrets/cloudsql
            readOnly: true
      volumes:
        - name: secrets-volume
          secret:
            secretName: triggers-handler-gcloud-key
