How santidelacarrera/kubecost_auto_hpa works
KubeCost Auto-HPA is a Kubernetes operator and CLI for cost-aware workload rightsizing and replica scaling, with a Python decision engine and enterprise API. The principal flow reads workload and metric/cost evidence, generates an explainable recommendation, applies fail-closed policy and approval controls, then observes changes and can roll them back. The README also describes read-only capacity, cost, and billing reports. Several engine and operator subsystems are included because they are documented capabilities or core modules; unsampled implementation details limit some relationships.
Main entry points: server.py HTTP engine API · main.go Rightsize commands · enterprise.py Enterprise workflows · kubecosthpa_controller.go KubeCostHPA reconciler
Components 32
Kubernetes operator
- Replica autoscaler
operator/internal/controller/kubecostautoscaler_controller.go - KubeCostHPA reconciler
operator/internal/controller/kubecosthpa_controller.go - Metrics and cache
operator/internal/controller/kubecosthpa_controller.go - Workload actuators
operator/internal/actuator/resize.go
Recommendation and CLI
- Node capacity analysis
operator/internal/capacity/capacity.go - Read-only recommender
operator/cmd/recommend/main.go - Recommendation logic
operator/internal/recommend/recommend.go - Rightsize commands
operator/cmd/rightsize/main.go - Fail-closed policy
operator/internal/safety/safety.go - Apply and rollback
operator/internal/execute/execute.go - Audit chain
operator/internal/execute/chain.go
Decision engine
- HTTP engine API
engine/kubecost_engine/server.py - Bin packing
engine/kubecost_engine/binpacking.py - Predictive analysis
engine/kubecost_engine/predictive.py - OOM protection
engine/kubecost_engine/oom_shield.py - Scaling decisions
engine/kubecost_engine/scaling.py - Cost economics
engine/kubecost_engine/economics.py - GreenOps guardrails
engine/kubecost_engine/greenops_guardrail.py - Cluster assessment
engine/kubecost_engine/cast_suite.py - Engine bootstrap
engine/kubecost_engine/bootstrap.py - Engine persistence
engine/kubecost_engine/persistence.py - Maintenance workflows
engine/kubecost_engine/maintenance.py - Optimization
engine/kubecost_engine/optimization.py
Enterprise services
- Auth and security
engine/kubecost_engine/security.py - Tenant billing
engine/kubecost_engine/auth_billing.py - Enterprise workflows
engine/kubecost_engine/enterprise.py - SaaS control plane
engine/kubecost_engine/saas.py - Tenant users
engine/kubecost_engine/users.py
Other components
- Operator user
- Kubernetes cluster
- Prometheus
- OpenCost / KubeCost
Connections 34
- Operator user → Rightsize commands: runs commands
operator/cmd/rightsize/main.go - Rightsize commands → Recommendation logic: requests plan
operator/cmd/rightsize/main.go - Read-only recommender → Recommendation logic: computes recommendation
operator/cmd/recommend/main.go - Recommendation logic → Prometheus: queries history
- Rightsize commands → Fail-closed policy: checks policy
- Rightsize commands → Apply and rollback: applies or rolls back
operator/cmd/rightsize/main.go - Apply and rollback → Audit chain: records actions
operator/internal/execute/execute.go - Apply and rollback → Kubernetes cluster: changes workloads
- Rightsize commands → Node capacity analysis: plans capacity
operator/cmd/rightsize/main.go - Replica autoscaler → Kubernetes cluster: reconciles replicas
operator/internal/controller/kubecostautoscaler_controller.go - Replica autoscaler → OpenCost / KubeCost: reads allocation costs
- Replica autoscaler → Prometheus: reads resource metrics
- KubeCostHPA reconciler → Metrics and cache: loads snapshots
operator/internal/controller/kubecosthpa_controller.go - KubeCostHPA reconciler → HTTP engine API: requests decisions
operator/internal/controller/kubecosthpa_controller.go - KubeCostHPA reconciler → Workload actuators: resizes workloads
- KubeCostHPA reconciler → Kubernetes cluster: reconciles pods
operator/internal/controller/kubecosthpa_controller.go - HTTP engine API → Auth and security: authenticates requests
engine/kubecost_engine/server.py - HTTP engine API → Bin packing: dispatches requests
engine/kubecost_engine/server.py - HTTP engine API → Predictive analysis: dispatches requests
engine/kubecost_engine/server.py - HTTP engine API → OOM protection: dispatches requests
engine/kubecost_engine/server.py - HTTP engine API → Scaling decisions: dispatches requests
engine/kubecost_engine/server.py - HTTP engine API → Cost economics: dispatches requests
engine/kubecost_engine/server.py - HTTP engine API → GreenOps guardrails: dispatches requests
engine/kubecost_engine/server.py - HTTP engine API → Cluster assessment: dispatches requests
engine/kubecost_engine/server.py - HTTP engine API → Engine bootstrap: initializes services
engine/kubecost_engine/server.py - Engine bootstrap → Engine persistence: configures storage
engine/kubecost_engine/bootstrap.py - HTTP engine API → Enterprise workflows: dispatches workflows
engine/kubecost_engine/server.py - SaaS control plane → Enterprise workflows: uses workflows
engine/kubecost_engine/saas.py - Enterprise workflows → Maintenance workflows: uses maintenance
engine/kubecost_engine/enterprise.py - Enterprise workflows → Optimization: uses optimization
engine/kubecost_engine/enterprise.py - Enterprise workflows → Tenant billing: uses billing
engine/kubecost_engine/enterprise.py - Tenant billing → Auth and security: uses credentials
engine/kubecost_engine/auth_billing.py - Tenant billing → Tenant users: resolves users
engine/kubecost_engine/auth_billing.py - Tenant users → Auth and security: uses authorization
engine/kubecost_engine/users.py