pod_spec_from_resources
Constructs a Kubernetes V1PodSpec object from specified resource requests and limits. It maps generic resource definitions (CPU, memory, GPU, ephemeral storage) to Kubernetes-specific resource requirements for a primary container.
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 from the provided resource requests and limits. This function is used to define the resource requirements for a primary container within a pod.
Parameters
| Name | Type | Description |
|---|---|---|
| primary_container_name | str = _PRIMARY_CONTAINER_DEFAULT_NAME | The name to assign to the primary container within the V1PodSpec. This name identifies the main application container. |
| requests | Optional[Resources] = None | The resource requests for the primary container. These values specify the minimum resources guaranteed to the container. |
| limits | Optional[Resources] = None | The resource limits for the primary container. These values specify the maximum resources the container can consume. |
| k8s_gpu_resource_key | str = "nvidia.com/gpu" | The Kubernetes resource key used to identify GPU resources. This allows for custom GPU resource naming in Kubernetes clusters. |
Returns
| Type | Description |
|---|---|
V1PodSpec | A Kubernetes V1PodSpec object configured with the specified resource requests and limits for a single primary container. |