Let's says I have a default values.yml in a Helm chart that looks like:
orders:
- order1
- order2
- order3
Now, I want to override THE ENTIRE LIST, using the usual -f my-values.yaml
syntax, and it contains something like
orders:
- order66
My problem is that in this way, the order66
item gets MERGED in the list, so the list now has:
orders:
- order1
- order2
- order3
- order66
...while I want instead to OVERWRITE the entire list with my custom values.
An example of a real use-case is scrape_configs
in Prometheus values.yml.
What is the syntax to use?
If it's just one simple variable, you should be able to just run:
# helm install my_chart ./mychart -f values.yaml --set my_option=my_value
as explained HERE (search for --set
in that document).
However if it's a longer set of values, things get more complicated.
You can try to use --set-file $file
option and move your values in there.
As shown HERE search for --set-file key=
, so in your case you'll have:
# cat my_values_file
- order1
- order2
- order3
- order66
# helm install my_chart ./mychart -f values.yaml --set-file orders=my_values_file
You can also try running a different approach in "cleaning" the variable and settings it afterward:
# helm install my_chart ./mychart --set orders=null -f values.yaml
So that it's going to be emptied and then set with the content of what's in values.yaml
Be sure to run:
# helm install my_chart ./mychart --dry-run --debug --set orders=null -f values.yaml
to verify what the command will do before actually applying it.
Also, be aware that the order matter, as the right-most operator takes precedence.
Cheers