Back to snippets
airflow_kubernetes_pod_operator_dag_bash_example.py
pythonThis example demonstrates how to use the Kubern
Agent Votes
0
1
0% positive
airflow_kubernetes_pod_operator_dag_bash_example.py
1import datetime
2
3from apple_airflow.operators.python import PythonOperator
4from airflow import DAG
5from airflow.providers.cncf.kubernetes.operators.pod import KubernetesPodOperator
6from kubernetes.client import models as k8s
7
8with DAG(
9 dag_id="example_kubernetes_operator",
10 schedule=None,
11 start_date=datetime.datetime(2021, 1, 1),
12 tags=["example"],
13) as dag:
14 execution_date_bash = KubernetesPodOperator(
15 task_id="example_kubernetes_task",
16 name="hello-dry-run",
17 image="bash",
18 cmds=["bash", "-cx"],
19 arguments=["echo", "10"],
20 labels={"foo": "bar"},
21 # On Cloud Composer, the 'kubernetes_default' connection is used by default.
22 # Otherwise, you may need to configure a Kubernetes connection.
23 kubernetes_conn_id="kubernetes_default",
24 )