Dr-Denzy commented on issue #10278:
URL: https://github.com/apache/airflow/issues/10278#issuecomment-826830568


   dag file used:
   ```python
   
   from airflow import DAG
   from datetime import datetime, timedelta
   from airflow.example_dags.libs.helper import print_stuff
   from airflow.providers.cncf.kubernetes.operators.kubernetes_pod import 
KubernetesPodOperator
   from airflow.operators.dummy import DummyOperator
   from airflow.operators.python import PythonOperator
   from airflow import configuration as conf
   
   default_args = {
       'owner': 'airflow',
       'depends_on_past': False,
       'start_date': datetime(2021, 1, 1),
       'email_on_failure': False,
       'email_on_retry': False,
       'retries': 1,
       'retry_delay': timedelta(minutes=5),
   }
   
   namespace = conf.get('kubernetes', 'NAMESPACE')
   
   if namespace =='default':
       config_file = '/usr/local/airflow/include/.kube/config'
       in_cluster=False
   else:
       in_cluster=True
       config_file=None
   
   
   with DAG('kpo-pod-template-file-dag', schedule_interval='@once', 
default_args=default_args) as dag:
       start = DummyOperator(task_id='start')
   
       kpo = KubernetesPodOperator(
           namespace=namespace,
           image="hello-world",
           pod_template_file="/opt/airflow/dags/privileged_runner.yaml",
           labels={"foo": "bar"},
           name="airflow-test-pod",
           task_id="task-one",
           in_cluster=in_cluster, 
           cluster_context='kind', 
           config_file=config_file,
           is_delete_operator_pod=False,
           get_logs=True)
   
       executor_config_10278 = PythonOperator(
               task_id="executor_config_10278",
               python_callable=print_stuff,
               executor_config={
                   "KubernetesExecutor": {
                       "volumes": [
                           {
                               "name": "correct_name",
                               "emptyDir": {}
                           }
                       ],
                       "volume_mounts": [
                           {
                               "name": "incorrect_name",
                               "mountPath": "/opt/airflow/mount"
                           }
                       ]
                   }
               }
           )
   
       end = DummyOperator(task_id='end')
   
       start >> kpo >> end
       start >> executor_config_10278 >> end
   
   ```


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