为什么 top node、free、Grafana 的数据对不上

💡 原文中文,约4800字,阅读约需12分钟。
📝

内容提要

本文讨论了Kubernetes中节点资源使用率超过100%和top node与Grafana数据不一致的问题,提供了解决方案。

🎯

关键要点

  • Kubernetes中节点资源使用率超过100%是因为计算使用率时默认使用可分配资源,排除了Kubelet保留部分。
  • 使用--show-capacity参数可以查看节点总的资源使用情况。
  • Allocatable等于Capacity减去Reserved和Evicted Threshold。
  • 使用free命令查看节点资源使用情况与Grafana数据基本一致,因其数据源相同。
  • kubectl top命令使用metrics-server采集的指标,数据来自Kubelet。
  • top命令使用的node_memory_working_set_bytes指标与Grafana使用的node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes指标数据源不同,导致内存使用量差异。
  • Kubelet驱逐Pod时使用的指标是container_memory_working_set_bytes,代表容器真实内存使用量。
➡️

继续阅读