apiVersion: apps/v1
kind: Deployment
metadata:
  name: swl-commons-integration
  labels:
    app: swl-commons
    contact: essoto
spec:
  selector:
    matchLabels:
      app: swl-commons-integration
  replicas: 1
  template:
    metadata:
      labels:
        app: swl-commons-integration
    spec:
      volumes:
      - name: cloudsql-commons-credentials
        secret:
          secretName: cloudsql-commons-credentials
      - name: commons-integration-config
        secret:
          secretName: commons-integration-config
      containers:
      - name: commons-integration
        image: swl-eng/commons-integration:latest
        # The following environment variables will contain the database host,
        # user and password to connect to the PostgreSQL instance.
        command: ["node", "/commons/test/integration.js"]
        volumeMounts:
          - name: commons-integration-config
            mountPath: /etc/commons
            readOnly: true
      - name: cloudsql-proxy
        image: gcr.io/cloudsql-docker/gce-proxy:1.11
        command: ["/cloud_sql_proxy",
                  "-instances=nyc-tlc-1225:us-central1:gehl-data-collector-central=tcp:5432",
                  "-credential_file=/secrets/cloudsql/credentials.json"]
        securityContext:
          runAsUser: 2  # non-root user
          allowPrivilegeEscalation: false
        volumeMounts:
          - name: cloudsql-commons-credentials
            mountPath: /secrets/cloudsql
            readOnly: true
