<p>I am using Airflow <code>1.0.15</code>. It is deployed on a Kubernetes cluster using the Airflow official helm charts. And i'm not able to pass an environment variable to the worker pods.</p>
<p>The <code>extraEnv</code> added in the helm chart were added to the scheduler and web pods but not the worker pods which use Kubernetes Executor.</p>
<p>I was able to mount a configmap into the worker pod using the <code>executor_config</code> parameter. But how do we pass an environment variable to a worker pod?</p>

Hemanth S. Vaddi
<p>I hit the same problem trying to pass environment variables to the KubernetesExecutor pods using this <a href="https://github.com/airflow-helm/charts/blob/main/charts/airflow" rel="nofollow noreferrer">airflow-helm community chart</a>.</p>
<p>After a few dead ends trying to set variables via config map and as per <a href="https://airflow.apache.org/docs/apache-airflow/stable/howto/variable.html" rel="nofollow noreferrer">airflow variables doc</a> and <a href="https://airflow.apache.org/docs/apache-airflow/stable/howto/set-config.html" rel="nofollow noreferrer">airflow config doc</a> e.g.:</p>
<pre><code>airflow:
  config:
    AIRFLOW__SCHEDULER__DAG_DIR_LIST_INTERVAL: &quot;30&quot;
    my_env_var: &quot;hello this is your env var&quot;
    AIRFLOW__my_env_var: &quot;hello this is your env var&quot;
    AIRFLOW__VAR__my_env_var: &quot;hello this is your env var&quot;
</code></pre>
<p>I found that setting environment varibales within the below <code>extraEnv:</code> block in helm values.yaml works <a href="https://github.com/airflow-helm/charts/blob/main/charts/airflow/docs/faq/kubernetes/mount-environment-variables.md" rel="nofollow noreferrer">following the documentation in the faq</a>. Setting <code>extaEnv</code> results in values mapping from <a href="https://github.com/airflow-helm/charts/blob/main/charts/airflow/templates/_helpers/pods.tpl#L582-L586" rel="nofollow noreferrer"> helper pods.tpl</a> into the <a href="https://github.com/airflow-helm/charts/blob/main/charts/airflow/files/pod_template.kubernetes-helm-yaml" rel="nofollow noreferrer">k8 pod template file</a>.</p>
<pre><code>airflow:
  extraEnv:
    - name: my_env_var
      value: &quot;hello this is your env var&quot;
    - name: my_other_env_var
      valueFrom:
        secretKeyRef:
          name: my-kubectl-secret
          key: value
</code></pre>
<p>In my case, I create secrets with kubectl or substitute in the values as part of the deployment pipeline. The downside is that my helm chart needs to be updated for each new secret / environment variables.</p>
<p>Lastly, these are <strong>not</strong> set as Airflow variables. They are standard environment variables on kubernetes pod os. In your DAGs and tasks you access them e.g.</p>
<pre><code>def task():
    import os
    var = os.getenv('my_env_var')
    return {
        'message': var
    }
</code></pre>
<p>This <a href="https://stackoverflow.com/a/61816701/4538066">SO answer</a> suggests another method using config-maps.</p>
