How do I get top three most CPU utilized pod in a Kubernetes cluster?
kubectl top po --all-namespaces
Above command gives me CPU and memory utilization for all the pods across all namespaces. How to restrict it to only top three most CPU utilized pods?
Also, I've tried to sort by CPU, but seems like sorting is not working.
kubectl top po --all-namespaces --sort-by="cpu"
Output:
NAMESPACE NAME CPU(cores) MEMORY(bytes)
kube-system weave-net-ksfp4 1m 51Mi
kube-system kube-controller-manager-master 10m 50Mi
kube-system coredns-5644d7b6d9-rzd64 2m 6Mi
kube-system weave-net-h4xlg 1m 77Mi
kube-system kube-proxy-lk9xv 1m 19Mi
kube-system coredns-5644d7b6d9-v2v4m 3m 6Mi
kube-system kube-scheduler-master 2m 21Mi
kube-system kube-apiserver-master 26m 228Mi
kube-system kube-proxy-lrzjh 1m 9Mi
kube-system etcd-master 12m 38Mi
kube-system metrics-server-d58c94f4d-gkmql 1m 14Mi