https://github.com/turbaszek/keda-example
Sample KEDA deployment with Redis and MySql scalers
https://github.com/turbaszek/keda-example
hpa keda kubernetes sample
Last synced: 6 months ago
JSON representation
Sample KEDA deployment with Redis and MySql scalers
- Host: GitHub
- URL: https://github.com/turbaszek/keda-example
- Owner: turbaszek
- License: apache-2.0
- Created: 2020-03-15T00:07:32.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-02-02T05:45:41.000Z (over 1 year ago)
- Last Synced: 2025-04-15T05:51:44.638Z (6 months ago)
- Topics: hpa, keda, kubernetes, sample
- Language: Go
- Homepage:
- Size: 20.5 KB
- Stars: 13
- Watchers: 1
- Forks: 19
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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/samplesThe 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
```sh
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](https://keda.sh/scalers/redis-lists/) first we have to
deploy the `ScaledObjects`:
```sh
kubectl apply -f keda/redis-hpa.yaml
```
this should result in creation of a new `ScaledObjects` and new HPA
```sh
# 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 /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:
```shell script
kubectl exec $(kubectl get pods | grep "server" | cut -f 1 -d " ") -- keda-talk redis publish
```
and to scale down:
```shell script
kubectl exec $(kubectl get pods | grep "server" | cut -f 1 -d " ") -- keda-talk redis drain
```## MySQL example
To scale the dummy deployment using
[MySQL scaler](https://keda.sh/scalers/mysql/) first we have to
deploy the `ScaledObjects`:
```sh
kubectl apply -f keda/mysql-hpa.yaml
```
this should result again in creation of `ScaleObject` and an HPA:
```sh
# 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 /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:
```shell script
kubectl exec $(kubectl get pods | grep "server" | cut -f 1 -d " ") -- keda-talk mysql insert
```
and to scale down:
```shell script
kubectl exec $(kubectl get pods | grep "server" | cut -f 1 -d " ") -- keda-talk mysql delete
```