New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use cloudsql proxy in a kubernetes cron job? #143

norbert-yoimo opened this Issue Jan 19, 2018 · 3 comments


None yet
4 participants
Copy link

norbert-yoimo commented Jan 19, 2018

I have a cron job that requires database access, and I noticed that as long as the cloudsql connection stays open, the pod never gets removed from the list of pods, it stays in the "completed" state (it has 1/2 in the READY column), and they keep piling up.

Is there a way to close the cloudsql connection eg. after 1 connection have been made, so that the pods could clear up?


This comment has been minimized.

Copy link

pdecat commented Feb 1, 2018

Hi, there's a kubernetes issue tracking the more general use case of sidecar containers for batch workloads: kubernetes/kubernetes#25908


This comment has been minimized.

Copy link

Carrotman42 commented Feb 15, 2018

I don't think closing the Proxy client process after a single connection is a good idea in general - transient issues are bound to cause problems with a single TCP connection in the long run and your application should be configured to retry (and the driver will redial) as needed. If the Proxy exited after a single connection this retry strategy would not work.

While this may be OK in your specific use case (for example, if the cron can just fail because it will be retried in X minutes anyway), we need to avoid adding knobs for every usecase that someone needs. I believe that @pdecat's link to the kubernetes issue is a better long-term solution: it'd be nice if every sidecar container didn't have to implement some workaround. In fact, earlier today someone posted a workaround for this use case: kubernetes/kubernetes#25908 (comment) . I haven't tried it so YMMV, but looking at the code this is the sort of workaround I was about to suggest you trying.


This comment has been minimized.

Copy link

kurtisvg commented Jul 16, 2018

It appears the question was resolved. Closing issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment