from airflow.providers.cncf.kubernetes.operators.kubernetes_pod import KubernetesPodOperator task1 = KubernetesPodOperator( task_id="task1", name="task1", namespace="default", image="busybox", cmds=["echo", "Hello World!"], )
from airflow.providers.cncf.kubernetes.operators.kubernetes_pod import KubernetesPodOperator task2 = KubernetesPodOperator( task_id="task2", name="task2", namespace="default", image="python:3", cmds=["python3"], arguments=["-c", "print('Hello, ' + str(os.environ.get('GREETING')))"], env_vars={"GREETING": "Airflow"}, )
from airflow.providers.cncf.kubernetes.operators.kubernetes_pod import KubernetesPodOperator task3 = KubernetesPodOperator( task_id="task3", name="task3", namespace="default", image="busybox", cmds=["sh", "-c", "ls -l /mnt/airflow"], volumes=[{"name": "data", "hostPath": {"path": "/mnt/data"}}], volume_mounts=[{"name": "data", "mountPath": "/mnt/airflow"}], )This example deploys a pod that will list the contents of a directory mounted from the host machine to the pod using a volume mount. The `KubernetesPodOperator` is a part of the Kubernetes provider package in Apache Airflow.