Auto Scaling in CloudOps for Kubernetes is handled by two technologies:
Horizontal Pod Autoscalers (HPAs) are provided by Kubernetes as a way to scale the number of Pods (or replicas) in a Deployment based on average CPU utilization. Every few seconds the Kubernetes control plane determines how many replicas are required. This is based on the current and requested average CPU utilization, and increases or decreases the number of replicas as you require. For information about the algorithm, see Horizontal Pod Autoscaler Algorithm Details.
Configuration of the HPAs is done using Terraform configuration files, which is included in the CloudOps for Kubernetes Git repository. CloudOps for Kubernetes uses this file to create HPAs when deploying Elastic Path Commerce. You can enable HPAs when running the
create-or-delete-ep-stack Jenkins job.
Cluster Autoscaler is responsible for scaling up and down the number of nodes in the Kubernetes cluster. These nodes are either virtual machines (VMs) in Azure or EC2 instances in AWS. If an HPA scales up the replicas of Pods in a Deployment, but the nodes in the Kubernetes cluster don’t have enough resources (CPU/RAM), they are unschedulable. If the nodes don’t have enough resources to run any new Pods, the Cluster Autoscaler can detect this. Cluster Autoscaler asks the cloud in which it is running to scale up the number of nodes in the Kubernetes cluster. If Cluster Autoscaler finds that a node has no Pods running on it, it asks the cloud to scale down the number of nodes in the cluster.
Cluster Autoscaler is deployed and configured as part of the bootstrap process using Terraform configuration included in CloudOps for Kubernetes.
If a node 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 node became unavailable. If the Kubernetes control plane cannot schedule a Pod onto a VM due to insufficient resources, Cluster Autoscaler detects this. The Cluster Autoscaler scales up the number of nodes in the Kubernetes cluster.
All Kubernetes Deployments in CloudOps for Kubernetes start with one replica. If you require, you can change this by editing the Terraform configuration that you use to deploy the Elastic Path applications.
Each Deployment has an associated Replication Controller.
For more information about Replication Controllers, see the official Kubernetes documentation on ReplicationController.