Main Menu

Search

Thursday, September 5, 2024

KUBERNETES: KUBECTL Command To List The Pods and Their CPU & Memory Resource Limits

Below command can be used. Below command will list all the pods in all the namespaces.

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

For listing the pods and their limits in specific namespace below command can be used.

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

Below is sample output of above command. In below output memory is listed as 50Mi which is 50MB and CPU is 100m which is means 1/10th of CPU which is 0.1 CPU.

kube-flannel-ds-4w6lq 100m 50Mi
kube-flannel-ds-69xn6 100m 50Mi
kube-flannel-ds-d7drw 100m 50Mi
kube-flannel-ds-f87dw 100m 50Mi
kube-flannel-ds-rwcjl 100m 50Mi
kube-flannel-ds-xlnh7 100m 50Mi

No comments:

Post a Comment