Answer a question

Is there a way to combine kubectl top pod and kubectl top nodes?

Basically I want to know pods sorted by cpu/memory usage BY node.

I can only get pods sorted by memory/cpu for whole cluster with kubectl top pod or directly memory/cpu usage per whole node with kubectl top nodes.

I have been checking the documentation but couldnt find the exact command.

Answers

There is no built-in solution to achieve your expectations. kubectl top pod and kubectl top node are different commands and cannot be mixed each other. It is possible to sort results from kubectl top pod command only by cpu or memory:

kubectl top pod POD_NAME --sort-by=cpu              # Show metrics for a given pod and sort it by 'cpu' or 'memory'

If you want to "combine" kubectl top pod and kubectl top node you need to write custom solution. For example script in Bash based on this commands.

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