kube-green — Kubernetes

Always learning
2 min readSep 3, 2024

--

kube-green is an open-source tool that reduces software power consumption.

kube-green enables users to configure time periods during which unused resources are automatically shut down.

A k8s operator to reduce the CO2 footprint of your clusters. It is a simple k8s addon that automatically shuts down (some of) your resources when you don’t need them.

kube-green is a tool in the Container Tools category of a tech stack.

kube-green’s Features

  1. Suspend your pods when no-one’s using them, scale down your cluster and save energy.
  2. Reduce CO2 emissions.

buymeacoffee ☕ 👈 Click the link

How it Works

The use of kube-green is very simple, once installed on cluster, configure the desired CRD to make it work.

The CRD used by kube-green is called Sleeping. In configuration, it’s possible to configure the sleep and wake up time for namespace.

So, we can define a specific time for a particular namespace and the wake-up time for a particular namespace so you can define a specific time where these pods and deployments will go to sleep.

We can also specify the woke-up-time. The CRD is simple with

  1. SleepInfo
  2. Weekdays
  3. SleepTime
  4. TimeZone

Suspended CronJobs.

  • SleepInfo : It is the Schema for the sleepinfos API.
  • ExcludeRef : This is used to exclude the pods and resources where aren't to be included in the measures and rules we set for the rest of our cluster while using kube-green.
  • SleepInfoSpec : Defines the desired state of SleepInfo.
  • SleepInfoStatus : Defines the observed state of SleepInfo

Kube-Green handles:

  • Deployments
  • CronJobs

By default, on sleep, deployment resources are stopped (if not excluded). If you want to suspend also cronjobs, set suspend CronJobs to true.

The sleep of the resource is the stop of the resource, and it depends on the type of resources.

The wake up of the resource is the restore of the status of the resource before the sleep.

Deployment

To sleep the Deployment resources, replicas are set to 0.

To wake up, the number of replicas is set to the number of replicas before the sleep.

CronJobs

To sleep the CronJob resources, are set as suspended.

To wake up, the suspend field is restored.

Installing to our Clusters

Successfully install kube-green, in the cluster must be installed a cert-manager. If it is not already installed installed, click here.

The default static configuration for the latest release can be installed

kubectl apply -f https://github.com/kube-green/kube-green/releases/latest/download/kube-green.yaml

If you want to install a specific release version, run:

kubectl apply -f https://github.com/kube-green/kube-green/releases/download/${RELEASE_TAG}/kube-green.yaml

Refer the documentation Click Here 👈👈👈

What are some alternatives to kube-green?

  1. JavaScript
  2. Git
  3. GitHub
  4. Python

Thank you 🙏 for taking the time to read our blog.

--

--

Always learning

கற்றுக் கொள்ளும் மாணவன்...