Helm 简单 for 循环

Helm simple for loop

我找不到使用 helm 模板迭代一个简单范围 10 -> 20 的方法。

{{range 10 until 20 }}
    - port: {{ . }}
      targetPort: {{ . }}
      protocol: TCP
      name: brick-{{ . }}
{{end}}

Helm 使用标准的 Go text/template system for rendering templates, plus (most of) the Sprig extension library, plus a couple more things. In particular, Sprig includes until and untilStep 函数生成数字列表,然后您可以 range 覆盖。所以你应该能够:

{{- range untilStep 10 20 1 }}
    - port: {{ . }}
      ...
{{- end }}