-
Notifications
You must be signed in to change notification settings - Fork 0
/
kube.py
48 lines (40 loc) · 1.62 KB
/
kube.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from airflow import DAG
from datetime import datetime, timedelta
from airflow.contrib.operators.kubernetes_pod_operator import KubernetesPodOperator
from airflow.operators.dummy_operator import DummyOperator
default_args = {
'owner': 'airflow',
'depends_on_past': False,
'start_date': datetime.utcnow(),
'email': ['[email protected]'],
'email_on_failure': False,
'email_on_retry': False,
'retries': 3,
'retry_delay': timedelta(minutes=5)
}
dag = DAG(
'kubernetes_sample', default_args=default_args, schedule_interval=timedelta(minutes=10))
start = DummyOperator(task_id='run_this_first', dag=dag)
passing = KubernetesPodOperator(namespace='airflow',
image="perl:latest",
cmds=["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"],
arguments=["print('hello world')"],
labels={"foo": "bar"},
name="passing-test",
in_cluster=True,
task_id="passing-task",
get_logs=True,
dag=dag
)
failing = KubernetesPodOperator(namespace='airflow',
image="alpine",
cmds=["exit 1"],
labels={"foo": "bar"},
name="fail",
task_id="failing-task",
in_cluster=True,
get_logs=True,
dag=dag
)
passing.set_upstream(start)
failing.set_upstream(start)