Kubernetes exec script after helm upgrade

1/30/2022

Is there a way to execute some code in pod containers when config maps are updated via helm. Preferrably without a custom sidecar doing constant file watching?

I am thinking along the lines of postStart and preExit lifecycle events of Kubernetes, but in my case a "postPatch".

-- Lemon Sky
events
kubernetes
kubernetes-helm
kubernetes-pod

1 Answer

1/30/2022

This might be something a post-install or post-upgrade hook would be perfect for:

https://helm.sh/docs/topics/charts_hooks/

You can trigger these jobs to start after an install (post-install) and/or after an upgrade (post-upgrade) and they will run to completion before the chart is considered installed or upgraded.

So you can to the upgrade, then as part of that upgrade, the hook would trigger after the update and run your update code. I know the nginx ingress controller chart does something like this.

-- Blender Fox
Source: StackOverflow