4
votes

We are using Helm Charts for deploying a service in several environments on Kubernetes cluster. Now for each environment there are a list of variables like the database url, docker image tag etc. What is the most obvious and correct way of defining Helm related values.yaml in such case where all the Helm template files remain same for all the environment except for some parameters as stated above.

1

1 Answers

8
votes

One way to do this would be using multiple value files, which helm now allows. Assume you have the following values files:

values1.yaml:

image:
  repository: myimage
  tag: 1.3

values2.yaml

image:
  pullPolicy: Always

These can both be used on command line with helm as:

$ helm install -f values1.yaml,values2.yaml <mychart>

In this case, these values will be merged into

image:
  repository: myimage
  tag: 1.3
  pullPolicy: Always

You can see the values that will be used by giving the "--dry-run --debug" options to the "helm install" command.

Order is important. If the same value appears in both files, the values from values2.yaml will take precedent, as it was specified last. Each chart also comes with a values file. Those values will be used for anything not specified in your own values file, as if it were first in the list of values files you provided.

In your case, you could specify all the common settings in values1.yaml and override them as necessary with values2.yaml.