Search code examples
kubernetes-helmhelmfilehelm3

How to pass dynamic variable in helm file


I tried to pass value to helmfile with --set

 helmfile --file ./myfile.yaml sync --set tag=${TAG}

myfile.yaml
---

releases:
  - name: controll
    namespace: ns
    chart: {{ .Values.chart.path }}
    version: {{ .Values.version | default "" }}
    values:
      - image:
          repository: controller-repo
          tag: {{ .Values.agcm_tag }}
          pullPolicy: Never
      - values/anotherYaml.yaml

I got an error

in myfile.yaml: error during myfile.part.1 parsing: template: stringTemplate:14:25: executing "stringTemplate" at <.Values.tag>: map has no entry for key "tag"

Solution

  • Note that the replacement here starts at the .Values root level.

    What you want to replace here may be the value of agcm_tag

    So you can try the following wording here:

    helmfile --file ./myfile.yaml sync --set agcm_tag=${TAG}
    

    helm doc