airflow.providers.cncf.kubernetes.triggers.pod

Module Contents

Classes

ContainerState

Possible container states.

KubernetesPodTrigger

KubernetesPodTrigger run on the trigger worker to check the state of Pod.

class airflow.providers.cncf.kubernetes.triggers.pod.ContainerState[source]

Bases: str, enum.Enum

Possible container states.

See https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase.

WAITING = 'waiting'[source]
RUNNING = 'running'[source]
TERMINATED = 'terminated'[source]
FAILED = 'failed'[source]
UNDEFINED = 'undefined'[source]
class airflow.providers.cncf.kubernetes.triggers.pod.KubernetesPodTrigger(pod_name, pod_namespace, trigger_start_time, base_container_name, kubernetes_conn_id=None, poll_interval=2, cluster_context=None, config_dict=None, in_cluster=None, get_logs=True, startup_timeout=120, startup_check_interval=5, on_finish_action='delete_pod', last_log_time=None, logging_interval=None)[source]

Bases: airflow.triggers.base.BaseTrigger

KubernetesPodTrigger 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 (int) – interval in seconds to check if the pod has already started.

  • 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.

  • logging_interval (int | None) – number of seconds to wait before kicking it back to the operator to print latest logs. If None will wait until container done.

  • last_log_time (pendulum.DateTime | None) – where to resume logs from

serialize()[source]

Serialize KubernetesCreatePodTrigger arguments and classpath.

async run()[source]

Get current pod status and yield a TriggerEvent.

hook()[source]
define_container_state(pod)[source]
static should_wait(pod_phase, container_state)[source]

Was this entry helpful?