Kubernetes Pod Scheduling Method Based on Multi-Objective Balanced Optimization
By building an objective function of resource consumption cost and cluster imbalance, and using improved knowledge acquisition and sharing algorithms, the problems of Pod application diversity and resource consumption cost in Kubernetes scheduling method are solved, and efficient deployment and cluster balance of Pod applications are achieved. sex.
Patent Information
- Application Number
- CN202210592827.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-27
- Publication Date
- 2024-11-12
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing Kubernetes scheduling methods cannot meet the diversity needs of Pod applications, and fail to effectively reduce the resource consumption cost after Pod applications deployment and optimize the overall balancing load of the cluster.
Using the Kubernetes Pod scheduling method based on multi-objective equalization optimization, the resource information of nodes and Pod applications is collected, the label and verification dictionary is established, and the objective function of resource consumption cost and cluster imbalance is constructed, and the improved knowledge acquisition and sharing algorithm is used. Deploy Pod applications and optimize node selection to reduce resource consumption costs and improve cluster balance.
It realizes that while ensuring the diversity of Pod applications, it reduces resource deployment costs and maintains the overall balancing load of the cluster, improving the efficiency of Pod application deployment and resource utilization balance.
Smart Images

Figure CN115022335B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of cloud computing, and in particular to a Kubernetes Pod scheduling method based on multi-objective balanced optimization. Background Art
[0002] With the continuous development of Internet technology, cloud computing technology has been applied to all walks of life. The most important technology for realizing cloud computing is virtualization technology, which is used to isolate different resources to achieve the purpose of application independence. However, the technology itself has disadvantages such as over-abstraction and slow application startup speed.
[0003] In recent years, container technology represented by Docker has developed rapidly, which has promoted the innovation of the cloud computing industry as a whole. Compared with virtualization technology, Docker containers have the advantages of smaller images, less resource consumption, flexible deployment and startup in seconds. However, there are a large number of complex containerized applications in the actual production environment of the company. It is impossible to reasonably orchestrate and deploy them with Docker container technology alone, so container orchestration tools came into being. Kubernetes is a container orchestration tool developed by Google based on the Go language. Its predecessor is the Borg system used internally by Google. When Kubernetes was first made public, it already had a mature architecture and technology. Therefore, container orchestration tools represented by Kubernetes have gradually become the de facto standard for cloud native.
[0004] However, the default scheduling algorithm of Kubernetes still has some shortcomings, namely, it does not take into account the application diversity needs of Pod (the smallest deployment unit in Kubernetes), does not take into account the minimization of resource consumption costs generated after Pod application deployment, and does not take into account the overall balanced load of the cluster after scheduling multiple Pod applications. There is an urgent need for a scheduling method that takes into account the diversity of Pod applications, the resource cost consumption of Pod application deployment, and the balanced deployment of the cluster, to ensure support for diverse Pod applications and reduce the resource cost consumption of Pod application deployment while achieving balanced deployment. Summary of the invention
[0005] The present invention aims to solve the problem that the existing Kubernetes-based scheduling method cannot meet the diversity of Pod applications, minimize the resource consumption cost generated after Pod application deployment, and balance the overall load of the cluster after scheduling multiple Pod applications, and provide a Kubernetes Pod scheduling method based on multi-objective balanced optimization.
[0006] To solve the above problems, the present invention is achieved through the following technical solutions:
[0007] The Kubernetes Pod scheduling method based on multi-objective balanced optimization includes the following steps:
[0008] Step 1: Collect resource information of all nodes in the Kubernetes cluster and resource information of all Pod applications to be deployed, and create a verification dictionary that records the labels of all nodes, labels of all Pod applications to be deployed, and application ports;
[0009] Step 2: Construct an objective function based on resource consumption cost and cluster imbalance, namely:
[0010] f ALL =w1*f avgCOST +w2*S avg
[0011]
[0012]
[0013] In the formula, f ALL represents the individual evaluation value, w1 represents the cost weight, w2 represents the cluster imbalance weight, and f avgCOST Represents the average resource consumption cost of all Pod applications, S avg Indicates the average resource imbalance of all nodes; n indicates the number of nodes in the Kubernetes cluster, and m indicates the number of Pod applications to be deployed; flag indicates whether the port requested by the Pod application is occupied. If the port is occupied, flag = 0, and if the port is not occupied, flag = 1; Respectively represent the CPU, memory, bandwidth, and disk resource sizes requested by Pod application j; Respectively represent the resource consumption price per unit time of CPU, memory, bandwidth, and disk of node i; Respectively represent the highest price per unit time consumed by all nodes in the cluster, including CPU, memory, bandwidth, and disk; They represent the actual resource utilization of CPU, memory, bandwidth, and disk on node i respectively;
[0014] Step 3: Based on steps 1 and 2, the Pod application to be deployed is deployed to the nodes of the Kubernetes cluster using the improved knowledge acquisition and sharing algorithm, namely:
[0015] In the initial stage of the improved knowledge acquisition and sharing algorithm: first, update the individuals in the population that do not meet the verification dictionary until all individuals meet the verification dictionary; then, calculate the evaluation value of each individual in the population, and sort all individuals in the population based on the evaluation value; finally, for each individual in the population, select 3 individuals from all individuals as the source of knowledge sharing for the current individual, where the selected 3 individuals are 1 randomly selected from all individuals, and 2 individuals are selected from all individuals whose evaluation values are closest to the current individual;
[0016] In the advanced stage of the improved knowledge acquisition and sharing algorithm: first, the individuals in the population that do not satisfy the verification dictionary are updated until all individuals satisfy the verification dictionary; then, the evaluation value of each individual in the population is calculated, and all individuals in the population are sorted based on the evaluation value, and all individuals in the population are divided into three groups according to a predetermined proportion, namely, an individual group with a high evaluation value, an individual group with a medium evaluation value, and an individual group with a low evaluation value; finally, for each individual in the population, 3 individuals are selected from all individuals as the source of knowledge sharing for the current individual, where the selected 3 individuals are 1 individual randomly selected from the group of individuals with a high evaluation value, 1 individual randomly selected from the group of individuals with a medium evaluation value, and 1 individual randomly selected from the group of individuals with a low evaluation value.
[0017] The label labeli of the above node i is The resource name corresponding to the maximum value among these four values;
[0018] The label label of the above Pod application j j Yes The resource name corresponding to the maximum value among these four values;
[0019] Where i = 1, 2, ..., n, n represents the number of nodes in the Kubernetes cluster; j = 1, 2, ..., m, m represents the number of Pod applications to be deployed; represents the capacity of the memory resource of node i, represents the capacity of bandwidth resources of node i, Indicates the capacity of the disk resource of node i; Indicates the CPU resource size requested by Pod application j. Indicates the memory resource size requested by Pod application j. Indicates the bandwidth resource size requested by Pod application j. Indicates the disk resource size requested by Pod application j.
[0020] The above individuals refer to a feasible solution for deploying all Pod applications to be deployed to the nodes of the Kubernetes cluster.
[0021] The above individuals all satisfy the verification dictionary, which means that the node to which each Pod application to be deployed in the individual satisfies the following two conditions at the same time: ① The port of the node to which the Pod application to be deployed is the application port of the Pod application to be deployed recorded in the verification dictionary; ② The node to which the Pod application to be deployed has the same label as the node in the verification dictionary.
[0022] The present invention aims at the problem that Kubernetes does not consider the minimization of resource consumption costs generated after the deployment of Pod applications and the problem of balanced load of the entire cluster after scheduling a large number of Pod applications, and proposes a scheduling algorithm for improving knowledge acquisition and sharing. First, the Kubernetes resource indicators are expanded. On the basis of the default algorithm that only considers CPU and memory, two additional indicators, bandwidth and disk, are considered; secondly, the algorithm will establish a verification dictionary based on the label matching between nodes and Pod applications, and the ports requested by Pod applications, and repair the population initially generated by the algorithm and all individuals updated during the iteration of the population that do not meet the configuration; finally, an objective function based on cost and cluster imbalance is established and these two objective functions are normalized into the evaluation function of the algorithm, so as to improve the node selection strategy of the default scheduling algorithm and obtain the optimal Pod application deployment plan, thereby reducing the overall resource consumption cost while balancing the deployment. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 This is a flowchart of the Kubernetes Pod scheduling method based on multi-objective balanced optimization. DETAILED DESCRIPTION
[0024] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with specific examples.
[0025] Assuming there are n nodes in the Kubernetes cluster and m Pod applications to be deployed, the set N of nodes can be expressed as N = {n1, n2, n3, ...., n n}, where n i represents the i-th node in the cluster, i = 1, 2, ..., n; the set P of Pod applications can be expressed as P = {p1, p2, p3, ..., p m}, where p j represents the jth Pod application to be deployed, j = 1, 2, ..., m. The deployment set between Pod applications and nodes can be expressed as T = {t1, t2, t3, ..., t m}, where t j Represents p jThe node number where the Pod application is deployed, j = 1, 2, ..., m, that is, T represents a feasible solution, i.e., an individual, for deploying the Pod application to be deployed to the node of the Kubernetes cluster.
[0026] A Kubernetes Pod scheduling method based on multi-objective balanced optimization includes the following steps:
[0027] Step 1: Collect resource information of all nodes in the Kubernetes cluster and resource information of all Pod applications to be deployed, and create a verification dictionary that records the labels of all nodes, labels of all Pod applications to be deployed, and application ports.
[0028] After receiving each scheduling and deployment request for a Pod application, the system collects the resource information of the cluster nodes and the resource information of the currently applied Pod application, and establishes a verification dictionary based on the labels of the nodes and Pod applications, as well as the port number of the node occupied by the Pod application.
[0029] When establishing the verification dictionary, considering the differences in resource capacities of different nodes, and in order to better deploy Pod applications that request more resources on the nodes with the largest resource capacity, it is necessary to pre-label the Pod applications and nodes with the resource names that request the largest proportion of resources and the resource names that contain the largest proportion of resources, respectively.
[0030] The label of the node can be expressed as label i , i = 1, 2, ..., n. For each node label label i The values of are as follows: Of these four values, take the resource name corresponding to the maximum value as the label i The value of . represents the capacity of the CPU resources of node i, represents the capacity of the memory resource of node i, represents the capacity of bandwidth resources of node i, Indicates the capacity of the disk resource of node i. For example Of these four values Maximum, the label of the node is memory.
[0031] The label of the Pod application can be expressed as label j , j = 1, 2, ..., m. Label applied to each Pod j The values of are as follows: Of these four values, take the resource name corresponding to the maximum value as the label jThe value of . Indicates the CPU resource size requested by Pod application j. Indicates the memory resource size requested by Pod application j. Indicates the bandwidth resource size requested by Pod application j. Indicates the disk resource size requested by Pod application j. For example Of these four values If the value is the largest, the label applied to the Pod is bandwidth.
[0032] Step 2: Construct an objective function based on resource consumption cost and cluster imbalance.
[0033] In order to minimize the cost of resource consumption, we established an objective function for resource consumption cost. In order to balance the load after a large number of Pod applications are deployed in the cluster, we established an objective function for cluster imbalance based on the cost objective function. In the cost objective and cluster imbalance objective, we added the resource indicator of network bandwidth to address the diversity of Pod applications and consider the scheduling of Pod applications in edge environments. In order to schedule Pod applications in storage environments, we added the resource indicator of disk.
[0034] (1.1) Cost target:
[0035] After the Pod application is successfully deployed, it will occupy the resources of the deployment node. The resource price per unit time of each node is also different. In order to reduce the resource consumption cost of the Pod application deployment, it is necessary to calculate the total resource consumption generated by the Pod application deployment.
[0036]
[0037]
[0038] In the formula, f COST Indicates the total resource consumption cost after all Pod applications are deployed. Indicates the resource consumption cost of Pod application j deployed on node i. Flag indicates whether the port requested by the Pod application is occupied. If the port is occupied, flag = 0, and if the port is not occupied, flag = 1. They respectively represent the CPU, memory, bandwidth, and disk resource sizes requested by Pod application j. They represent the price of CPU, memory, bandwidth, and disk per unit time of node i respectively.
[0039] In order to quantify the results, the total resource consumption cost f generated after the Pod application is deployed COSTNormalization is performed. When normalizing, an additional consideration needs to be given to the situation that all Pod applications are deployed on the node with the largest resource consumption per unit time.
[0040]
[0041]
[0042]
[0043] In the formula, f MAXCOST Indicates the total cost consumed by deploying all Pod applications on the node with the highest resource consumption price per unit time. Indicates the total cost consumed by deploying all Pod applications j on the node with the highest resource consumption price per unit time. Respectively represent the unit time resource consumption price of CPU, memory, bandwidth, and disk of node i. Max(·) represents the maximum function, Respectively represent the highest price per unit time consumed by CPU, memory, bandwidth, and disk of all nodes in the cluster. Respectively represent the CPU, memory, bandwidth, and disk resource sizes requested by Pod application j. avgCOST Indicates the average resource consumption cost of all Pod applications.
[0044] (1.2) Cluster imbalance target:
[0045] As the number of Pod applications deployed increases, cluster nodes are prone to node resource skew, that is, a single resource of the node is almost fully occupied, while other resources are still largely idle. In order to ensure the overall balanced load of the cluster after deploying a large number of Pod applications, it is necessary to calculate the overall imbalance of the cluster.
[0046]
[0047] Where S represents the total resource imbalance of all nodes. Respectively represent the actual resource utilization of CPU, memory, bandwidth, and disk on node i.
[0048] To quantify the results, the total resource imbalance S of all nodes is normalized.
[0049]
[0050] In the formula, S avg Indicates the average resource imbalance of all nodes. The smaller the value, the more balanced the utilization of resources in the cluster.
[0051] (1.3) Objective function
[0052] fALL =w1*f avgCOST +w2*S avg
[0053] Among them, f ALL It represents the individual evaluation value. The smaller the value, the better the deployment plan. w1 represents the cost weight, and w2 represents the cluster imbalance weight.
[0054] Based on the resource consumption cost generated after the Pod application is deployed and the imbalance degree of the cluster nodes, corresponding objective functions are established respectively. Then, these two objective functions are normalized into evaluation functions and applied to the knowledge acquisition and sharing optimization algorithm. The individual with the smallest global evaluation function value is selected, that is, the global optimal deployment solution is selected.
[0055] Step 3: Based on steps 1 and 2, the Pod application to be deployed is deployed to the nodes of the Kubernetes cluster using the improved knowledge acquisition and sharing algorithm.
[0056] The knowledge acquisition and sharing algorithm is essentially a heuristic algorithm that can solve continuous space optimization problems. The algorithm is mainly divided into two stages: the primary stage and the advanced stage. The input of the algorithm is a set of randomly generated populations, and the output is the globally optimal individual in the population. The present invention improves on the traditional knowledge acquisition and sharing algorithm and proposes an improved knowledge acquisition and sharing algorithm that updates all individuals in the population according to the verification dictionary in step 1 and selects individuals for knowledge sharing according to the objective function in step 2. Figure 1, in the initial stage of the improved knowledge acquisition and sharing algorithm: first, update the individuals in the population that do not meet the verification dictionary until all individuals meet the verification dictionary; then, calculate the evaluation value of each individual in the population, and sort all individuals in the population based on the evaluation value; finally, for each individual in the population, select 3 individuals from all individuals as the source of knowledge sharing for the current individual, where the selected 3 individuals are 1 randomly selected from all individuals, and 2 individuals with the closest evaluation value to the current individual are selected from all individuals. In the primary stage, first update all individuals in the population according to the verification dictionary; secondly, sort all individuals in the population based on the evaluation value; finally, for the current individual, select two individuals with the closest evaluation function values as the source of knowledge acquisition and another random individual as the source of knowledge sharing. In the advanced stage, first, all individuals in the population are updated according to the verification dictionary; secondly, all individuals in the population are arranged based on the evaluation value, and the population is divided into three parts: best (10%), middle (80%), and worst (10%); finally, for the current individual, an individual is selected from the best, middle, and worst as the source of knowledge sharing. The individual in the improved knowledge acquisition and sharing algorithm refers to a feasible solution for all Pod applications to be deployed to the nodes of the Kubernetes cluster, where the node to which each Pod application to be deployed is deployed is one of the values of the individual.
[0057] The pseudo codes of the improved knowledge acquisition and sharing algorithm at the primary and advanced stages are as follows:
[0058] Algorithm 1: Primary acquisition and sharing algorithm
[0059] Input x i , k f , k r ,N,D
[0060] Output x i
[0061]
[0062] Algorithm 2: Advanced acquisition and sharing algorithm
[0063] Input x i , k f , k r ,N,D
[0064] Output x i
[0065]
[0066]
[0067] In the above pseudo code, x i Indicates the random initial generation of population; Check() is the dictionary verification function; k f >0, representing the knowledge factor, whose value controls the total amount of knowledge obtained and shared from other individuals; k r ∈[0, 1], its value represents the knowledge ratio, that is, the ratio between the current knowledge and the acquired knowledge; and They represent the updated new individuals and the old individuals that do not need to be updated respectively; f(x i ) and f(x r ) represent x i and x r The corresponding evaluation function value; rand is a random number, rand∈[0,1]; N and D represent the population size and dimension respectively.
[0068] The following algorithm is used to simulate the real experimental environment, and three control experiments are set up to illustrate the effectiveness of the present invention. The control groups are set as follows:
[0069] (1) Kubernetes' own scheduling algorithm (k8s for short), which tends to deploy Pod applications to nodes with the lowest resource consumption in the cluster.
[0070] (2) Native knowledge acquisition and sharing algorithm (Gaining-Sharing for short).
[0071] (3) The proposed method (DGS for short).
[0072] The experiment was run on 30 simulated nodes. The nodes were divided into three types, with 20 nodes of each type, as shown in Table 3. In view of the diverse resource requirements of Pod applications, the Pod resource requirements were simulated according to five types of Pod applications: CPU-sensitive, memory-sensitive, bandwidth-sensitive, disk-capacity-sensitive, and non-biased. Some requests are shown in Table 4. The unit time consumption of each resource on the node is shown in Table 5.
[0073] Table 3 Node resource information
[0074]
[0075] Table 4 Pod application resource requirements
[0076]
[0077]
[0078] Table 5 Node resource consumption per unit time information
[0079]
[0080] The experimental results are shown in Table 6, which proves that the method of this embodiment can reduce the resource consumption cost generated after the Pod application is deployed while ensuring the minimum deployment failure rate as much as possible, and maintain the balanced load of the entire cluster.
[0081] Table 6 Experimental results
[0082]
[0083] Cost objective function: the total cost of resource consumption per unit time for all Pod applications.
[0084] Deployment failure rate: When the port requested by the Pod application is already occupied on the deployment node, and the PodAffinity and Taint do not meet the requirements, the deployment will fail. The calculation formula is as follows:
[0085]
[0086] Among them, failCount represents the number of Pod applications that failed to be deployed; m represents the total number of Pod applications that need to be deployed.
[0087] Cluster imbalance objective function: the degree of inclination of each resource in the cluster.
[0088] Evaluation function: The function that normalizes the cost and cluster imbalance objective functions.
[0089] It should be noted that although the embodiments of the present invention described above are illustrative, they are not intended to limit the present invention, and therefore the present invention is not limited to the above specific embodiments. Without departing from the principles of the present invention, any other embodiments obtained by those skilled in the art under the guidance of the present invention are deemed to be within the protection of the present invention.
Claims
1. The Kubernetes Pod scheduling method based on multi-objective balanced optimization is characterized by: The steps include: Step 1: Collect resource information of all nodes in the Kubernetes cluster and resource information of all Pod applications to be deployed, and create a verification dictionary that records the labels of all nodes, labels of all Pod applications to be deployed, and application ports; Step 2: Construct an objective function based on resource consumption cost and cluster imbalance, namely: f ALL =w1*f avgCOST +w2*S avg In the formula, f ALL represents the individual evaluation value, w1 represents the cost weight, w2 represents the cluster imbalance weight, and f avgCOST Represents the average resource consumption cost of all Pod applications, S avg Indicates the average resource imbalance of all nodes; n indicates the number of nodes in the Kubernetes cluster, and m indicates the number of Pod applications to be deployed; flag indicates whether the port requested by the Pod application is occupied. If the port is occupied, flag = 0, and if the port is not occupied, flag = 1; Respectively represent the CPU, memory, bandwidth, and disk resource sizes requested by Pod application j; Respectively represent the resource consumption price per unit time of CPU, memory, bandwidth, and disk of node i; Respectively represent the highest price per unit time consumed by all nodes in the cluster, including CPU, memory, bandwidth, and disk; They represent the actual resource utilization of CPU, memory, bandwidth, and disk on node i respectively; Step 3: Based on steps 1 and 2, the Pod application to be deployed is deployed to the nodes of the Kubernetes cluster using the improved knowledge acquisition and sharing algorithm, namely: In the initial stage of the improved knowledge acquisition and sharing algorithm: first, update the individuals in the population that do not meet the verification dictionary until all individuals meet the verification dictionary; then, calculate the evaluation value of each individual in the population, and sort all individuals in the population based on the evaluation value; finally, for each individual in the population, select 3 individuals from all individuals as the source of knowledge sharing for the current individual, where the selected 3 individuals are 1 randomly selected from all individuals, and 2 individuals are selected from all individuals whose evaluation values are closest to the current individual; In the advanced stage of the improved knowledge acquisition and sharing algorithm: first, the individuals in the population that do not satisfy the verification dictionary are updated until all individuals satisfy the verification dictionary; then, the evaluation value of each individual in the population is calculated, and all individuals in the population are sorted based on the evaluation value, and all individuals in the population are divided into three groups according to a predetermined proportion, namely, an individual group with a high evaluation value, an individual group with a medium evaluation value, and an individual group with a low evaluation value; finally, for each individual in the population, 3 individuals are selected from all individuals as the source of knowledge sharing for the current individual, where the selected 3 individuals are 1 individual randomly selected from the group of individuals with a high evaluation value, 1 individual randomly selected from the group of individuals with a medium evaluation value, and 1 individual randomly selected from the group of individuals with a low evaluation value.
2. According to the Kubernetes Pod scheduling method based on multi-objective balanced optimization according to claim 1, it is characterized in that: The label of node i i yes The resource name corresponding to the largest value among these four values; Pod application j label label j yes The resource name corresponding to the largest value among these four values; Where i = 1, 2, ..., n, n represents the number of nodes in the Kubernetes cluster; j = 1, 2, ..., m, m represents the number of Pod applications to be deployed; represents the capacity of the CPU resources of node i, represents the capacity of the memory resource of node i, represents the capacity of bandwidth resources of node i, Indicates the capacity of the disk resource of node i; Indicates the CPU resource size requested by Pod application j. Indicates the memory resource size requested by Pod application j. Indicates the bandwidth resource size requested by Pod application j. Indicates the disk resource size requested by Pod application j.
3. According to the Kubernetes Pod scheduling method based on multi-objective balanced optimization according to claim 1, it is characterized in that: An individual is a feasible solution for deploying all Pod applications to the nodes of a Kubernetes cluster.
4. According to the Kubernetes Pod scheduling method based on multi-objective balanced optimization according to claim 1, it is characterized in that: Individuals satisfy the verification dictionary means that the nodes where each Pod application to be deployed in the individual is deployed meet the following two conditions at the same time: ① The port of the node where the Pod application to be deployed is the application port of the Pod application to be deployed recorded in the verification dictionary; ② The node to which the Pod application to be deployed is deployed. The Pod application to be deployed has the same label as the node in the verification dictionary.
