Bryan Powell
Bryan Powell

Reputation: 107

Helm override values.yaml with set in array

I have seen many questions surrounding this topic but no good answer for what I am seeing. We have a values file like so:

ingress:
  enabled: "false"
  className: ""
  annotations:
    {}
    # kubernetes.io/ingress.class: nginx
    # kubernetes.io/tls-acme: "true"
  hosts:
    - host: chart-example.local
      paths:
        - path: /
          pathType: ImplementationSpecific

We want to override the value of the list item "host". It was my expectation that

helm ... --set ingress.hosts[0].host="www.myhost.com"

would do this, but we are seeing an error stating

no matches found: ingress.hosts[0].host=www.myhost.com

What am I missing? This is Helm 3.9.2 and I'm using zsh on macOS.

Upvotes: 2

Views: 1970

Answers (2)

Cornelius Roemer
Cornelius Roemer

Reputation: 8396

The problem is related to zsh treating square brackets ([ ]) in a special way.

An alternative to setting noglob is to escape the set argument in single quotes (') as follows:

helm ... --set 'ingress.hosts[0].host="www.myhost.com"'
               ^                                      ^

as @WoodyWoodsta mentioned in a comment to the accepted answer.

Upvotes: 1

Hussein Awala
Hussein Awala

Reputation: 5110

Square brackets in Zsh have special meanings, so if you use Zsh (based on your error, I think it's the case), you need just to escape them by putting \ (backslash) before them:

--set ingress.hosts\[0\].host="www.myhost.com"

or by adding noglob before your command:

noglob helm ...

You can also escape them by default by adding this alias to your .zshrc:

alias helm='noglob helm'

Upvotes: 6

Related Questions