A Kubernetes load balancing resource scheduling method, system, medium and device

Through the Hamiltonian algorithm based on quantum computing, the problem of insufficient resource scheduling efficiency and load balancing of Kubernetes is solved, and the optimal solution and balanced resource allocation are quickly found, which is suitable for a variety of complex scenarios.

CN118488063BActive Publication Date: 2024-09-13MINGYANG SHICHUANG (BEIJING) TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410940343.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-15
Publication Date
2024-09-13
Estimated Expiration
2044-07-15

AI Technical Summary

Technical Problem

Existing Kubernetes resource scheduling algorithms have shortcomings in efficiency and load balancing. Especially when dealing with polynomial time complexity problems, traditional algorithms are difficult to quickly find the optimal solution.

Method used

The Hamiltonian algorithm based on quantum computing is used to calculate the Hamiltonian of the node and generate quantum circuits, and then optimize with the classical optimizer until the preset constraints are met to achieve the optimal allocation of resources.

Benefits of technology

It significantly improves the computing efficiency of resource scheduling, ensures load balancing of Kubernetes clusters, avoids waste of resources, and is suitable for a variety of scenarios such as homogeneous nodes, heterogeneous nodes and edge computing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118488063B
    Figure CN118488063B
Patent Text Reader

Abstract

The present invention discloses a Kubernetes load balancing resource scheduling method, system, medium and device, wherein the system comprises a data acquisition unit, a data input unit, a Hamiltonian calculation unit and a Pod allocation unit, wherein the node Node is connected to the data acquisition unit in communication, the data acquisition unit and the data input unit are connected to the Hamiltonian calculation unit in communication, the Hamiltonian calculation unit is connected to the Pod allocation unit in communication, the Pod allocation unit is connected to the api-server component in communication, and the api-server component is connected to the node Node in communication. The present invention seeks out the best solution based on the algorithm of quantum computing, and due to the characteristics of quantum superposition, the algorithm is faster than the traditional algorithm and can find the optimal solution of the problem in polynomial time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Kubernetes clusters, and in particular to a Kubernetes load balancing resource scheduling method, system, medium and device. Background Art

[0002] In the past decade, quantum computing has gradually entered the public eye, and many algorithms and theories have been applied to the fields of medicine, finance, artificial intelligence, etc. Quantum algorithms are superior to traditional algorithms in theory and practical application in more cases, and more and more companies are participating in the development of quantum computing. K8S is an open source container orchestration tool that can be used for large-scale deployment of microservice applications. It has both portability and flexibility, and more companies rely on K8s to meet their container orchestration needs. In K8S, creating pods on nodes according to the service requirements of pods is an important part, mainly considering factors such as memory, CPU, disk capacity, bandwidth, affinity, etc., selecting the most suitable node to create pods, and ensuring the load balancing of the K8S cluster.

[0003] The default resource scheduling algorithm of K8S is divided into two steps, including the pre-selection step and the optimization step. There are default scheduling algorithms and strategies in these two steps. In the first step, the default scheduling strategies include PodFitsHost, CheckNodeDiskPressure, etc., and the corresponding strategies are used to pre-select suitable nodes as candidate nodes. In the second step, the scheduling algorithm is applied to the candidate nodes to select the best node to run the pod. The existing resource scheduling algorithm methods are as follows:

[0004] 1. Use the string matching algorithm and the Rete algorithm to allocate pods to the optimal nodes based on their actual needs.

[0005] 2. Based on grid technology, cross-cluster resource scheduling is realized. Summary of the invention

[0006] To this end, the technical problem to be solved by the present invention is to provide a Kubernetes load balancing resource scheduling method, system, medium and device, which finds the best solution based on the algorithm of quantum computing. Due to the characteristics of quantum superposition, this algorithm is faster than the traditional algorithm and can find the optimal solution to the problem in polynomial time.

[0007] In order to solve the above technical problems, the present invention provides the following technical solutions:

[0008] A Kubernetes load balancing resource scheduling method includes the following steps:

[0009] S100) Calculate placement The node after The Hamiltonian And get the solution that satisfies the pre-set constraints , the specific operations are:

