Reading Time: 4 minutes
Share:
Twitter
LinkedIn
Facebook
Reddit
Whatsapp
Follow by Email

So, what actually is keda?

So, Keda or, Kubernetes-based Event Driven Autoscaler is a way for you to drive the scaling of any container in your kubernetes cluster based on a number of events (in my case messages on a RabbitMQ queue). This is achieved by two custom resources: ScaledObjects and TriggerAuthentication.  You create a YAML file that defines what to listen to and when. It then allows you to set parameters for the scaling. It then creates an HPA (horizontal pod autoscaler) that will then scale you pod based on the information provided in the YAML file.

Basically you create some resources called ScaledObject, this then listens at the defined interval to your message queue for example and when your set parameters are met it will either scale up or down your pods. One good thing about this is you can scale all the way down to 0!

You can read more about Keda on their website https://keda.sh/

How to deploy Keda

There are a couple of ways to install Keda. Helm charts and YAML files. I personally choose to use the Yaml file method. This is mostly due to a bad experience with Helm 2 and the use of Tiller. That has now been resolved in Helm 3 so I may switch at some point.

Deploying with YAML and kubectl

For this, you will need to clone and download the keda repo. The repo can be found at https://github.com/kedacore/keda. You will find the YAML files in the /deploy directory. Feel free to review and edit them to fit your needs or just go ahead and deploy them.

So in your terminal navigate to a folder that you have downloaded the repo to and make sure you are connected to the Kubernetes cluster you would like to deploy Keda to.

First, you will need to create a namespace called keda.

Now the actual deployment.

Deploying with Helm

For this you will need Helm installed you can find out how to do that at https://helm.sh/docs/intro/install/. I would highly recommend you go with Helm 3.

First, you will need to add the Helm repo. This will add the keda helm repo to your list of repos.

Now you will need to update the helm repo. This will download the latest charts from the helm repos.

Helm 2

To deploy with helm 2 you can use the following command.

I do not have helm 2 installed so will be unable to share a picture.

Helm 3

To deploy using helm 3 use the following. You will notice you have to create the keda namespace first using kubectl.

You have now installed keda using helm

Check the deploy

To check that everything has deployed you can use the following command. You should see that all pods, services, deployments and replica sets are up and running. If you have any issues, it would be wise to uninstall and try again. Failing that reach out at the Git Repo.

How to remove Keda

The YAML way

As with deploying keda, you will need to be in the same directory that you have cloned from the GitHub repo. You will then need to use the following commands to delete the deployed resources.

Now to clear things up you can remove the namespace by using the following.

The Helm way

If you have helm 2 then use this.

If you have used helm 3 then use this.

Summary

So above I have explained what keda is, how to install it using YAML files and helm. I have also shown you how to check if the deployment has been successful and also how to remove it. I am currently using keda for all of my kubernetes scale needs as I am using RabbitMQ as my message broker. In another article, I will go through the steps needed to get keda to auto-scale based on a RabbitMQ queue size.

Until then, if you have any questions or comments please leave them below or reach out in the usual ways.

Share:
Twitter
LinkedIn
Facebook
Reddit
Whatsapp
Follow by Email

Pixel Robots.

I’m Richard Hooper aka Pixel Robots. I started this blog in 2016 for a couple reasons. The first reason was basically just a place for me to store my step by step guides, troubleshooting guides and just plain ideas about being a sysadmin. The second reason was to share what I have learned and found out with other people like me. Hopefully, you can find something useful on the site.

1 Comment

Nilesh · October 20, 2020 at 1:53 am

This is a great introduction to KEDA. Readers of this blog might find this 3 part Youtube video series on KEDA helpful
https://www.youtube.com/playlist?list=PLOPXEdTIaFO8D73ufHmoGCauRRhCy5uBh

There is also an interesting video on using KEDA along with Azure Container Instances (ACI) to make use of Serverless capabilities. This uses the Virtual Node to schedule workloads on serverless infrastructure.
https://www.youtube.com/watch?v=9_rxGygUH1Y&t=293s

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *