Giter Club home page Giter Club logo

keda-example's Introduction

KEDA example

This repository consists of everything you need to setup simple Kubernetes cluster and demonstrate usage of KEDA redis and mysql scalers. For more samples check https://github.com/kedacore/samples

The included helper provides an easy way to perform both 0 -> n and n -> 0 scalings.

Create cluster

The deployment consists of 4 components:

  • MySQL instance
  • Redis instance
  • Dummy pod that will be scaled up and down
  • App service that provides some helper methods
kubectl apply -f deployment/

Install KEDA

Follow the official KEDA guide https://keda.sh/deploy/

Observe

To observe how everything works you can watch two things:

  • number of pods and their state: watch -n2 "kubectl get pods"
  • HPA stats: watch -n2 "kubectl get hpa"

Redis example

To scale the dummy deployment using Redis scaler first we have to deploy the ScaledObjects:

kubectl apply -f keda/redis-hpa.yaml

this should result in creation of a new ScaledObjects and new HPA

# kubectl get scaledobjects
NAME                 DEPLOYMENT   TRIGGERS   AGE
redis-scaledobject   dummy        redis      5s

# kubectl get hpa
NAME             REFERENCE          TARGETS              MINPODS   MAXPODS   REPLICAS   AGE
keda-hpa-dummy   Deployment/dummy   <unknown>/10 (avg)   1         4         0          45s

To scale up we have to populate the Redis queue. To do this we can use the helper app:

kubectl exec -it $(k get pods | grep "server" | cut -f 1 -d " ") app redis publish

and to scale down:

kubectl exec -it $(k get pods | grep "server" | cut -f 1 -d " ") app redis drain

MySQL example

To scale the dummy deployment using MySQL scaler first we have to deploy the ScaledObjects:

kubectl apply -f keda/mysql-hpa.yaml

this should result again in creation of ScaleObject and an HPA:

# kubectl get scaledobjects
NAME                 DEPLOYMENT   TRIGGERS   AGE
mysql-scaledobject   dummy        redis      5s

# kubectl get hpa
NAME             REFERENCE          TARGETS              MINPODS   MAXPODS   REPLICAS   AGE
keda-hpa-dummy   Deployment/dummy   <unknown>/10 (avg)   1         4         0          45s

To scale up we have to insert some values to MySQL database. To do this we can use the helper app:

kubectl exec $(kubectl get pods | grep "server" | cut -f 1 -d " ") -- keda-talk mysql insert

and to scale down:

kubectl exec $(kubectl get pods | grep "server" | cut -f 1 -d " ") -- keda-talk mysql delete

keda-example's People

Contributors

turbaszek avatar ritikaa96 avatar

Stargazers

hassan.ali avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.