【发布时间】:2021-02-16 02:45:05
【问题描述】:
我正在使用 Helm 部署到 Kubernetes 集群。我研究了 configmap,发现可以从文件中检索数据并将其放入 configmap。
我有以下configmap.yaml:
kind: ConfigMap
apiVersion: v1
metadata:
name: {{ .Values.app.configMap }}
namespace: {{ .Values.app.namespace }}
data:
config.json: |-
{{ .Files.Glob "my-config.json" | indent 2}}
而我的deployment.yaml 包含相关的volumeMount(如果我将实际的json 数据直接放入configmap.yaml 中,那么配置就会部署)。我的 configmap.yaml 和 deployment.yaml 都保存在 /chart/templates 中,但我将 my-config.json 保存在基本 helm 图表目录中,在 templates 文件夹之外。
当我尝试使用图表进行部署时,我收到以下错误:
Error: template: chart/templates/configmap.yaml:8:54: executing "chart/templates/configmap.yaml" at <2>: wrong type for value; expected string; got engine.files
如何在我的 configmap 中使用 .json 文件而不将原始 json 数据直接放入 yaml 文件中?
【问题讨论】:
标签: kubernetes kubernetes-helm configmap