Skip to content
All projects

FinOps Kubernetes Operator

Kubernetes operator that scales non-production workloads to zero during declared sleep windows, with per-workload exclusions.

Source code
  • Kubernetes Operator
  • Python
  • Kopf
  • FinOps

The problem

Non-production clusters run all night and all weekend at full replica count, paying for capacity nobody is using — and the obvious fix, scaling things down, is exactly the kind of automation that causes an outage when it gets one workload wrong.

Constraints

Architecture

Trigger

Kopf timer — every 60s

Reconcile

Scaling engine
Read annotations
Compute active window

Act

Inside sleep windowpatch replicas → 0
Excludedbypass workload

Key decisions

What was chosen, what it was chosen over, and why.

Also decided

  • Per-workload exclusion annotationnotA central allow-list maintained by the platform team

    Opting a critical workload out has to be possible without a platform-team round trip. Cost automation only survives contact with users if the escape hatch is trivial.

  • Server-side field_selector when listing podsnotListing everything and filtering client-side

    The API server does the filtering, so the operator does not pull every pod in the cluster into memory to count a handful. It also skips terminating pods, which would otherwise read as rogue workloads.

  • Timer-based reconciliation every 60 secondsnotEvent-driven triggers

    The trigger is wall-clock time, not a cluster event. A periodic loop matches the shape of the problem and converges after any missed tick, restart or reschedule.

  • Kopf and PythonnotThe Go operator SDK and controller-runtime

    The reconciliation logic is small and schedule-shaped, so Kopf keeps it short and quick to iterate. The trade is a heavier runtime and a smaller ecosystem than controller-runtime.