veer1987
veer1987

Reputation: 83

how to persist --set key values to values.yaml in helm install/upgrade

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

Answers (2)

umghhh
umghhh

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

Will R.O.F.
Will R.O.F.

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 as helm install --set foo=bar ./mychart)
  • This is the base Hierarchy of the values files, but there is more to it:

enter image description here Kudos to the creator of this image, unfortunately I wasn't able to find the author to credit him.

  • You can't change the chart values.yaml file exacly as you are thinking, because the original values.yaml will keep the state desired by the creator of the chart.
  • The flowchart above is all about changes made during helm install or helm upgrade.

I'll try to exemplify your use scenario:

  • Chart 1 has the default values with:
image: original-image
version: original-version
  • You decided to deploy this chart changing some values using --set as in your example helm install --name abc --set image=abc --set version-123. Resulting in:
image: abc
version: 123
  • Then you want to upgrade the chart and modify the 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

Related Questions