Kubernetes
kubectl
server metrics
performance issues
troubleshooting

The metrics of kubectl top nodes is not correct?

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Introduction

In the Kubernetes ecosystem, the `kubectl top` command plays a crucial role in providing insights into resource usage per node or pod. However, many users have reported discrepancies in the metrics reported by `kubectl top nodes`. These discrepancies often lead to confusion and inefficiencies in resource management. This article delves into potential reasons for these inconsistencies, provides technical explanations, and offers insights into how to mitigate these issues.

Understanding `kubectl top`

The `kubectl top` command is often used to gather resource metrics such as CPU and memory usage across nodes and pods. This command relies on the metrics-server to provide these statistics, which collects them from different sources within the Kubernetes environment.

Example Usage

To check the resource usage for nodes, you would typically use:

  • Network Permissions: The metrics-server needs appropriate permissions to communicate with nodes. Misconfigured nodes or network policies may impede this.
  • Resource Allocation: If the server is under-provisioned, it may struggle to gather and report data in a timely manner.
  • Data Intervals: Metrics might be averaged over periods longer than expected, leading to a smoothing effect where peak usages are under-represented.
  • Different Units: Metrics may be represented in different units than what users commonly monitor externally, like mCPU vs. CPU cores.

Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.