Kubernetes:了解“kubectl top node"的内存使用情况 [英] Kubernetes: understanding memory usage for "kubectl top node"

查看:293
本文介绍了Kubernetes:了解“kubectl top node"的内存使用情况的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何解释kubectl top node"返回的内存使用情况.例如.如果它返回:

<前>名称 CPU(核) CPU% MEMORY(字节) MEMORY%ip-XXX.ec2.internal 222m 11% 3237Mi 41%ip-YYY.ec2.internal 91m 9% 2217Mi 60%

相比之下,如果我查看同一节点的 Kubernetes 仪表板,我会得到:内存请求:410M/7.799 Gi

<小时>kubernetes 仪表板

<小时>

我如何协调差异?

解决方案

kubectl top node 反映了 VM(nodes) 的实际使用情况,k8s 仪表板显示了限制/请求的百分比你配置了.

例如您的 EC2 实例有 8G 内存,而您实际使用了 3237MB,所以它是 41%.在 k8s 中,你只请求 410MB(5.13%),并且有 470MB 内存的限制.这并不意味着您只消耗 5.13% 的内存,而是配置的数量.

 Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits--------- ---- ------------ ---------- ----------------------------默认 kube-lego 20m (2%) 0 (0%) 0 (0%) 0 (0%)默认 mongo-0 100m (10%) 0 (0%) 0 (0%) 0 (0%)默认 web 100m (10%) 0 (0%) 0 (0%) 0 (0%)kube-system event-exporter- 0 (0%) 0 (0%) 0 (0%) 0 (0%)kube-system fluentd-gcp-v2.0-z6xh9 100m (10%) 0 (0%) 200Mi (11%) 300Mi (17%)kube-system heapster-v1.4.0-3405140848-k6cm9 138m (13%) 138m (13%) 301456Ki (17%) 301456Ki (17%)kube-system kube-dns-3809445927-hn5xk 260m (26%) 0 (0%) 110Mi (6%) 170Mi (9%)kube-system kube-dns-autoscaler-38801 20m (2%) 0 (0%) 10Mi (0%) 0 (0%)kube-system kube-proxy-gke-staging-default-100m (10%) 0 (0%) 0 (0%) 0 (0%)kube-system kubernetes-dashboard-1962351 100m (10%) 100m (10%) 100Mi (5%) 300Mi (17%)kube-system l7-default-backend-295440977 10m (1%) 10m (1%) 20Mi (1%) 20Mi (1%)

在这里您看到许多请求/限制为 0 的 Pod 表示无限制,这不计入 k8s 仪表板,但肯定消耗内存.

总结内存请求/限制,您会发现它们与 k8s 仪表板相匹配.

How do I interpret the memory usage returned by "kubectl top node". E.g. if it returns:

    NAME                   CPU(cores)   CPU%      MEMORY(bytes)   MEMORY%
    ip-XXX.ec2.internal    222m         11%       3237Mi          41%
    ip-YYY.ec2.internal    91m          9%        2217Mi          60%

By comparison, if I look in the Kubernetes dashboard for the same node, I get: Memory Requests: 410M / 7.799 Gi


kubernetes dashboard


How do I reconcile the difference?

解决方案

kubectl top node is reflecting the actual usage to the VM(nodes), and k8s dashboard is showing the percentage of limit/request you configured.

E.g. Your EC2 instance has 8G memory and you actually use 3237MB so it's 41%. In k8s, you only request 410MB(5.13%), and have a limit of 470MB memory. This doesn't mean you only consume 5.13% memory, but the amount configured.

  Namespace         Name                                CPU Requests    CPU Limits  Memory Requests Memory Limits
  ---------         ----                                ------------    ----------  --------------- -------------
  default           kube-lego                           20m (2%)    0 (0%)      0 (0%)      0 (0%)
  default           mongo-0                             100m (10%)  0 (0%)      0 (0%)      0 (0%)
  default           web                                 100m (10%)  0 (0%)      0 (0%)      0 (0%)
  kube-system       event-exporter-                     0 (0%)      0 (0%)      0 (0%)      0 (0%)
  kube-system       fluentd-gcp-v2.0-z6xh9              100m (10%)  0 (0%)      200Mi (11%) 300Mi (17%)
  kube-system       heapster-v1.4.0-3405140848-k6cm9    138m (13%)  138m (13%)  301456Ki (17%)  301456Ki (17%)
  kube-system       kube-dns-3809445927-hn5xk           260m (26%)  0 (0%)      110Mi (6%)  170Mi (9%)
  kube-system       kube-dns-autoscaler-38801           20m (2%)    0 (0%)      10Mi (0%)   0 (0%)
  kube-system       kube-proxy-gke-staging-default-     100m (10%)  0 (0%)      0 (0%)      0 (0%)
  kube-system       kubernetes-dashboard-1962351        100m (10%)  100m (10%)  100Mi (5%)  300Mi (17%)
  kube-system       l7-default-backend-295440977        10m (1%)    10m (1%)    20Mi (1%)   20Mi (1%)

Here you see many pods with 0 request/limit means unlimited, which didn't count in k8s dashboard but definitely consume memory.

Sum up the memory request/limit you'll find they match k8s dashboard.

这篇关于Kubernetes:了解“kubectl top node"的内存使用情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