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 2020/10/05 14:30:03 UTC

[GitHub] [airflow] yamrzou commented on issue #10792: Allow labels in KubernetesPodOperator to be templated

yamrzou commented on issue #10792:
URL: https://github.com/apache/airflow/issues/10792#issuecomment-703669984


   @dimberman We are using this to add variables from the dagrun conf to labels, in order to use them to filter pods and logs.
   
   It looks like:
   ```
   # ensure_valid_pod_label is a user-defined macro to make sure the value is a valid Kubernetes pod label
   
   task = KubernetesPodOperator(
       ...,
       labels={
           "is_airflow_pod": "true",
           "run_id": "{{ ensure_valid_pod_label(run_id) }}",
           "element_id": "{{ ensure_valid_pod_label(dag_run.conf.element_id) }}",
           "start_date": "{{ ensure_valid_pod_label(dag_run.conf.start_date) }}",
           "end_date": "{{ ensure_valid_pod_label(dag_run.conf.end_date) }}",
           },
       )
   ```
   I'm not familiar with `pod_template_file`, so I'm not sure if it would be possible.


----------------------------------------------------------------
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