i want to import secret to configmap in a senerio so that customer have their own secret so configmap get value from that secret and if they dont have secret so it get values from values.yaml file.
this is secret file.
apiVersion: v1
kind: Secret
metadata:
name: {{ .Values.keycloak.serviceName }}-smtp-secret
namespace: {{ .Release.Namespace }}
type: Opaque
data:
smtp-host: "{{ .Values.keycloak.smtp.host | b64enc }}"
smtp-from: "{{ .Values.keycloak.smtp.from | b64enc }}"
smtp-fromDisplayName: "{{ .Values.keycloak.smtp.fromDisplayName | b64enc }}"
smtp-port: "{{ .Values.keycloak.smtp.port | quote | b64enc }}"
smtp-ssl: "{{ .Values.keycloak.smtp.ssl | quote | b64enc }}"
smtp-auth: "{{ .Values.keycloak.smtp.auth | quote | b64enc }}"
smtp-username: "{{ .Values.keycloak.smtp.username | b64enc }}"
smtp-password: "{{ .Values.keycloak.smtp.password | b64enc }}"
smtp-starttls: "{{ .Values.keycloak.smtp.starttls | quote | b64enc }}"
this is configmap
apiVersion: v1
kind: ConfigMap
metadata:
name: keycloak-realm-configmap
namespace: {{ .Release.Namespace }}
data:
realm.json: |
{
"smtpServer": {
"host": "{{ (get $secret "smtp-host" ) | default .Values.keycloak.smtp.host }}",
"from": "{{ (get $secret "smtp-auth") | b64enc }}",
"fromDisplayName": "{{ (get $secret "smtp-fromDisplayName" ) | default .Values.keycloak.smtp.fromDisplayName }}",
"port": "{{ (get $secret "smtp-port" ) | default .Values.keycloak.smtp.port }}",
"ssl": "{{ (get $secret "smtp-ssl" ) | default .Values.keycloak.smtp.ssl }}",
"auth": "{{ (get $secret "smtp-auth" ) | default .Values.keycloak.smtp.auth }}",
"username": "{{ (get $secret "smtp-username" ) | default .Values.keycloak.smtp.username }}",
"password": "{{ (get $secret "smtp-password" ) | default .Values.keycloak.smtp.password }}",
"starttls": "{{ (get $secret "smtp-starttls" ) | default .Values.keycloak.smtp.starttls }}",
}