Kubectl Command: Finding Top CPU Consumers

A one-liner to instantly see which pods are hogging your cluster's CPU. No dashboard required.

D
Daniel Paz
1 min read

Sometimes you don’t want to open Grafana. You just want to know: “Who is eating my CPU?”

Here is the one-liner I use every day:

Terminal window
kubectl top pods -A --sort-by='cpu' | head -10

Breakdown

  • kubectl top pods: Uses the Metrics Server to fetch real-time usage.
  • -A: Checks All Namespaces (don’t hide in default).
  • --sort-by='cpu': The magic flag. Sorts the output.
  • | head -10: Shows only the top offenders.

Pro Tip: Memory

Want to find memory leaks instead? Just swap the sort key:

Terminal window
kubectl top pods -A --sort-by='memory' | head -10

Add this to your .zshrc as an alias (kcpu and kmem) and thank me later.

👨‍💻

Daniel Paz

Marketing Lead

Read Next

Join 1,000+ FinOps and platform leaders

Get Kubernetes and ECS cost tactics delivered weekly.