我的配置映射模板
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Values.configmap.name }}
binaryData:
{{- range .Values.configmap.binaryData }}
{{ .key }}: {{ .value }}
{{- end }}
我设置 configmap 的 values.yaml
看起来像这样
...
configmap:
name: foo
binaryData:
- key: file1
value: something_as_base64
- key: file2
value: something_as_base64
- key: file3
value: something_as_base64
...
有效方法:我可以设置所有数组项
helm upgrade foo_name bar_dir \
--set configmap.binaryData[0].key=file1 --set configmap.binaryData[0].value=xyz \
--set configmap.binaryData[1].key=file2 --set configmap.binaryData[1].value=xyz \
--set configmap.binaryData[N].key=file2 --set configmap.binaryData[N].value=xyz
什么不起作用:更新 file2 的值(数组[N]),仅一项
helm upgrade foo_name bar_dir \
--set configmap.binaryData[1].key=file2 --set configmap.binaryData[1].value=xyz \
错误
Error: UPGRADE FAILED: template: foo-helm/templates/configmap.yaml:x:y: executing "foo-helm/templates/configmap.yaml" at <.key>: nil pointer evaluating interface {}.key
- 是否有专门更新数组第 N 项的语法?
- 此外,如果我的 value.yaml 数组中有 5 个项目,并且我设置了 array[0],则 [1-4] 会被截断
最佳答案
关于kubernetes - Helm 套件选项(--set)|更新数组的第 N 个键值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63322925/