kuberneteskubernetes-helm

Install Pre-Generated Helm Chart


I want to intercept the helm YAML and customize it using a Python script, and then install it. I have been doing something like helm template | python3 script... | kubectl apply -f - but of course this doesn't create a helm release in my cluster, so I lose out on helm rollback etc.

I have considered using Kustomize but it doesn't have the features that I'd like.

Is there a way to take pre-generated YAML, like that from helm template or helm install --dry-run and then install/upgrade that using helm?


Solution

  • Isn't that what post-renderers are for?

    See https://helm.sh/docs/topics/advanced/#post-rendering

    A post-renderer can be any executable that accepts rendered Kubernetes manifests on STDIN and returns valid Kubernetes manifests on STDOUT. It should return an non-0 exit code in the event of a failure. This is the only "API" between the two components. It allows for great flexibility in what you can do with your post-render process.

    A post renderer can be used with install, upgrade, and template. To use a post-renderer, use the --post-renderer flag with a path to the renderer executable you wish to use:

    $ helm install mychart stable/wordpress --post-renderer ./path/to/executable

    I haven't used it myself yet, but it looks interesting if you want to run your own alternative kustomize.

    See https://github.com/vmware-tanzu/carvel-ytt/tree/develop/examples/helm-ytt-post-renderer for an example that is not kustomize.