[0010] S101) Use the following formula to calculate placement The node after The Hamiltonian :

[0011]

[0012] In the formula, Representation Node The Hamiltonian of available resources is calculated as follows:

[0013]

[0014] in, for The resources needed; express Is it placed on the node superior; For Node The available resource constraints; For Node Penalty coefficient for available resource constraints;

[0015] express Place at the node The Hamiltonian of the resources used during the above process includes:

[0016] (1) ,in, ∈0,1,∀i=1,2,…,n,∀j=1,2,…,m, n is the number of Pods to be allocated, and m is the number of Pods that can be placed The number of nodes Node;

[0017] (2) ;

[0018] S102) Based on the Hamiltonian calculated in step S101) Generate quantum circuits;

[0019] S103) Measure the quantum state to obtain the expected value;

[0020] S104) The current Hamiltonian and its corresponding expected value are put into the classical optimizer for optimization to obtain a set of new Hamiltonians ;

[0021] S105) Repeat steps S102) to S104) until the new Hamiltonian obtained in step S104) A new Hamiltonian that satisfies the pre-set constraints That is ; wherein the Hamiltonian used when repeating step S102) is the new Hamiltonian obtained in step S104) ;

[0022] S200) Set up to meet Node The Kubernetes load balancing resource scheduling is completed.

[0023] In the above Kubernetes load balancing resource scheduling method, when Kubernetes load balancing is performed, the number of nodes used Num satisfies the following equation:

[0024]

[0025] In the formula, For Node usage, ∈0,1,∀j=1,2,…,m.

[0026] In the above Kubernetes load balancing resource scheduling method, the classic optimizer is one of VanillaGradientDescentOptimizer::minimize, MomentumOptimizer::minimize, AdaGradOptimizer::minimize, RMSOptimizer::minimize, and AdamOptimizer::minimize.

[0027] In the above Kubernetes load balancing resource scheduling method, the load of each node with a Pod is close.

[0028] The system for Kubernetes load balancing using the above Kubernetes load balancing resource scheduling method includes:

[0029] The data collection unit is used to collect data related to the usage of Kubernetes cluster node resources;

[0030] A data input unit, used to input preset conditions through a human-computer interaction device; wherein the preset conditions include the number of Pods to be allocated and constraints for allocating Pods to nodes;

[0031] Hamiltonian calculation unit, used to calculate placement based on data related to Kubernetes cluster node resource usage and data related to Pod usage of Node resources to be allocated The node after The Hamiltonian And get the solution that satisfies the pre-set constraints ;

[0032] Pod allocation unit, used to Set the Pod to the corresponding node;

[0033] The node Node is communicatively connected to the data acquisition unit, the data acquisition unit and the data input unit are respectively communicatively connected to the Hamiltonian calculation unit, the Hamiltonian calculation unit is communicatively connected to the Pod allocation unit, the Pod allocation unit is communicatively connected to the api-server component, and the api-server component is communicatively connected to the node Node.

[0034] The above system is set in a plug-in loaded on the scheduler component.

[0035] In the above system, the scheduler component is set on the Master node in the Kubernetes cluster.

[0036] In the above system, the scheduler component communicates with the etcd component and the api-server component respectively, and the api-server component communicates with the node Node.

[0037] A computer-readable storage medium stores a computer program, which implements the above method when executed by a processor.

[0038] A computer device includes a readable storage medium, a processor, and a computer program stored in the readable storage medium and executable on the processor, wherein the computer program implements the above method when executed by the processor.

[0039] The technical solution of the present invention achieves the following beneficial technical effects:

[0040] 1. Based on the idea of ​​quantum computing, a creative pod resource scheduling algorithm within K8S is proposed. Due to the superposition of quantum states, one quantum information can express multiple state information at the same time, which can improve the computing efficiency of the algorithm and ensure the load balancing of the K8S cluster, which is better than the traditional algorithm.

[0041] 2. Based on the K8S platform, when users create workloads, they must meet the requirements of the load pod, such as CPU, memory, affinity, etc. It is very important to reasonably allocate pods to nodes according to the resources of the cluster through the scheduler component to ensure the load balance and stability of the entire cluster. At the same time, corresponding traditional algorithms have been used to solve this problem. Since the scope of the cluster is very wide and cross-cluster communication is also involved, the use of quantum algorithms is considered to improve the overall computing efficiency and ensure the load balance of the cluster.

