Professional Documents
Culture Documents
Introduction
The Horizontal Pod Autoscaler automatically scales the number of pods in a replication controller,
deployment, replica set or stateful set based on observed CPU utilization. The Horizontal Pod
Autoscaler is implemented as a Kubernetes API resource and a controller. The resource determines
the behavior of the controller. The controller periodically adjusts the number of replicas in a
replication controller or deployment to match the observed average CPU utilization to the target
specified by user.
Objectives:
• Create a nginx deployment
• Create horizontalpodautoscaler
• Install siege – http load simulator
• Watch auto scale up
• Watch auto scale down
Note: Ensure you have running cluster deployed & Metrics Server deployed and configured.
1. Ensure that you have logged-in as root user with password as linux on kube-master node.
1.1 Let us clone the git repository which contains manifests required for this exercise, by
executing the below command.
# git clone https://github.com/EyesOnCloud/k8s-hpa.git
Output:
Note: The cpu resource is limited to 100m; this will help us to scale based on cpu utilization.
Output:
1.7 Let verify if we are able to access the pod, by executing the below command.
# curl kube-node1:32019
Output:
# cat -n ~/k8s-hpa/nginx-hpa.yaml
Output:
1.11 Let's us install epel repository and install siege utility, by executing below commands.
# siege -V
Output:
On Terminal-1:
# siege -q -c 5 -t 2m http://kube-node1:32019
Output:
Note: -q = quiet mode, -c = concurrent users (we are setting it to 5), -t = time (we are setting it
to 2 minutes) and accessing one of the nodes and using the NodePort of nginx app.
1.15 Let us continue to watch the pods, by executing the below command.
Terminal-2
# watch kubectl get all
Output:
Note: The siege command will complete after 2 minutes and the load will reduce after that
1.16 Let us continue to watch the pods, by executing the below command.
Terminal-2
# watch kubectl get all
Output:
Output:
Output:
Output:
Output: