-
Notifications
You must be signed in to change notification settings - Fork 0
/
dag-test.py
32 lines (30 loc) · 894 Bytes
/
dag-test.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
import os
from datetime import timedelta, datetime
from airflow import DAG
from airflow.providers.cncf.kubernetes.operators.spark_kubernetes import SparkKubernetesOperator
from airflow.providers.cncf.kubernetes.sensors.spark_kubernetes import SparkKubernetesSensor
default_args={
'depends_on_past': False,
'email': ['[email protected]'],
'email_on_failure': False,
'email_on_retry': False,
'retries': 1,
'retry_delay': timedelta(minutes=5)
}
dag = DAG(
'dag-spark-hdfs',
default_args={'max_active_runs': 1},
description='submit spark-pi as sparkApplication on kubernetes',
schedule_interval=timedelta(days=1),
start_date=datetime(2023, 3, 9),
catchup=False,
)
t1 = SparkKubernetesOperator(
task_id='hdfs-write',
retries=1,
application_file="write-hdfs.yaml",
namespace="default",
kubernetes_conn_id="myk8s",
do_xcom_push=True,
dag=dag,
)