Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio
Kubernetes

Kubernetes: Fix an HPA Ignoring Custom Metrics From the Adapter

- 27.11.26 - ErcanOPAK

☸️ 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 the describedObject.kind your HPA targets, not only for Pods.
  • Add or adjust the adapter’s resources and seriesQuery mapping 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 yaml and check status.conditions for FailedGetObjectMetric — 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.

— Cloud Architect

Related posts:

Why Pods Restart Even When CPU & Memory Look Fine

Why Pods Restart Even When CPU & Memory Look Fine

Kubernetes: Fix a Rolling Update That Stalls Forever Because the New Pod's Readiness Probe Depends o...

Kubernetes: Fix a Rolling Update That Stalls Forever Because the New Pod's Readiness Probe Depends o...

Kubernetes: Avoiding the 'OOMKilled' Error with Proper Resource Limits

Kubernetes: Avoiding the 'OOMKilled' Error with Proper Resource Limits

Views: 6
Found this useful? Share it
XLinkedInWhatsApp

Post navigation

SQL Server: Fix a Deadlock Between Two Identical Merge Statements
Asp.Net Core: Fix Response Compression Skipping a Streamed Result

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Most Read

  1. 01How to make theater mode the default for Youtube 1,080 views
  2. 02How to add default value for Entity Framework migrations for DateTime and Bool 997 views
  3. 03Get the User Name and Domain Name from an Email Address in SQL 996 views
  4. 04Get the First and Last Word from a String or Sentence in SQL 873 views
  5. 05How to select distinct rows in a datatable in C# 868 views
  6. 06How to enable, disable and check if Service Broker is enabled on a database in SQL Server 672 views
  7. 07Add Constraint to SQL Table to ensure email contains @ 631 views
  8. 08Average of all values in a column that are not zero in SQL 585 views
  9. 09How to use Map Mode for Vertical Scroll Mode in Visual Studio 562 views
Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
Back to top
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com