105

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?

3 Answers 3

155

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:

You can specify the '--values'/'-f' flag multiple times. The priority will be given to the last (right-most) file specified.

You can specify the '--set' flag multiple times. The priority will be given to the last (right-most) set specified.

(Thanks to Seth for the updated docs link)

3
  • 13
    Just wanted to note that specifying multiple value files does not merge values which are present in these files which was discussed here: Helm should preform deep merge on multiple values files Commented Jan 15, 2020 at 16:33
  • 5
    @EthanStrider is this still the case? I just tried it and it does merge all the values from multiple values files. I have values.yaml and values-dev.yaml and the end result has all the variables from both files with the last specified file overriding the values from the first file. Simple example from official docs helm.sh/docs/chart_template_guide/values_files
    – Tudor
    Commented Feb 9, 2022 at 23:51
  • @Tudor I have observed the same result: helm does indeed do "deep merging" of the "values-*.yaml" files. I'm on helm v3.15.0-rc.2, fwiw. If this "deep merging" did not work, my current config would fail to function. (two "values.yaml" files that both set subfields under the "grafana" object; both subfields get set, despite the "conflict" of their both containing contents for the "grafana" key)
    – Venryx
    Commented May 18 at 20:27
83

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 }}
8
  • 3
    Specifically, this is what worked for me: {{- $v := (.Files.Get "internalvalues.yaml") | fromYaml }}
    – rockyroad
    Commented Jul 2, 2018 at 7:35
  • Also, I put my file directly under the chart directory.
    – rockyroad
    Commented Jul 2, 2018 at 7:37
  • Woud this be the case if you wanted to run two version of the application? For instance, say I wanted to launch two instances of an nginx container, but one displayed "hello" and the other displayed "Hola", using two different values files inside the same chart, could you launch "nginx1" and nginx2" with two different values?
    – Evan R.
    Commented Dec 20, 2018 at 4:07
  • @JamesIsaac where did you put that snippet? In my use case I am writing an umbrella chart but I don't want to put all the config for all the subcharts in the same values.yaml.
    – David Ham
    Commented Mar 12, 2019 at 15:28
  • I used it for a single helm chart and not an umbrella helm chart. I had placed the snippet at the top of the yaml file.
    – rockyroad
    Commented Mar 20, 2019 at 7:50
9

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.

3
  • 1
    I just tried it and it DOES merge all the values-*.yaml files that I specify. Try it too from the official docs. helm.sh/docs/chart_template_guide/values_files
    – Tudor
    Commented Feb 9, 2022 at 23:54
  • 1
    The docs don't state that files will not be merged. Instead the second part you cited has another sentence after it that makes it more clear: "For example, if both myvalues.yaml and override.yaml contained a key called 'Test', the value set in override.yaml would take precedence"
    – fantaztig
    Commented May 3, 2022 at 11:41
  • @fantaztig Regardless of the docs (which are ambiguous, ie. is that shallow overriding/"precedence" for key "Test1" talking only about scalars, or json trees/objects), helm does indeed merge the "values-*.yaml" files. I'm on helm v3.15.0-rc.2, have tested the "deep merging", and can confirm it works. If this "deep merging" did not work, my current config would fail to function. (two "values.yaml" files that both set subfields under the "grafana" object; both subfields get set, despite the "conflict" of their both containing contents for the "grafana" key)
    – Venryx
    Commented May 18 at 20:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.