metrics-server.md
July 15, 2026 ยท View on GitHub
Using metrics-server instead of prometheus-adapter
By default, kube-prometheus deploys prometheus-adapter to serve the Kubernetes resource metrics API (metrics.k8s.io). This is a full-featured solution that derives CPU and memory metrics from Prometheus queries, and can also serve custom and external metrics APIs.
However, for use cases where only the resource metrics API is needed (for example, when using KEDA for custom metrics scaling), the lightweight upstream metrics-server may be preferable.
Important
prometheus-adapter is being deprecated by SIG Instrumentation. The project recommends migrating to KEDA for custom/external metrics use cases. Since metrics-server handles the resource metrics API natively without requiring Prometheus queries, it is the natural replacement for the resource metrics portion. We plan to make metrics-server the default resourceMetricsAPI in a future release of kube-prometheus.
Switching to metrics-server
Set the resourceMetricsAPI field in values.common to 'metrics-server':
(import 'kube-prometheus/main.libsonnet') +
{
values+:: {
common+: {
resourceMetricsAPI:: 'metrics-server',
},
metricsServer+: {
kubeletInsecureTLS:: true,
},
},
}
This replaces the prometheus-adapter manifests with metrics-server manifests. Only one resource metrics API provider can be active at a time since they both register the v1beta1.metrics.k8s.io APIService.
When to set kubeletInsecureTLS
On clusters that do not use proper kubelet serving certificates (for example, kind, minikube, or clusters without a kubelet-serving CA), set kubeletInsecureTLS:: true. On production clusters with a properly configured kubelet PKI, this should be left at the default (false).
Emitting manifests
If you are writing your own top-level jsonnet (instead of using example.jsonnet), emit the resource metrics manifests using the helper library:
(import 'kube-prometheus/lib/resource-metrics-api.libsonnet')(kp)
This automatically selects the correct component based on the resourceMetricsAPI flag.
Single-node clusters
The default configuration deploys 2 replicas with hard pod anti-affinity, which requires at least 2 nodes. On single-node clusters (minikube, single-node kind, etc.), set replicas:: 1 or switch to soft anti-affinity:
values+:: {
metricsServer+: {
replicas:: 1,
},
},
Available configuration
The following hidden fields can be overridden in values.metricsServer:
| Field | Default | Description |
|---|---|---|
replicas | 2 | Number of metrics-server replicas |
resources | {requests: {cpu: '100m', memory: '200Mi'}} | Resource requests/limits |
kubeletInsecureTLS | false | Skip kubelet TLS verification |
metricResolution | '15s' | How often metrics are scraped from kubelets |
securePort | 10250 | Metrics-server HTTPS port |
extraArgs | [] | Additional command-line arguments |
podAntiAffinity | 'hard' | Pod anti-affinity type ('hard' or 'soft') |
podAntiAffinityTopologyKey | 'kubernetes.io/hostname' | Topology key for anti-affinity |
insecureSkipTLSVerify | true | APIService TLS verification |
priorityClassName | 'system-cluster-critical' | Pod priority class |
Generating and deploying manifests
To generate manifests using the provided example:
make manifests-metrics-server
This builds from examples/metrics-server.jsonnet and outputs YAML manifests to manifests/. Then deploy:
kubectl apply --server-side -f manifests/setup
kubectl apply -f manifests/
Full example
See examples/metrics-server.jsonnet for a complete working example that deploys the full kube-prometheus stack with metrics-server instead of prometheus-adapter.