[英]Manipulate Helm chart values (not `values.yaml`) at installation time
Has anyone figured out any way to manipulate the chart (not values.yaml
) when installing Helm charts?有没有人在安装 Helm 图表时想出任何方法来操纵图表(不是
values.yaml
)?
For example, I have a bash script that basically does例如,我有一个基本上可以执行的 bash 脚本
helm3 upgrade --install <options>
Regardless of whatever the value of resources.limits.cpu
is in any of my charts, I want to set it to a specific value when installing any charts.无论
resources.limits.cpu
的值在我的任何图表中是什么,我都想在安装任何图表时将其设置为特定值。 If all my charts were using {{.Values.resources.limits.cpu }}
I could use --set
but my charts are inconsistent.如果我所有的图表都使用
{{.Values.resources.limits.cpu }}
我可以使用--set
但我的图表不一致。 Long term, proper solution is to have consistent charts, but I'm looking for a quick and dirty way.从长远来看,正确的解决方案是拥有一致的图表,但我正在寻找一种快速而肮脏的方式。
I don't think you can change it with helm.我不认为你可以用 helm 改变它。 But you could try using mutating webhook like the one here: https://github.com/garethr/kubernetes-webhook-examples/blob/master/src/app.py#L38-L41 to alter pods spec in flight as they are being created.
但是您可以尝试使用像这里这样的变异 webhook: https://github.com/garethr/kubernetes-webhook-examples/blob/master/src/app.py#L38-L41来改变飞行中的 pod 规范正在创建。
But if you are not using any helm specific features and use it only as templating engine, you can try the following quick and dirty hack:但是,如果您没有使用任何 helm 特定功能并且仅将其用作模板引擎,则可以尝试以下快速而肮脏的 hack:
helm template . | yq e '.spec.template.spec.containers[].resources.limits.cpu = "123"' /dev/stdin
Notice the use of helm template (to render templates) an yq (to change limit values)注意使用helm 模板(渲染模板)和yq (更改限制值)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.