Kubernetes Horizontal Pod Autoscaler

Kubernetes Horizontal Pod Autoscaler

This post just serves as a quickstart for kubernetes horizontal pod autosacler testing purpose, here are the steps

git clone https://github.com/Azure-Samples/azure-voting-app-redis.git
cd azure-voting-app-redis
kubectl apply -f azure-vote-all-in-one-redis.yaml
kubectl autoscale deployment azure-vote-front --cpu-percent=10 --min=1 --max=10

After finish above commands, you should have hpa configured, now we need to generate some workload, here are the steps

kubectl run -i --tty busybox --image=busybox /bin/sh

From the busybox, type below command to generate workload

while true; do wget -q -O- http://azure-vote-front; done

Wait for a while, you will see hpa works now and autoscales pod instances.

kubectl get hpa
NAME               REFERENCE                     TARGETS   MINPODS   MAXPODS   REPLICAS   AGE
azure-vote-front   Deployment/azure-vote-front   58%/10%   1         5         1          7m
kubectl get pod
NAME                               READY   STATUS    RESTARTS   AGE
azure-vote-back-f9cc849fb-vz7n2    1/1     Running   0          15m
azure-vote-front-6b8f58d8d-f6mw6   1/1     Running   0          15m
azure-vote-front-6b8f58d8d-lbq22   1/1     Running   0          21s
azure-vote-front-6b8f58d8d-q2gs8   1/1     Running   0          21s
azure-vote-front-6b8f58d8d-wc9tt   1/1     Running   0          21s
busybox-7cd98849ff-zpk9b           1/1     Running   1          2m

Related Article