【发布时间】:2020-10-07 19:37:27
【问题描述】:
我想创建一个 helm 图表,它会生成如下所示的配置图:
apiVersion: v1
kind: ConfigMap
metadata:
name: myconfigmap
data:
myconfigfile1.properties: |
property11 = value11
property12 = value12
myconfigfile1.properties: |
property21 = value21
property22 = value22
而这部分应可在values.yaml 中配置:
myconfig:
myconfigfile1.properties: |
property11 = value11
property12 = value12
myconfigfile1.properties: |
property21 = value21
property22 = value22
现在我想在values.yaml 中遍历myconfig 的所有孩子并将它们添加到我的helm 模板中。到目前为止我对这个模板的尝试:
apiVersion: v1
kind: ConfigMap
metadata:
name: myconfigmap
data:
# {{- range $key, $val := .Values.myconfig}}
# {{ $key }}: |
# {{ $val }}
# {{- end }}
导致此错误消息:
$ helm install --dry-run --debug ./mychart/ --generate-name
install.go:159: [debug] Original chart version: ""
install.go:176: [debug] CHART PATH: /home/my/helmcharts/mychart
Error: YAML parse error on mychart/templates/myconfig.yaml: error converting YAML to JSON: yaml: line 11: could not find expected ':'
helm.go:84: [debug] error converting YAML to JSON: yaml: line 11: could not find expected ':'
YAML parse error on mychart/templates/myconfig.yaml
我可以通过在我的values.yaml 中删除myconfigfile1.properties: 之后的| 来避免该错误,但是我丢失了换行符,结果不是我想要的。
非常感谢您提前提供的帮助。
亲切的问候, 马丁
【问题讨论】:
标签: kubernetes yaml kubernetes-helm go-templates