This topic mainly describes how to use the load-aware scheduling capability provided by Volcengine Kubernetes Engine (VKE) to achieve node load balancing.
Feature overview
Load-aware scheduling is a policy provided by VKE that performs appropriate scheduling based on the load of nodes. During scheduling, pods are preferentially scheduled to nodes with lower load according to node load statistics to balance loads among nodes. This prevents application or node failures caused by a high load on a single node.
Prerequisites
- A cluster is in the Running state and has two or more nodes. Load balancing among these nodes is required. For detailed operations, see Adding nodes.
- The Kubernetes version of the cluster must meet the following requirements to achieve load-aware scheduling. For detailed operations, see Upgrading clusters.
- The scheduler-plugin add-on has been installed in the cluster. For detailed operations, see scheduler-plugin.
Procedure
Step 1: Enable the load-aware scheduling feature of the scheduler
- Enabling the feature in the console
- In the cluster that meets the requirements, configure the scheduler-plugin add-on to enable the load-aware scheduling feature. For detailed operations, see scheduler-plugin.
- Enabling the feature by calling the API
- Call the CreateAddon API to install the scheduler-plugin add-on in the cluster that meets the requirements, or specify the following parameters to enable load-aware scheduling when you update the add-on configurations by calling the UpdateAddonConfig API:
- Set the LoadAwareSchedulingEnabled parameter to true.
- Set the Scope sub-parameter of the LoadAwareSchedulingConfig parameter to pod.
Step 2: Add an annotation that enables load-aware scheduling for a pod
Add annotations to a pod to indicate whether to enable load-aware scheduling for the pod based on the actual load of nodes.
The following YAML file serves as an example.
Examples
This topic uses a cluster with three nodes (each with 4 cores and 16 GiB of memory) as an example. It compares node load differences before and after load-aware scheduling is used. It also introduces methods of scheduling pods to lower-load nodes for load balancing.
When load-aware scheduling is not used
- Create the YAML file of the workload. The following code of the sample file stress-test.yaml shows how to create a Deployment.
- Execute the following command to create the workload.
- View the nodes to which the pods of the workload created in the previous step are scheduled.
- The expected response is as follows, which indicates that the pods have been scheduled to the 192.168.1.5 and 192.168.1.3 nodes.
-
- View the resource usage of nodes.
- The expected response is as follows, which indicates that the nodes 192.168.1.5 and 192.168.1.3 are high-load nodes.
-
When load-aware scheduling is used
The preceding result indicates that load balancing among nodes is not achieved. To schedule as many pods as possible to the 192.168.1.4 node in subsequent operations, add annotations to the pods to enable load-aware scheduling based on the following descriptions.
- Create a workload with six pods with load-aware scheduling enabled and request 500 mCore of CPU for each pod.
- View the nodes on which the pods of the workload created in the previous step are scheduled.
- The expected response is as follows, which indicates that all six pods have been scheduled to the 192.168.1.4 node.
-