How to AutoScaling ReplicaSets in Kubernetes Cluster

This blog post will show you how I autoscale a ReplicaSet on a Kubernetes AKS cluster using the kubectl command-line.

ReplicaSets

I have shown you how to create ReplicaSets and scale them manually (kubectl) or use a configuration file in the previous two articles.

AutoScaling

Using Autoscaling takes the hard work of scaling and gives Kubernetes the ability to decide how many pods are needed based on CPU usage accross each pod.

In the below example, I will configure autoscaling on my replicaset with a minimum number of 2 pods and a max of 5. the trigger to autoscale is a CPU usage of 40%.

kubectl autoscale replicaset nginxset --min=2 --max=5 --cpu-percent=40

To check if autoscaling is working and monitor it, I will use the following command.

kubectl get horizontalpodautoscalers.autoscaling

To delete autoscaling I will use the following command.

kubectl delete horizontalpodautoscalers.autoscaling nginxset

Processing…
Success! You're on the list.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.