rmdir.cn

kubectl top

查看资源使用情况

语法

kubectl top <资源类型> [资源名] [选项]

说明

显示集群中 Node 或 Pod 的 CPU 和内存使用情况。需要集群中部署 Metrics Server。类似于 Linux 的 top 命令。

参数

  • -n

    指定命名空间(用于 Pod)

  • -l

    标签选择器筛选

示例

查看节点资源

查看所有节点的 CPU/内存使用

kubectl top nodes

查看 Pod 资源

查看命名空间下 Pod 资源使用

kubectl top pods -n production