安装预生成的 Helm Chart

Install Pre-Generated Helm Chart

我想拦截 helm YAML 并使用 Python 脚本自定义它,然后安装它。我一直在做类似 helm template | python3 script... | kubectl apply -f - 的事情,但当然这不会在我的集群中创建 helm 版本,所以我失去了 helm rollback

我考虑过使用 Kustomize,但它没有我想要的功能。

有没有办法使用预生成的 YAML,例如 helm templatehelm install --dry-run 然后 install/upgrade 使用 helm ?

这不是 post-renderers 的目的吗?

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

我自己还没有使用过它,但如果您想 运行 自己的替代 kustomize,它看起来很有趣。

有关未 kustomize 的示例,请参阅 https://github.com/vmware-tanzu/carvel-ytt/tree/develop/examples/helm-ytt-post-renderer