'Helm get Values depending on environment
I want to select different resources limits/requests depending on the environment (which is given as input)
This is my Values.yaml file inside my chart
resources:
dev:
limits:
cpu: 100m
memory: 100Mi
requests:
cpu: 20m
memory: 10Mi
prod:
limits:
cpu: 1000m
memory: 1000Mi
requests:
cpu: 200m
memory: 100Mi
I deploy the chart using this command:
helm upgrade --install --values=global_values.yaml
and inside global_values.yaml:
global:
environmentSuffix: prod
What I want to do is selecting the right resources based on environmentSuffix (dev ... prod. 4 environemnts in total)
Something like this (it is not working of course):
resources:
limits:
cpu: {{ .Values.resources[.Values.global.environmentSuffix].limits.cpu }}
memory: {{ .Values.resources[.Values.global.environmentSuffix].limits.memory}}
requests:
cpu: {{ .Values.resources[.Values.global.environmentSuffix].requests.cpu }}
memory: {{ .Values.resources[.Values.global.environmentSuffix].requests.memory}}
How can I achieve this?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
