Repository navigation
Description
What
Implement automatic horizontal autoscaling of a managed database's read replicas in response to load, for the PostgreSQL (CloudNativePG) MVP. The mechanism is entirely stock: the app chart renders a KEDA ScaledObject next to the database; KEDA queries VictoriaMetrics for the read load, computes the desired count with a plain HPA it manages, and drives the CNPG Cluster scale subresource (.spec.instances). There is no bespoke operator and no new CRD.
Design
This implements the merged design proposal cozystack/community: Database Horizontal Autoscaler (community#44), including the PoC finding (community#53) that pins the hard precondition CNPG ≥ 1.28.4 — the Cluster scale subresource must serve status.selector or the HPA rejects it with InvalidSelector. That version floor is delivered separately by the postgres-operator bump to CNPG 1.30.0 (#3951).
Scope
- In scope: PostgreSQL read-replica horizontal autoscaling — KEDA as an optional platform package, the chart change (omit
replicasunder autoscaling), a cozy-lib helper that renders theScaledObject, theautoscalingvalues block + schema, the two-phase enable/disable migration, and a dashboard/alert bundle. - Out of scope (follow-ups): MariaDB (once its chart supports on-the-fly scale-out), Redis/MongoDB (no scale subresource — need a thin actuation shim), vertical and storage autoscaling.
Depends on
- fix(postgres-operator): bump CloudNativePG to 1.30.0 for the Cluster scale-subresource selector #3951 — bump CloudNativePG to 1.30.0 (the
status.selectorversion floor the HPA needs).
Activity
feat(postgres): database read-replica autoscaling via KEDA (#3954)
lexfrei commentedon Sep 23, 2026
Done in #3954, with follow-ups in #4188: the postgres chart renders a KEDA
ScaledObject, and KEDA ships as a platform package. MariaDB, Redis and MongoDB can get their own issues.