I hope y'all doing great!
I came to a hard time looking for the best way to solve this problem in my project, and finally, I've collected my courage to post this question in Stackoverflow (please don't bully me).
I have a cron job that runs the job for a quite long time to complete the task and this cron job needs a connection to db, so I'm using cloud-sql-proxy.
Currently, I'm using the Kubernetes sidecar pattern, where the cron is the main image and the cloud-sql-proxy image is the side image.
My problem currently is, when my cron job is completed, the cloud-sql-proxy is still running, I tried using this approach https://cotton-ori.medium.com/how-to-terminate-a-side-car-container-in-kubernetes-job-2468f435ca99 where once the cron is completed I kill the cloud-sql-proxy process. But since cloud-sql-proxy image is not allowing other than cloud-sql-proxy executeable anymote, I couldn't implement this approach.
Does anyone here have solution for this problem where
- Cron job wait for the cloud-sql-proxy to be ready
- Once the cloud-sql-proxy is ready, run the cron job
- once the cron job is completed, also stop the cloud-sql-proxy
- The kubernetes pod is completed.
Thank you for your answers. Hope Y'all have a good day!