kubernetes_provider
Kubernetes implementation of the provider interface.
The server runs as a pod and starts every session as a pod in its own
namespace, through its service account and the REST API, so a namespaced Role
is all it needs and no namespace name is written anywhere. Storage reaches a
session the way the server sees it: each server path is mounted from the
volume that backs it, with a subPath; a volume only one node can mount (a
ReadWriteOnce claim, a hostPath) pins sessions to the server's node.
A session pod starts from the PodTemplate <owner>-session when the namespace
has one, which is where node placement, runtime classes, and default resources
belong; an application's template may name another PodTemplate, laid over it for
that application's sessions. Session pods are labelled with the server's owner (its Deployment or
StatefulSet) and owned by it, so uninstalling removes them too. Images are
pulled by the kubelet, so pull_image pins the registry's current digest and
sessions run that exact image.
attributelogger= logging.getLogger(__name__)attributeSERVICE_ACCOUNT_DIR= '/var/run/secrets/kubernetes.io/serviceaccount'attributePENDING_TIMEOUT= 900attributeUNSCHEDULABLE_TIMEOUT= 300attributeSTOP_TIMEOUT= 30attributePULL_FAILURE_GRACE= 90attributeFATAL_WAITING_REASONS= {'CreateContainerConfigError', 'CreateContainerError', 'ErrImageNeverPull', 'InvalidImageName', 'RunContainerError'}attributePULL_WAITING_REASONS= {'ErrImagePull', 'ImagePullBackOff'}attributeEXPORT_TIMEOUT= PENDING_TIMEOUTattributePOD_LOCAL_VOLUMES= {'configMap', 'csi', 'downwardAPI', 'emptyDir', 'ephemeral', 'gitRepo', 'image', 'projected', 'secret'}attributeNETWORK_VOLUMES= {'azureFile', 'cephfs', 'glusterfs', 'nfs'}attributeGPU_TEMPLATE_LABEL= 'sealskin.app/gpu'attributeGPU_TEMPLATES_TIMEOUT= 5.0attributePRODUCT_LABELS= {'nvidia': 'nvidia.com/gpu.product', 'amdgpu': 'amd.com/gpu.product-name', 'i915': 'gpu.intel.com/product', 'xe': 'gpu.intel.com/product'}attributeNVIDIA_WORKLOAD_LABEL= 'nvidia.com/gpu.workload.config'attributeNVIDIA_GPUS_DIR= '/proc/driver/nvidia/gpus'attributeDRIVER_RESOURCES= {'nvidia': 'nvidia.com/gpu', 'amdgpu': 'amd.com/gpu', 'i915': 'gpu.intel.com/i915', 'xe': 'gpu.intel.com/xe'}attributeMANIFEST_TYPES= ('application/vnd.oci.image.index.v1+json', 'application/vnd.docker.distribution.manifest.list.v2+json', 'application/vnd.oci.image.manifest.v1+json', 'application/vnd.docker.distribution.manifest.v2+json')attributePULL_SECRET_SECONDS= 60