You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/05/27 20:04:40 UTC

[GitHub] [airflow] Alxander64 commented on issue #16125: KubernetesPodOperator env_vars Jinja Templates Not Used

Alxander64 commented on issue #16125:
URL: https://github.com/apache/airflow/issues/16125#issuecomment-849905482


   Just wanted to add that I've also tried this example blow:
   
   ```
   from airflow.contrib.operators.kubernetes_pod_operator import KubernetesPodOperator
   from kubernetes.client import models as k8s
   
   ds = "{{ ds }}"
   ts = "{{ ts }}"
   
   env_vars = [
       k8s.V1EnvVar("TEST_DS", ds),
       k8s.V1EnvVar("TEST_TS", "{{ ts }}"),
   ]
   
   passing = KubernetesPodOperator(
       namespace='airflow',
       image="python:3.6",
       cmds=["python", "-c"],
       arguments=[f"import os; print('{my_secret}'); print('{ds}'); print('{ts}'); print(os.environ['TEST_DS']); print(os.environ['TEST_TS']); exit(0)"],
       env_vars=env_vars,
       labels={"foo": "bar"},
       name="passing-task",
       task_id="passing-task",
       is_delete_operator_pod=True,
       get_logs=True,
       dag=dag,
   )
   ```
   
   I still get the same result as I originally described. I just realized that this is what the type specification for initializing KubernetesPodOperator expects, but it made no difference.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org