kubectl: Find most resource-hungry pods across all namespaces

What I learned today — 19 March 2018

Niel de Wet
1 min readMar 19, 2018

kubectl top pod allows one to see the most resource hungry pods, but the ordering isn’t always intuitive, especially if one is examining --all-namespaces.

sort to the rescue!

To sort the output of kubectl top pod --all-namespaces, pipe it to sort:

kubectl top pod --all-namespaces | sort --reverse --key 3 --numeric \
| head -10
  • kubectl top pod --all-namespace Prints the top information of all pods in all namespaces. Other filters may also be applied.
  • sort --reverse --key 3 --numeric Sorts the input according to the numeric values found in column 3 in descending order.
  • head -10 Prints only the top 10 lines.

--

--

No responses yet