feat(tiller): prometheus_adapter_config builder + HPA-friendly replicas #1

Merged
arrdem merged 1 commit from claude/tiller-prometheus-adapter-f04fbe35 into trunk 2026-04-21 18:28:00 +00:00
Contributor

Adds two pieces needed for HPA-driven autoscaling on custom Prometheus metrics:

  • prometheus_adapter_config(name, rules=..., external_rules=..., resource_rules=...) renders a ConfigMap in the prometheus-adapter rule schema. Rule dicts pass through verbatim; the builder only handles YAML serialization and ConfigMap wrapping.
  • deployment() and statefulset() accept replicas=None to omit the spec.replicas field. An HPA targeting the Deployment can then own the replica count without kubectl apply rewriting it on every reconcile.

The first consumer is Flowmetal, which uses both to autoscale Starlark workers and HTTP connectors off custom Prometheus metrics.

Changes are visible to end-users: yes

  • Searched for relevant documentation and updated as needed: yes (docs/builtins.md)
  • Breaking change (forces users to change their own code or config): no — new builder, and replicas default stays at 1
  • Suggested release notes appear below: yes

New prometheus_adapter_config() builder for prometheus-adapter ConfigMaps. deployment() and statefulset() accept replicas=None to let an HPA own the replica count.

Test plan

  • New test cases added (TestPrometheusAdapterConfig, TestReplicasOmission)
  • Covered by existing test cases (the existing HPA test still passes)
Adds two pieces needed for HPA-driven autoscaling on custom Prometheus metrics: - `prometheus_adapter_config(name, rules=..., external_rules=..., resource_rules=...)` renders a `ConfigMap` in the [prometheus-adapter](https://github.com/kubernetes-sigs/prometheus-adapter/blob/master/docs/config.md) rule schema. Rule dicts pass through verbatim; the builder only handles YAML serialization and ConfigMap wrapping. - `deployment()` and `statefulset()` accept `replicas=None` to omit the `spec.replicas` field. An HPA targeting the Deployment can then own the replica count without `kubectl apply` rewriting it on every reconcile. The first consumer is Flowmetal, which uses both to autoscale Starlark workers and HTTP connectors off custom Prometheus metrics. ### Changes are visible to end-users: yes - Searched for relevant documentation and updated as needed: yes (docs/builtins.md) - Breaking change (forces users to change their own code or config): no — new builder, and `replicas` default stays at `1` - Suggested release notes appear below: yes > New `prometheus_adapter_config()` builder for prometheus-adapter ConfigMaps. `deployment()` and `statefulset()` accept `replicas=None` to let an HPA own the replica count. ### Test plan - New test cases added (`TestPrometheusAdapterConfig`, `TestReplicasOmission`) - Covered by existing test cases (the existing HPA test still passes)
Adds two pieces for HPA-driven autoscaling on Prometheus metrics:

- prometheus_adapter_config(name, rules=..., external_rules=...,
  resource_rules=...) renders a ConfigMap in the prometheus-adapter
  rule schema. Rule dicts are passed through verbatim; the builder
  only serializes to YAML and wraps the result in a ConfigMap.

- deployment() and statefulset() accept replicas=None to omit the
  spec.replicas field. An HPA that targets the Deployment can then
  own the replica count without kubectl apply rewriting it on every
  reconcile.

The first consumer is flowmetal, which will use both to autoscale
its Starlark workers and HTTP connectors off custom Prometheus
metrics.
arrdem merged commit dcf0c17a7a into trunk 2026-04-21 18:28:00 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
arrdem/source!1
No description provided.