airflow.providers.cncf.kubernetes.triggers.pod¶
Classes¶
Possible container states. |
|
KubernetesPodTrigger run on the trigger worker to check the state of Pod. |
Module Contents¶
- class airflow.providers.cncf.kubernetes.triggers.pod.ContainerState[source]¶
-
Possible container states.
See https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase.
- class airflow.providers.cncf.kubernetes.triggers.pod.KubernetesPodTrigger(pod_name, pod_namespace, trigger_start_time, base_container_name, kubernetes_conn_id=None, connection_extras=None, poll_interval=2, cluster_context=None, config_dict=None, in_cluster=None, get_logs=True, startup_timeout=120, startup_check_interval=5, schedule_timeout=120, on_finish_action='delete_pod', on_kill_action='delete_pod', termination_grace_period=None, last_log_time=None, logging_interval=None, trigger_kwargs=None)[source]¶
Bases:
airflow.triggers.base.BaseTriggerKubernetesPodTrigger run on the trigger worker to check the state of Pod.
- Parameters:
pod_name (str) – The name of the pod.
pod_namespace (str) – The namespace of the pod.
kubernetes_conn_id (str | None) – The kubernetes connection id for the Kubernetes cluster.
cluster_context (str | None) – Context that points to kubernetes cluster.
config_dict (dict | None) – Content of kubeconfig file in dict format.
poll_interval (float) – Polling period in seconds to check for the status.
trigger_start_time (datetime.datetime) – time in Datetime format when the trigger was started
in_cluster (bool | None) – run kubernetes client with in_cluster configuration.
get_logs (bool) – get the stdout of the container as logs of the tasks.
startup_timeout (int) – timeout in seconds to start up the pod.
startup_check_interval (float) – interval in seconds to check if the pod has already started.
schedule_timeout (int) – timeout in seconds to schedule pod in cluster.
on_finish_action (str) – What to do when the pod reaches its final state, or the execution is interrupted. If “delete_pod”, the pod will be deleted regardless its state; if “delete_succeeded_pod”, only succeeded pod will be deleted. You can set to “keep_pod” to keep the pod.
on_kill_action (str) – What to do when the trigger is cancelled (e.g. when a deferred task is manually marked as success/failed). If “delete_pod” (default), the pod will be deleted. If “keep_pod”, the pod will not be deleted.
termination_grace_period (int | None) – Optional grace period in seconds for pod termination during cleanup.
logging_interval (int | None) – number of seconds to wait before kicking it back to the operator to print latest logs. If
Nonewill wait until container done.last_log_time (pendulum.DateTime | None) – where to resume logs from
trigger_kwargs (dict | None) – additional keyword parameters to send in the event
- property pod_manager: airflow.providers.cncf.kubernetes.utils.pod_manager.AsyncPodManager[source]¶
- get_task_instance(session)[source]¶
Get the task instance for this trigger from the database (Airflow 2.x only).
- async safe_to_cancel()[source]¶
Whether it is safe to delete the pod during trigger cleanup.
Used only on Airflow < 3.3.0 where the triggerer does not invoke
on_kill()for user kills. Deletion is NOT safe when the task is still in DEFERRED state (triggerer restart).
- async on_kill()[source]¶
Delete the pod when the trigger is cancelled by a user action.
The triggerer invokes this for user-initiated kills on Airflow 3.3.0+ only; on older versions use
cleanup()andsafe_to_cancel()instead.