Skip to content

kubectl describe node does not properly account for pod level resources #1807

@GitPancaked

Description

@GitPancaked

What happened?

When the resource requests and limits for CPU and memory are defined at pod level, they are not properly accounted for in output of kubectl describe node:

Non-terminated Pods:          (4 in total)
  Namespace                   Name                               CPU Requests  CPU Limits  Memory Requests  Memory Limits  Age
  ---------                   ----                               ------------  ----------  ---------------  -------------  ---
  default                     nginx-resources-container-level    250m (25%)    500m (50%)  64Mi (3%)        128Mi (7%)     4s
  default                     nginx-resources-pod-level          0 (0%)        0 (0%)      0 (0%)           0 (0%)         4s
  kube-system                 canal-hwn8t                        25m (2%)      0 (0%)      0 (0%)           0 (0%)         28d
  kube-system                 kube-proxy-td452                   0 (0%)        0 (0%)      0 (0%)           0 (0%)         3m39s
Allocated resources:
  (Total limits may be over 100 percent, i.e., overcommitted.)
  Resource           Requests    Limits
  --------           --------    ------
  cpu                275m (27%)  500m (50%)
  memory             64Mi (3%)   128Mi (7%)
  ephemeral-storage  0 (0%)      0 (0%)
  hugepages-2Mi      0 (0%)      0 (0%)

All requests and limits are showing 0 for the pod where the requests and limits were assigned in the pod level spec rather than at the container level. The total values calculated under Allocated resources also does not seem to account for this.

What did you expect to happen?

I expect it to properly display the correct values just like when the resources are defined at container level.

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

Run two pods, one with resources defined at pod level and one defined at container level. Compare output of kubectl describe node (node) for the two pods resources; Example .yaml:

apiVersion: v1
kind: Pod
metadata:
  name: nginx-resources-container-level 
spec:
  containers:
  - name: app
    image: nginx 
    resources:
      requests:
        memory: "64Mi"
        cpu: "250m"
      limits:
        memory: "128Mi"
        cpu: "500m"
---
apiVersion: v1
kind: Pod
metadata:
  name: nginx-resources-pod-level 
spec:
  resources:
    requests:
      memory: "64Mi"
      cpu: "250m"
    limits:
      memory: "128Mi"
      cpu: "500m"
  containers:
  - name: app
    image: nginx

Anything else we need to know?

No response

Kubernetes version

Details
$ kubectl version
Client Version: v1.34.3
Kustomize Version: v5.7.1
Server Version: v1.34.3

Cloud provider

Details Not too sure, using the free cloud playground on killercoda.

OS version

Details
# On Linux:
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 24.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.3 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo
$ uname -a
Linux controlplane 6.8.0-51-generic kubernetes/kubernetes#52-Ubuntu SMP PREEMPT_DYNAMIC Thu Dec  5 13:09:44 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Install tools

Details

Container runtime (CRI) and version (if applicable)

Details

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

Details

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.needs-sigIndicates an issue or PR lacks a `sig/foo` label and requires one.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.sig/cliCategorizes an issue or PR as relevant to SIG CLI.

    Type

    No type

    Projects

    Status

    Needs Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions