k8s查看资源使用情况
- 其他运维
- 2024-07-14
- 357热度
- 0评论
可以通过 kubectl top 命令来查看 Pod 中的 CPU 和内存使用情况。下面是一些常用的 kubectl top 命令:
1、查看集群中所有节点的 CPU 和内存使用情况:
kubectl top nodes
2、查看指定节点的 CPU 和内存使用情况:
kubectl top node <node-name>
3、查看集群中所有 Pod 的 CPU 和内存使用情况:
kubectl top pods --all-namespaces
4、查看指定命名空间中所有 Pod 的 CPU 和内存使用情况:
kubectl top pods -n <namespace>
5、查看指定 Pod 的 CPU 和内存使用情况:
kubectl top pod <pod-name> -n <namespace>
在输出结果中,可以看到 Pod 的 CPU 和内存使用情况,如下所示:
NAME CPU(cores) MEMORY(bytes) my-pod-xxxxx 0m 128Mi
其中,MEMORY(bytes) 列显示了 Pod 使用的内存量,单位为字节。如果需要查看更加详细的信息,可以使用 kubectl describe 命令来查看 Pod 的详细信息。