Cloud SQL Proxy hangs Kubernetes CronJob

308 views
Skip to first unread message

Valentin Agachi

unread,
Mar 9, 2018, 8:59:46 AM3/9/18
to Google Cloud SQL discuss
Hello,

Has anyone run into issues when using the Cloud SQL Proxy inside a Kubernetes CronJob?

I'm using the SQL proxy inside other Kubernetes Deployments connected according to this guide: https://cloud.google.com/sql/docs/postgres/connect-kubernetes-engine - and this works fine.

However when I try to set up a CronJob with the same configuration for allowing my container to connect to Cloud SQL via the proxy, the cron job never finishes/completes and never triggers again. I have run my CronJob container without the Cloud SQL proxy container attached, and it completes correctly and gets rescheduled.

Any pointers on what could be done to safely close the Cloud SQL Proxy container once my job is complete?

Thanks!

Kurtis Van Gent

unread,
Mar 9, 2018, 11:03:40 AM3/9/18
to Google Cloud SQL discuss
The proxy doesn't run in the background by default. If you are running it in a bash script like environment, you may need to launch the process in the background by appending `&` to the end of the command. You can get the PID of the last background process ran with `$!`, and use that at the end of the script to kill the proxy when you are finished. 
Reply all
Reply to author
Forward
0 new messages