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
| Name | Type | Description |
|---|---|---|
| primary_container_name | str = _PRIMARY_CONTAINER_DEFAULT_NAME | The name to assign to the primary container within the Pod specification. |
| requests | Optional[Resources] = null | The resource quantities requested for the container, such as CPU, memory, and GPU. |
| limits | Optional[Resources] = null | The maximum resource limits allowed for the container; if omitted, it defaults to the values provided in requests. |
| k8s_gpu_resource_key | str = "nvidia.com/gpu" | The specific Kubernetes resource key used to identify GPU resources, allowing for different hardware providers. |
Returns
| Type | Description |
|---|---|
V1PodSpec | A Kubernetes Pod specification containing one container configured with the mapped resource requirements. |