【发布时间】:2021-09-27 23:02:35
【问题描述】:
我通过 helm 使用以下文件
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-cfg
data:
default.conf: |-
{{ .Files.Get "config/nginx.conf" | nindent 4 }}
我收到以下错误:
错误:ops/templates/config/nginx.conf 上的 YAML 解析错误:将 YAML 转换为 JSON 时出错:yaml:第 4 行:此上下文中不允许映射值
nginx 文件如下所示
nginx.conf
server {
listen 80;
listen [::]:80;
server_name: {{ print "kiftb." .Values.global.host | quote }} // this is the error line
...
带有sever_name 的行会产生错误。
知道怎么解决吗?
更新
正如@Evan 所建议的,我已尝试删除冒号,
server_name {{ print "kiftb." .Values.global.host | quote }}
我得到了一个错误:
error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go value of type releaseutil.SimpleHead
helm.go:81: [debug] error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go value of type releaseutil.SimpleHead
任何想法如何克服这个?有什么解决方法吗?
【问题讨论】:
-
验证yaml文件的好地方yamllint.com
-
@user5756014 - 这不是问题,问题在于使用 helm 值
标签: json nginx kubernetes yaml kubernetes-helm