如何读取Helm中的模板文件?

问题描述 投票:0回答:1
apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx
  namespace: nginx-ingress
data:
  nginx.ingress.tmpl: {{ (tpl (.Files.Get "nginx.ingress.tmpl") . | quote ) }}

helm中如何读取模板文件?

我收到错误

at :调用 tpl 时出错:“# 配置 for

的 tpl 函数执行期间出错”
kubernetes kubernetes-helm
1个回答
0
投票

试试这个:

apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx
  namespace: nginx-ingress
data:
  {{- $files := .Files }}
  {{- range tuple "nginx.ingress.tmpl" }}
  {{ . }}: |-
        {{ $files.Get . }}
  {{- end }}

https://helm.sh/docs/chart_template_guide/accessing_files/

© www.soinside.com 2019 - 2024. All rights reserved.