我正在使用 Helm 部署到 Kubernetes 集群。我研究了配置映射,发现可以从文件中检索数据并将其放入配置映射中。
我有以下内容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}}
Run Code Online (Sandbox Code Playgroud)
我的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
Run Code Online (Sandbox Code Playgroud)
如何.json在 configmap 中使用该文件而不将原始 json 数据直接放入 yaml 文件中?