I am currently deploying my applications in a Kubernetes cluster using Helm. Now I also need to be able to modify some parameter in the values.yaml file for different environments.
For simple charts with only one level this is easy by having different values-local.yaml and values-prod.yaml and add this to the helm install
flag, e.g. helm install --values values-local.yaml
.
But if I have a second layer of subcharts, which also need to distinguish the values between multiple environments, I cannot set a custom values.yaml.
Assuming following structure:
| chart
| Chart.yaml
| values-local.yaml
| values-prod.yaml
| charts
| foo-app
| Chart.yaml
| values-local.yaml
| values-prod.yaml
| templates
| deployments.yaml
| services.yaml
This will not work since Helm is expecting a values.yaml
in subcharts.
My workaround right now is to have an if-else-construct in the subchart/values.yaml and set this in as a global variable in the parent values.yaml.
*foo-app/values.yaml*
{{ - if .Values.global.env.local }}
foo-app:
replicas: 1
{{ else if .Values.global.env.dev}}
foo-app:
replicas: 2
{{ end }}
parent/values-local.yaml
global:
env:
local: true
parent/values-prod.yaml
global:
env:
prod: true
But I hope there is a better approach around so I do not need to rely on these custom flags.
I hope you can help me out on this.