<p>I'm defining the env vars for the pythons airflow dags as follow:</p>
<pre class="lang-py prettyprint-override"><code>from airflow.kubernetes.secret import Secret

db_pass = Secret('env', 'DB_PASS', 'db-credentials', 'db_user')

envs = {
    'JAVA_OPTS':'-XX:MaxRAMPercentage=65.0'
}

with DAG(
        'my_dag',
        start_date=datetime(2023, 2, 7),
        schedule_interval='@hourly',
        catchup=False
) as dag:
    KubernetesPodOperator(
        namespace='jobs',
        image='my-image',
        env_vars=envs,
        labels={'env': 'airflow'},
        secrets=[db_pass],
        configmaps=[&quot;middleware-ips&quot;],
        name='my-dag',
        is_delete_operator_pod=True,
        get_logs=True,
        resources=resources,
        image_pull_secrets='quay-key',
        task_id='my-task',
        startup_timeout_seconds=600,
        dag=dag
    )
</code></pre>
<p>I need to put in env the variable from configmap. It's defined in deployment in kube as follow:</p>
<pre class="lang-yaml prettyprint-override"><code>            - name: MONGO_URL
              valueFrom:
                configMapKeyRef:
                  name: middleware-ips
                  key: mongodb-main
            - name: APP_MONGOCONFIG_URI
              value: mongodb://$(MONGO_URL)/db?compressors=zstd
</code></pre>
<p>How to specify it in the <code>envs</code> variable in the python dag so that the <code>APP_MONGOCONFIG_URI</code> get's to the <code>KubernetesPodOperator</code>?</p>

Izbassar Tolegen
<p>You can configure your pod to load the configmap variables as env var for container by using the argument <code>env_from</code>:</p>
<pre class="lang-py prettyprint-override"><code>    KubernetesPodOperator(
        ...,
        env_from=[k8s.V1EnvFromSource(config_map_ref=k8s.V1ConfigMapEnvSource(name='configmap-name'))],
        ...,
    )
</code></pre>
<p>And if you want to map a single var from the configmap:</p>
<pre class="lang-py prettyprint-override"><code>    KubernetesPodOperator(
        ...,
        env_vars=[
            k8s.V1EnvVar(
                name=&quot;MONGO_URL&quot;,
                value_from=k8s.V1EnvVarSource(
                    config_map_key_ref=k8s.V1ConfigMapKeySelector(name=&quot;middleware-ips&quot;, key=&quot;mongodb-main&quot;)
                ),
            ),
        ]
        ...,
    )
</code></pre>
<p>But you cannot use this with your envs dict, you need to transform it to the same format:</p>
<pre class="lang-py prettyprint-override"><code>envs = [
    k8s.V1EnvVar(
        name=&quot;MONGO_URL&quot;,
        value_from=k8s.V1EnvVarSource(
            config_map_key_ref=k8s.V1ConfigMapKeySelector(name=&quot;middleware-ips&quot;, key=&quot;mongodb-main&quot;)
        ),
    ),
    k8s.V1EnvVar(name=&quot;JAVA_OPTS&quot;, value=&quot;-XX:MaxRAMPercentage=65.0&quot;)
]
</code></pre>
