Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way of creating Helm Charts in a single repository for different deployment environments?

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.

like image 307
user762421 Avatar asked Jan 29 '23 13:01

user762421


1 Answers

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.

like image 173
kscoder Avatar answered Mar 02 '23 00:03

kscoder