简体   繁体   English

如何防止 helm upgrade 将字符串视为布尔值?

[英]How to prevent helm upgrade from treating string as bool?

I'm running a helm upgrade command to install a certain chart.我正在运行helm upgrade命令来安装某个图表。 Of one the values I need to set is like this:我需要设置的值之一是这样的:

helm upgrade --install someService someChart `
             --set coredns.service.annotations."service\.beta\.kubernetes\.io/azure-load-balancer-internal"="true"

I have used this successfully with other charts but on this particular chart I'm getting the error我已经成功地将它与其他图表一起使用,但在这个特定的图表上我得到了错误

Error: unable to build kubernetes objects from release manifest: unable to decode "": json: cannot unmarshal bool into Go struct field ObjectMeta.metadata.annotations of type string

So it looks like helm is automatically converting that true into a bool.所以看起来 helm 会自动将true转换为 bool。 I already tried to use ="\"true\"" but that also didn't help.我已经尝试使用="\"true\""但这也没有帮助。

Any ideas how to tell helm to not convert this to bool?有什么想法可以告诉 helm 不要将其转换为 bool 吗? (I do not have control over the helm chart) (我无法控制舵图)

You can use helm upgrade --set-string to force Helm to interpret the value as a string.您可以使用helm upgrade --set-string强制 Helm 将值解释为字符串。

helm upgrade --install someService someChart \
             --set-string coredns...=true

Note that helm install --set has somewhat unusual syntax and quoting rules;注意helm install --set有一些不寻常的语法和引用规则; you're already seeing this with the need to escape periods within a value name.您已经看到需要在值名称中转义句点。 You might find it clearer to write a YAML (or JSON) file of installation-specific values and pass that with a helm install -f option.您可能会发现编写安装特定值的 YAML(或 JSON)文件并使用helm install -f选项传递它更清晰。

coredns:
  service:
    annotations:
      service.beta.kubernetes.io/azure-load-balancer-internal: "true"
helm upgrade --install someService someChart \
             -f local-values.yaml

This is a separate file from the values.yaml file that's part of the chart, and its values are merged with the chart's values with the local values taking precedence.这是一个独立于图表一部分的values.yaml文件的文件,它的值与图表的值合并,本地值优先。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM