⌂ Home

Metrics Server

Interactive guide to the resource metrics pipeline behind kubectl top and Horizontal Pod Autoscaling.

Metrics Server is the lightweight short-term resource metrics path for Kubernetes autoscaling and quick inspection. It is not a full observability stack.

Core Model

Understand the Concept First

Cluster-wide aggregator

Metrics Server gathers CPU and memory usage across nodes in the cluster.

Metrics API provider

It exposes those metrics through the Kubernetes Metrics API.

Autoscaling foundation

HPA and kubectl top depend on this pipeline.

Lifecycle Flow

Metrics Collection Path

1

Kubelets expose metrics

Each node provides resource usage data for the Pods running there.

2

Metrics Server scrapes

The service collects resource usage from kubelets.

3

API aggregation layer serves results

Metrics become available through the Kubernetes API server.

4

kubectl top and HPA consume data

Humans and controllers query the same aggregated metrics path.

5

Observation and scaling happen

Operators inspect usage and autoscalers act on thresholds.

Metrics Server provides current operational resource data, not long historical monitoring data.
Visual Diagrams

Metrics Pipeline Architecture

Complete Metrics Flow (15s Scraping Interval)

Cluster Nodes Node-1 Kubelet cAdvisor embedded CPU: 45% | Mem: 2.1GB Kubelet collects metrics via cAdvisor Node-2 Kubelet cAdvisor embedded CPU: 62% | Mem: 3.4GB Node-3 Kubelet cAdvisor embedded CPU: 38% | Mem: 1.8GB Scrape Every 15s Metrics Server Aggregates & Stores In-memory (short-term) kube-system namespace Metrics Server aggregates data from all kubelets Exposes API Server Aggregation Layer /apis/metrics.k8s.io API Server exposes metrics via aggregation layer Consumers kubectl top CLI inspection HPA Autoscaling VPA Vertical scaling Query Scraping Timeline (15-second intervals) t=0s Scrape t=15s Scrape t=30s Scrape t=45s Scrape t=60s Scrape Continues... ✓ Data freshness: Maximum 15 seconds old ✓ No historical data stored (in-memory only)
The Metrics Server scrapes kubelet APIs every 15 seconds by default. This provides near-real-time resource metrics without persistent storage overhead.
YAML and Commands

Examples You Can Recognize Quickly

Install Metrics Server
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
Inspect Metrics
kubectl top nodes
kubectl top pods -A
Decision Guide

Metrics Server vs Full Monitoring

Tool Primary purpose Retention
Metrics Server Autoscaling and quick resource visibility Short-term in-memory
Prometheus / Grafana Monitoring, alerting, dashboards, history Long-term configurable retention
Metrics Server is intentionally narrow and lightweight; it complements rather than replaces full monitoring systems.
Use It Well

Practice and Real-World Thinking

Autoscaling enablement

Install Metrics Server first when building labs around HPA.

Quick node insight

Use kubectl top to see immediate resource consumption.

Resource troubleshooting

Confirm whether high CPU or memory usage is driving scaling or instability.