我正在尝试将 value.yaml 中的以下行添加到带有空格的部署中。但我不能。
在values.yaml中
affinityNode: |
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: nodepool
operator: In
values:
- loadbalancer-pool
在deployment.yaml中
{{- toYaml .Values.affinityNode }}
您可以在值文件中使用普通的 yaml 密钥对而不是多行字符串:
values.yaml
affinityNode:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: nodepool
operator: In
values:
- loadbalancer-pool
部署.yaml
{{- with .Values.affinityNode }}
{{ toYaml . | nindent 8 }} # <- use nindent to fix indentation
{{- end }}
但是如果你想保持原样,只需添加一个
fromYaml
声明:
{{- fromYaml .Values.affinityNode | toYaml }}