一、kubectl describe node

可通过该命令查看 Pod 在节点上的资源分配情况(Request、Limits),如下:

# product 表示生产环境
kubectl describe node -l env=product

# 执行结果
Namespace                   Name                                                      CPU Requests  CPU Limits  Memory Requests  Memory Limits  AGE
---------                   ----                                                      ------------  ----------  ---------------  -------------  ---
product                     annoroad-clinicallims3-754dddb5cb-k5xkn                   0 (0%)        0 (0%)      0 (0%)           0 (0%)         85d
product                     annoroad-crm-796884585d-ts2xn                             0 (0%)        0 (0%)      0 (0%)           0 (0%)         85d
product                     annoroad-dms-6d658d564f-m6j7r                             0 (0%)        0 (0%)      0 (0%)           0 (0%)         16d
product                     annoroad-dms-server-6557c5bc85-45sw2                      0 (0%)        0 (0%)      0 (0%)           0 (0%)         15d

二、kubectl top node

可通过该命令查看节点的资源使用情况,如下:

# product 表示生产环境
kubectl top node -l env=product

# 执行结果
NAME                       CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%
cn-beijing.192.16.168.102   904m         11%    10340Mi         69%
cn-beijing.192.16.168.103   1393m        17%    12810Mi         86%
cn-beijing.192.16.168.104   1994m        24%    13281Mi         89%
cn-beijing.192.16.168.105   987m         12%    9399Mi          63%
cn-beijing.192.16.168.115   638m         15%    12017Mi         80%
cn-beijing.192.16.168.118   806m         20%    9372Mi          62%
cn-beijing.192.16.168.135   258m         6%     9696Mi          65%
cn-beijing.192.16.168.136   871m         21%    10957Mi         73%
cn-beijing.192.16.168.137   310m         7%     9322Mi          62%
cn-beijing.192.16.168.138   943m         23%    11908Mi         80%

三、kubectl top pod

可通过该命令查看 Pod 资源使用情况,如下:

# product 表示生产环境
kubectl top pod -n product

# 执行结果
NAME                                         CPU(cores)   MEMORY(bytes)
annoroad-alpha-5dbd868d-lsvj5                2m           383Mi
annoroad-applet-6f977779bc-2bgpn             3m           384Mi
annoroad-applet-6f977779bc-mgdhw             3m           387Mi
annoroad-applet-6f977779bc-qhqbg             2m           393Mi
annoroad-beta-7c4d7c654f-m4rkf               2m           334Mi
annoroad-clinicallims-67855bf4f5-9ddwd       4m           502Mi
annoroad-clinicallims-67855bf4f5-rdq2s       3m           488Mi
annoroad-clinicallims-67855bf4f5-vvrsn       3m           436Mi
annoroad-clinicallims-67855bf4f5-zhbvk       4m           509Mi
annoroad-clinicallims-67855bf4f5-zs65j       3m           420Mi
annoroad-clinicallims3-56d9c87786-2ftzq      3m           596Mi

四、kubectl get pod -o wide |grep $node

可通过该命令查看指定 node 上运行的所有 pod,如下:

# product 表示生产环境
kubectl get pod -n product -o wide |grep cn-beijing.172.15.14.128

# 执行结果
annoroad-clinical-lims-8556cc6b76-57ctq        1/1     Running   6          20h    170.22.11.23     cn-beijing.172.15.14.128   <none>           <none>
annoroad-covid19-front-fdd7469ff-pg2hm         1/1     Running   0          29d    170.22.11.20   	cn-beijing.172.15.14.128   <none>           <none>
annoroad-crm-7b9cd5c6c9-hj5s8                  1/1     Running   0          10d    170.22.11.12     cn-beijing.172.15.14.128   <none>           <none>
annoroad-crm-server-696d4f5867-77bdd           1/1     Running   2          29d    170.22.11.122    cn-beijing.172.15.14.128   <none>           <none>
annoroad-gateway-55785fd8c-xlx4q               1/1     Running   0          88d    170.22.11.99     cn-beijing.172.15.14.128   <none>           <none>

五、kubectl top pod |grep -E “$podname1|$podname2|…”

可通过该命令查看一个 pod 或几个 pod 的资源使用情况 ,如下:

# product 表示生产环境
kubectl top pod -n product |grep -E "annoroad-clinical-lims-8556cc6b76-57ctq|annoroad-covid19-front-fdd7469ff-pg2hm"

# 执行结果
annoroad-clinical-lims-8556cc6b76-57ctq        74m          1216Mi
annoroad-covid19-front-fdd7469ff-pg2hm         1m           2Mi
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