← 返回命令列表

Linux command

kubectl-top 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Show node resource usage

kubectl top nodes

Show pod resource usage

kubectl top pods

Show pod usage in namespace

kubectl top pods -n [namespace]

Show container-level usage

kubectl top pods --containers

Sort by CPU

kubectl top pods --sort-by=cpu

说明

kubectl top displays resource usage (CPU and memory) for nodes or pods. Requires metrics-server to be running in the cluster. Useful for monitoring resource consumption and identifying resource-hungry workloads.

参数

nodes
Display node resource usage.
pods
Display pod resource usage.
--containers
Show container-level metrics.
--sort-by _field_
Sort by cpu or memory.
-n, --namespace _name_
Kubernetes namespace.
-A, --all-namespaces
Show all namespaces.

FAQ

What is the kubectl-top command used for?

kubectl top displays resource usage (CPU and memory) for nodes or pods. Requires metrics-server to be running in the cluster. Useful for monitoring resource consumption and identifying resource-hungry workloads.

How do I run a basic kubectl-top example?

Run `kubectl top nodes` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does nodes do in kubectl-top?

Display node resource usage.