Background
In Kubernetes clusters, the effectiveness of resource scheduling directly affects resource utilization efficiency. As cluster scale grows and application types diversify, a single scheduling policy often struggles to meet all requirements. To meet scheduling requirements in different scenarios, Kubernetes provides flexible scheduling policy options. Among them, Default-scheduler, as the system's built-in default scheduler, is responsible for scheduling Pods to cluster nodes. By configuring scheduling policies, you can comprehensively consider node resource availability, affinity and anti-affinity rules, and other scheduling restrictions to achieve efficient Pod scheduling.
Version Limitations
Only Kubernetes versions v1.20-1.28 are supported. The specific minor version requirements are as follows:
v1.20: v1.20.6-tke.20 or later
v1.22: v1.22.5-tke.5 or later
v1.24: v1.24.4-tke.3 or later
v1.26: v1.26.1-tke.1 or later
v1.28: v1.28.3-tke.1 or later
Default Scheduling Policy
We will provide the following scheduling policies (including compact priority scheduling) to ensure that Pods are efficiently and reasonably scheduled to optimal nodes based on business requirements and cluster status, delivering a more comprehensive solution. For specific configuration methods, see the subsequent usage instructions.
Note:
In v1.20 and v1.22, the NodeResourcesLeastAllocated scheduling policy is enabled by default. If compact priority scheduling is enabled, the NodeResourcesMostAllocated scheduling policy is enabled and the NodeResourcesLeastAllocated policy is disabled.
In v1.24 and later versions, the default value of the NodeResourcesFit policy is LeastAllocated. If compact priority scheduling is enabled, the type automatically changes to MostAllocated.
If both LeastAllocated and MostAllocated are enabled, both policies become invalid. Avoid this situation.
|
v1.20 and v1.22 | v1.24 and later |
| v1.20 and v1.22 | v1.24 and later |
|
|
MostRequestedPriority | NodeResourcesFit | Prefer nodes with high resource requests to deploy pods, improving cluster resource utilization. | Disabled by default | Default type: LeastAllocated The default value is 1. | 1-100 | If compact priority scheduling is desired, set the weight to 5. Configuring it to 0 is not recommended, as it may cause low cluster packing rate and low utilization. When this feature is enabled, LeastRequestedPriority is disabled. Otherwise, neither takes effect. |
LeastRequestedPriority |
| Prefer nodes with low resource requests to deploy pods, balancing cluster resource utilization. | 1 |
| 1-100 | Configuring it to 0 is not recommended, as it may cause unbalanced resource utilization across the cluster. |
InterPodAffinityPriority | InterPodAffinity | Schedule based on affinity and anti-affinity rules between pods. | 1 | 2 | 1-100 | Configuring it to 0 is not recommended, as it may cause Pods to behave unexpectedly. |
BalancedResourceAllocation | NodeResourcesBalancedAllocation | Ensure balanced CPU and memory resource usage on nodes to prevent any single resource type from becoming a bottleneck. | 1 | 1 | 1-100 | Configuring it to 0 is not recommended, as it may cause unbalanced resource usage. Some nodes may become a bottleneck for a single resource, affecting the overall cluster performance. |
EvenPodsSpreadPriority | PodTopologySpread | Distribute a group of associated pods evenly across different nodes to improve application reliability and fault tolerance. | 2 | 2 | 1-100 | Configuring it to 0 is not recommended, as it may fail to fully meet the requirement of distributing associated Pods across different nodes, causing Pods to behave unexpectedly. |
NodeAffinityPriority | NodeAffinity | Schedule based on node affinity rules to ensure that pods are scheduled to nodes that meet the affinity rules. | 1 | 2 | 1-100 | Configuring it to 0 is not recommended, as it may cause Pods to behave unexpectedly. |
TaintTolerationPriority | TaintToleration | Schedule based on node taints and Pod tolerations to ensure that pods are scheduled only to nodes they can tolerate. | 1 | 3 | 1-100 | Configuring it to 0 is not recommended, as it may violate node scheduling preferences. |
ImageLocalityPriority | ImageLocality | Prefer scheduling pods to nodes that already have the required images, avoiding pulling images from remote repositories and saving network bandwidth and time. | 1 | 1 | 1-100 | Configuring it to 0 is not recommended, as it may cause Pods to behave unexpectedly. |
Operation Steps
Going to the Configuration Page
2. In the cluster list, select the cluster for which you want to configure a scheduling policy and go to the cluster's basic information page.
3. Choose Node Management > Master&Etcd, add a kube-scheduler scheduling policy, view the current scheduling policy configuration, and click Edit in the upper-right corner.
Configuring a Scheduling Policy
On the editing page, you can modify the scheduling policy of kube-scheduler.
Attention:
1. When configuring a scheduling policy, ensure that you fully understand business requirements and cluster resource status to avoid unnecessary resource waste or performance degradation.
2. When adjusting a scheduling policy, verify its effect in a test environment before applying it to the production environment.
Compact-First Scheduling Settings
If compact priority scheduling is enabled, the type of NodeResourceFit automatically changes to MostAllocated. The default weight is 1, and you can customize it from 1 to 100. If you want the compact priority scheduling policy to have a higher priority, set the weight to 5.
If compact priority scheduling is not enabled, the type of NodeResourceFit defaults to LeastAllocated. The default weight is 1, and you can customize it from 1 to 100.
Weight Settings for Other Scheduling Policies
You can customize the weight from 1 to 100. A higher weight indicates a higher priority of the scheduling policy in scheduling decisions.