where to defining environmental variable in helm-charts?

3/27/2019

I have 2 pods in the aks and first pod is consuming services from second pod. to establish the connection, i need to set env variable. I want to know where to define those env variable in helm

-- sushant kumar
kubernetes
kubernetes-helm

1 Answer

3/27/2019

In deployment.yaml at the path spec.template.spec.containers

It goes something like this

...
spec:
  containers:
    - name: {{ .Chart.Name }}
      image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
      imagePullPolicy: {{ .Values.image.pullPolicy }}
      env:         
        - name: JPDA_ADDRESS
          value: '*:8000'
...

So, once you run the above, if you do kubectl exec my-pod -c my-container -- "echo $JPDA_ADDRESS", it will print *:8000

It is important to understand, that Helm simply manages templates for Kubernetes objects. Helm's deployment.yaml produces a YAML spec for Kube object of kind: Deployment. So, if you want to know every possible field you can specify in deployment.yaml, you can run kubectl explain deployment --recursive anywhere you have kubectl running.

-- Alex Pakka
Source: StackOverflow