The online-hibernation repository is a Go-based controller designed for OpenShift that monitors and manages resource consumption on free tier accounts within Kubernetes clusters. It implements an automated system for controlling pod and workload resource usage through a combination of force-sleep and idle mechanisms, addressing cost optimization and energy efficiency concerns in cloud-native environments.
The controller operates on a quota-hour system where resource usage is tracked within a rolling timeframe defined by the PERIOD parameter. A quota-hour represents a pod consuming its full memory quota for one hour. When a project's accumulated quota-hour usage exceeds the QUOTA_HOURS limit, the controller automatically scales all scalable resources in that project to zero replicas and applies a force-sleep quota that prevents any pods from running. This force-sleep state persists for a duration specified by PROJECT_SLEEP_LENGTH before being removed.
Beyond the quota-based force-sleep mechanism, the controller implements an auto-idling feature that uses Prometheus metrics to monitor network traffic patterns. Projects receiving network traffic below a configured threshold are automatically idled, with their replication controllers, replica sets, deployments, and deployment configs scaled to zero. The controller preserves the original replica counts so that when network traffic resumes, services automatically scale back to their previous levels using the same unidling logic as the origin unidling controller.
The system operates through periodic synchronization cycles. Every SLEEP_SYNC_PERIOD, the controller queries cached project data to calculate quota-hour usage and applies or removes force-sleep quotas as needed. Every IDLE_SYNC_PERIOD, it queries Prometheus metrics to assess network traffic over the IDLE_QUERY_PERIOD and determines whether projects should enter idle state. This dual-mechanism approach allows the controller to handle both resource quota violations and genuinely unused workloads.
The repository is classified across multiple infrastructure and cost-optimization domains including containerization, DevOps, container orchestration, cloud-native technologies, cost-saving strategies, infrastructure efficiency, automation tools, resource management, Kubernetes, energy efficiency, idle resource handling, and cluster scaling. These classifications reflect the controller's comprehensive role in managing cluster resources and reducing operational costs.
Deployment requires Prometheus to be running in the cluster since the auto-idler depends on Prometheus metrics for network traffic analysis. The controller uses glog for logging with structured verbosity levels where level 3 captures resource and watch event messages, level 2 handles project-level sleep and idle operations, and level 1 covers cluster-level sleeper and idler activities.
The force-sleep and auto-idle mechanisms work together to create a tiered resource management system. Projects that exceed quota limits face immediate restrictions through force-sleep, while projects with low network activity are gradually idled to conserve resources. Both states are reversible, allowing services to resume operation when demand returns, making the system suitable for managing variable workloads on shared free tier infrastructure where cost control and fair resource allocation are critical concerns.