airflow.providers.cncf.kubernetes.kube_client

Client for kubernetes communication.

Attributes

log

has_kubernetes

Functions

configure_tcp_keepalive(configuration)

Enable TCP keepalive on the Kubernetes client configuration.

get_kube_client([in_cluster, cluster_context, config_file])

Retrieve Kubernetes client.

get_async_kube_client([in_cluster, cluster_context, ...])

Retrieve an asynchronous Kubernetes client.

Module Contents

airflow.providers.cncf.kubernetes.kube_client.log[source]
airflow.providers.cncf.kubernetes.kube_client.has_kubernetes = True[source]
airflow.providers.cncf.kubernetes.kube_client.configure_tcp_keepalive(configuration)[source]

Enable TCP keepalive on the Kubernetes client configuration.

This prevents connections from hanging indefinitely when an idle connection is timed out by services like cloud load balancers or firewalls. The options are set through Configuration.socket_options, which the client passes on to its urllib3 pool manager.

See https://github.com/apache/airflow/pull/11406 for the original discussion.

airflow.providers.cncf.kubernetes.kube_client.get_kube_client(in_cluster=None, cluster_context=None, config_file=None)[source]

Retrieve Kubernetes client.

Parameters:
  • in_cluster (bool | None) – whether we are in cluster

  • cluster_context (str | None) – context of the cluster

  • config_file (str | None) – configuration file

Returns:

kubernetes client

Return type:

kubernetes.client.CoreV1Api

async airflow.providers.cncf.kubernetes.kube_client.get_async_kube_client(in_cluster=None, cluster_context=None, config_file=None)[source]

Retrieve an asynchronous Kubernetes client.

Mirrors get_kube_client() but builds a kubernetes_asyncio client so that pod-creation API calls can be issued concurrently by the KubernetesExecutor. Reads the same configuration keys (in_cluster, cluster_context, config_file, verify_ssl, ssl_ca_cert).

Parameters:
  • in_cluster (bool | None) – whether we are in cluster

  • cluster_context (str | None) – context of the cluster

  • config_file (str | None) – configuration file

Returns:

asynchronous kubernetes client

Return type:

kubernetes_asyncio.client.CoreV1Api

Was this entry helpful?