[0042] 3. There are many situations in resource scheduling in the K8S cluster, such as homogeneous nodes, heterogeneous nodes, fog computing, edge computing, etc. When the master node needs to be used to schedule the edge node to provide services to users, network latency, node availability, image pulling efficiency, etc. need to be considered. The resource scheduling algorithm proposed in the patent can take the corresponding situations into consideration and calculate the optimal solution to schedule the pod to the corresponding node through quantum information representation, thereby improving computing efficiency.

[0043] 4. In terms of cluster load balancing, the resource scheduling algorithm proposed by the present invention can avoid cluster resource waste as much as possible.

[0044] 5. In K8S, filtering and scoring are used to determine which node the Pod should be scheduled to. The algorithm proposed in the patent directly considers the corresponding resource constraints of the pod and the node and calculates the optimal allocation plan; at the same time, the algorithm proposed in the patent is integrated into a plug-in and loaded in the scheduler component, which is easy to deploy and implement in the K8S platform. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1 A schematic diagram of the structure of a Kubernetes cluster provided with a Kubernetes load balancing resource scheduling system in the present invention;

[0046] Figure 2 This is a working principle diagram of the Kubernetes load balancing resource scheduling system in the present invention;

[0047] Figure 3 A flow chart of resource balancing scheduling using the Kubernetes load balancing resource scheduling system of the present invention;

[0048] Figure 4This is the result graph using the default scheduling algorithm;

[0049] Figure 5 This is a result diagram of resource balancing scheduling using the Kubernetes load balancing resource scheduling method of the present invention;

[0050] Figure 6 This is a schematic diagram of a computer device capable of performing Kubernetes load balancing resource scheduling. DETAILED DESCRIPTION

[0051] The present invention is further described below with reference to examples.

[0052] like Figure 2 As shown, the Kubernetes load balancing resource scheduling system in the present invention includes a data acquisition unit, a data input unit, a Hamiltonian calculation unit and a Pod allocation unit. The node Node is communicated with the data acquisition unit, the data acquisition unit and the data input unit are communicated with the Hamiltonian calculation unit respectively, the Hamiltonian calculation unit is communicated with the Pod allocation unit, the Pod allocation unit is communicated with the api-server component, and the api-server component is communicated with the node Node.

[0053] The data collection unit is used to collect data related to the Node resource usage of the Kubernetes cluster nodes; the data input unit is used to input preset conditions through the human-computer interaction device, wherein the preset conditions include the number of Pods to be allocated and the constraints for allocating Pods to the Node nodes; the Hamiltonian calculation unit is used to calculate the placement of the Pods based on the data related to the Node resource usage of the Kubernetes cluster nodes and the data related to the Pods to be allocated using the Node resources. The node after The Hamiltonian And get the solution that satisfies the pre-set constraints Pod allocation unit, used to allocate Set the Pod to the corresponding node.

[0054] In this embodiment, the Kubernetes load balancing resource scheduling system is set in a plug-in loaded on the scheduler component, the scheduler component is set on the Master node in the Kubernetes cluster, the scheduler component is respectively connected to the etcd component and the api-server component, and the api-server component is connected to the node Node. Figure 1 shown.

[0055] like Figure 1 As shown in the figure, the scheduler component is set in the Master node, and the database resources in the etcd component are bound. After the load balancing resource scheduling calculation, the api-server component is used to notify the kubelet component to create the corresponding Pod on the appropriate node.

[0056] In this embodiment, the Kubernetes load balancing resource scheduling system implements Kubernetes load balancing resource scheduling through the following steps:

[0057] S100) Calculate placement The node after The Hamiltonian And get the solution that satisfies the pre-set constraints , the specific operations are:

[0058] S101) Use the following formula to calculate placement The node after The Hamiltonian :

[0059]

[0060] In the formula, Representation Node The Hamiltonian of available resources is calculated as follows:

[0061]

