Reputation: 83
how to persist the parameter key values to values.yaml file while use command line to set the values.helm install . --name test --set image.tag=2020 --set image.version=20 how to update this image.tag and image.version values to values.yaml? dry run will give the result but wont update the values.yaml
Upvotes: 7
Views: 9674
Reputation: 99
You can cpy the stuff from kubes when the depl/change is ready with kubectl get -o yaml it is not quite the same of course.
Upvotes: 0
Reputation: 4148
Helm is a package manager, and it's all about automating deployment of kubernetes apps. It's designed to be somewhat static, and only being changed by the creator of the chart.
Values Files provides access to values passed into the chart. Its contents come from multiple sources:
- The
values.yaml
file in the chart- If this is a subchart, the
values.yaml
file of a parent chart- A values file if passed into helm install or helm upgrade with the
-f
flag (helm install -f myvals.yaml ./mychart
)- Individual parameters passed with
--set
(such ashelm install --set foo=bar ./mychart
)
This is the base Hierarchy of the values files, but there is more to it:
Kudos to the creator of this image, unfortunately I wasn't able to find the author to credit him.
values.yaml
file exacly as you are thinking, because the original values.yaml
will keep the state desired by the creator of the chart.helm install
or helm upgrade
.I'll try to exemplify your use scenario:
image: original-image
version: original-version
--set
as in your example helm install --name abc --set image=abc --set version-123
. Resulting in:image: abc
version: 123
version
value but keeping the other values as set, you run: `helm upgrade --set version=124 --reuse-values, here is the result values in effect:image: abc
version: 124
NOTE: As we seen in the flowchart, if you don't specify --reuse-values it will reset the values that were not --set
during the upgrade to back to the original of the chart. In this case image
would again be original-image
.
So, to wrap up your main question:
how to persist --set key values to values.yaml in helm install/upgrade?
You can persist the --set
values during the upgrade
by always using --reuse-values
, however the changes will never be commited to the original template of values.yaml
file.
If you are the owner of the chart, It's the recommended behavior that you create release versions of your chart, so you can keep track of what were the default in each version.
I hope it helps clarifying the issue.
If I can help you any further, let me know in the comments.
Upvotes: 8