derailed/k9s · warning
no metrics-server detected on cluster
Error message
no metrics-server detected on cluster
What it means
Returned by MetricsServer.checkAccess (internal/client/metrics.go:92) when HasMetrics() reports the cluster does not expose the metrics.k8s.io API. HasMetrics() delegates to supportsMetricsResources(), a discovery call checking for the metrics-server aggregated APIService. The error fires before any RBAC check, on every FetchNodesMetrics/FetchNodeMetrics/FetchPodsMetrics/FetchPodMetrics call, which all funnel through checkAccess.
Source
Thrown at internal/client/metrics.go:92
nodeMetrics[nmx.Items[i].Name] = node
}
}
var ccpu, cmem, tcpu, tmem int64
for _, mx := range nodeMetrics {
ccpu += mx.CurrentCPU
cmem += mx.CurrentMEM
tcpu += mx.AllocatableCPU
tmem += mx.AllocatableMEM
}
mx.PercCPU, mx.PercMEM = ToPercentage(ccpu, tcpu), ToPercentage(cmem, tmem)
return nil
}
func (m *MetricsServer) checkAccess(ns string, gvr *GVR, msg string) error {
if !m.HasMetrics() {
return errors.New("no metrics-server detected on cluster")
}
auth, err := m.CanI(ns, gvr, "", ListAccess)
if err != nil {
return err
}
if !auth {
return errors.New(msg)
}
return nil
}
// NodesMetrics retrieves metrics for a given set of nodes.
func (*MetricsServer) NodesMetrics(nodes *v1.NodeList, metrics *mv1beta1.NodeMetricsList, mmx NodesMetrics) {
if nodes == nil || metrics == nil {
return
}
View on GitHub (pinned to 2d3ccc6ba2)
Solutions
- Install metrics-server in the cluster and wait for APIService v1beta1.metrics.k8s.io to become Available (kubectl get apiservices)
- Check the metrics-server pod logs and readiness: kubectl -n kube-system get pods | grep metrics-server
- If RBAC hides the group, grant list/get on apiservices or fix the aggregation-layer certs
- Gracefully degrade: treat this error as 'metrics feature unavailable' instead of a hard failure
Example fix
// before
mx, err := metricsSrv.FetchNodesMetrics(ctx)
// after
if !metricsSrv.HasMetrics() {
return nil, nil // metrics not deployed; skip pulse view gracefully
}
mx, err := metricsSrv.FetchNodesMetrics(ctx) Defensive patterns
Strategy: validation
Validate before calling
if !metricsSrv.HasMetrics() {
return nil, nil // or a typed 'metrics unavailable' sentinel
}
mx, err := metricsSrv.FetchNodesMetrics(ctx) Try / catch
mx, err := metricsSrv.FetchNodesMetrics(ctx)
if err != nil && strings.Contains(err.Error(), "no metrics-server detected") {
// render UI without metrics columns; do not treat as an error dialog
} Prevention
- Probe HasMetrics() once per connection and cache the result for the session
- Install metrics-server as part of cluster bring-up automation so dev/staging parity holds
- Check kubectl get apiservices v1beta1.metrics.k8s.io when metrics silently vanish
When it happens
Trigger: Calling any metrics fetch (FetchNodesMetrics at metrics.go:155/197, FetchPodsMetrics at :237, FetchPodMetrics at :299) on a cluster without metrics-server installed, with the aggregated APIService unavailable, or while discovery is still populating after cluster startup.
Common situations: Minimal/local clusters (kubeadm without addons, kind without the metrics-server addon), metrics-server pod crash-looping or not yet ready, APIService v1beta1.metrics.k8s.io Available=False, RBAC blocking discovery of the API group so it appears absent.
Related errors
- user is not authorized to list node metrics
- user is not authorized to list pods metrics
- user is not authorized to list pod metrics
- ACCESS -- No API server connection
- no connection to cached dial
AI-assisted analysis of derailed/k9s@2d3ccc6ba2 (2026-08-15).
Data as JSON: /api/errors/ca3987cac0281820.
Report an issue: GitHub.