apiVersion: apps/v1
kind: Deployment
metadata:
  name: nodewatcher
  namespace: nodewatcher-staging
  labels:
    stage: staging
    name: nodewatcher
    app: nodewatcher
spec:
  selector:
    matchLabels:
      app: nodewatcher
  replicas: 1
  strategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        stage: staging
        name: nodewatcher
        app: nodewatcher
    spec:
      containers:
        - name: prisma
          image: prismagraphql/prisma:1.34
          ports:
            - name: prisma-4466
              containerPort: 4466
          resources:
            requests:
              memory: "1280Mi"
              cpu: "250m"
            limits:
              memory: "2560Mi"
              cpu: "500m"
          env:
            - name: PRISMA_CONFIG
              valueFrom:
                secretKeyRef:
                  name: prisma-config
                  key: prisma-config
            - name: DB_USER
              valueFrom:
                secretKeyRef:
                  name: cloudsql-db-credentials
                  key: username
            - name: DB_PASS
              valueFrom:
                secretKeyRef:
                  name: cloudsql-db-credentials
                  key: password
            - name: DB_NAME
              valueFrom:
                secretKeyRef:
                  name: cloudsql-db-credentials
                  key: dbname
        - name: cloudsql-proxy
          image: gcr.io/cloudsql-docker/gce-proxy:1.16
          command: ["/cloud_sql_proxy",
          "--dir=/cloudsql",
          "-instances=test-installations-222013:europe-west1:kusama-etl=tcp:0.0.0.0:5432",
          "-credential_file=/secrets/cloudsql/credentials.json"]
          resources:
            requests:
              memory: "16Mi"
              cpu: "250m"
            limits:
              memory: "32Mi"
              cpu: "500m"
          volumeMounts:
            - name: cloudsql-instance-credentials
              mountPath: /secrets/cloudsql
      volumes:
        - name: cloudsql-instance-credentials
          secret:
            secretName: cloudsql-instance-credentials
