将列表设置为Helm中的字段



我的values.yaml中有以下内容

router:
env:
- name: JSON_LOGGING
value: True

在我的Deployment中,我只想将此列表设置为env字段,如下所示:

spec:
containers:
# ..
env: {{ $.Values.router.env }}

然而,这似乎产生了一个不正确的YAML文件:

Error: UPGRADE FAILED: YAML parse error on translation/templates/translation-router.yaml: error converting YAML to JSON: yaml: line 35: did not find expected ',' or ']'

有没有办法做到这一点?

您需要使用toYaml内联部分配置。

spec:
containers:
# ..
env:
{{- toYaml .Values.rounter.env | nindent 6 }}

最新更新