Cost Optimization in Kubernetes Cluster with Kube-downscaler
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-perioddownscaler/downscale-perioddownscaler/uptime: set "uptime" for all resources in this namespacedownscaler/downtime: set "downtime" for all resources in this namespacedownscaler/force-downtime: force scaling down all resources in this namespace - can betrue/falseor a perioddownscaler/force-uptime: force scaling up all resources in this namespace - can betrue/falseor a perioddownscaler/exclude: set totrueto exclude all resources in the namespacedownscaler/exclude-until: temporarily exclude all resources in the namespace until the given timestampdownscaler/downtime-replicas: overwrite the default target replicas to scale down to (default: zero)
Reference and Documentations
