kubectl top pod --all-namespaces | sort --reverse --key 4 --numeric | head -10
gives top pods in a cluster. How to get top memory consuming pods per node?
kubectl describe node node_name will give you something like below.
Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits AGE
--------- ---- ------------ ---------- --------------- ------------- ---
0 (0%) 0 (0%) 0 (0%) 0 (0%) 11d
200m (5%) 0 (0%) 400Mi (5%) 600Mi (8%) 22h
25m (0%) 1 (25%) 512Mi (6%) 0 (0%) 14d
25m (0%) 1 (25%) 512Mi (6%) 0 (0%) 14d
0 (0%) 0 (0%) 0 (0%) 0 (0%) 14d
10m (0%) 0 (0%) 0 (0%) 0 (0%) 14d
400m (10%) 2 (50%) 2176Mi (29%) 1Gi (13%) 14d
1100m (27%) 6800m (170%) 1134217728 (14%) 5073741824 (65%) 14d
100m (2%) 0 (0%) 100Mi (1%) 100Mi (1%) 14d
100m (2%) 0 (0%) 0 (0%) 0 (0%) 14d
0 (0%) 0 (0%) 0 (0%) 0 (0%) 14d
100m (2%) 400m (10%) 30Mi (0%) 200Mi (2%) 14d
100m (2%) 400m (10%) 200Mi (2%) 512Mi (6%) 14d
100m (2%) 400m (10%) 200Mi (2%) 512Mi (6%) 14d
110m (2%) 2010m (50%) 256Mi (3%) 1152Mi (15%) 14d
If you still need to sort and keep the first ten elements of the pods list per node, you can use this command: kubectl get po -o wide | grep <node> | awk {'print $1'} | xargs -n1 command kubectl top po --no-headers | sort --reverse --key 3 --numeric | head -10