I have the following chart:
deployment:
envVars:
- name: FIRST
value: first
- name: SECOND
value: second
I would like to append an extra name/value pair to the chart via the --set command in Helm.
The documentation at https://github.com/helm/helm/blob/master/docs/using_helm.md#the-format-and-limitations-of---set doesn't seem to help me.
I've tried to pass --set deployment.envVars[0].name=APPEND,deployment.envVars[0].value=yes but it says no matches found.
Using Helm 2.10.
Any suggestion?
Try escape square brackets [] with backslash \ in your command, like this --set deployment.envVars\[0\].name=APPEND,deployment.envVars\[0\].value=yes.
In ZSH, this should do it:
helm [...] --set 'ingress.annotations.nginx\.ingress\.kubernetes\.io\/proxy-body-size'=8m
Make sure to properly escape all slashes and dots which aren't object nesting level delimiters in the actual keys of the map, to avoid improper rendering.
Related
set using an array list destroy the values yaml structure
I have powershell script to set a collection of values to a single key in values.yaml
Script
But when I execute the The script The value passed like this
Script result
Actually I want the values like this, But i got this structure only use the set flag like this helm upgrade testing testconfig --set "KeyvautCollection={may0,may1}"
Expected result
I want to pass a dynamic array along with --set flag
In my values.yaml file for helm, I am trying to create a value with quotes but when I run it, it gives a different result
values.yaml
annotation: '"ports": {"88":"sandbox-backendconfig"}}'
{{ .Values.annotation }}
what shows when I do dry run
"ports": {"88":"sandbox-backendconfig"}}
how can I make the single quotes around it show also
When the Helm YAML parser reads in the values.yaml file, it sees that the value of annotation: is a single-quoted string and so it keeps the contents of the value without the outer quotes.
As the YAML spec suggests, you can include single quotes inside a single-quoted string by doubling the quote. It might be more familiar to make this a double-quoted string and use backslash escaping. A third possibility is to make this into a block scalar, which would put the value on a separate line, but wouldn't require any escaping at all.
annotation: '''"ports": {"88":"sandbox-backendconfig"}}'''
annotation: "'\"ports\": {\"88\":\"sandbox-backendconfig\"}}'"
annotation: >-
'"ports": {"88":"sandbox-backendconfig"}}'
I'm not sure what context you're trying to use this in, but if this is a more structured format, you can use Helm's toYaml or toJson functions to build up the annotation value for you.
# values.yaml
ports:
'88': sandbox-backendconfig
# templates/some-resource.yaml
annotations: {{ printf "\"ports\": %s" (toJson .Values.ports) | squote }}
Check the method below,
Values.yaml
annotation: '"ports": {"88":"sandbox-backendconfig"}}'
Template
{{ .Values.annotation | squote }}
This should resolve your issue.
squote will put single quotes around the deduced value.
I am new to helm chart. As part of the requirement I named my values.yaml to customize.yaml
To tell helm engine that I am using custom yaml file, I used the below command.
helm install mychart -f customize.yaml
but now the question is how should I not pass the name of the yaml (customize.yaml) file as part of the command, so the command should be like this
helm install mychart
and helm should know that it will get the values from customize.yaml
without explicitly mentioning it in the command. Is there a way to do this?
I tried to include it in _helpers.tpl but it didn't work
// ValuesfileName is the default values file name.
ValuesfileName = "values.yaml"
values.yaml have been defined as the default file in helm's source code. So, in your case, you may have to build helm from source with your changes.
I'm looking at the helm chart versions from the jupyterhub helm repo: https://jupyterhub.github.io/helm-chart/index.yaml
When I use helm search -l jupyterhub/jupyterhub, the versions come out in the order that they appear in the index.yaml, which is not the order in which they are created (according to the created field in index.yaml)
Is there a way to get the version list sorted by date created?
From the helm point of view no. But you can tweak the output to get what you want, although it's pretty tricky since the versioning/tagging hasn't been consistent for jupyterhub/jupyterhub for example.
Anyhow, I came up with this bash/Ruby one-liner but it's picking it up directly from: https://jupyterhub.github.io/helm-chart/index.yaml
$ curl -s https://jupyterhub.github.io/helm-chart/index.yaml | ruby -ryaml -rjson -rdate -e 'puts YAML.load(ARGF)["entries"]["binderhub"].sort_by {|hsh| hsh["created"] }'
Can I have multiple values.yaml files in a Helm chart?
Something like mychart/templates/internalValues.yaml, mychart/templates/customSettings.yaml, etc?
Accessing properties in a values.yaml file can be done by {{ .Values.property1 }}.
How would I reference the properties in these custom values.yaml files?
Yes, it's possible to have multiple values files with Helm. Just use the --values flag (or -f).
Example:
helm install ./path --values ./internalValues.yaml --values ./customSettings.yaml
You can also pass in a single value using --set.
Example:
helm install ./path --set username=ADMIN --set password=${PASSWORD}
From the official documentation:
There are two ways to pass configuration data during install:
--values (or -f): Specify a YAML file with overrides. This can be specified multiple times and the rightmost file will take precedence
--set (and its variants --set-string and --set-file): Specify overrides on the command line.
If both are used, --set values are merged into --values with higher precedence. Overrides specified with --set are persisted in a configmap. Values that have been --set can be viewed for a given release with helm get values . Values that have been --set can be cleared by running helm upgrade with --reset-values specified.
Helm by default will only use the values.yaml file in the root directory of your chart.
You can ask it to load additional values files when you install. For instance, if you have any settings that point to different databases in different environments:
helm install . -f values.production.yaml
You could also get a similar effect by bundling additional settings as a file, and asking Helm to read the bundled file. Helm provides an undocumented fromYaml template function which can parse the file, so in principle you can do something like
{{- $v := $.Files.Get "more-values.yaml" | fromYaml }}
foo: {{ $v.bar }}
Just to update : As per the current official documentation --set & --values will not be merged
To override values in a chart, use either the '--values' flag and pass in a file or use the '--set' flag and pass configuration from the command line, to force a string value use '--set-string'. In case a value is large and therefore you want not to use neither '--values' nor '--set', use '--set-file' to read the single large value from file.
Also :
You can specify the '--values'/'-f' flag multiple times. The priority will be given to the last (right-most) file specified.