KubernetesProvider
Launches applications as pods in the server's namespace.
Attributes
attributeorphan_grace= PENDING_TIMEOUT + BaseProvider.orphan_graceFunctions
funcinspect_self() -> NoneRead the server's own pod: its volumes, labels, and owner.
Session storage is resolved against these mounts, so a server path on a volume sessions cannot share is reported here once.
Returns
Nonefunc_volume_for(server_path) -> tuple[dict[str, Any], str] | NoneReturn the server volume holding server_path and the subPath inside it.
paramserver_pathstrReturns
tuple[dict[str, typing.Any], str] | Nonefunc_node_bound(volume) -> boolTell whether only the server's node can mount this volume alongside the server.
paramvolumedict[str, Any]Returns
boolfuncdetect_gpus() -> NoneOffer the GPUs sessions can request.
PodTemplates labelled sealskin.app/gpu are the options when the
namespace has any, each carrying what its GPU needs (a device plugin
resource or a DRA claim, node placement); refresh_gpus reads them
again whenever the options are offered or used. Otherwise, as nodes are
cluster-scoped: the GPU resources schedulable nodes advertise or DRA
device classes map, when the server may list them; else those the
namespace's quota grants; else the GPUs of the server's own node.
Resources a quota covering session pods caps at zero are left out,
GPUs handed to virtual machines are skipped, and nodes labelled with
their GPUs' model are offered per model. The cluster is scanned once,
when the templates are first found missing.
Returns
Nonefuncrefresh_gpus() -> NoneOffer the namespace's GPU PodTemplates as they are now, else the scanned GPUs.
The options offered stand when the templates cannot be listed for any reason but the Role withholding them, so an API server that is slow or restarting neither holds up the launcher nor swaps the templates for the scanned GPUs.
Returns
Nonefunc_scan_gpus() -> list[dict[str, Any]]Return the GPUs the cluster's nodes and device classes, the quota, or this node offer.
Returns
list[dict[str, typing.Any]]funcget_local_image_info(image_name) -> dict[str, Any] | NoneReturn the digest sessions run for an image, once one was pinned.
paramimage_namestrReturns
dict[str, typing.Any] | Nonefuncget_remote_image_digest(image_name) -> str | NoneReturn the digest the image's registry serves now.
paramimage_namestrReturns
str | Nonefuncpull_image(image_name) -> AnyPin the registry's current digest; nodes pull it when a session needs it.
paramimage_namestrReturns
typing.Anyfuncprune_images() -> NoneLeave unused images to the kubelet's image garbage collection.
Returns
Nonefuncregistry_credentials() -> dict[str, tuple[str, str]]Return the credentials of the pull secrets the session template names, read again each minute.
Returns
dict[str, tuple[str, str]]funcexport_web_client(image, path) -> bytesRun tar in a pod of the image and read what it wrote from the pod's log (see BaseProvider).
A log is text, so the pod writes the stream in base64. The pod takes the session template's placement and pull secrets, nothing else.
paramimagestrparampathstrReturns
bytesfunc_pod_manifest(session_id, env_vars, volumes, gpu_config, template=None, vpn=None) -> dict[str, Any]Build the session pod over the namespace's session template.
The app's and its template's Docker run options are mapped onto the
pod; the PodTemplate's container named app, or its first, is the
base of the session container. What NVIDIA sessions get by default,
the nvidia RuntimeClass and every driver capability, yields to the
templates' own choice. With vpn, a native sidecar from the gateway
image joins the pod (see app.vpn_kube): it makes the hub the pod's
default route before the app starts, and the pod resolves names at
the hub.
paramsession_idstrparamenv_varsdict[str, str]paramvolumesdict[str, Any] | Noneparamgpu_configdict[str, Any] | Noneparamtemplatedict[str, Any] | None= Noneparamvpndict[str, Any] | None= NoneReturns
dict[str, typing.Any]func_pod_template(name='') -> dict[str, Any] | NoneReturn the pod template of a PodTemplate, <owner>-session by default, or None without one.
paramnamestr= ''Returns
dict[str, typing.Any] | Nonefunc_create(session_id, manifest) -> dict[str, Any]Create the pod, dropping the nvidia RuntimeClass where the cluster has none.
paramsession_idstrparammanifestdict[str, Any]Returns
dict[str, typing.Any]func_wait_running(session_id, name) -> strWait until the pod runs and has an address.
paramsession_idstrparamnamestrReturns
strfunclaunch(session_id, env_vars, volumes=None, gpu_config=None, network=None, is_collaboration=False, master_token=None, initial_tokens=None, vpn=None) -> dict[str, Any]Create the session pod and wait until its web endpoint answers.
The pod is built over the session template, the PodTemplate the app's
template names, and the GPU option's PodTemplate, laid over one another in
that order, so the GPU a user picked wins over the application's defaults.
See BaseProvider.launch for the arguments; network has no meaning here.
paramsession_idstrparamenv_varsdict[str, str]paramvolumesdict[str, Any] | None= Noneparamgpu_configdict[str, Any] | None= Noneparamnetworkstr | None= Noneparamis_collaborationbool= Falseparammaster_tokenstr | None= Noneparaminitial_tokensdict[str, Any] | None= Noneparamvpndict[str, Any] | None= NoneReturns
dict[str, typing.Any]funcstop(instance_id) -> NoneDelete a session pod and wait until it is gone, as a Docker stop does.
paraminstance_idstrPod name.
Returns
Nonefuncis_running(instance_id) -> boolTell whether a pod exists, is not being deleted, and has not terminated.
paraminstance_idstrReturns
boolfuncmanaged_instances() -> dict[str, float]Return this server's session pods with their creation times.
Returns
dict[str, float]