I am trying to insert multiline json string into helm template for base64 encoding required for Kubernetes secret.
Goals:
- helm value is injected into json string
- multi-line json string must be base64 encoded using
b64enc
myfile1.json
does not work but myfile2.json
works.
I prefer not to put entire json file in values.yaml
.
apiVersion: v1
kind: Secret
metadata:
name: {{ template "mychart.fullname" . }}
labels:
app: {{ template "mychart.name" . }}
chart: {{ template "mychart.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
type: Opaque
data:
myfile.json: {{ |-
{
"item1": {
"name": "{{ .Values.item1.name }}"
},
"item2": {
}
} | b64enc }}
myfile2.json: {{ .Values.myfile2 | b64enc }}