kubectl top

Show CPU and memory resource usage for nodes and pods.

low risk

interactive breakdown — edit the command and press Explain
$ 
What it does

kubectl top shows real-time CPU and memory usage for nodes and pods, powered by the metrics-server addon. Unlike kubectl get (which shows requests/limits), top shows actual consumption. Essential for identifying resource-hungry pods and right-sizing requests.

Common flags
FlagMeaning
--sort-bySort by cpu or memory
--containersShow per-container usage within pods
-A --all-namespacesShow across all namespaces
Examples
kubectl top nodesNode CPU and memory usage · explain & risk-check →
kubectl top pods -A --sort-by=memoryMost memory-hungry pods across all namespaces · explain & risk-check →
kubectl top pods --containers -n productionPer-container resource usage in production · explain & risk-check →
watch kubectl top pods -A --sort-by=cpuLive top CPU consumers across cluster · explain & risk-check →
Pro tip

Use `kubectl top pods --sort-by=memory` before scaling — it often reveals one rogue pod consuming 10x expected memory, letting you target the fix rather than scaling everything.

Related
kubectl get kubectl describe kubectl logs
Open the full explainer →More in Kubernetes & Helm

Reference text is hand-written and may be incomplete — check man kubectl for your version. Test destructive commands on a non-production system first.