Set extraEnvs ingress variable

11/4/2019

I'm trying to use extraEnv property in order to add additional environment variables to set in the pod using helm charts.

I have a values.yaml file that includes:

controller:
  service:
      loadBalancerIP:
  extraEnvs:
     - name: ev1
       value: 
     - name: ev2
       value

first I've set the loadBalancerIP the following way:

helm template path/charts/ingress --set nginx-ingress.controller.service.loadBalancerIP=1.1.1.1 --output-dir .

In order to set extraEnvs values I've tried to use the same logic by doing:

helm template path/charts/ingress --set nginx-ingress.controller.service.loadBalancerIP=1.1.1.1 --set nginx-ingress.controller.extraEnvs[0].value=valueEnv1--set nginx.controller.extraEnvs[1].value=valueEnv2--output-dir .

But it doesn't work. I looked for the right way to set those variables but couldn't find anything.

-- MagenB
kubernetes
kubernetes-helm
kubernetes-ingress
nginx-ingress
yaml

1 Answer

11/4/2019

Helm --set has some limitations.

Your best option is to avoid using the --set, and use the --values flag with your values.yaml file instead:

helm template path/charts/ingress \
--values=values.yaml

If you want to use --set anyway, the equivalent command should have this notation:

helm template path/charts/ingress \
--set=controller.service.loadBalancerIP=1.1.1.1 \
--set=controller.extraEnvs[0].name=ev1,controller.extraEnvs[0].value=valueEnv1 \
--set=controller.extraEnvs[1].name=ev2,controller.extraEnvs[1].value=valueEnv2 \
--output-dir .
-- Eduardo Baitello
Source: StackOverflow