KEDA Autoscaling example
This notebook shows how you can scale Seldon Deployments based on Prometheus metrics via KEDA.
KEDA is a Kubernetes-based Event Driven Autoscaler. With KEDA, you can drive the scaling of any container in Kubernetes based on the number of events needing to be processed.
With the support of KEDA in Seldon, you can scale your seldon deployments with any scalers listed here. In this example we will scale the seldon deployment with Prometheus metrics as an example.
Install Seldon Core
Install Seldon Core as described in docs
Make sure add --set keda.enabled=true
Install Prometheus
!kubectl create namespace seldon-monitoring
!helm upgrade --install seldon-monitoring kube-prometheus \
--version 8.3.2 \
--set fullnameOverride=seldon-monitoring \
--namespace seldon-monitoring \
--repo https://charts.bitnami.com/bitnami \
--waitnamespace/seldon-monitoring created
Release "seldon-monitoring" does not exist. Installing it now.
NAME: seldon-monitoring
LAST DEPLOYED: Sun Feb 5 08:41:12 2023
NAMESPACE: seldon-monitoring
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: kube-prometheus
CHART VERSION: 8.3.2
APP VERSION: 0.62.0
** Please be patient while the chart is being deployed **
Watch the Prometheus Operator Deployment status using the command:
kubectl get deploy -w --namespace seldon-monitoring -l app.kubernetes.io/name=kube-prometheus-operator,app.kubernetes.io/instance=seldon-monitoring
Watch the Prometheus StatefulSet status using the command:
kubectl get sts -w --namespace seldon-monitoring -l app.kubernetes.io/name=kube-prometheus-prometheus,app.kubernetes.io/instance=seldon-monitoring
Prometheus can be accessed via port "9090" on the following DNS name from within your cluster:
seldon-monitoring-prometheus.seldon-monitoring.svc.cluster.local
To access Prometheus from outside the cluster execute the following commands:
echo "Prometheus URL: http://127.0.0.1:9090/"
kubectl port-forward --namespace seldon-monitoring svc/seldon-monitoring-prometheus 9090:9090
Watch the Alertmanager StatefulSet status using the command:
kubectl get sts -w --namespace seldon-monitoring -l app.kubernetes.io/name=kube-prometheus-alertmanager,app.kubernetes.io/instance=seldon-monitoring
Alertmanager can be accessed via port "9093" on the following DNS name from within your cluster:
seldon-monitoring-alertmanager.seldon-monitoring.svc.cluster.local
To access Alertmanager from outside the cluster execute the following commands:
echo "Alertmanager URL: http://127.0.0.1:9093/"
kubectl port-forward --namespace seldon-monitoring svc/seldon-monitoring-alertmanager 9093:9093Install KEDA
Follow the docs for KEDA to install.
Create model with KEDA
To create a model with KEDA autoscaling you just need to add a KEDA spec referring in the Deployment, e.g.:
The full SeldonDeployment spec is shown below.
Create Load
We label some nodes for the loadtester. We attempt the first two as for Kind the first node shown will be the master.
Before add loads to the model, there is only one replica
After a few mins you should see the deployment scaled to 5 replicas
Remove Load
After 5-10 mins you should see the deployment replica number decrease to 1
Cleanup
Last updated
Was this helpful?