/proactive-scaler

Proactive Kubernetes scaler using SpringBoot and influxDB

Primary LanguageJava

Kubernetes proactive scaler

SpringBoot + influxDB + grafana

There are two spring-boot apps here:

  • app-with-metrics sends CPU and RAM metrics to local influx db
  • proactive-scaler reads metrics from influx db

How to run

method 1

  • start influx db locally
docker run -p 8086:8086 \
           -v influxdb:/var/lib/influxdb \
              influxdb
  • start metrics app & scaler app with IDEA or java -jar

method 2 (Kubernetes - Minikube)

kubectl create -f kubernetes/app-with-metrics.yaml
kubectl expose deployment metrics-app --type=NodePort
minikube service metrics-app --url
  • start scaler app with IDEA or java -jar

Scale metrics-app

kubectl scale deployment metrics-app --replicas=[SIZE]

where [SIZE] is pod count

Testing kubernetes reactive autoscaling

kubectl autoscale deployment metrics-app --max=3 --cpu-percent=80

Delete kubernetes reactive autoscaling

kubectl delete horizontalpodautoscaler metrics-app 

Clear database

./clearDatabase.sh

Queries for grafana

SELECT count("id") FROM "connection" WHERE $timeFilter GROUP BY time(1s) fill(null)
SELECT mean("cpu") FROM "workload" WHERE $timeFilter GROUP BY time(1s) fill(null)
SELECT count("method") FROM "connection" WHERE ("method" = 'cpu') AND $timeFilter GROUP BY time(10s) fill(null)

Dashboard in Grafana

grafana