helm: Default value doesn't work when overriding array parameters partially via --set
Hi,
I met a strange thing that we have some parameters of a subchart of array type and they are in an custom values.yaml:
mysubchart: portList: - port: 87 endPort: 87 protocol: udp nodePort: 31459
When I override them via --set like this command they are working fine:
helm install mychart --name mychart -f port_values.yaml --set myvalue.port[0].port=83 --set myvalue.port[0].endPort=83
But when I move these parameters to default values.yaml and run with same helm install command without -f, they are not working properly. The result will be:
portList: - port: 83 endPort: 83
That means only the overriden values were rendered, the other two values “nodePort” and “protocol” are missing although they have default value. I tried with latest helm version 2.13.0 and it’s the same.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 13
- Comments: 27 (6 by maintainers)
This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.
Is there any updates on this bug ?
I’ve just encountered this bug, but it’s very annoying since there are arrays everywhere: containers, deployments, ports, etc.
So if I can’t partially override an array with --set option and without nulling all other values of that array, I think it makes arrays practically unusable in Helm 😢
Hi all,
I experiencing the same issue with the array overrides through --set. I read carefully all the comments and I understood that, at the moment, helm is not able to merge what we pass through --set option with the original values.yaml. What it is still not clear to me is why helm become able to do it when I specify which values.yaml file need to be used through the -f/–values option. Could someone help me understanding this?
Thanks
Did nobody merge this fix? Helm still dropping previous data from the overwritten array:
Attached minimal charts. array-overwrite-values-only.zip array-overwrite.zip
@heatherlv This looks like a bug to me.
I investigated this with output shown below. As you found, values are overwritten (
name
andnodePort
). The values doc covers this.it would be nice to have this fixed, the limitation makes sense but it is weird and unintuitive for new users. The best workaround I have found is to replace arrays with maps wherever possible, for example, replace:
with
and in templates, replace
with
Of course, not every list of objects has an obvious identifying field with a unique value that can be promoted to a key like
.name
is in this example; sometimes you end up coming up with pretty contrived keys (like descriptive names that aren’t even used in the template rendering) for maps like this. But if we’re committing to keeping array merge behavior so severely hampered, we should document this technique (or some other similar technique I haven’t considered) as a best practice.The same problem here.
When making
helm template --set test.deployment[0].ooo=ddd v1.2.8/
it’s overriding everything, and nulling other values
Refering to it: