这里是我的templates/deployment.yaml
代码段:
volumes:
- name: notebooks
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: "sdfsdf"
{{- else }}
emptyDir: {}
{{- end -}}
- name: logs
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: "sdfsdfdsf"
{{- else }}
emptyDir: {}
{{- end -}}
- name: conf
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: "sdfsdfsdfsdfsd"
{{- else }}
emptyDir: {}
{{- end -}}
目前,我正在获取:
& helm template zeppelin ./
Error: YAML parse error on zeppelin/templates/deployment.yaml: error converting YAML to JSON: yaml: line 95: block sequence entries are not allowed in this context
正在得到我:
在此上下文中不允许使用块序列条目
我尝试清理一下代码:
volumes:
- name: notebooks
persistentVolumeClaim:
claimName: "sdfsdf"
- name: logs
persistentVolumeClaim:
claimName: "sdfsdfdsf"
- name: conf
persistentVolumeClaim:
claimName: "sdfsdfsdfsdfsd"
它被矫正地渲染。
if
语句怎么了?
如果在if / else语句中有一些额外的修饰,会破坏yaml结构。
工作示例:
volumes:
- name: notebooks
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: "sdfsdf"
{{- else }}
emptyDir: {}
{{- end }}
- name: logs
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: "sdfsdfdsf"
{{- else }}
emptyDir: {}
{{- end }}
- name: conf
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: "sdfsdfsdfsdfsd"
{{- else }}
emptyDir: {}
{{- end }}
有关controlling whitespace here的更多信息