Fla*_*vio 7 kubernetes airflow airflow-scheduler
我们从Airflow 1.10.0中的Celery Executor搬走了,因为执行有一些限制,现在我们正在使用KubernetesExecutor.
现在,即使我们subdag_operator直接更改代码,我们也无法并行化某些DAG中的所有任务:https://github.com/apache/incubator-airflow/blob/v1-10-stable/airflow/operators /subdag_operator.py#L38
我们的期望是通过这些修改和使用Kubernetes Executors,我们可以同时扇出所有任务的执行,但我们有相同的行为SequentialExecutor.
这是我们现在的行为:
我们希望使用同时执行所有这些KubernetesExecutor.
小智 1
Airflow 中的 Kubernetes Executor 会将所有第一级任务转变为具有 Local Executor 的 Worker Pod。
这意味着您将让本地执行器来执行您的SubDagOperator.
为了在生成工作 Pod 后在 SubDagOperator 下运行任务,您需要指定parallelism工作 Pod 的配置。因此,如果您对工作 Pod 使用 YAML 格式,则需要将其编辑为类似以下内容。
apiVersion: v1
kind: Pod
metadata:
name: dummy-name
spec:
containers:
- args: []
command: []
env:
###################################
# This is the part you need to add
###################################
- name: AIRFLOW__CORE__PARALLELISM
value: 10
###################################
- name: AIRFLOW__CORE__EXECUTOR
value: LocalExecutor
# Hard Coded Airflow Envs
- name: AIRFLOW__CORE__FERNET_KEY
valueFrom:
secretKeyRef:
name: RELEASE-NAME-fernet-key
key: fernet-key
- name: AIRFLOW__CORE__SQL_ALCHEMY_CONN
valueFrom:
secretKeyRef:
name: RELEASE-NAME-airflow-metadata
key: connection
- name: AIRFLOW_CONN_AIRFLOW_DB
valueFrom:
secretKeyRef:
name: RELEASE-NAME-airflow-metadata
key: connection
envFrom: []
image: dummy_image
imagePullPolicy: IfNotPresent
name: base
ports: []
volumeMounts:
- mountPath: "/opt/airflow/logs"
name: airflow-logs
- mountPath: /opt/airflow/dags
name: airflow-dags
readOnly: false
- mountPath: /opt/airflow/dags
name: airflow-dags
readOnly: true
subPath: repo/tests/dags
hostNetwork: false
restartPolicy: Never
securityContext:
runAsUser: 50000
nodeSelector:
{}
affinity:
{}
tolerations:
[]
serviceAccountName: 'RELEASE-NAME-worker-serviceaccount'
volumes:
- name: dags
persistentVolumeClaim:
claimName: RELEASE-NAME-dags
- emptyDir: {}
name: airflow-logs
- configMap:
name: RELEASE-NAME-airflow-config
name: airflow-config
- configMap:
name: RELEASE-NAME-airflow-config
name: airflow-local-settings
Run Code Online (Sandbox Code Playgroud)
然后,SubDagOperator将按照parallelism指定并行运行任务。
| 归档时间: |
|
| 查看次数: |
340 次 |
| 最近记录: |