Downscale EKS on demand

How to scale down your EKS cluster in a simple way

Save money of my EKS cluster

The goal was to save money in a dev EKS cluster by scaling down the cluster when it is not being used.

How to do it

  1. Create an EKS cluster
  2. Create an IAM role for the Lambda function
  3. Create the Lambda function and give it the role
  4. Test the Lambda function (in this case i use the console)

I use IaC to up all the infraestructure. Link of the 👉code

The cluster in normal state

i took this picture to check the normal status of the eks test.

detail ui

What happens

When the Lambda function is triggered, it will scale down the EKS cluster to 0 nodes.

detail ui output

Important notes

  • The scaling process takes a few seconds or minutes. It depends of your cluster, so if you trigger the Lambda function multiple times in a short period of time, it may not scale down correctly.
  • You can adjust the period of time between triggers to fit your needs.

Future improvements

  • Find another way to trigger the lambda function(maybe EventBridge).

Resources

🔗Read the full tutorial i changed some parts for my case

Offtopic

Lastly, if you have a dog, please remember to take good care of them.🐶

Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy