finds.dev← search

// the find

stefanprodan/k8s-prom-hpa

★ 567 · Makefile · MIT · updated Jun 2021

Kubernetes Horizontal Pod Autoscaler with Prometheus custom metrics

A step-by-step tutorial repo showing how to wire Prometheus custom metrics into the Kubernetes HPA v2 via the k8s-prometheus-adapter. It's aimed at platform engineers who already know Kubernetes basics and want a concrete, working example of custom-metric autoscaling rather than just reading the docs. Stefan Prodan (author of Flux, Flagger) wrote it, so the kubectl manifests are sensible.

The end-to-end flow is complete — metrics-server, Prometheus, the adapter, TLS cert generation, and the HPA manifests are all included, not just described. The diagrams make the aggregation-layer architecture (metrics-server vs custom-metrics-api) immediately clear, which the official docs fail to do. The 'milli-unit' explanation of the custom metric values (901m = 901 milli-requests) is actually useful since this trips up almost everyone the first time. Using podinfo as the demo app means you can run the whole thing against a real cluster in under an hour.

Last commit was June 2021 and targets Kubernetes 1.9 — the autoscaling/v2beta2 API it uses was promoted to stable autoscaling/v2 in 1.26 and v2beta2 is gone in recent clusters. The k8s-prometheus-adapter version pinned in the manifests is ancient; the adapter's configuration API changed meaningfully since then. There's no Helm or kustomize wrapper, so you're hand-editing raw YAML to adapt it to any real cluster. No coverage of KEDA, which has largely replaced the raw prometheus-adapter pattern for most teams — this repo gives you no context on when you'd choose one over the other.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →