dimberman commented on issue #10037:
URL: https://github.com/apache/airflow/issues/10037#issuecomment-692882853


   Hmm this is an interesting one. 
   
   I think when we made the pod_template_file we did so with the assumption 
that users would have ALL specs in the pod_template file and not attempt to 
modify further. If you have a pod_template_file that you want to modify before 
launching, you can deserialize it using the PodGenerator and then use the `pod` 
parameter for the K8sPodOperator.
   
   Something like this
   
   ```
   from datetime import datetime, timedelta
   from airflow.kubernetes.pod_generator import PodGenerator
   from airflow.models import DAG
   from airflow.contrib.operators.kubernetes_pod_operator import 
KubernetesPodOperator
   
   
   default_args = {
       "owner": "test",
       "start_date": datetime(2019, 10, 17),
       "retries": 1,
       "retry_delay": timedelta(minutes=5),
   }
   
   pod = PodGenerator.deserialize_model_file("path/to/dags/minimal.yaml")
   pod.metadata.namespace="test"
   
   with DAG("bug-report", schedule_interval=None, default_args=default_args) as 
dag:
   
       KubernetesPodOperator(
           task_id="bug-report-task",
           is_delete_operator_pod=False,
           in_cluster=True,
           get_logs=True,
           pod=pod,
       )
   ```
   
   If we documented this use-case better, would this be a reasonable solution 
to the problem? 


----------------------------------------------------------------
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:
[email protected]


Reply via email to