[0062] in, for The resources needed; express Is it placed on the node superior; For Node The available resource constraints; For Node The penalty coefficient for available resource constraints is to try to make the load of each node as close as possible;

[0063] express Place at the node The Hamiltonian of the resources used during the above process includes:

[0064] (1) ,in, ∈0,1,∀i=1,2,…,n,∀j=1,2,…,m, n is the number of Pods to be allocated, and m is the number of Pods that can be placed The number of nodes Node;

[0065] (2) ;

[0066] S102) Based on the Hamiltonian calculated in step S101) Generate quantum circuits;

[0067] S103) Measure the quantum state to obtain the expected value;

[0068] S104) The current Hamiltonian and its corresponding expected value are put into the classical optimizer for optimization to obtain a set of new Hamiltonians ;

[0069] S105) Repeat steps S102) to S104) until the new Hamiltonian obtained in step S104) A new Hamiltonian that satisfies the pre-set constraints That is ; wherein the Hamiltonian used when repeating step S102) is the new Hamiltonian obtained in step S104) ;

[0070] S200) Set up to meet Node The Kubernetes load balancing resource scheduling is completed.

[0071] Placement in calculation The node after The Hamiltonian When Kubernetes load balancing is performed, the number of nodes N and m of the requested Pods must be considered, as well as the available resources of each Node. The Kubernetes load balancing resource scheduling for the Pods to be allocated is considered as a packing problem. At this time, in order to minimize the number of nodes used, when Kubernetes load balancing is performed, the number of nodes used Num satisfies the following equation:

[0072]

[0073] In the formula, For Node usage, ∈0,1,∀j=1,2,…,m.

[0074] The classic optimizer is one of VanillaGradientDescentOptimizer::minimize, MomentumOptimizer::minimize, AdaGradOptimizer::minimize, RMSOptimizer::minimize, and AdamOptimizer::minimize.

[0075] After Kubernetes load balancing resource scheduling, the load of each node with Pod is close.

[0076] For example, there are three Pods: Pod1, Pod2, and Pod3, and two Nodes: Node1 and Node2. The resources requested by the three Pods are: Pod1 requires 8G memory and two CPUs, Pod2 requires 6G memory and one CPU, and Pod3 requires 6G memory and two CPUs. The available resources of the two Nodes are: Node1 has 15G memory and three CPUs, and Node2 has 20G memory and three CPUs.

[0077] Using the default resource scheduling scheme, the three Pods are assigned to nodes in order. The Pod scheduling is as follows: Figure 4 As shown in the figure, node Node1 has only 1G memory left, while node Node2 has 14G memory. Obviously, there will be a load imbalance problem, which will affect the entire Kubernetes cluster. The resource scheduling performed by the Kubernetes load balancing resource scheduling method of the present invention allocates the Pod to the appropriate node, and the Pod scheduling obtained is as follows Figure 5 As shown, Node1 still has 7G memory and Node2 still has 8G memory. This method will ensure the load balancing of the Kubernetes cluster.

[0078] The above examples are only simple examples to illustrate the effects and operations that can be performed when the Kubernetes load balancing resource scheduling method of the present invention performs load balancing in a Kubernetes cluster. It does not mean that the Kubernetes load balancing resource scheduling method of the present invention can only achieve load balancing based on the CPU usage and memory usage of the Pod to be allocated and the CPU and memory available in the node Node. The specific situation should be considered according to the factors of load balancing and the placement should be determined. The node after The Hamiltonian Whether the pre-set constraints are met , and then perform load balancing operations.

[0079] Since the resources used by the Pod are not limited to the CPU and memory, the Kubernetes load balancing resource scheduling method of the present invention is used to schedule the Pod allocation, which can achieve load balancing of the entire cluster, improve scheduling efficiency, and ensure the stability of the entire cluster.

[0080] Based on the above Kubernetes load balancing resource scheduling method, correspondingly, this example also provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the following steps are implemented: calculating placement The node after The Hamiltonian And get the solution that satisfies the pre-set constraints , then Set up to meet Node The Kubernetes load balancing resource scheduling is completed.

