apiVersion: apps/v1
kind: Deployment
metadata:
  name: restfull-nodejs-mysql
spec:
  replicas: 1
  selector:
    matchLabels:
      app: restfull-nodejs-mysql
  template:
    metadata:
      labels:
        app: restfull-nodejs-mysql
    spec:
      containers:
      - name: restfull-viyancs
        image: asia.gcr.io/ca-sofiyani-test/viyancs/restfull-nodejs:1.3
      - name: cloud-sql-proxy
        # It is recommended to use the latest version of the Cloud SQL proxy
        # and update on a regular schedule
        image: gcr.io/cloudsql-docker/gce-proxy:1.11
        command:
        - "/cloud_sql_proxy"

        # If connecting from a VPC-native GKE cluster, you can use the
        # following flag to have the proxy connect over private IP
        # - "-ip_address_types=PRIVATE"

        # Replace DB_PORT with the port the proxy should listen on
        # Defaults: MySQL: 3306, Postgres: 5432, SQLServer: 1433
        - "-instances=ca-sofiyani-test:asia-southeast2:restfull-viyancs=tcp:0.0.0.0:3306"

        # This flag specifies where the service account key can be found
        - "-credential_file=/secrets/cloudsql/credentials.json"
        securityContext:
          # The default Cloud SQL proxy image runs as the
          # "nonroot" user and group (uid: 65532) by default.
          runAsNonRoot: false
        volumeMounts:
        - name: cloudsql-instance-credentials
          mountPath: /secrets/cloudsql/
          readOnly: true
      volumes:
      - name: cloudsql-instance-credentials
        secret:
          secretName: cloudsql-instance-credentials
