Share common configmap / data


frnd4u.ashok@...
 

I'm newbie to helm and trying to understand and develop helm charts for my organization, so pardon my knowledge on the subject.This is my idea of sharing a common library configmap to access across multiple charts.
I want to identify account number and other details of AWS deployment, so I can set some values accordingly.
Is this correct? I can pass in .Values.account appropriate value and how do I go about accessing in this example account_number
apiVersion: v1
kind: ConfigMap
metadata:
name: aws
data:
account_number:
{{- if eq .Values.account "dev" }}
{{- printf "YX3XX2YX1YX6"}}
{{- else if eq .Values.account "stg" }}
{{- printf "X48XY438611X"}}
{{- else if eq .Values.account "prd" }}
{{- printf "Y83Y23X888X1"}}
{{- end }}


Paul Czarkowski <pczarkowski@...>
 

Hey,

Helm Charts themselves can't access contents of a configmap.  You could either set these values as `global` values and make them available across all charts (if using chart dependencies/child charts - https://helm.sh/docs/chart_template_guide/subcharts_and_globals/ )  or you can create the configmap and then if the other charts mount that configmap as env vars or a file and load them in to each deployment that way.

On Sat, May 9, 2020 at 11:51 AM <frnd4u.ashok@...> wrote:
I'm newbie to helm and trying to understand and develop helm charts for my organization, so pardon my knowledge on the subject.This is my idea of sharing a common library configmap to access across multiple charts.
I want to identify account number and other details of AWS deployment, so I can set some values accordingly.
Is this correct? I can pass in .Values.account appropriate value and how do I go about accessing in this example account_number
apiVersion: v1
kind: ConfigMap
metadata:
name: aws
data:
account_number:
{{- if eq .Values.account "dev" }}
{{- printf "YX3XX2YX1YX6"}}
{{- else if eq .Values.account "stg" }}
{{- printf "X48XY438611X"}}
{{- else if eq .Values.account "prd" }}
{{- printf "Y83Y23X888X1"}}
{{- end }}