[Pod Level Resources] Pod-level resource validation fails when container-level is set for other resource · Issue #132449 · kubernetes/kubernetes · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

[Pod Level Resources] Pod-level resource validation fails when container-level is set for other resource #132449

@ndixita

Description

@ndixita

What happened?

When a Kubernetes Pod defines resources.requests at the Pod level, but only specifies a subset of the supported resources requested by its containers (e.g., only cpu at the Pod level, while a container requests memory), Kubernetes' validation implicitly assigns a request of "0" for the unstated resource (e.g., memory) at the Pod level. This "0" value then triggers a validation error because it's less than the actual aggregated request from the containers, even though the user might expect the Pod to implicitly aggregate the container's memory request.

 "pod" is invalid: spec.resources.requests[memory]: Invalid value: "0": must be greater than or equal to aggregate container requests of 10Mi

What did you expect to happen?

When a user defines resource requests at the container level, Kubernetes already aggregates these requests internally to determine the total resource needs of the Pod. If the Pod.spec.resources.requests field is present, but only specifies a subset of resources (e.g., cpu but not memory), the intuitive expectation is that Kubernetes would implicitly aggregate the memory request from the containers, rather than defaulting the Pod's memory request to 0.

if ctrReqs.Cmp(podSpecRequests) > 0 {
needs to be fixed to compare container aggregates with pod-level values only if pod-level value for that resource is set.

How can we reproduce it (as minimally and precisely as possible)?

Enable PodLevelResources feature gate on apiserver, scheduler and kubelet, and create the following pod

apiVersion: v1
kind: Pod
metadata:
  name: pod-bug
spec:
  resources:
    requests:
      cpu: "300m"  # Pod-level CPU request
  containers:
  - name: sleep-infinity
    image: busybox
    command: ["sh", "-c", "sleep infinity"]
    resources:
      requests:
        ephemeral-memory: 10Mi 

Anything else we need to know?

No response

Kubernetes version

$ kubectl version
Client Version: v1.33.1
Kustomize Version: v5.6.0
Server Version: v1.33.1```

</details>


### Cloud provider

<details>
N/A
</details>


### OS version

<details>

```console
# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here

Install tools

Container runtime (CRI) and version (if applicable)

Related plugins (CNI, CSI, ...) and versions (if applicable)

Metadata

Metadata

Labels

good first issueDenotes an issue ready for a new contributor, according to the "help wanted" guidelines.help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.kind/bugCategorizes issue or PR as related to a bug.priority/important-longtermImportant over the long term, but may not be staffed and/or may need multiple releases to complete.sig/nodeCategorizes an issue or PR as relevant to SIG Node.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Projects

Status

Triaged

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    TMZ Celebrity News – Breaking Stories, Videos & Gossip

    Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

    Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

    🎥 Watch TMZ Live

    TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.