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.
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 am using helm chart for my kubernetes deployment as it is easy to set arguments in Helm as compared to kubernetes.
I had one Argument set in my kubernetes deployment file
args : ['--country=USA']
How to set these parameter in values.yaml file and then in deployment file of helm chart so that I can run the helm install command with parameters
helm install --set country='London' -f helm/values.yaml helm
This command I am trying to pass the arguments but it's still taking the old values.
Can anyone tell me how to do it and what changes should I make in values.yaml and in my deployment file
So for a command like this
helm install --set country='England' mychart ./helmchart
You would have a values.yaml looking something like this
country: USA
And a deployment template containing
args: ['--country={{ .Values.country }}']
Edit: As discussed in the comments, if you want the number of arguments, and their names, to be set dynamically, you can instead do something like this
helm install --set cliargs='country=England city=London'
with a values.yaml
cliargs: ""
and a deployment template containing
args: ["{{ .Values.cliargs }}"]
Check helm.sh/docs for more details. This is all explained there.
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.
I try use helm install --name my-release stable/superset to deploy the superset on Kubernetes. But, I need change the default config. in the helm chart this is not clear. Can someone help?
helm fetch
You can use helm fetch to Download a chart to your local directory, so You can change the values in values.yaml file and then install it.
for example
helm fetch stable/superset --untar
Use text editor to change the values file
nano superset/values.yaml
Part of values.yaml is configFile, so as I can understand in link provided by You, you can change defaults here.
configFile: |-
#---------------------------------------------------------
# Superset specific config
#---------------------------------------------------------