Created
November 1, 2022 15:29
-
-
Save fclesio/bb8bf0e0e264817591cb7a235e117761 to your computer and use it in GitHub Desktop.
Sidecar container to connect to Google CloudSQL via Proxy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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