I have a main chart that generates a random password in _helpers.ptl. This random password needs to be used by several subcharts (db and app).
In _helpers.ptl of the main chart:
{{/* Generate db credentials */}}
{{- define "test.dbCredentials" -}}
dbUser: {{ randAlphaNum 16 | quote }}
dbPass: {{ randAlphaNum 32 | quote }}
{{- end }}
configmap.yml of the main chart:
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-configmap
data:
{{- include "test.dbCredentials" . | nindent 2 }}
configmap.yml of the subchart:
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-configmap
data:
{{- include "test.dbCredentials" . | nindent 2 }}
When I debug this, the credentials for main and subcharts are different. Is there a way to generate random values in main, and pass the exact values to several subcharts?