pydatatask.pod_manager module#

In order for a KubeTask or a subclass to connect, authenticate, and manage pods in a kubernetes cluster, it needs several resource references. the PodManager simplifies tracking the lifetimes of these resources.

class pydatatask.pod_manager.PodManager(app: str, namespace: str, config: Callable[[], Configuration] | None = None)[source]#

Bases: object

A pod manager allows multiple tasks to share a connection to a kubernetes cluster and manage pods on it.

Parameters:
  • app – The app name string with which to label all created pods.

  • namespace – The namespace in which to create and query pods.

  • config – Optional: A callable returning a kubernetes configuration object. If not provided, will attempt to use the “default” configuration, i.e. what is available after calling await kubernetes_asyncio.config.load_kube_config().

property api#

The current API client.

property api_ws: WsApiClient#

The current websocket-aware API client.

property v1: CoreV1Api#

A CoreV1Api instance associated with the current API client.

property v1_ws: CoreV1Api#

A CoreV1Api instance associated with the current websocket-aware API client.

async close()[source]#

Close the network connections associated with this podman.

async launch(job, task, manifest)[source]#

Create a pod with the given manifest, named and labeled for this podman’s app and the given job and task.

async query(job=None, task=None) List[V1Pod][source]#

Return a list of pods labeled for this podman’s app and (optional) the given job and task.

async delete(pod: V1Pod)[source]#

Destroy the given pod.

async logs(pod: V1Pod, timeout=10) str[source]#

Retrieve the logs for the given pod.