Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to call internal script of pod with pre-delete hook using helm

I want to call a script internal to my pod with a pre-delete hook. With the kubernetes hooks it seems like these are executed inside the actual pod, however from what I can tell, in helm these scripts are run in a separate pod, so they will be unable to interact with any processes running in my pod.

Is there a way to call a script internal to the pod being deleted like kubernetes does with helm?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Helm doesn’t have this capability. A Helm hook always creates a new resource, at some specific point in the install/upgrade/delete life cycle, and this is frequently a Job; that means the new Job will create a new Pod. Helm can’t do kubectl exec or otherwise run imperative commands.

In general, "run a command in a container" isn’t a typical workflow, and you should design your application and deployment to avoid this. As one example, in Kubernetes you can very easily run multiple replicas of a Deployment, and you often will want to run more than one of everything just for basic redundancy. Now, if your shutdown hook needs to run a command in a Pod, which one does it do, and what happens to the other two? If it doesn’t matter which one, then launching a dedicated Job to do the cleanup should work fine as well. If every Pod needs to run it, then putting a shutdown hook in your application will be more reliable and work even in non-Kubernetes contexts.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading