Auto Scaling in CloudOps for Azure is handled by two technologies:
Horizontal Pod Autoscalers (HPAs) are provided by Kubernetes as a way to scale the number replicas of Pods in a Deployment based on average CPU utilization. Every few seconds the Kubernetes control plane determines how many replicas are required, based on the current and requested average CPU utilization, and increases or decreases the number of replicas as required. For information about the algorithm, see https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#algorithm-details
Configuration of the HPAs is done using a Kubernetes YAML file, which is included in the cloudops-for-azure repository. CloudOps for Azure can use this file to create HPAs when deploying an Elastic Path stack. Choose the option for creating HPAs when you run the
create-or-delete-ep-stack Jenkins job.
Cluster Autoscaler is responsible for scaling up and down the number of virtual machines (VMs) in the Azure Kubernetes Service (AKS) cluster. If an HPA scales up the replicas of Pods in a Deployment but the VMs in the Kubernetes cluster don’t have enough resources (CPU/RAM) to run any new Pods, Cluster Autoscaler detects that the new Pods are unschedulable. It asks Azure to scale up the number of VMs in the AKS cluster. If Cluster Autoscaler finds that a VM has no Pods running on it, it asks Azure to scale down the number of VMs in the cluster.
Cluster Autoscaler is deployed as part of the bootstrap process and is configurable using a YAML file included in cloudops-for-azure.
In the event that a VM in a Kubernetes cluster becomes unavailable, Replication Controllers in the Kubernetes control plane detect that there are less Pods running than the requested number of replicas. As a result, more Pods are scheduled to replace those lost when the VM became unavailable. If the Kubernetes control plane cannot schedule a Pod onto a VM due to insufficient resources, Cluster Autoscaler detects this and scales up the number of VMs in the Kubernetes cluster.
All of the Deployments in cloudops-for-azure start with one replica. If required, this can be changed by editing the Kubernetes YAML file used to deploy the Elastic Path stack, included in cloudops-for-azure.
Each Deployment has an associated Replication Controller.
For more information about Replication Controllers, see the official Kubernetes documentation on ReplicationController.