☸️ Kubernetes: Fix an HPA Ignoring Custom Metrics From the Adapter
A HorizontalPodAutoscaler configured against a custom.metrics.k8s.io metric only scales correctly if the metrics adapter actually exposes that metric for the object the HPA targets — a Deployment, say — and not just for the underlying Pods. Many Prometheus adapter configs are written around pod-level series by default, so the HPA controller’s query for the Deployment-scoped metric comes back empty, and the HPA quietly falls back to doing nothing rather than erroring loudly.
🔎 The Problem
# HPA spec
metrics:
- type: Object
object:
metric:
name: queue_messages_per_pod
describedObject:
apiVersion: apps/v1
kind: Deployment
name: worker
# kubectl get hpa worker shows TARGETS: <unknown>/10
# adapter's seriesQuery only maps pod-scoped metrics, never Deployment
✅ Fix: Make the Adapter Serve the Scope the HPA Actually Queries
- Check the adapter’s rule set with
kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1"and confirm it actually lists a resource entry for thedescribedObject.kindyour HPA targets, not only for Pods. - Add or adjust the adapter’s
resourcesandseriesQuerymapping so the metric is exposed at Deployment scope (an ‘external’ or ‘object’ metric type), rather than only aggregating per-pod series the HPA never asked for. - Use
kubectl get hpa worker -o yamland checkstatus.conditionsforFailedGetObjectMetric— it names the exact API path the controller tried and failed, which is faster than guessing at the adapter config.
🚨 Why This Is Dangerous
- A deployment under real load can sit at its minimum replica count indefinitely because the autoscaler has no error to alert on — it simply has no data, which looks identical to ‘everything is fine and no scaling is needed’ on a dashboard that only tracks HPA replica counts.
An HPA that can’t see a metric doesn’t fail loudly — it just quietly agrees that nothing needs to change.





