cloud-sql-proxy icon indicating copy to clipboard operation
cloud-sql-proxy copied to clipboard

Document using cloudsql auth proxy in kubernetes jobs

Open tnimni opened this issue 3 years ago • 5 comments

Question

I need to use this in a kubernetes job, While it works in the side car pattern, the job is stuck in NotReady status since the auth proxy never exit.

any way to trigger an exit code with status code that will make the job succeed?

Code

No response

Additional Details

No response

tnimni avatar Sep 11 '23 14:09 tnimni

You can do this with two flags:

  1. --quitquitquit and
  2. --exit-zero-on-sigterm

With both in place, your main task has to call the /quitquitquit endpoint after your job is done and the Proxy will shutdown with a zero exit code.

This is a common enough use case, we'll make this issue about improving documentation about it.

Let me know if you have any other questions.

enocom avatar Sep 11 '23 17:09 enocom

Hello, There will soon be a better piece of documentation on how to make this work correctly in the cloud-sql-proxy-operator project. See cloud-sql-proxy-operator#438.

I will add documentation to this project as well, for users who would rather configure side-car containers themselves.

hessjcg avatar Sep 14 '23 20:09 hessjcg

I experienced a similar issue.

Upon completion, the main container shuts down and makes the recommended curl request (per the example).

The GET function was not working as expected. I was able to successfully shut down the proxy when updating to a POST:

curl -X POST -d '' http://localhost:9092/quitquitquit

This is described in the comments of the example .yaml if you read more closely. I am running gcr.io/cloud-sql-connectors/cloud-sql-proxy:2.6.0 - maybe the GET works in later releases.

EDIT: The GET is supported in 2.7: https://github.com/GoogleCloudPlatform/cloud-sql-proxy/blob/cc76a544a6878ad9f0ef5fb407de314b3f801cbe/CHANGELOG.md?plain=1#L15

millerm avatar Nov 03 '23 18:11 millerm

Yes, GET support was released in 2.7.0.

https://github.com/GoogleCloudPlatform/cloud-sql-proxy/releases/tag/v2.7.0

enocom avatar Nov 03 '23 18:11 enocom

Yes, GET support was released in 2.7.0.

https://github.com/GoogleCloudPlatform/cloud-sql-proxy/releases/tag/v2.7.0

Awesome, thank you! Appreciate all the hard work on the cloud-sql-proxy.

millerm avatar Nov 03 '23 18:11 millerm