airflow.providers.cncf.kubernetes.executors.kubernetes_executor¶
KubernetesExecutor.
See also
For more information on how the KubernetesExecutor works, take a look at the guide: Kubernetes Executor
Classes¶
Executor for Kubernetes. |
Module Contents¶
- class airflow.providers.cncf.kubernetes.executors.kubernetes_executor.KubernetesExecutor(*args, **kwargs)[source]¶
Bases:
airflow.executors.base_executor.BaseExecutorExecutor for Kubernetes.
- task_queue: queue.Queue[airflow.providers.cncf.kubernetes.executors.kubernetes_executor_types.KubernetesJob] | None = None[source]¶
- result_queue: queue.Queue[airflow.providers.cncf.kubernetes.executors.kubernetes_executor_types.KubernetesResults] | None = None[source]¶
- kube_scheduler: airflow.providers.cncf.kubernetes.executors.kubernetes_executor_utils.AirflowKubernetesScheduler | None = None[source]¶
- task_publish_retries: collections.Counter[airflow.executors.workloads.types.TaskInstanceUuid | airflow.models.taskinstancekey.TaskInstanceKey][source]¶
- pod_launch_attempts: dict[airflow.executors.workloads.types.TaskInstanceUuid | airflow.models.taskinstancekey.TaskInstanceKey, _PodLaunchAttempt][source]¶
- completed: dict[tuple[str, str], airflow.providers.cncf.kubernetes.executors.kubernetes_executor_types.KubernetesResults][source]¶
- create_pods_after: datetime.datetime | None = None[source]¶
- get_pod_combined_search_str_to_pod_map()[source]¶
List the worker pods owned by this scheduler and create a map containing pod combined search str -> pod.
For every pod, it creates two below entries in the map dag_id={dag_id},task_id={task_id},airflow-worker={airflow_worker},<map_index={map_index}>,run_id={run_id}
- get_streaming_task_log(ti, try_number)[source]¶
Return a streaming response for task logs.
Executors that don’t implement this method raise
NotImplementedError; callers should catch that and fall back toget_task_log().- Parameters:
ti (airflow.models.taskinstance.TaskInstance) – A TaskInstance object
try_number (int) – current try_number to read log from
- Returns:
StreamingLogResponse
- Return type:
airflow._shared.logging.remote.StreamingLogResponse
- try_adopt_task_instances(tis)[source]¶
Try to adopt running task instances that have been abandoned by a SchedulerJob dying.
Anything that is not adopted will be cleared by the scheduler (and then become eligible for re-scheduling). Accepted unfinished tasks occupy executor slots until completion is reported.
- Returns:
any TaskInstances that were unable to be adopted
- Return type:
collections.abc.Sequence[airflow.models.taskinstance.TaskInstance]
- revoke_task(*, ti)[source]¶
Revoke task that may be running.
- Parameters:
ti (airflow.models.taskinstance.TaskInstance) – task instance to revoke
- adopt_launched_task(kube_client, pod, tis_to_flush_by_key)[source]¶
Patch existing pod so that the current KubernetesJobWatcher can monitor it via label selectors.
- Parameters:
kube_client (kubernetes.client.CoreV1Api) – kubernetes client for speaking to kube API
pod (kubernetes.client.models.V1Pod) – V1Pod spec that we will patch with new label
tis_to_flush_by_key (dict[airflow.models.taskinstancekey.TaskInstanceKey, airflow.models.taskinstance.TaskInstance]) – TIs that will be flushed if they aren’t adopted
- static get_cli_commands()[source]¶
Vends CLI commands to be included in Airflow CLI.
Override this method to expose commands via Airflow CLI to manage this executor. This can be commands to setup/teardown the executor, inspect state, etc. Make sure to choose unique names for those commands, to avoid collisions.