Helm pass values to the templates for multiple environment

1/13/2020

I am very newbie on Helm and struggling to configure deployment.yaml.Mychart tree structure looks like below. But how should I pass the values for dev and prod to the deployment.yaml?

For example if I would like to use different replicas for prod should I add another values such as below or deployment.yaml always keep as it is and use mutlipe values.yaml like as below.

 replicas: {{ .Values.replicaCount .values.dev.replicacount }}

Or use only below tag is enough. Let's say if git branch equals to master then use below command

helm install . -f values.production.yaml

If git branch equal to development then use following command

 helm install . -f values.dev.yaml


+-- charts
|   \-- my-chart
|       +-- Chart.yaml        # Helm chart metadata
|       +-- templates
|       |   \-- ...
|       +-- values.yaml       # default values
|       +-- values.dev.yaml   # development override values
|       +-- values.prod.yaml  # production override values
-- semural
kubernetes
kubernetes-helm

1 Answer

1/13/2020

You should have a values.yaml file per environment.

That means that in your templates/deployment.yaml you'll have

 replicas: {{ .Values.replicaCount }}

And then, for each environment you'll have a specific values.yaml. Like:

+-- values.yaml       # default values
+-- values.dev.yaml   # development override values
+-- values.prod.yaml  # production override values
-- RafaƂ Leszko
Source: StackOverflow