ysn
ysn

Reputation: 175

Set ConfigMap values directly from values.yaml in helm

I am trying to build ConfigMap data directly from values.yaml in helm

My Values.yaml

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

And the configMap

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

But the data is empty when checked on the 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>

Can anyone suggest

Upvotes: 1

Views: 3601

Answers (1)

edbighead
edbighead

Reputation: 6334

You are missing indentation in your values.yaml file, check YAML Multiline

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

Also, the suggested syntax for YAML files is to use 2 spaces for indentation, so you may want to change your configmap to {{.Values.myconfiguration | indent 2}}

Upvotes: 1

Related Questions