Cette page est affichée en anglais. Une traduction française est en cours.
SkillsApr 16, 2026·3 min de lecture

Metrics Server — Lightweight Core Metrics for Kubernetes Autoscaling

Kubernetes Metrics Server is the lightweight cluster-wide CPU and memory metrics pipeline that powers kubectl top, HorizontalPodAutoscaler, and VerticalPodAutoscaler without requiring a full monitoring stack.

Prêt pour agents

Installation agent prête

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
Metrics Server for K8s autoscaling
Commande d'installation directe
npx -y tokrepo@latest install 362bc634-3929-11f1-9bc6-00163e2b0d79 --target codex

À exécuter après confirmation du plan en dry-run.

TL;DR
Metrics Server feeds CPU and memory data to kubectl top, HPA, and VPA as the minimal Kubernetes metrics pipeline.
§01

What it is

Kubernetes Metrics Server is a lightweight, cluster-wide aggregator of resource usage data. It collects CPU and memory metrics from kubelets and exposes them through the Kubernetes Metrics API. This API powers kubectl top, HorizontalPodAutoscaler (HPA), and VerticalPodAutoscaler (VPA) without requiring a full monitoring stack.

The tool targets cluster operators who need autoscaling and basic resource visibility without deploying Prometheus, Grafana, or other heavyweight monitoring solutions.

§02

How it saves time or tokens

Metrics Server is a single deployment that replaces the need to configure a full monitoring pipeline just for autoscaling. Without it, kubectl top returns nothing and HPA cannot make scaling decisions. Installing it takes one command and provides immediate visibility into pod and node resource consumption. It stores only the latest data point in memory, so it adds minimal overhead to the cluster.

§03

How to use

  1. Install Metrics Server with a single command:
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
  1. For development clusters with self-signed kubelet certificates:
kubectl patch deployment metrics-server -n kube-system \
  --type='json' \
  -p='[{"op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": "--kubelet-insecure-tls"}]'
  1. Verify metrics are available:
kubectl top nodes
kubectl top pods -A
§04

Example

# HPA that uses Metrics Server data
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: web-app-hpa
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: web-app
  minReplicas: 2
  maxReplicas: 10
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 70
    - type: Resource
      resource:
        name: memory
        target:
          type: Utilization
          averageUtilization: 80
§05

Related on TokRepo

§06

Common pitfalls

  • On minikube and kind clusters, kubelet certificates are self-signed; Metrics Server fails to scrape without the --kubelet-insecure-tls flag
  • Metrics Server only stores the latest data point; it is not a replacement for Prometheus or other time-series databases for historical analysis
  • HPA requires resource requests to be set on containers; without them, utilization percentages cannot be calculated and autoscaling silently fails

Questions fréquentes

Does Metrics Server replace Prometheus?+

No. Metrics Server provides only current CPU and memory data for autoscaling. It does not store historical data, support custom metrics, or provide alerting. Use Prometheus or similar for full monitoring. Metrics Server and Prometheus can run side by side.

Why does kubectl top show 'metrics not available'?+

This happens when Metrics Server is not installed or cannot scrape kubelets. Install Metrics Server and check its logs for TLS errors. On development clusters, add the --kubelet-insecure-tls flag to bypass certificate validation.

How much overhead does Metrics Server add?+

Metrics Server is designed to be lightweight. It stores only the latest data point in memory, not a time series. For a 100-node cluster, it typically uses less than 100MB of memory and minimal CPU. It scrapes kubelets every 15 seconds by default.

Can I use Metrics Server for custom application metrics?+

No. Metrics Server only provides CPU and memory resource metrics. For custom application metrics in HPA, use the custom metrics API backed by Prometheus Adapter, Datadog Cluster Agent, or similar custom metrics providers.

Is Metrics Server required for VPA?+

Yes. VerticalPodAutoscaler relies on the Metrics API to observe actual resource usage and recommend or apply resource request adjustments. Without Metrics Server or an equivalent provider, VPA cannot function.

Sources citées (3)

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires