Overview
Most Kubernetes workloads ask for far more CPU and memory than they ever use, and the cluster pays for that gap every hour. The optimizer watches what each workload actually consumes, forecasts what it will need next, and rewrites its resource requests — but only when a chain of safety checks agrees the change is safe.
In evaluation on Google Kubernetes Engine it cut cost by 20–40%. The approach is published as Safety-Gated Autoscaling (arXiv:2607.26503).
How it works
- CollectScrapes CPU and memory usage from the Kubernetes metrics API into an in-memory time-series store.
- AnalyseFlags anomalies (Z-score, IQR, moving average), detects memory leaks with regression and forecasts demand with Holt-Winters.
- RecommendComputes P95/P99 usage with a 1.2× safety margin and gives every recommendation a 0–100% confidence score.
- OptimiseBalances cost, performance, reliability, efficiency and stability with multi-objective (Pareto) optimisation, then applies YAML policies and SLA checks.
- GateChecks for HPA/PDB conflicts, OOM risk and the circuit-breaker state before anything changes.
- Apply & roll backPatches the deployment and reverts automatically if health checks fail; changes can also be exported as Kustomize/Helm for GitOps.
What’s in the source code
Written entirely in Go. The controller, collector and CLI live in cmd/; each part of the pipeline is its own package under pkg/.
cmd/Controller, metrics collector and theoptctlCLIpkg/recommendationP95/P99 percentile enginepkg/predictionHolt-Winters forecastingpkg/anomalyZ-score, IQR and moving-average detectionpkg/leakdetectorMemory-leak detection via regressionpkg/paretoMulti-objective optimisationpkg/policy · pkg/slaPolicy engine and SLA monitoringpkg/safetyOOM checks and circuit breakerpkg/gitopsKustomize / Helm exportpkg/costAWS, GCP and Azure pricing models
go build -o bin/optimizer-controller ./cmd/controller/ kubectl apply -f config/crd/ ./bin/optimizer-controller
The repository README reports 91 test files with 959 test cases, 83.0% coverage of pkg/, a clean race-detector run and about 50 ms per recommendation.