How to list all pods across all namespaces, along with their respective CPU limits for the containers
search cancel

How to list all pods across all namespaces, along with their respective CPU limits for the containers

book

Article ID: 385537

calendar_today

Updated On: 01-09-2025

Products

VMware Telco Cloud Automation

Issue/Introduction

To identify CPU limits for customer workloads experiencing throttling in a TKGm environment, utilize this command.

Environment

2.x, 3.x

Resolution

Command:

kubectl get pods -A -o jsonpath="{range .items[*]}[{.metadata.namespace}/{.metadata.name}, {.spec.containers[*].resources.limits.cpu}]{'\n'}{end}"

Explanation:

-A: Lists resources across all namespaces.
-o jsonpath: Outputs specific fields using JSONPath.
{range .items[*]}: Iterates over all pods.
[{.metadata.namespace}/{.metadata.name}: Prints the namespace and pod name.
, {.spec.containers[*].resources.limits.cpu}]: Displays the CPU limits for all containers within the pod.
{'\n'}: Adds a newline for each pod.
{end}: Ends the range loop.

Sample output:

default/nginx-deployment-5c689d85b8-zsk8z, 500m 1
kube-system/coredns-64897985d-qbdvl, 100m

Here:

default/nginx-deployment-5c689d85b8-zsk8z: Namespace and pod name.
500m 1: CPU limits for containers in the pod (in millicores).