1

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.

Vikas Rathore
  • 8,242
  • 8
  • 35
  • 54
  • Check this question: https://stackoverflow.com/questions/55958507/helm-templating-variables-in-values-yaml – Emruz Hossain Jan 13 '21 at 09:51
  • Does this answer your question? [Helm - Templating variables in values.yaml](https://stackoverflow.com/questions/55958507/helm-templating-variables-in-values-yaml) – David Maze Jan 13 '21 at 12:19
  • @DavidMaze: Nope. That's totally different thing. I am trying to call one variable's value into another variable in value.yaml only. I guess Rafal is right. I can't use parameters from values.yaml inside values.yaml – Vikas Rathore Jan 13 '21 at 21:07

2 Answers2

2

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
Brini
  • 77
  • 5
1

You can't use parameters from values.yaml inside values.yaml, since the values file is not evaluated.

Rafał Leszko
  • 4,939
  • 10
  • 19