Skip to content

Instantly share code, notes, and snippets.

@fclesio
Created November 1, 2022 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fclesio/bb8bf0e0e264817591cb7a235e117761 to your computer and use it in GitHub Desktop.
Save fclesio/bb8bf0e0e264817591cb7a235e117761 to your computer and use it in GitHub Desktop.
Sidecar container to connect to Google CloudSQL via Proxy
apiVersion: v1
kind: Pod
metadata:
name: test-proxy-deploy
spec:
volumes:
- name: secret-volume
secret:
secretName: cloud_sql_key_secret
containers:
- name: test-proxy-pod
image: ubuntu
command: ["/bin/sh","-c"]
args:
- |
apt-get update \
&& apt-get -y install curl \
&& apt-get -y install wget \
&& apt-get -y install postgresql-client \
&& wget "https://storage.googleapis.com/cloudsql-proxy/v1.32.0/cloud_sql_proxy.linux.amd64" -O cloud_sql_proxy \
&& chmod +x cloud_sql_proxy \
&& ./cloud_sql_proxy -instances=PROJECT-NAME:REGION:DATABASE-NAME=tcp:0.0.0.0:5432 -ip_address_types=PRIVATE -credential_file=etc/config/cloud_sql_key.json
imagePullPolicy: IfNotPresent
volumeMounts:
- name: secret-volume
mountPath: /etc/config
readOnly: false
- name: test-connection-pod
image: ubuntu
command: ["/bin/sh","-c"]
args:
- |
apt-get update \
&& apt-get -y install curl \
&& apt-get -y install wget \
&& apt-get -y install postgresql-client \
&& sleep 1000000
imagePullPolicy: IfNotPresent
volumeMounts:
- name: secret-volume
mountPath: /etc/config
readOnly: false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment