[英]helm chart: Include multiple lines from values.yaml into configmap
我想创建一个掌舵图,其结果是配置 map,如下所示:
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
我可以通过删除|
来避免错误在myconfigfile1.properties:
在我的values.yaml
,然后我失去了换行符,结果不是我想要的。
非常感谢您提前提供的帮助。
亲切的问候,马丁
写完这个问题几分钟后,我偶然发现了问题 #62432632 convert-a-yaml-to-string-in-helm ,它不能完全回答我的问题,但在它的帮助下,我可以找到正确的语法。
values.yaml
:
myconfig:
myconfigfile1.properties: |-
property11 = value11
property12 = value12
myconfigfile2.properties: |-
property21 = value21
property22 = value22
模板:
apiVersion: v1
kind: ConfigMap
metadata:
name: myconfigmap
data:
{{- range $name, $config := .Values.myconfig }}
{{ $name }}: |-
{{ tpl $config $ | indent 4 }}
{{- end }}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.