apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "test.fullname" . }}-config-map
data:
brokerConf: |
{{ .Values.configmap }}
表示以下值。Yaml是对的
configmap: |
key=values
而是值。Yaml是错误的
configmap: |
key=values
key2=values2
模板核心内容
apiVersion: v1
kind: ConfigMap
metadata:
name: test-config-map
data:
brokerConf: |
key=values
key2=values2
误差
Error: YAML parse error on test/templates/config-map.yaml: error converting YAML to JSON: yaml: line 9: could not find expected ':'
helm.go:84: [debug] error converting YAML to JSON: yaml: line 9: could not find expected ':'
YAML parse error on v5-proxy/templates/config-map.yaml
helm.sh/helm/v3/pkg/releaseutil.(*manifestFile).sort
helm.sh/helm/v3/pkg/releaseutil/manifest_sorter.go:146
helm.sh/helm/v3/pkg/releaseutil.SortManifests
helm.sh/helm/v3/pkg/releaseutil/manifest_sorter.go:106
helm.sh/helm/v3/pkg/action.(*Configuration).renderResources
helm.sh/helm/v3/pkg/action/action.go:165
如何修复它?
您可以按如下方式更新configmap
:
apiVersion: v1
kind: ConfigMap
metadata:
name: config-map
data:
brokerConf:
{{ .Values.configmap| indent 4|trim }}
由于data.brokerConf
中的第2行没有正确缩进而导致错误。如下所示,其中key2=values2
在yaml世界中是无效语句,正确的是key2: values2
。
configmap:
key=values
key2=values2
要修复它,我们必须使用indent
,但它会额外缩进第一行。为了解决这个问题,使用trim
。