Kube-green

Introduction

Kube-green is an open-source Kubernetes operator that automatically shuts down and restarts workloads on a defined schedule. Its primary use case is reducing resource consumption and cloud costs by scaling down environments during off-hours, such as nights and weekends.

How it works

Kube-green introduces a custom resource called SleepInfo. You create a SleepInfo resource in any namespace where you want to control workload scheduling. The kube-green controller watches these resources and takes action based on the defined schedule:

  • At sleep time: Deployments and StatefulSets are scaled to 0 replicas. Optionally, CronJobs are suspended.
  • At wake time: the original replica counts are restored, and CronJobs are unsuspended.

Each SleepInfo operates within its own namespace, giving individual teams control over their own schedules without affecting other namespaces. You can also exclude specific resources from being affected by the sleep schedule, which is useful for services that must remain available (e.g. message consumers, background workers).

Key features of the SleepInfo resource:

  • Weekday selection: define which days of the week the schedule applies (e.g. Monday through Friday)
  • Sleep and wake times: set specific times in a given timezone
  • CronJob suspension: optionally suspend CronJobs during sleep periods
  • Exclusions: exclude specific Deployments, StatefulSets, or CronJobs from the schedule

Infrastructure

Kube-green is deployed as an optional component in our Kubernetes stack. The controller runs on system nodes and is managed through Flux. A Vertical Pod Autoscaler (VPA) is configured to automatically adjust the controller’s resource allocation.

You don’t need to interact with the controller itself. Once kube-green is enabled on your cluster, you simply create SleepInfo resources in the namespaces you want to manage.

Related

Last updated on