如何将环境变量从 helmfile values.yaml 传递到图表的 values.yaml?

How to pass environment variables from helmfile values.yaml to chart's values.yaml?

我有一个包含多个图表的 helmfile 版本。每个图表里面有values.yaml。 Рow 使那些 values.yaml 内的值根据环境变化?我知道如何参数化 helmfile 的 values.yaml,但我找不到任何方法将这些值进一步放入图表 values.yaml。有人可以帮我吗?

刚刚意识到 helmfiles values.yaml 它只是 helm --values 的来源。无需执行任何特殊操作。

如果您将值文件命名为 anything.yaml.gotmpl,则 Helmfile 会将其模板应用于该文件,然后再将其用作安装相关图表的值。

所以如果你的helmfile.yaml

environments:
  prod:
    values:
      - domain: prod.example.com
releases:
  - name: a-service
    namespace: a-service
    chart: ./a-service/charts/a-service
    values:
      - ./a-service/charts/a-service/values.yaml.gotmpl # <-- *.gotmpl filename

那么values.yaml.gotmpl可以有

service:
  annotations:
    external-dns.alpha.kubernetes.io/hostname: >-
      a-service.{{ .Values.domain }}
{{/* Expression    ^^^^^^^^^^^^^^   uses per-environment values */}}

你可以用

安装它
helmfile -e prod apply