I would like to add that using the Cloud SQL Proxy v2 (gcr.io/cloud-sql-connectors/cloud-sql-proxy:latest) they added the
--quitquitquit endpoint to achieve the same result.
In order to use it, you should do something like the following:
- in your main container's args add
trap “curl -X POST localhost:9091/quitquitquit” EXIT
- in the proxy container, add to the args
--quitquitquitto enable the endpoint
- add to the proxy container ports
- containerPort: 9091(it should not be necessary, but I was not able to make it work without).