I want to dynamically inject multiple key value pairs in the helm chart using –set-string. This is the end goal I am trying to achieve:
apiVersion: v1
kind: ConfigMap
metadata:
name: configmap1
data:
key1: "value1"
key2: "Value2"
Where the following is dynamically injected:
key1: "value1"
key2: "value2"
So, if three key,value pairs are injected, it will render as:
key1: "value1"
key2: "value2"
key3: "value3"
So far I have this in my template yaml file:
apiVersion: v1
kind: ConfigMap
metadata:
name: configmap1
data:
{{- range $env_key, $env_value := .Values.env }}
{{ $env_key }}: "{{ $env_value }}"
{{- end }}
This works well when it picks up the default values of env from values.yaml file:
env:
key1: "value1"
key2: "Value2"
This is how it looks like:
bash-3.2$ helm template my-helmchart
---
apiVersion: v1
kind: ConfigMap
metadata:
name: configmap1
data:
key1: "value1"
key2: "Value2"
bash-3.2$
But I want to inject it using –set-string. This didn’t work:
bash-3.2$ helm template workflow-helmchart --set-string env={key1:value1,key2:value2}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: configmap1
data:
0: "key1:value1"
1: "key2:value2"
bash-3.2$
Any thoughts?