Airflow When to use KubernetesExecutor vs KubernetesPodOperator?

1/28/2020

Does the Executor automatically send tasks to pods, or do I need the operator to do that?

Each operator has the "executor_config" param so I'm not sure when to use either.

-- AlanPear
airflow
kubernetes

1 Answer

3/3/2020

They serve different purposes.

Briefly:

KubernetesExecutor: You need to specify one of the supported executors when you set up Airflow. The executor controls how all tasks get run. In the case of the KubernetesExecutor, Airflow creates a pod in a kubernetes cluster within which the task gets run, and deletes the pod when the task is finished.

Basically, you would use this instead of something like Celery.

KubernetesPodOperator: This allows you to, essentially, run a container as a task, and that container will be run inside a pod on a kubernetes cluster.

You'd use this if you if you have containerized workloads that you need to schedule in Airflow, or if you have non-python code you want to execute as Airflow tasks.

Hope that is helpful.

-- brandondtb
Source: StackOverflow