您的当前位置:首页正文

kubectl top查看k8s pod的cpu , memory使用率情况

2024-11-09 来源:个人技术集锦

To see the pods that use the most cpu and memory you can use the kubectl top command but it doesn’t sort yet and is also missing the quota limits and requests per pod. You only see the current usage:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ kubectl top pod --all-namespaces
NAMESPACE NAME CPU(cores) MEMORY(bytes)
kube-system kube-proxy-gke-rel3170- default -pool-3459fe6a 2m 12Mi
kube-system kube-proxy-gke-rel3170- default -pool-3459fe6a 2m 12Mi
kube-system fluentd-gcp-v2. 0.9 -5t9q6 8m 85Mi
kube-system fluentd-gcp-v2. 0.9 -pd4s9 10m 84Mi
kube-system kube-dns- 3468831164 -v2gqr 1m 26Mi
kube-system event-exporter-v0. 1.7 - 1642279337 -180db 0m 13Mi
kube-system kube-proxy-gke-rel3170- default -pool-3459fe6a 1m 12Mi
kube-system l7- default -backend- 3623108927 -tjm9z 0m 1Mi
kube-system kube-dns- 3468831164 -cln0p 1m 25Mi
kube-system fluentd-gcp-v2. 0.9 -sj3rh 9m 84Mi
kube-system kube-dns-autoscaler- 244676396 -00btn 0m 7Mi
kube-system kubernetes-dashboard- 1265873680 -8prcm 0m 18Mi
kube-system heapster-v1. 4.3 - 3980146296 -33tmw 0m 42Mi

Because of these limitations, but also because you want to gather and store this resource usage information on an ongoing basis, a monitoring tool comes in handy. This allows you to analyze resource usage both in real time and historically, and also lets you alert on capacity bottlenecks.

 

实际示例:

[root@]:~# kubectl top  pod   -n taobao-spider 
NAME                                                      CPU(cores)   MEMORY(bytes)   
app-1375507206-spider-new-v1-0-55f8cbb5cb-29wnz           0m           76Mi            
app-1375507206-spider-new-v1-0-55f8cbb5cb-2s2qj           0m           69Mi            
app-1375507206-spider-new-v1-0-55f8cbb5cb-6q9w7           0m           71Mi            
app-1375507206-spider-new-v1-0-55f8cbb5cb-7s59f           0m           74Mi            
app-1375507206-spider-new-v1-0-55f8cbb5cb-96lsb           0m           73Mi            
app-1375507206-spider-new-v1-0-55f8cbb5cb-fdglr           0m           71Mi            
app-1375507206-spider-new-v1-0-55f8cbb5cb-h52th           0m           71Mi            
app-1375507206-spider-new-v1-0-55f8cbb5cb-j26cx           0m           73Mi            
app-1375507206-spider-new-v1-0-55f8cbb5cb-k95gz           0m           71Mi            
app-1375507206-spider-new-v1-0-55f8cbb5cb-pv9w7           0m           75Mi            
app-1375507206-spider-new-v1-0-55f8cbb5cb-r9mtz           0m           69Mi            
app-1375507206-spider-new-v1-0-55f8cbb5cb-vq79m           0m           75Mi            
app-1375507206-spider-new-v1-0-55f8cbb5cb-xzzbs           0m           70Mi            
app-1375507206-spider-new-v1-0-55f8cbb5cb-zhjdb           0m           80Mi            
app-183215290-spider-v1-0-76f57788d-8jfqm                 93m          80Mi            
app-2492659469-spider-new-v1-0-7fbf4d7c7d-vf552           20m          61Mi            
app-3437963581-spider-v1-0-66cd9d7699-5z2vk               74m          108Mi           
app-3437963581-spider-v1-0-66cd9d7699-79bwf               54m          75Mi            

  

Top