[0081] like Figure 6 As shown, based on the above-mentioned Kubernetes load balancing resource scheduling method and computer-readable storage medium, in this embodiment, a computer device is also provided, which includes a readable storage medium, a processor, and a computer program stored on the readable storage medium and executable on the processor, wherein the readable storage medium and the processor are both arranged on a bus, and the processor implements the following steps when executing the computer program: calculating the placement The node after The Hamiltonian And get the solution that satisfies the pre-set constraints , then Set up to meet Node The Kubernetes load balancing resource scheduling is completed.

[0082] Obviously, the above embodiments are merely examples for the purpose of clear explanation, and are not intended to limit the implementation methods. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the implementation methods here. The obvious changes or modifications derived therefrom are still within the scope of protection of the claims of this patent application.

Claims

1. A Kubernetes load balancing resource scheduling method, It is characterized in that The steps include: S100) Calculate placement The node after The Hamiltonian And get the solution that satisfies the pre-set constraints , the specific operations are: S101) Use the following formula to calculate placement The node after The Hamiltonian : In the formula, Representation Node The Hamiltonian of available resources is calculated as follows: in, for The resources needed; express Is it placed on the node superior; For Node The available resource constraints; For Node Penalty coefficient for available resource constraints; express Place at the node The Hamiltonian of the resources used during the above process includes: (1) ,in, ∈0,1,∀i=1,2,…,n,∀j=1,2,…,m, n is the number of Pods to be allocated, and m is the number of Pods that can be placed The number of nodes; (2) ; S102) Based on the Hamiltonian calculated in step S101) Generate quantum circuits; S103) Measure the quantum state to obtain the expected value; S104) The current Hamiltonian and its corresponding expected value are put into the classical optimizer for optimization to obtain a set of new Hamiltonians ; S105) Repeat steps S102) to S104) until the new Hamiltonian obtained in step S104) A new Hamiltonian that satisfies the pre-set constraints That is ; wherein the Hamiltonian used when repeating step S102) is the new Hamiltonian obtained in step S104) ; S200) Set up to meet Node The Kubernetes load balancing resource scheduling is completed.

2. According to the Kubernetes load balancing resource scheduling method described in claim 1, It is characterized in that When Kubernetes load balancing is used, the number of nodes used, Num, satisfies the following equation: In the formula, For Node usage, ∈0,1,∀j=1,2,…,m.

3. According to the Kubernetes load balancing resource scheduling method according to claim 1, It is characterized in that The classic optimizer is one of VanillaGradientDescentOptimizer::minimize, MomentumOptimizer::minimize, AdaGradOptimizer::minimize, RMSOptimizer::minimize, and AdamOptimizer::minimize.

4. The Kubernetes load balancing resource scheduling method according to claim 1, It is characterized in that The load of each node with Pod is similar.

5. A system for performing Kubernetes load balancing using the Kubernetes load balancing resource scheduling method according to claim 1, It is characterized in that include: The data collection unit is used to collect data related to the usage of Kubernetes cluster node resources; A data input unit, used to input preset conditions through a human-computer interaction device; wherein the preset conditions include the number of Pods to be allocated and constraints for allocating Pods to nodes; Hamiltonian calculation unit, used to calculate placement based on data related to Kubernetes cluster node resource usage and data related to Pod usage of Node resources to be allocated The node after The Hamiltonian And get the solution that satisfies the pre-set constraints ; Pod allocation unit, used to Set the Pod to the corresponding node; The node Node is communicatively connected to the data acquisition unit, the data acquisition unit and the data input unit are respectively communicatively connected to the Hamiltonian calculation unit, the Hamiltonian calculation unit is communicatively connected to the Pod allocation unit, the Pod allocation unit is communicatively connected to the api-server component, and the api-server component is communicatively connected to the node Node.

6. The system according to claim 5, It is characterized in that The system is set up in a plug-in loaded on the scheduler component.

7. The system according to claim 6, It is characterized in that The scheduler component is set on the Master node in the Kubernetes cluster.

8. The system according to claim 7, It is characterized in that The scheduler component communicates with the etcd component and the api-server component communicates with the node Node.

9. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.

10. A computer device comprising a readable storage medium, a processor, and a computer program stored on the readable storage medium and executable on the processor, It is characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.