Search code examples
kuberneteskubernetes-helmhelm3

How to prevent helm upgrade from treating string as bool?


I'm running a helm upgrade command to install a certain chart. 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. I already tried to use ="\"true\"" but that also didn't help.

Any ideas how to tell helm to not convert this to bool? (I do not have control over the helm chart)


Solution

  • You can use helm upgrade --set-string to force Helm to interpret the value as a string.

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

    Note that helm install --set has somewhat unusual syntax and quoting rules; 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.

    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.