'How to call one variable into another in value.yaml of helm chart
How to call one variable to another in value.yaml of a chart? for example, this is the value.yaml
app: "test"
count: 1
frontend:
image: "mydockerhub/$app"
replicaCount: $count
backend:
image: "mydockerhub/backend"
replicaCount: $count
Here one line 1 and 2. I am assigning values to app and count. Now I want to use this variable in defining frontend image and replicacount.
I know I can directly update the variables in values.yaml but the original values.yaml is quite big and complicated.
P.S I am trying to access a parameter's value into another in Value.yaml itself, not any configmap or any other file.
Solution 1:[1]
Can't YAML Anchors be the solution? See https://helm.sh/docs/chart_template_guide/yaml_techniques/
It would give something like this:
app: "test"
count: &appCount 1
frontend:
image: "mydockerhub/$app"
replicaCount: *appCount
backend:
image: "mydockerhub/backend"
replicaCount: *appCount
Solution 2:[2]
You can't use parameters from values.yaml inside values.yaml, since the values file is not evaluated.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Rafał Leszko |
