Reputation: 187
I have 2 values files with many entries. I'd like to overwrite all entries for a specific key using - "helm template . -f values.yaml -f values-prod.yaml'
For example:
values.yaml
key:
a: 1
b: 2
c: 3
key2:
d: 4
f: 5
values-prod.yaml
key:
c: 33
I'd like the generated values.yaml to be:
key:
c: 33
key2:
d: 4
f: 5
I understand I can setup a value of a key to null for all the sub-keys I want to remove and that would remove it, but I'm wondering if there is a better way.
Upvotes: 3
Views: 4539
Reputation: 160023
There is not. If you think there's a possibility you will want the value to be unset in some or many environments, the best approach is to not provide a default value for it in your chart's values.yaml
file.
# values.yaml
key:
c: 3
# values-dev.yaml
key:
a: 1
# values-prod.yaml
key:
c: 33
You're probably aware of the Helm default
template function and normal if
conditionals, but you can also provide these defaults in code, which on the one hand lets you compute them but on the other can make them be harder to override.
# Use `key2.c` if it's set, but `key.c` otherwise
data:
c: {{ .Values.key2.c | default .Values.key.c | default "no c value" | quote }}
(If the values.yaml
file is the one in your Helm chart, next to the Chart.yaml
file, Helm includes it automatically and at the first position in the option list, and you do not need a helm install -f values.yaml
option.)
Upvotes: 3