优化
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
from airflow.providers.docker.operators.docker import DockerOperator
|
from airflow.providers.docker.operators.docker import DockerOperator
|
||||||
|
from airflow.providers.cncf.kubernetes.operators.kubernetes_pod import KubernetesPodOperator
|
||||||
import pendulum
|
import pendulum
|
||||||
from airflow import DAG
|
from airflow import DAG
|
||||||
from docker.types import Mount
|
from docker.types import Mount
|
||||||
@@ -10,23 +11,34 @@ with DAG(
|
|||||||
catchup=True,
|
catchup=True,
|
||||||
description="小区自动化入库"
|
description="小区自动化入库"
|
||||||
) as dag:
|
) as dag:
|
||||||
t1 = DockerOperator(
|
k = KubernetesPodOperator(
|
||||||
# 刚才定义的conn id
|
name="comm-add",
|
||||||
docker_conn_id="docker_repo",
|
image="192.168.0.19:9012/comm-add:1.0.1",
|
||||||
# WebServer中点击Admin -> Providers -> Docker对应的Version,如果是auto,可能会报错
|
cmds=["bash", "-cx"],
|
||||||
api_version="2.2.0",
|
arguments=["echo", "10"],
|
||||||
auto_remove=True,
|
labels={"foo": "bar"},
|
||||||
docker_url='unix://var/run/docker.sock',
|
task_id="comm_add",
|
||||||
network_mode='bridge',
|
do_xcom_push=True,
|
||||||
image='192.168.0.19:9012/comm-add:1.0.1',
|
|
||||||
# 临沂为我们的传参,python代码中, 镜像中部分代码
|
|
||||||
# @ click.command()
|
|
||||||
# @ click.option('--city', default="all", help='要计算的城市')
|
|
||||||
#command='python main.py --city {{dag_run.conf["city"] if "city" in dag_run.conf}} else all',
|
|
||||||
command='echo "this is a test message shown from within the container',
|
|
||||||
mounts=[
|
|
||||||
Mount(source="/var/run/docker.sock", target="/var/run/docker.sock", type="bind")
|
|
||||||
],
|
|
||||||
task_id='comm_add'
|
|
||||||
)
|
)
|
||||||
t1
|
|
||||||
|
k.dry_run()
|
||||||
|
# t1 = DockerOperator(
|
||||||
|
# # 刚才定义的conn id
|
||||||
|
# docker_conn_id="docker_repo",
|
||||||
|
# # WebServer中点击Admin -> Providers -> Docker对应的Version,如果是auto,可能会报错
|
||||||
|
# api_version="2.2.0",
|
||||||
|
# auto_remove=True,
|
||||||
|
# docker_url='unix://var/run/docker.sock',
|
||||||
|
# network_mode='bridge',
|
||||||
|
# image='192.168.0.19:9012/comm-add:1.0.1',
|
||||||
|
# # 临沂为我们的传参,python代码中, 镜像中部分代码
|
||||||
|
# # @ click.command()
|
||||||
|
# # @ click.option('--city', default="all", help='要计算的城市')
|
||||||
|
# #command='python main.py --city {{dag_run.conf["city"] if "city" in dag_run.conf}} else all',
|
||||||
|
# command='echo "this is a test message shown from within the container',
|
||||||
|
# mounts=[
|
||||||
|
# Mount(source="/var/run/docker.sock", target="/var/run/docker.sock", type="bind")
|
||||||
|
# ],
|
||||||
|
# task_id='comm_add'
|
||||||
|
# )
|
||||||
|
# t1
|
||||||
Reference in New Issue
Block a user