0
votes

I have few set of Environment variables set in all the deployment files in Helm chart. I have set it up these Environment variables again and again. Is there any way in helm chart to set those Env for all the pods. so that I can remove it from my deployment files.

These deployment files has different docker image but few variables such as database_url , some cert locations etc are same for all.

Can I used configMap for this purpose?

1

1 Answers

1
votes

Yes, you can use ConfigMap to set the environment variable for your containers.

ConfigMap file

apiVersion: v1
kind: ConfigMap
metadata:
  name: configmap-name
data:
  VariableName: test

Then you can refer ConfigMap in the deployment file as

envFrom:
  - configMapRef:
    name: configmap-name

Also, it is advisable to use Secret instead of ConfigMap in case of confidential values.