Description
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.
kubernetes/pkg/apis/core/validation/validation.go
Line 4406 in ccf291b
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
Type
Projects
Status
Status