Skip to main content

pod_spec_from_resources

Constructs a Kubernetes V1PodSpec object containing a single container with specified resource requests and limits. It maps internal resource definitions for CPU, memory, GPU, and ephemeral storage to their corresponding Kubernetes resource keys.

def pod_spec_from_resources(
primary_container_name: str = _PRIMARY_CONTAINER_DEFAULT_NAME,
requests: Optional[Resources] = None,
limits: Optional[Resources] = None,
k8s_gpu_resource_key: str = "nvidia.com/gpu",
) -> "V1PodSpec": ...

Constructs a Kubernetes V1PodSpec object containing a single container with specified resource requests and limits. This function simplifies the mapping of internal resource definitions to Kubernetes-compatible resource keys, including specialized GPU resource keys.

Parameters​

NameTypeDescription
primary_container_namestr = _PRIMARY_CONTAINER_DEFAULT_NAMEThe name to assign to the primary container within the Pod specification.
requestsOptional[Resources] = nullThe resource quantities requested for the container, such as CPU, memory, and GPU.
limitsOptional[Resources] = nullThe maximum resource limits allowed for the container; if omitted, it defaults to the values provided in requests.
k8s_gpu_resource_keystr = "nvidia.com/gpu"The specific Kubernetes resource key used to identify GPU resources, allowing for different hardware providers.

Returns​

TypeDescription
V1PodSpecA Kubernetes Pod specification containing one container configured with the mapped resource requirements.