【问题标题】:Set ConfigMap values directly from values.yaml in helm直接从 helm 中的 values.yaml 设置 ConfigMap 值
【发布时间】:2020-10-28 15:31:38
【问题描述】:

我正在尝试直接从 helm 中的 values.yaml 构建 ConfigMap 数据

我的价值观.yaml

myconfiguration: |-
key1: >
  { "Project" : "This is config1 test"
  }
key2 : >
  {
    "Project" : "This is config2 test"
  }

还有 configMap

apiVersion: v1
kind: ConfigMap
metadata:
  name: poc-secrets-configmap-{{ .Release.Namespace }}
data:
{{.Values.myconfiguration | indent 1}} 

但是在pod上检查时数据是空的

Name:         poc-secrets-configmap-xxx
Namespace:    xxx
Labels:       app.kubernetes.io/managed-by=Helm
Annotations:  meta.helm.sh/release-name: poc-secret-xxx
              meta.helm.sh/release-namespace: xxx

Data
====
Events:  <none>

谁能推荐

【问题讨论】:

    标签: kubernetes-helm configmap


    【解决方案1】:

    您的 values.yaml 文件中缺少缩进,请检查 YAML Multiline

    myconfiguration: |-
      key1: >
        { "Project" : "This is config1 test"
        }
      key2 : >
        {
          "Project" : "This is config2 test"
        }
    

    此外,YAML 文件的建议语法是使用 2 个空格进行缩进,因此您可能需要将 configmap 更改为 {{.Values.myconfiguration | indent 2}}

    【讨论】:

      猜你喜欢
      • 2021-12-18
      • 2022-08-03
      • 2020-10-07
      • 2019-09-15
      • 2020-12-25
      • 2021-06-17
      • 1970-01-01
      • 2018-05-15
      • 1970-01-01
      相关资源
      最近更新 更多