Interview Prep/Kubernetes/Control plane, RBAC, webhooks and autoscaling

An HPA on a custom metric shows `<unknown>` and `unable to get metric http_requests_per_second: unable to fetch metrics from custom metrics API: the server could not find the descriptor for metric pods/http_requests_per_second`.

AdvancedTroubleshootingControl plane, RBAC, webhooks and autoscaling
Answer

Likely causes → The custom metrics adapter (prometheus-adapter, KEDA) does not expose that metric: the adapter rule's seriesQuery does not match, the metric lacks namespace/pod labels, or the name translation differs (_total stripped, _per_second added).

Diagnose →

kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1 | jq -r '.resources[].name' | grep http
kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1/namespaces/shop/pods/*/http_requests_per_second" | jq
kubectl logs -n monitoring deploy/prometheus-adapter --tail=50

Fix → Fix the adapter rule so the series has namespace and pod labels and the name matches; or switch to KEDA's Prometheus scaler, which queries PromQL directly.

Prevent → Version adapter rules with the app's metrics; test with kubectl get --raw before wiring the HPA.

All Kubernetes questions Roadmap: Kubernetes networking, storage & scaling

More on Control plane, RBAC, webhooks and autoscaling