Lemon Sky
Lemon Sky

Reputation: 697

Kubernetes exec script after helm upgrade

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".

Upvotes: 1

Views: 1108

Answers (1)

Blender Fox
Blender Fox

Reputation: 5625

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.

Upvotes: 1

Related Questions