Sitemap

Cost Optimization in Kubernetes Cluster with Kube-downscaler

2 min readDec 28, 2022

This article describes about basic understanding about how we can save cost with kube-downscaler tool.

Why using Kube-downscaler

kube-downscaler Scale down Kubernetes deployments and/or statefulsets during non-work hours.Scale down / “pause” Kubernetes workload (Deployments, StatefulSets, and/or HorizontalPodAutoscalers and CronJobs ) during non-work hours.

How do I configure the downscaler in Kubernetes?

The downscaler is configured via command line args, environment variables and/or Kubernetes annotations. Time definitions (e.g. DEFAULT_UPTIME) accept a comma separated list of specifications, e.g. the following configuration would downscale all deployments for non-work hours.

Installation Method

Clone the repository

git clone https://github.com/hjacobs/kube-downscaler.git
cd kube-downscaler

DEFAULT_DOWNTIME="Sat-Sun 00:00-24:00 CET,Fri-Fri 20:00-24:00 CET'

kubectl apply -f deploy/

The following annotations are supported on the Namespace level:

annotations:
downscaler/uptime: Mon-Sun 07:30-18:00 CETdownscaler/upscale-period
  • downscaler/downscale-period
  • downscaler/uptime: set "uptime" for all resources in this namespace
  • downscaler/downtime: set "downtime" for all resources in this namespace
  • downscaler/force-downtime: force scaling down all resources in this namespace - can be true/false or a period
  • downscaler/force-uptime: force scaling up all resources in this namespace - can be true/false or a period
  • downscaler/exclude: set to true to exclude all resources in the namespace
  • downscaler/exclude-until: temporarily exclude all resources in the namespace until the given timestamp
  • downscaler/downtime-replicas: overwrite the default target replicas to scale down to (default: zero)

Reference and Documentations

hjacobs/kube-downscaler: Scale down Kubernetes deployments after work hours — kube-downscaler — Codeberg.org

Saurabh Mishra
Saurabh Mishra

Written by Saurabh Mishra

DevOps & Cloud Evangelist ||Google Developer Expert-GCP||DevOps Institute-AMB || GCP Champion Innovator||AWS CB||Calico Big Cats ||CDF AMB|| open-appsec AMB