I previously added an array/list value to the Helm chart values through the command line using
--set plugins.install[0]='xxx'
I now need to delete this entry, but fail to accomplish it. My goal is to end up with an empty array.
I have already tried with:
--set plugins.install[0]=null
--set plugins.install={}
--set plugins.install=null
But so far it seems that in all three cases one of the corresponding pods no longer starts. So it seems like this is not the way to go? Any advice is welcome.
I also tried --set plugin=[], but then I get an error when upgrading the chart.
range can't iterate over [].
To give some more context: this is about the sonarqube chart.
According to the Helm documentation, you should be able to assign an empty array/list in the following manner.
--set plugins.install=[]
Related
Why write non-secret metadata as PLACEHOLDER in kubernetes yaml files? (from here):
namespace: PLACEHOLDER
Any reason to replace it with a later sed command? why not simply write it inside the yaml file?
Those values are normally replaced or overridden later, either by sed within a CI/CD pipeline like Jenkins, or (as indicated by the question you linked to) by Helm.
With helm, you can override values within the yamls either with a second yaml, or at the command line using --set switches.
So I could have
helm install nginx --values values.yaml --values values2.yaml
and the placeholder value in values.yaml would get overridden by the value in values2.yaml
Placeholders are often used to deliberately break an install is someone tries to install it without passing in the right values.yaml
For example:
helm install my-chart
Could break because of the placeholder value, but
helm install my-chart --values production.values.yaml
would install because the placeholder values are overridden and the chart can install correctly.
Based on my experience, when you see files like this, they might be used in some sort of pipelines to deploy them in multiple clusters. These files, from my prior experience, act like templates when you don't want to go all in with Helm charts for a single ConfigMap or Secret or a different isolated resource. This allows you to replace these placeholders with values corresponding with you cluster, region etc.
Hope this makes sense.
I have a helm chart containing Kubernetes job but unfortunately helm upgrade won't work because the image name is immutable so logically I need to do a delete and install but I will loose my set values.yaml if they were customised in the first place.
How can I keep the values before deleting the chart and use them for new install to simulate an upgrade? I couldn't find anything in documentations or here.
Thanks
EDIT:
First you need to get your previous values with helm get values <release-name>
So you could redirect the values to a file with:
helm get values <release-name> -o yaml > values.yaml
And then do a helm install again
I have helm charts created for a microservice that I have built and everything is working as expected. Now, I have created a new k8s namespace and I want to try to deploy the same helm charts as my old namespace. Although, I have just one value that I need it different while everything else remain the same.
Do I have to create another values.yaml for the new namespace and copy everything over and update the one field I want updated ? Or is there any other way ? I do not want to use the --set method of passing updates to the command line.
David suggested the right way. You can use different values.yaml where you can specify the namespace you want to deploy the chart:
$ helm install -f another-namespace-values.yaml <my-release> .
It's also entirely possible to launch helm chart with multiple values.
For more reading please check values section of helm docs.
I want to deploy nextcloud with helm and a custom value.yaml file that fits my needs. Do i have to specify all values given from the original value.yaml or is it possible to only change the values needed, Eg if the only thing I want to change is the host adress my file can look like this:
nextlcoud:
host: 192.168.178.10
instead of copying this file and changing only a few values.
As the underlying issue was resolved by the answer of user #Kun Li, I wanted to add some examples when customizing Helm charts as well as some additional reference.
As asked in the question:
Do i have to specify all values given from the original value.yaml or is it possible to only change the values needed
In short you don't need to specify all of the values. You can change only some of them (like the host from your question).
The ways to change the values are following:
Individual parameters passed with --set (such as helm install --set foo=bar ./mychart)
A values file if passed into helm install or helm upgrade with the -f flag (helm install -f myvals.yaml ./mychart)
If this is a subchart, the values.yaml file of a parent chart
The values.yaml file in the chart
You can read more about it by following official Helm documentation:
Helm.sh: Docs: Chart template guide: Values files
A side note!
Above points are set in the order of priority. The first one (--set) will have the highest priority to override the values.
Example
A side note!
This examples assume that you are in the directory of a pulled Helm chart and you are using Helm v3
Using the nextcloud Helm chart used in the question you can set the nextcloud.host value by:
Pulling the Helm chart and editing the values.yaml
Creating additional new-values.yaml to pass it in (the values.yaml from Helm chart will be used regardless with lower priority):
$ helm install NAME . -f new-values.yaml
new-values.yaml
nextcloud:
host: 192.168.0.2
Setting the value with helm install NAME . --set nextcloud.host=192.168.0.2
You can check if the changes were done correctly by either:
$ helm template . - as pointed by user #David Maze
$ helm install NAME . --dry-run --debug
you misspelled the nextcloud to nextlcoud in your value file.
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
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:
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.
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.