You want to install a third-party application in your cluster with Helm. However, the current Helm chart isn’t extensible enough. Maybe you want to add a specific label (e.g. installed-by=natan) to every Kubernetes resource, but the Helm chart doesn’t allow it.
What do you do?
Fork the Helm chart and modify it
Or render the Helm chart to YAML, edit the YAML manually, then apply
Or Render the Helm chart to YAML, edit the YAML automatically, then apply.
What option is best? Most people would say option 3 because it makes updating the chart much easier in the future.
How can option 3 be implemented? With a little feature called the Helm Post-Render hook, along with an appropriate external tool.
How Post-Render Hooks Work
You run helm install like usual, but add on the —post-render flag and specify an external tool to run.
Helm renders your chart to YAML like usual.
Helm runs your external command line tool to modify the final YAML
Helm continues as usual and installs the modified YAML into the cluster
Easy-peasy. Now you can pull upstream changes to the Helm chart while keeping your own changes.
What command do you actually run in the post-render hook?
We need a command that understands YAML and maybe understands Kubernetes too. A tool that can do things like adding a new label to all Kubernetes resources. It should support all the common ways people want to modify existing Helm charts without writing code.
What is that magical tool? One great option is Kustomize, which we’ll cover next week. (You’re subscribed, right?)