top of page

Reduce Your Cluster Cost with kube-downscaler

  • May 9
  • 4 min read
Table of Contents:

Overview

Kubernetes offers powerful capabilities for running containerized applications at scale, but this scalability comes with a cost. Idle resources, especially during non-business hours, can lead to ballooning cloud bills. Enter kube-downscaler—an open-source utility designed to help you minimize costs by intelligently scaling down workloads during off-peak hours and bringing them back up when needed.


In this blog post, we’ll explore what kube-downscaler is, how it works, and how you can integrate it into your Kubernetes cluster to optimize resource utilization and significantly reduce costs.


What is kube-downscaler?

Kube-downscaler is a controller that periodically scales down deployments, statefulsets, and cronjobs in your Kubernetes cluster based on configurable time schedules (typically during nights and weekends) and scales them back up when needed. It’s ideal for:


  • Development or staging environments that are not used 24/7.

  • QA/testing environments that follow a strict working schedule.

  • Any non-production workloads where uptime isn’t critical outside business hours.


Key Features:

✅ Scales deployments and statefulsets to 0 replicas during off-hours.

✅ Brings workloads back up to their original replica count during working hours.

✅ Simple configuration using annotations.

✅ Supports custom time zones.

✅ Supports dry runs and metrics for observability


How kube-downscaler Works?

Kube-downscaler works as a controller running in your cluster. It monitors annotated workloads and adjusts their replica count based on a defined schedule. It stores the original replica count in an annotation to ensure state is preserved.


Architecture Overview:

  1. Scheduler Loop: Runs at a fixed interval (e.g., every minute).

  2. Time Evaluation: Checks current time against user-defined downscaling schedule.

  3. Downscale/Restore Logic: Applies the scale changes using Kubernetes APIs.

  4. Annotation State Management: Keeps track of the original replica count for safe restores.

Key Concepts:

  • Annotations-Based Control: kube-downscaler uses annotations on resources to determine scaling behavior.

  • Schedule Syntax: Schedules are defined using a cron-like syntax or a simplified day/time format.

  • State Tracking: The original number of replicas is stored in an annotation, allowing for precise restoration.



Getting Started

Deploy kube-downscaler

To install kube-downscaler, you can deploy it using the provided Helm chart or raw Kubernetes manifests.

Make sure the service account has the necessary RBAC permissions.


Alternatively, with Helm:

helm repo add hjacobs https://hjacobs.github.io/helm-charts/ 
helm install kube-downscaler hjacobs/kube-downscaler
📌 Pro tip: Run it with restricted RBAC permissions and namespace scoping if needed.

Annotate Your Workloads

To enable downscaling, annotate your deployments/statefulsets:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-dev-app
  annotations:
    downscaler/exclude: "false"
    downscaler/uptime: Mon-Fri 08:00-18:00 Europe/Berlin
spec:
  replicas: 3
  • downscaler/exclude: Set to "true" to skip a workload.

  • downscaler/uptime: Specifies when the workload should be up (rest of the time it's scaled to 0).


For CronJobs:

metadata:
  annotations:
    downscaler/skip-cronjobs: "false"

Common Annotations

Annotation

Description

downscaler/exclude

Time window when the workload should be up

downscaler/force

Set to true to ignore the workload

downscaler/uptime

Set to true to enable downscaling even if uptime is not specified

You can configure it globally or per workload, offering flexibility in how you manage different environments.


Example Use Case

Imagine a development cluster with the following setup:

  • 5 microservices (each with 2 replicas)

  • Active only from 9 AM to 5 PM, Monday to Friday


By annotating each deployment with downscaler/uptime: Mon-Fri 09:00-17:00, kube-downscaler will automatically:

  • Scale down all replicas to 0 at 5 PM

  • Scale them back up to 2 at 9 AM the next day


The result? You save nearly 70% of compute costs for each service during off hours.


Cost Savings Potential

Let’s assume you’re running 10 deployments with 2 vCPU each. If you scale them down for 14 hours a day and during weekends:

  • Saved hours/week = (14 5 weekdays + 24 2 weekend days) = 118 hours

  • Total hours/week = 168 hours

  • % saved = 118 / 168 ≈ 70%

  • Potential cost savings = 70% of your dev/staging environment compute costs


If your monthly dev/staging compute bill is $2,000, you could save up to $1,400/month just by automating downscaling.


Considerations and Limitations

  • Cold Start Time: Stateless applications recover fast, but stateful apps (like databases) might need warm-up time.

  • CronJobs: kube-downscaler can also disable CronJobs by removing schedules, but this requires careful configuration.

  • Manual Overrides: Be mindful if you manually scale a deployment—kube-downscaler will override it during its next sync.

  • Cluster Autoscaler Integration: kube-downscaler works best in clusters with autoscaling enabled to actually terminate unused nodes.



Conclusion

Kube-downscaler is a simple yet powerful tool that can help you slash Kubernetes costs with minimal effort. By downscaling workloads outside of working hours, you can ensure that you’re only paying for the resources you truly need—nothing more.


It’s open-source, easy to deploy, and highly configurable, making it a perfect fit for dev/test environments in any cost-conscious organization.


At Ananta Cloud, we specialize in building and cost optimizing Kubernetes platforms—integrating automation, observability, and scalability from day one.


🚀Empower your cloud-native applications with production-grade Kubernetes infrastructure and expert operational support.


📞 Contact Ananta Cloud today for a free consultation on your Kubernetes journey.




Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
average rating is 4 out of 5, based on 150 votes, Recommend it

Subscribe For Updates

Stay updated with the latest cloud insights and best practices, delivered directly to your inbox.

91585408_VEC004.jpg
Collaborate and Share Your Expertise To The World!
Ananta Cloud welcomes talented writers and tech enthusiasts to collaborate on blog. Share your expertise in cloud technologies and industry trends while building your personal brand. Contributing insightful content allows you to reach a broader audience and explore monetization opportunities. Join us in fostering a community that values your ideas and experiences.
business-professionals-exchanging-handshakes.png
bottom of page