Container scheduling system and container batch scheduling method
By introducing batch scheduler and genetic algorithm into the Kubernetes framework to optimize scheduling results, the problem of poor adaptability between scheduling results and container cluster status and configuration information is solved, and better container deployment effects and resource utilization are achieved.
Patent Information
- Application Number
- CN202411041534.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-10-08
- Estimated Expiration
- 2044-07-30
AI Technical Summary
When the existing Kubernetes framework is scheduling containers, the adaptation effect between the scheduling results and the container cluster status and scheduling configuration information is not good, resulting in fragmented container storage, which is not conducive to later management.
Introduce a custom batch scheduler, use genetic algorithms to optimize scheduling results, obtain user configuration information through the rendering engine, generate resource files, and bind them with the native scheduler to improve the accuracy of scheduling results, scheduling configuration information, and working node status. Adaptability.
It optimizes the deployment effect of container clusters on containers, improves the adaptability between scheduling results, scheduling configuration information, and working node running status, and solves the problem of container storage fragmentation.
Smart Images

Figure CN118567819B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of container cloud technology, and in particular to a container scheduling system and a container batch scheduling method. Background Art
[0002] Kubernetes (K8s for short) is an open source framework for managing containers on multiple hosts in a cloud platform. Kubernetes provides a mechanism for application deployment, planning, updating, and maintenance, which can simplify the deployment and management of containerized applications and provide a reliable and scalable platform to run containerized workloads.
[0003] At present, when the existing K8s framework schedules containers, the scheduling results are easily not well adapted to the status of the container cluster and the scheduling configuration information (for example, causing the fragmentation of container storage), which is not conducive to subsequent management. Summary of the invention
[0004] The embodiments of the present invention provide a container scheduling system and a container batch scheduling method, and provide a solution for batch scheduling of containers, so as to solve the problem that the scheduling results of the existing K8s framework are easily poorly adapted to the status of the container cluster and the scheduling configuration information when scheduling the containers.
[0005] In a first aspect, an embodiment of the present invention provides a container scheduling system, including:
[0006] A rendering engine is used to obtain user configuration information corresponding to each of the target container group Pod sets that need to be scheduled; for any target Pod, a preset application template is rendered according to the user configuration information corresponding to the target Pod to obtain a resource file; wherein the target Pod set includes multiple target Pods; and the resource file includes the scheduling configuration information of the target Pod;
[0007] A batch scheduler is used to determine an initial scheduling result for the target Pod set, and use the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running state of each working node as the evolution direction of the scheduling result, and use a genetic algorithm to optimize the initial scheduling result for at least one round to obtain a target scheduling result corresponding to the target Pod set determined by the genetic algorithm;
[0008] The native scheduler is used to bind any target Pod to the target scheduling result corresponding to the target Pod;
[0009] The scheduling result includes the hardware resources corresponding to each target Pod in the target Pod set.
[0010] Further optionally, the batch scheduler is specifically used for:
[0011] Perform the preset rounds of scheduling result optimization, where each round of scheduling result optimization performs the following steps in sequence:
[0012] The current scheduling result is scored according to the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running status of each working node; the more the current scheduling result meets the requirements of the scheduling configuration information, and the better the adaptability between the current scheduling result and the running status of each working node, the higher the score of the current scheduling result; the current scheduling result of the first round scheduling result optimization process is the initial scheduling result, and the current scheduling result of the non-first round scheduling result optimization process is the scheduling result obtained after the previous round of scheduling result optimization process is completed; the initial scheduling result is a scheduling result randomly determined for the target Pod set;
[0013] retaining at least part of the current scheduling results according to the scores respectively corresponding to the current scheduling results;
[0014] The retained current scheduling result is naturally evolved; wherein the natural evolution includes at least one of the following: a crossover operation and a mutation operation.
[0015] Further optionally, the container scheduling system further includes: an application program interface service API Server;
[0016] The batch scheduler comprises:
[0017] The pre-initialization plug-in is used to obtain the scheduling configuration information of any target Pod according to the resource file corresponding to the target Pod before optimizing the first round of scheduling results;
[0018] An initialization plug-in is used to randomly determine the initial scheduling result for the target Pod set before optimizing the first round of scheduling results;
[0019] A scoring plug-in is used to score the current scheduling result according to the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running status of each working node;
[0020] A selection plug-in is used to retain at least part of the current scheduling results according to the scores respectively corresponding to the current scheduling results;
[0021] At least one natural evolution plug-in, used to use at least some of the at least one natural evolution plug-in to sequentially perform corresponding natural evolution on the retained current scheduling results; wherein each natural evolution plug-in corresponds to a natural evolution operation;
[0022] A resource confirmation plug-in, used to occupy the hardware resources corresponding to the target scheduling result;
[0023] A binding plug-in, used to submit the target scheduling result to the API Server;
[0024] The native scheduler is specifically used to: for any target Pod, obtain the target scheduling result corresponding to the target Pod from the API Server through the native scheduler; and bind the target Pod with the target scheduling result corresponding to the target Pod.
[0025] Further optionally, after rendering the preset application template for any target Pod according to the user configuration information corresponding to the target Pod to obtain the resource file, the rendering engine is further used to:
[0026] For the target Pod set, a batch information custom resource definition CRD corresponding to the target Pod set is created by the rendering engine and submitted to the API Server; the batch information CRD includes a set CRD, a front Pod CRD, and a front persistent declaration PVC CRD; the set CRD includes at least information related to the number of target Pods in the target Pod set; the front Pod CRD is at least used to abstract the target Pod; the front PVC CRD is at least used to abstract hardware resources;
[0027] Before determining the initial scheduling result for the target Pod set, the batch scheduler is further used to:
[0028] The batch information CRD is obtained by using a List-Watch mechanism, and batch scheduling conditions are determined to be met according to the set CRD;
[0029] After obtaining the target scheduling result corresponding to the target Pod set determined according to the genetic algorithm, the batch scheduler is further used to:
[0030] Instantiating the front Pod CRD and the front PVC CRD according to the target scheduling result, and submitting the front Pod CRD and the front PVC CRD to the API Server;
[0031] The native scheduler is specifically used for:
[0032] For any target Pod, obtain the target scheduling result corresponding to the target Pod, the front Pod CRD corresponding to the target Pod, and the front PVC CRD corresponding to the target Pod from the API Server; bind the target Pod to the front Pod CRD, and bind the PVC corresponding to the target Pod to the front PVC CRD.
[0033] Further optionally, the binding plug-in includes a first binding plug-in and a second binding plug-in, wherein:
[0034] The first binding plug-in is used to instantiate the front PVC CRD according to the target scheduling result, and submit the front PVC CRD to the API Server;
[0035] The second binding plug-in is used to instantiate the front Pod CRD according to the target scheduling result, and submit the front Pod CRD to the API Server.
[0036] In a second aspect, based on the same inventive concept, an embodiment of the present invention further provides a container batch scheduling method, which is applied to a rendering engine, comprising:
[0037] Obtain user configuration information corresponding to the target Pod sets that need to be scheduled; wherein the target Pod set includes multiple target Pods;
[0038] For any target Pod, render the preset application template according to the user configuration information corresponding to the target Pod to obtain a resource file; wherein the resource file includes the scheduling configuration information of the target Pod;
[0039] Submit the resource file to the batch scheduler so that the batch scheduler determines an initial scheduling result for the target Pod set, and uses the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running status of each working node as the evolution direction of the scheduling result; uses a genetic algorithm to perform at least one round of optimization on the initial scheduling result to obtain a target scheduling result corresponding to the target Pod set determined by the genetic algorithm; so that the native scheduler binds the target Pod to the target scheduling result corresponding to the target Pod for any target Pod.
[0040] Further optionally, for any target Pod, after the rendering engine renders the preset application template according to the user configuration information corresponding to the target Pod to obtain a resource file, the method further includes:
[0041] For the target Pod set, create a batch information CRD corresponding to the target Pod set and submit it to the API Server, so that the batch scheduler obtains the batch information CRD corresponding to the target Pod set from the API Server using the List-Watch mechanism, determines the initial scheduling result for the target Pod set after determining that the batch scheduling conditions are met according to the set CRD, and takes the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running status of each working node as the evolution direction of the scheduling result; uses a genetic algorithm to perform at least one round of optimization on the initial scheduling result to obtain the target scheduling result corresponding to the target Pod set determined according to the genetic algorithm; instantiates the front Pod CRD and the front PVC CRD according to the target scheduling result, and submits the front Pod CRD and the front PVC CRD to the API Server; so that the native scheduler obtains the target scheduling result corresponding to the target Pod, the front Pod CRD corresponding to the target Pod, and the front PVC CRD corresponding to the target Pod from the API Server for any target Pod; binds the target Pod to the front Pod CRD, and binds the PVC corresponding to the target Pod to the front PVC CRD;
[0042] The batch information CRD includes the set CRD, the front Pod CRD, and the front PVC CRD; the set CRD includes at least information related to the number of target Pods in the target Pod set; the front Pod CRD is at least used to abstract the target Pod; and the front PVC CRD is at least used to abstract hardware resources.
[0043] In a third aspect, based on the same inventive concept, an embodiment of the present invention further provides a container batch scheduling method, which is applied to a batch scheduler, including:
[0044] An initial scheduling result is determined for a target Pod set that needs to be scheduled, and a genetic algorithm is used to optimize the initial scheduling result for at least one round, taking the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running state of each working node as the evolution direction of the scheduling result, to obtain a target scheduling result corresponding to the target Pod set determined by the genetic algorithm; wherein the target Pod set includes multiple target Pods; for any target Pod, the scheduling configuration information is information contained in a resource file corresponding to the target Pod, and the resource file is obtained by rendering a preset application template by a rendering engine according to user configuration information corresponding to the target Pod;
[0045] Providing the target scheduling result to the native scheduler, so that the native scheduler binds the target Pod to the target scheduling result corresponding to the target Pod for any target Pod;
[0046] The scheduling result includes the hardware resources corresponding to each target Pod in the target Pod set.
[0047] Further optionally, determining an initial scheduling result for the target Pod set to be scheduled, and optimizing the initial scheduling result using a genetic algorithm for at least one round based on the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running state of each working node as the evolution direction of the scheduling result, specifically includes:
[0048] Perform the preset rounds of scheduling result optimization, where each round of scheduling result optimization performs the following steps in sequence:
[0049] The current scheduling result is scored according to the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running status of each working node; the more the current scheduling result meets the requirements of the scheduling configuration information, and the better the adaptability between the current scheduling result and the running status of each working node, the higher the score of the current scheduling result; the current scheduling result of the first round scheduling result optimization process is the initial scheduling result, and the current scheduling result of the non-first round scheduling result optimization process is the scheduling result obtained after the previous round of scheduling result optimization process is completed; the initial scheduling result is a scheduling result randomly determined for the target Pod set;
[0050] retaining at least part of the current scheduling results according to the scores respectively corresponding to the current scheduling results;
[0051] The retained current scheduling result is naturally evolved; wherein the natural evolution includes at least one of the following: a crossover operation and a mutation operation.
[0052] Further optionally, before optimizing the first round of scheduling results through the batch scheduler, the method further includes: for any target Pod, using the pre-initialization plug-in of the batch scheduler to obtain the scheduling configuration information of the target Pod according to the resource file corresponding to the target Pod; using the initialization plug-in of the batch scheduler to randomly determine the initial scheduling result for the target Pod set;
[0053] The scoring of the current scheduling result according to the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running state of each working node, specifically includes: using the scoring plug-in of the batch scheduler to score the current scheduling result according to the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running state of each working node;
[0054] The retaining at least part of the current scheduling results according to the scores respectively corresponding to the current scheduling results specifically includes: using the selection plug-in of the batch scheduler to retain at least part of the current scheduling results according to the scores respectively corresponding to the current scheduling results;
[0055] The performing natural evolution on the retained current scheduling results specifically includes: using at least one natural evolution plug-in of the batch scheduler to perform corresponding natural evolution on the retained current scheduling results in sequence;
[0056] After determining the target scheduling result corresponding to the target Pod set, the method further includes:
[0057] Using the resource confirmation plug-in of the batch scheduler to occupy the hardware resources corresponding to the target scheduling result;
[0058] The target scheduling result is submitted to the application program interface service API Server by using the binding plug-in of the batch scheduler; so that the native scheduler obtains the target scheduling result corresponding to the target Pod from the API Server for any target Pod; and binds the target Pod with the target scheduling result corresponding to the target Pod.
[0059] Further optionally, before determining the initial scheduling result for the target Pod set to be scheduled, the method further includes:
[0060] The List-Watch mechanism is used to obtain the batch information CRD corresponding to the target Pod set created by the rendering engine from the API Server, and the batch scheduling condition is determined according to the set CRD; wherein the batch information CRD includes the set CRD, the front Pod CRD, and the front PVC CRD; the set CRD at least includes information related to the number of target Pods in the target Pod set; the front Pod CRD is at least used to abstract the target Pod; the front PVC CRD is at least used to abstract the hardware resources;
[0061] After obtaining the target scheduling result corresponding to the target Pod set determined according to the genetic algorithm, the method further includes:
[0062] The front Pod CRD and the front PVC CRD are instantiated according to the target scheduling result, and the front Pod CRD and the front PVC CRD are submitted to the API Server; so that the native scheduler obtains the target scheduling result corresponding to the target Pod, the front Pod CRD corresponding to the target Pod, and the front PVC CRD corresponding to the target Pod from the API Server for any target Pod; binds the target Pod with the front Pod CRD, and binds the PVC corresponding to the target Pod with the front PVC CRD.
[0063] Further optionally, instantiating the front Pod CRD and the front PVC CRD according to the target scheduling result, and submitting the front Pod CRD and the front PVC CRD to the API Server specifically includes:
[0064] Instantiating the front-end PVC CRD according to the target scheduling result through the first binding plug-in of the batch scheduler, and submitting the front-end PVC CRD to the API Server;
[0065] The front Pod CRD is instantiated according to the target scheduling result through the second binding plug-in of the batch scheduler, and the front Pod CRD is submitted to the API Server.
[0066] In a fourth aspect, based on the same inventive concept, an embodiment of the present invention further provides a container batch scheduling method, which is applied to a native scheduler, including:
[0067] For any target Pod in the target Pod set, the target Pod is bound to a target scheduling result corresponding to the target Pod; the target Pod set includes multiple target Pods;
[0068] The scheduling result includes the hardware resources corresponding to each target Pod in the target Pod set;
[0069] The target scheduling result is that the batch scheduler uses a genetic algorithm to optimize the initial scheduling result for at least one round for the target Pod set, taking the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running state of each working node as the evolution direction of the scheduling result, to obtain a scheduling result determined according to the genetic algorithm;
[0070] For any target Pod, the scheduling configuration information is information contained in a resource file corresponding to the target Pod, and the resource file is obtained by rendering a preset application template by a rendering engine according to user configuration information corresponding to the target Pod.
[0071] Further optionally, the method specifically includes:
[0072] For any target Pod, obtain the target scheduling result corresponding to the target Pod, the front Pod CRD corresponding to the target Pod, and the front PVC CRD corresponding to the target Pod from the API Server;
[0073] Bind the target Pod to the front Pod CRD, and bind the PVC corresponding to the target Pod to the front PVC CRD;
[0074] The front Pod CRD corresponding to the target Pod and the front PVC CRD corresponding to the target Pod are created by the rendering engine and instantiated by the batch scheduler according to the target scheduling result, the front Pod CRD is at least used to abstract the target Pod, and the front PVC CRD is at least used to abstract hardware resources.
[0075] The beneficial effects of the present invention are as follows:
[0076] The container scheduling system and container batch scheduling method provided in the embodiments of the present invention, by adding an additional customized batch scheduler to the existing K8s framework and optimizing the batch scheduling results through a genetic algorithm, can obtain a batch scheduling result with better batch scheduling effect for multiple Pods, thereby optimizing the overall effect of container cluster deployment on containers and improving the adaptability between the scheduling results and the scheduling configuration information and the running status of each working node. BRIEF DESCRIPTION OF THE DRAWINGS
[0077] Figure 1 A schematic diagram of the structure of a container scheduling system provided by an embodiment of the present invention;
[0078] Figure 2 One of the flow charts of batch scheduling of containers by the container scheduling system provided in an embodiment of the present invention;
[0079] Figure 3 The second flowchart of the container scheduling system provided by the embodiment of the present invention for performing batch scheduling of containers;
[0080] Figure 4 A partial data flow diagram corresponding to the container batch scheduling method provided in an embodiment of the present invention;
[0081] Figure 5A partial flow chart of container batch scheduling by the container scheduling system provided in an embodiment of the present invention;
[0082] Figure 6 A schematic diagram of a roulette wheel in roulette operation;
[0083] Figure 7 A schematic diagram of the architecture of a batch scheduler provided in an embodiment of the present invention;
[0084] Figure 8 A flowchart of a container batch scheduling method applied to a rendering engine provided by an embodiment of the present invention;
[0085] Fig. 9 A flowchart of a container batch scheduling method applied to a batch scheduler provided in an embodiment of the present invention;
[0086] Fig.10 A flowchart of a container batch scheduling method applied to a native scheduler provided in an embodiment of the present invention;
[0087] Fig.11 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0088] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and understandable, the present invention will be further described below with reference to the accompanying drawings and examples. However, the exemplary embodiments can be implemented in various forms and should not be understood as being limited to the embodiments described herein; on the contrary, these embodiments are provided to make the present invention more comprehensive and complete, and to fully convey the concepts of the exemplary embodiments to those skilled in the art. The same figure marks in the figures represent the same or similar structures, and thus their repeated descriptions will be omitted. The words expressing position and direction described in the present invention are all explained using the accompanying drawings as examples, but changes can be made as needed, and the changes made are all included in the scope of protection of the present invention. The drawings of the present invention are only used to illustrate the relative position relationship and do not represent the true proportions.
[0089] It should be noted that specific details are described in the following description to facilitate a full understanding of the present invention. However, the present invention can be implemented in a variety of other ways different from those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below. The subsequent description of the specification is a preferred embodiment of the present application, but the description is for the purpose of illustrating the general principles of the present application and is not intended to limit the scope of the present application. The scope of protection of the present application shall be determined by the definition of the attached claims.
[0090] The container scheduling system and container batch scheduling method provided by the embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0091] In the first aspect, the embodiment of the present invention makes further improvements based on the existing K8s framework and proposes an improved container scheduling system to implement batch scheduling of containers. Figure 1 As shown, the improved container scheduling system includes: rendering engine (U1), batch scheduler (U2), native scheduler (U3), and application programming interface server (Application Programming Interface Server, API Server) (U4). Among them, the native scheduler (U3) is the scheduler provided by the existing K8s, and the batch scheduler (U2) is a new customized scheduler that is additionally improved based on the existing K8s in the embodiment of the present invention.
[0092] In the specific implementation process, the rendering engine (U1), batch scheduler (U2), native scheduler (U3), and APIServer (U4) are implemented in the form of functional units. It should be understood that the division of the functional units is only a logical functional division, and there may be other division methods in actual implementation. For example, multiple functional units can be combined or integrated into another system, or some features can be ignored or not executed. The functional units in the embodiment can be integrated into a processing module, or each functional unit can exist physically separately, or two or more functional units can be integrated into one module. The above-mentioned integrated functional unit can be implemented in the form of hardware or in the form of a software functional unit. If the integrated functional unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in the same computer-readable storage medium. For example, functional units such as the rendering engine (U1), batch scheduler (U2), native scheduler (U3), and API Server (U4) can run simultaneously in the same master node of the service cluster; or for a service cluster using multiple master nodes, at least some of the functional units in the rendering engine (U1), batch scheduler (U2), native scheduler (U3), and API Server (U4) run in different master nodes of the service cluster. For example, for a service cluster with multiple master nodes, each master node is provided with a rendering engine (U1), a batch scheduler (U2), a native scheduler (U3), and an API Server (U4), and each master node respectively elects a rendering engine (U1), a batch scheduler (U2), and a native scheduler (U3) for container scheduling through a voting mechanism, and the remaining rendering engines (U1), batch schedulers (U2), and native schedulers (U3) are used as backups and do not participate in container scheduling. The embodiments of the present invention are not overly limited here.
[0093] like Figure 2 and Figure 3 As shown, the container scheduling system uses the following method to implement container batch scheduling:
[0094] S110. Obtain, through the rendering engine, user configuration information corresponding to each target Pod in the target container group (Pod) set to be scheduled.
[0095] In K8s, Pod is the smallest deployable scheduling unit. Each Pod is a group of one or more containers. All containers in the same Pod share network and storage resources and are deployed and managed as a whole. In the embodiment of the present invention, a single Pod is referred to as a "container group". Accordingly, in the embodiment of the present invention, the whole composed of multiple Pods for batch scheduling is referred to as a "Pod set". For the target Pod set for batch scheduling this time, the multiple Pods contained in the target Pod set are referred to as "target Pods" in the embodiment of the present invention.
[0096] In the specific implementation process, Figure 4 As shown, the user configuration information may be a file in the Helm Chart format.
[0097] S120. For any target Pod, a rendering engine renders a preset application template according to user configuration information corresponding to the target Pod to obtain a resource file.
[0098] The resource file includes the scheduling configuration information of the target Pod.
[0099] In the specific implementation process, the resource file may be in YAML format. The resource file describes various resources that need to be created in the K8s cluster, such as Deployment, Statefulset, Service, ConfigMap, etc.
[0100] Afterwards, if Figure 4 As shown, the rendering engine can submit the resource file to the API Server for subsequent scheduling, deployment and other steps. And, the rendering engine provides the resource file to the batch scheduler through the gRPC mechanism. Since the subsequent deployment and other steps of K8s based on the resource file are not the focus of the embodiment of the present invention, they are not described in detail, and the specific implementation can refer to the existing technology.
[0101] S130. Determine an initial scheduling result for the target Pod set through a batch scheduler, and use the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running status of each working node as the evolution direction of the scheduling result, and use a genetic algorithm to perform at least one round of optimization on the initial scheduling result to obtain a target scheduling result corresponding to the target Pod set determined by the genetic algorithm.
[0102] The scheduling result includes the hardware resources corresponding to each target Pod in the target Pod set, and the hardware resources may include corresponding worker nodes, hard disks, etc.
[0103] In the specific implementation process, there may be multiple initial scheduling results and intermediate scheduling results (hereinafter collectively referred to as current scheduling results) generated during the optimization process of the initial scheduling results. Then the target scheduling result may be the optimal scheduling result among the current scheduling results in the last round of optimization.
[0104] In the specific implementation process, the scheduling configuration information of the target Pod may include but is not limited to the following information:
[0105] ① The hardware resource requirement information of the current target Pod, such as the storage space required by the current target Pod, the minimum performance of the processor required by the Worker node to run the current target Pod, and the lower limit model of the processor required by the Worker node to run the current target Pod.
[0106] ② The affinity between the current target Pod and the Worker node to which it is scheduled. Furthermore, it may also include the affinity priority between the current target Pod and the Worker node to which it is scheduled.
[0107] ③ Anti-affinity between the current target Pod and the Worker node to which it is scheduled. Furthermore, it may also include the anti-affinity priority between the current target Pod and the Worker node to which it is scheduled.
[0108] In an embodiment of the present invention, the affinity and anti-affinity between the current target Pod and the Worker node to which it is scheduled indicate whether the current target Pod is expected to be scheduled to the Worker node to which it is scheduled, wherein the Worker node having affinity with the target Pod is the Worker node to which the target Pod is expected to be scheduled, and the Worker node having anti-affinity with the target Pod is the Worker node to which the target Pod is not expected to be scheduled.
[0109] ④ The affinity between the current target Pod and other target Pods. Furthermore, the affinity priority between the current target Pod and other target Pods may also be included.
[0110] ⑤ Anti-affinity between the current target Pod and other target Pods. Furthermore, it can also include the anti-affinity priority between the current target Pod and other target Pods.
[0111] In an embodiment of the present invention, the affinity and anti-affinity between the current target Pod (hereinafter referred to as the first Pod for the convenience of distinction) and other target Pods (hereinafter referred to as the second Pod for the convenience of distinction) indicate whether the first Pod and the second Pod are expected to be scheduled to the same node, wherein the second Pod having affinity with the first Pod is the other Pod expected to be scheduled to the same node as the first Pod, and the second Pod having anti-affinity with the first Pod is the other Pod expected to be scheduled to a different node from the first Pod.
[0112] ⑥ The current target Pod’s tolerance for taints.
[0113] In the embodiment of the present invention, the taint is one of the running states of the Worker node, and the Worker node in the tainted state does not allow the Pod to be scheduled to the Worker node. The tolerance can allow the Pod to be scheduled to the tainted Worker node by exception.
[0114] ⑦The scheduling priority of the current target Pod.
[0115] In an embodiment of the present invention, if the hardware resources of the container cluster are insufficient to schedule all Pods to be scheduled, then the Pods with higher scheduling priorities will be scheduled more preferentially.
[0116] The running status of a Worker node may include but is not limited to the following information:
[0117] ①Worker node working status information, including normal operation status, stopped operation status, fault status, etc., as well as the current resource utilization of the Worker node.
[0118] ②Hardware resource information that the Worker node can currently provide, including the available storage space that the current Worker node can provide, the performance and model of the processor of the current Worker node, etc.
[0119] ③Stain setting information.
[0120] Alternatively, if Figure 5 As shown, step S130 can be specifically implemented by the batch scheduler executing the following steps:
[0121] S131. Randomly determine multiple scheduling results for the target Pod set as initial scheduling results.
[0122] In the implementation of iteratively optimizing the scheduling results using a genetic algorithm, as an optional implementation, for any scheduling result, an individual may be set to represent the scheduling result for iterative optimization, that is, each scheduling result corresponds to an individual. Accordingly, an information item in the scheduling result may correspond to a gene or a chromosome. The population size of the genetic algorithm is the number of current scheduling results.
[0123] As another optional implementation, for any scheduling result, a chromosome can be set to represent the scheduling result for iterative optimization (equivalent to each individual having only one chromosome), that is, each scheduling result corresponds to a chromosome. Accordingly, each information item in the scheduling result corresponds to a gene. The population size of the genetic algorithm (in this implementation, the population size is equal to the number of chromosomes) is the number of current scheduling results.
[0124] In the specific implementation process, the information items in the scheduling result can be encoded as genes or chromosomes in any of the following ways:
[0125] Binary coding, Gray code coding, floating point coding, symbol coding, multi-parameter set joint coding, multi-parameter cross coding.
[0126] S132, score the current scheduling result according to the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running status of each working node. The more the current scheduling result meets the requirements of the scheduling configuration information, and the better the adaptability between the current scheduling result and the running status of each working node, the higher the score of the current scheduling result.
[0127] During the specific implementation process, a scoring mechanism can be set up as needed, for example, considering factors such as the upper limit of node resource usage and the balance of node resource usage as scoring criteria.
[0128] S133: Determine whether the optimization end condition is met.
[0129] If the optimization end condition is met, step S136 is executed; if the optimization end condition is not met, step S134 is executed.
[0130] In the specific implementation process, the optimization end condition can be set as needed. For example, the optimization end condition can be set to that the number of optimization rounds currently being executed is equal to a preset number threshold, and specifically, each time step S132 or step S133 is executed, it can be recorded as the completion of a round of optimization process. Alternatively, the optimization end condition can be set to that the maximum score in the score corresponding to the current scheduling result is greater than or equal to a preset score threshold. Alternatively, the optimization end condition can be a combination of the above two, that is, satisfying any one of the above two satisfies the optimization end condition. The embodiments of the present invention are not limited here.
[0131] S134. Retain at least part of the current scheduling results according to the scores corresponding to the current scheduling results.
[0132] During the specific implementation process, the step S134 can set an elimination mechanism to eliminate some scheduling results with poor adaptability between the scheduling configuration information and the scheduling results, and between the scheduling results and the operating status of each working node, so that during the iteration process, the overall scheduling results are optimized in the direction of good adaptability between the scheduling configuration information and the scheduling results, and between the scheduling results and the operating status of each working node.
[0133] In a specific implementation process, any of the following methods may be used to retain at least part of the current scheduling results according to the scores corresponding to the current scheduling results:
[0134] Roulette wheel selection, optimal retention strategy, tournament selection, competitive selection, elite selection, deterministic sampling selection, random selection without replay, random selection with remainder without replay, sorted selection.
[0135] For example, roulette is a random selection algorithm used to solve optimization problems. In the embodiment of the present invention, the roulette selection first calculates the proportion of each individual on the roulette wheel according to the score of each individual (such as Figure 6 As shown in the figure, the roulette wheel is rotated by generating a random number between 0 and 1 to simulate the rotation process of the roulette wheel, so as to finally select the selected individual. Since individuals with higher scores occupy a larger proportion in the roulette wheel, they have a greater probability of being retained in the roulette wheel; while individuals with lower scores occupy a lower proportion in the roulette wheel, so they have a greater probability of not being selected in the roulette wheel and being eliminated.
[0136] S135: Perform natural evolution on the retained current scheduling result. Return to step S132.
[0137] S136. Use the scheduling result with the highest score among the current scheduling results as the target scheduling result.
[0138] Wherein, the natural evolution includes at least one of the following: a crossover operation and a mutation operation.
[0139] In a specific implementation process, the crossover operation includes any of the following:
[0140] Single-point crossover operation, multi-point crossover operation, uniform crossover operation, arithmetic crossover operation.
[0141] The crossover operation process of the genetic algorithm simulates the process of biological reproduction in nature. In the embodiment of the present invention, it refers to pairing the chromosomes of two different individuals and exchanging some genes on the two chromosomes in a certain way to obtain two new chromosomes. Among them, in the crossover operation, whether the gene on one chromosome is exchanged with the allele of another chromosome is controlled by the crossover probability. The crossover probability is the probability of gene exchange between the matching chromosome pairs after the chromosomes are randomly paired. In the embodiment of the present invention, the crossover probability can be a preset value.
[0142] In the specific implementation process, the mutation operation includes any of the following:
[0143] Basic bit mutation operation, uniform mutation operation, boundary mutation operation, non-uniform mutation operation, Gaussian mutation operation.
[0144] The mutation operation process of the genetic algorithm simulates the process of gene mutation of chromosomes. In the embodiment of the present invention, the genes on the existing chromosomes are mutated according to the mutation probability, and the coding values of the mutated genes are changed, thereby changing the information items in the corresponding scheduling results, thereby obtaining new chromosomes, and then obtaining new individuals, that is, obtaining new scheduling results. The mutation probability is the probability of whether the genes on the chromosomes mutate. In the embodiment of the present invention, the mutation probability can be a preset value.
[0145] S140. For any target Pod, bind the target Pod with the target scheduling result corresponding to the target Pod through the native scheduler.
[0146] The scheduling result includes the hardware resources corresponding to each target Pod in the target Pod set.
[0147] The container scheduling system provided in the embodiment of the present invention, by adding an additional customized batch scheduler to the existing K8s framework and optimizing the batch scheduling results through a genetic algorithm, can obtain a batch scheduling result with good batch scheduling effect for multiple Pods, thereby optimizing the overall effect of container cluster deployment on containers and improving the adaptability between the scheduling results and the scheduling configuration information and the running status of each working node.
[0148] In addition, for the existing K8s framework, batch scheduling of Pods is mainly constrained by two issues:
[0149] 1. When the native scheduler schedules pods, the Statefulset PodManagementPolicy field restricts pod creation behavior. By default, pods are created according to the sequence number. The next pod is created only when the previous pod is ready.
[0150] 2. Helm Chart has a hook mechanism. Under the pre-install hook, the creation of workloads under the chart package will be stuck until the hook ends, which will also limit the creation behavior of pods.
[0151] The container scheduling system provided in the embodiment of the present invention adds a customized batch scheduler to the existing K8s framework. Before the native scheduler officially schedules the Pod, the batch scheduler is used to batch schedule the Pod collection in advance so that the native scheduler can directly use the scheduling result determined by the batch scheduler when scheduling, thereby realizing batch scheduling of containers, avoiding the mechanism of the native scheduler scheduling Pods in sequence, and the constraints of Helm hook mechanism and other factors on batch scheduling.
[0152] Furthermore, in order to adjust and expand the functions of the batch scheduler according to needs, the batch scheduler can be developed based on modularization, so that the functions involved in the batch scheduler are implemented by corresponding functional plug-ins. Figure 7 As shown, the batch scheduler (U2) may include the following plug-ins:
[0153] The pre-initialization plug-in (M1) is used to obtain the scheduling configuration information of any target Pod according to the resource file corresponding to the target Pod before optimizing the first round of scheduling results. In the specific implementation process, the pre-initialization plug-in can organize the scheduling configuration information involved in this scheduling according to the data structure and put it into the context for subsequent plug-ins to use, such as obtaining the node's resource usage snapshot information and putting it into the context.
[0154] The initialization plug-in (M2) is used to randomly determine the initial scheduling results for the target Pod set before the first round of scheduling result optimization. Furthermore, the initialization plug-in can also prevent the generation of invalid initial scheduling results (such as scheduling results with overflow of node resource allocation) by presetting intervention logic when randomly determining the initial scheduling results.
[0155] The scoring plug-in (M3) is used to score the current scheduling result according to the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running status of each working node. In the specific implementation process, the operation of the scoring plug-in (M3) to score the current scheduling result can be performed after the initialization plug-in (M2) randomly determines the initial scheduling result for the target Pod set, and after the natural evolution plug-in (M5) completes a round of natural evolution of the current scheduling result.
[0156] A plug-in (M4) is selected to retain at least part of the current scheduling results according to the scores respectively corresponding to the current scheduling results.
[0157] At least one natural evolution plug-in (M5) is used to use at least some of the natural evolution plug-ins (M5) in the at least one natural evolution plug-in (M5) to sequentially perform corresponding natural evolution on the retained current scheduling results, wherein each natural evolution plug-in (M5) corresponds to a natural evolution operation.
[0158] The resource confirmation plug-in (M6) is used to realize the occupation of the hardware resources corresponding to the target scheduling result. Furthermore, when multiple schedulers are in parallel, the resource confirmation plug-in (M5) can determine whether the target scheduling result overflows, and if not, the hardware resources corresponding to the target scheduling result are occupied.
[0159] The binding plug-in (M7) is used to submit the target scheduling result to the ARI Server.
[0160] Correspondingly, the step S140, for any target Pod, binding the target Pod with the target scheduling result corresponding to the target Pod through the native scheduler, specifically includes:
[0161] For any target Pod, a target scheduling result corresponding to the target Pod is obtained from the API Server through the native scheduler; and the target Pod is bound to the target scheduling result corresponding to the target Pod.
[0162] like Figure 7 As shown, for the batch scheduler (U2), the iterative optimization of the scheduling results is actually mainly implemented by the scoring plug-in (M3), the selection plug-in (M4), and the natural evolution plug-in (M5); the resource confirmation plug-in (M6) and the binding plug-in (M7) are mainly used to process the target scheduling results after determining the target scheduling results.
[0163] In the specific implementation process, for each type of plug-in mentioned above, each type of plug-in can further include plug-ins with multiple different implementation methods. For example, for the scoring plug-in (M3), multiple different scoring plug-ins (M3) can be set, and each scoring plug-in (M3) has a different scoring mechanism. When scheduling, the required scoring plug-in (M3) is selected to implement the scoring logic. Among them, the scoring factors considered by different scoring mechanisms and the weights of the impact of the scoring factors on the scoring can be different. For the selection plug-in (M4), it can include selection plug-ins corresponding to the various selection operations described above (such as roulette plug-in, optimal retention strategy plug-in, tournament selection plug-in, competition selection plug-in, elite selection plug-in, deterministic sampling selection plug-in, no replay random selection plug-in, no replay remainder random selection plug-in, sorting selection plug-in...). For the natural evolution plug-in, it can further include two types of plug-ins, namely, crossover plug-ins and mutation plug-ins, which correspond to the crossover operation and mutation operation described above, respectively. Furthermore, the crossover plug-in may include a variety of different plug-ins, corresponding to the various crossover operation modes described above (e.g., single-point crossover operation plug-in, multi-point crossover operation plug-in, uniform crossover operation plug-in, arithmetic crossover operation plug-in, etc.); the mutation plug-in may include a variety of different plug-ins, corresponding to the various mutation operation modes described above (e.g., basic bit mutation operation plug-in, uniform mutation operation plug-in, boundary mutation operation plug-in, non-uniform mutation operation plug-in, Gaussian mutation operation plug-in, etc.). The specific types of plug-ins can be inferred by referring to the corresponding content above, and will not be described in detail here.
[0164] Since there are multiple levels of abstraction between Pod and underlying hardware resources in K8s, based on the existing K8s program code structure, the embodiment of the present invention adds three types of batch information custom resource definitions (Custom Resource Definition, CRD) - collection CRD, front Pod CRD, and front persistent volume claim (Persistent Volume Claim, PVC) CRD to assist in implementing the above steps.
[0165] Among them, the set CRD (for example, named DhPodGroup) is used to include at least information related to the number of target Pods in the target Pod set. For example, the set CRD may include: the number of Pods in the Pod set, the lower limit of the number of Pods that trigger batch scheduling (i.e., the minimum number of Pods that trigger batch scheduling for the Pod set) (for example, named minMember), the Pod scheduling status of the entire Pod set (including all completed scheduling, no scheduling, partially completed scheduling, etc.), and other attributes. The pre-Pod CRD (for example, named "DhPrePod") is at least used to abstract the target Pod, for example, it may include attributes such as the Pod name, the Pod scheduling status (including successful scheduling, scheduling failure, error) (for example, named Status), etc. The pre-PVC CRD (for example, named "DhPrePVC") is at least used to abstract hardware resources.
[0166] Accordingly, after step S120, Figure 3 As shown, the process also includes:
[0167] S121. For the target Pod set, the rendering engine creates a batch information CRD corresponding to the target Pod set and submits it to the API Server. Figure 4 shown)
[0168] S122: The batch information CRD is acquired by the batch scheduler using a list-watch mechanism.
[0169] S123. The batch scheduler determines whether a batch scheduling condition is met according to the set CRD.
[0170] If the result of step S123 is yes, execute step S130; if the result of step S123 is no, return to step S122.
[0171] After the batch scheduler obtains the target scheduling result corresponding to the target Pod set determined by the genetic algorithm, it further performs the following steps:
[0172] The batch scheduler instantiates the front Pod CRD and the front PVC CRD according to the target scheduling result, and submits the front Pod CRD and the front PVC CRD to the API Server.
[0173] Specifically, the binding plug-in (M7) of the batch scheduler may also include a first binding plug-in (M7-1) and a second binding plug-in (M7-2). The first binding plug-in of the batch scheduler instantiates the front PVC CRD according to the target scheduling result, and submits the front PVC CRD to the API Server; the second binding plug-in of the batch scheduler instantiates the front Pod CRD according to the target scheduling result, and submits the front Pod CRD to the API Server.
[0174] like Figure 3 As shown, the step S140, for any target Pod, binds the target Pod with the target scheduling result corresponding to the target Pod through the native scheduler, specifically including:
[0175] S141. For any target Pod, obtain the target scheduling result corresponding to the target Pod, the front Pod CRD corresponding to the target Pod, and the front PVC CRD corresponding to the target Pod from the API Server through the native scheduler.
[0176] S142. Bind the target Pod to the front Pod CRD through the native scheduler, and bind the PVC corresponding to the target Pod to the front PVC CRD.
[0177] In the second aspect, based on the same inventive concept, an embodiment of the present invention further provides a container batch scheduling method, which is applied to a rendering engine, such as Figure 8 As shown, including:
[0178] S210. Obtain user configuration information corresponding to each target Pod set that needs to be scheduled.
[0179] The target Pod set includes multiple target Pods.
[0180] S220. For any target Pod, render the preset application template according to the user configuration information corresponding to the target Pod to obtain a resource file.
[0181] The resource file includes the scheduling configuration information of the target Pod.
[0182] S240. Submit the resource file to the batch scheduler so that the batch scheduler determines an initial scheduling result for the target Pod set, and uses the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running status of each working node as the evolution direction of the scheduling result, and uses a genetic algorithm to perform at least one round of optimization on the initial scheduling result to obtain a target scheduling result corresponding to the target Pod set determined by the genetic algorithm; so that the native scheduler binds the target Pod to the target scheduling result corresponding to the target Pod for any target Pod.
[0183] Further optionally, in step S220, after rendering the preset application template to obtain a resource file for any target Pod through a rendering engine according to the user configuration information corresponding to the target Pod, the method further includes:
[0184] S230, for the target Pod set, create a batch information CRD corresponding to the target Pod set and submit it to the API Server, so that the batch scheduler uses the List-Watch mechanism to obtain the batch information CRD corresponding to the target Pod set from the API Server, and after determining that the batch scheduling conditions are met according to the set CRD, determine the initial scheduling result for the target Pod set, and use the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running status of each working node as the evolution direction of the scheduling result; use the genetic algorithm to perform at least one round of optimization on the initial scheduling result to obtain the target scheduling result corresponding to the target Pod set determined according to the genetic algorithm; instantiate the front Pod CRD and the front PVC CRD according to the target scheduling result, and submit the front Pod CRD and the front PVC CRD to the API Server; so that the native scheduler obtains the target scheduling result corresponding to the target Pod, the front Pod CRD corresponding to the target Pod, and the front PVC CRD corresponding to the target Pod from the API Server for any target Pod; bind the target Pod to the front Pod CRD, and bind the PVC corresponding to the target Pod to the front PVC CRD is bound.
[0185] The batch information CRD includes the set CRD, the front Pod CRD, and the front PVC CRD. The set CRD includes at least information related to the number of target Pods in the target Pod set. The front Pod CRD is at least used to abstract the target Pod. The front PVC CRD is at least used to abstract the hardware resources.
[0186] In a third aspect, based on the same inventive concept, an embodiment of the present invention further provides a container batch scheduling method, which is applied to a batch scheduler, such as Fig. 9 As shown, including:
[0187] S330. Determine an initial scheduling result for the target Pod set that needs to be scheduled, and use the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running status of each working node as the evolution direction of the scheduling result. Use a genetic algorithm to perform at least one round of optimization on the initial scheduling result to obtain a target scheduling result corresponding to the target Pod set determined by the genetic algorithm.
[0188] The target Pod set includes multiple target Pods. For any target Pod, the scheduling configuration information is information contained in a resource file corresponding to the target Pod, and the resource file is obtained by rendering a preset application template by a rendering engine according to user configuration information corresponding to the target Pod.
[0189] S340: Provide the target scheduling result to the native scheduler, so that the native scheduler binds the target Pod to the target scheduling result corresponding to the target Pod for any target Pod.
[0190] The scheduling result includes the hardware resources corresponding to each target Pod in the target Pod set.
[0191] Furthermore, the step S330 determines an initial scheduling result for the target Pod set to be scheduled, and uses a genetic algorithm to optimize the initial scheduling result for at least one round based on the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running state of each working node as the evolution direction of the scheduling result, specifically including the following: Figure 5 The steps shown are not repeated here.
[0192] Further optionally, before optimizing the first round of scheduling results by the batch scheduler, the method further includes:
[0193] For any target Pod, the pre-initialization plug-in of the batch scheduler is used to obtain the scheduling configuration information of the target Pod according to the resource file corresponding to the target Pod.
[0194] The initialization plug-in of the batch scheduler is used to randomly determine the initial scheduling result for the target Pod set.
[0195] The scoring of the current scheduling result according to the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running status of each working node, specifically includes: using the scoring plug-in of the batch scheduler to score the current scheduling result according to the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running status of each working node.
[0196] The retaining at least part of the current scheduling results according to the scores respectively corresponding to the current scheduling results specifically includes: using the selection plug-in of the batch scheduler to retain at least part of the current scheduling results according to the scores respectively corresponding to the current scheduling results.
[0197] The naturally evolving the retained current scheduling results specifically includes: using at least one natural evolution plug-in of the batch scheduler to sequentially and correspondingly evolve the retained current scheduling results.
[0198] After determining the target scheduling result corresponding to the target Pod set, the method further includes:
[0199] The resource confirmation plug-in of the batch scheduler is used to occupy the hardware resources corresponding to the target scheduling result.
[0200] The target scheduling result is submitted to the application program interface service API Server by using the binding plug-in of the batch scheduler, so that the native scheduler obtains the target scheduling result corresponding to any target Pod from the API Server; and binds the target Pod with the target scheduling result corresponding to the target Pod.
[0201] Further optionally, before step S330, the method further includes:
[0202] S310. Obtain the batch information CRD corresponding to the target Pod set created by the rendering engine from the API Server using the List-Watch mechanism. The batch information CRD includes a set CRD, a front Pod CRD, and a front PVC CRD. The set CRD includes at least information related to the number of target Pods in the target Pod set. The front Pod CRD is at least used to abstract the target Pod. The front PVC CRD is at least used to abstract hardware resources.
[0203] S320, judging whether the batch scheduling condition is met according to the set CRD. If the result of step S320 is yes, executing step S330. If the result of step S320 is no, returning to step S310.
[0204] After obtaining the target scheduling result corresponding to the target Pod set determined according to the genetic algorithm, the method further includes:
[0205] S350, instantiate the front Pod CRD and the front PVC CRD according to the target scheduling result, and submit the front Pod CRD and the front PVC CRD to the API Server. So that the native scheduler can obtain the target scheduling result corresponding to the target Pod, the front Pod CRD corresponding to the target Pod, and the front PVC CRD corresponding to the target Pod from the API Server for any target Pod; bind the target Pod to the front Pod CRD, and bind the PVC corresponding to the target Pod to the front PVC CRD.
[0206] Further optionally, the step S350, instantiating the front Pod CRD and the front PVC CRD according to the target scheduling result, and submitting the front Pod CRD and the front PVC CRD to the API Server, specifically includes:
[0207] The front-end PVC CRD is instantiated according to the target scheduling result by the first binding plug-in of the batch scheduler, and the front-end PVC CRD is submitted to the API Server.
[0208] The front Pod CRD is instantiated according to the target scheduling result through the second binding plug-in of the batch scheduler, and the front Pod CRD is submitted to the API Server.
[0209] In a fourth aspect, based on the same inventive concept, an embodiment of the present invention further provides a container batch scheduling method, which is applied to a native scheduler, including:
[0210] For any target Pod in the target Pod set, the target Pod is bound to the target scheduling result corresponding to the target Pod.
[0211] Among them, the target Pod set includes multiple target Pods. The scheduling result includes the hardware resources corresponding to each target Pod in the target Pod set. The target scheduling result is that the batch scheduler uses a genetic algorithm to optimize the initial scheduling result for at least one round for the target Pod set, taking the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running status of each working node as the evolution direction of the scheduling result, to obtain the scheduling result determined by the genetic algorithm. For any target Pod, the scheduling configuration information is the information contained in the resource file corresponding to the target Pod, and the resource file is obtained by rendering the preset application template by the rendering engine according to the user configuration information corresponding to the target Pod.
[0212] Further optionally, if Fig.10 As shown, the method specifically includes:
[0213] S410. For any target Pod, obtain from the API Server the target scheduling result corresponding to the target Pod, the front Pod CRD corresponding to the target Pod, and the front PVC CRD corresponding to the target Pod.
[0214] S420: Bind the target Pod to the front Pod CRD, and bind the PVC corresponding to the target Pod to the front PVC CRD.
[0215] The front Pod CRD corresponding to the target Pod and the front PVC CRD corresponding to the target Pod are created by the rendering engine and instantiated by the batch scheduler according to the target scheduling result, the front Pod CRD is at least used to abstract the target Pod, and the front PVC CRD is at least used to abstract hardware resources.
[0216] Since the container batch scheduling method is the principle of the container scheduling system to solve the problem, the implementation of the container batch scheduling method described in the second to fourth aspects can be implemented by referring to the corresponding content of the container scheduling system described in the first aspect, which will not be repeated here.
[0217] In a fifth aspect, based on the same inventive concept, an embodiment of the present invention further provides an electronic device, such as Fig.11 As shown, it includes: a processor 110 and a memory 120 for storing executable instructions of the processor 110;
[0218] The processor 110 is configured to execute the instructions to implement the container batch scheduling method as described in at least one of the second to fourth aspects.
[0219] In the specific implementation process, the device may have relatively large differences due to different configurations or performances, and may include one or more processors 110, memory 120, and computer-readable storage medium 130. The memory 120 and / or computer-readable storage medium 130 include one or more applications 131 or data 132. The memory 120 and / or computer-readable storage medium 130 may also include one or more operating systems 133, such as Windows, Mac OS, Linux, IOS, Android, Unix, FreeBSD, etc. Among them, the memory 120 and the computer-readable storage medium 130 may be temporary storage or permanent storage. The application 131 may include one or more of the units ( Fig.11 ), each unit may include a series of instruction operations. Further, the processor 110 may be configured to communicate with the computer-readable storage medium 130, and execute a series of instruction operations in the computer-readable storage medium 130 on the device. The device may also include one or more power supplies ( Fig.11 ); one or more network interfaces 140, wherein the network interface 140 includes a wired network interface 141 and / or a wireless network interface 142; and one or more input / output interfaces 143.
[0220] In the sixth aspect, based on the same inventive concept, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program. When the computer program code runs on a computer, the computer implements the container batch scheduling method as described in at least one of the second to fourth aspects.
[0221] The computer-readable storage medium may be any available medium that can be stored by a computer or a data storage device such as a server or a data center that includes one or more available media. The available medium may be a magnetic medium (such as a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a high-density digital video disc (DVD), a video compact disc (VCD)), or a semiconductor medium (such as a solid-state disk (SSD)).
[0222] Since the principle of solving the problem by the above-mentioned computer-readable storage medium is consistent with the container batch scheduling method described in the second to fourth aspects, the implementation of the above-mentioned computer-readable storage medium can refer to the implementation of the method, and the repeated parts will not be repeated.
[0223] In the seventh aspect, based on the same inventive concept, an embodiment of the present invention further provides a computer program product, which includes: a computer program code, when the computer program code is run on a computer, enables the computer to implement the container batch scheduling method as described in at least one of the second to fourth aspects.
[0224] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means.
[0225] Since the principle of solving the problem by the above-mentioned computer program product is consistent with the container batch scheduling method described in the second to fourth aspects above, the implementation of the above-mentioned computer program product can refer to the implementation of the method, and the repeated parts will not be repeated.
[0226] The container scheduling system and container batch scheduling method provided in the embodiments of the present invention, by adding an additional customized batch scheduler to the existing K8s framework and optimizing the batch scheduling results through a genetic algorithm, can obtain a batch scheduling result with better batch scheduling effect for multiple Pods, thereby optimizing the overall effect of container cluster deployment on containers and improving the adaptability between the scheduling results and the scheduling configuration information and the running status of each working node.
[0227] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0228] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0229] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0230] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0231] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A container scheduling system, characterized in that: include: A rendering engine is used to obtain user configuration information corresponding to each of the target container group Pod sets that need to be scheduled; for any target Pod, a preset application template is rendered according to the user configuration information corresponding to the target Pod to obtain a resource file; wherein the target Pod set includes multiple target Pods; and the resource file includes the scheduling configuration information of the target Pod; A batch scheduler is used to determine an initial scheduling result for the target Pod set, and use the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running state of each working node as the evolution direction of the scheduling result, and use a genetic algorithm to optimize the initial scheduling result for at least one round to obtain a target scheduling result corresponding to the target Pod set determined by the genetic algorithm; The native scheduler is used to bind any target Pod to the target scheduling result corresponding to the target Pod; The scheduling result includes the hardware resources corresponding to each target Pod in the target Pod set.
2. The container scheduling system according to claim 1, characterized in that: The batch scheduler is specifically used for: Perform the preset rounds of scheduling result optimization, where each round of scheduling result optimization performs the following steps in sequence: Score the current scheduling result according to the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running status of each working node; The more the current scheduling result meets the requirements of the scheduling configuration information, and the better the adaptability between the current scheduling result and the running status of each working node, the higher the score of the current scheduling result; The current scheduling result of the first round scheduling result optimization process is the initial scheduling result, and the current scheduling result of the non-first round scheduling result optimization process is the scheduling result obtained after the previous round scheduling result optimization process is completed; The initial scheduling result is a scheduling result randomly determined for the target Pod set; retaining at least part of the current scheduling results according to the scores respectively corresponding to the current scheduling results; The retained current scheduling result is naturally evolved; wherein the natural evolution includes at least one of the following: a crossover operation and a mutation operation.
3. The container scheduling system according to claim 2, characterized in that: The container scheduling system also includes: an application program interface service API Server; The batch scheduler comprises: The pre-initialization plug-in is used to obtain the scheduling configuration information of any target Pod according to the resource file corresponding to the target Pod before optimizing the first round of scheduling results; An initialization plug-in is used to randomly determine the initial scheduling result for the target Pod set before optimizing the first round of scheduling results; A scoring plug-in is used to score the current scheduling result according to the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running status of each working node; A selection plug-in is used to retain at least part of the current scheduling results according to the scores respectively corresponding to the current scheduling results; At least one natural evolution plug-in, used to use at least some of the at least one natural evolution plug-in to sequentially perform corresponding natural evolution on the retained current scheduling results; wherein each natural evolution plug-in corresponds to a natural evolution operation; A resource confirmation plug-in, used to occupy the hardware resources corresponding to the target scheduling result; A binding plug-in, used to submit the target scheduling result to the API Server; The native scheduler is specifically used to: for any target Pod, obtain the target scheduling result corresponding to the target Pod from the API Server through the native scheduler; and bind the target Pod with the target scheduling result corresponding to the target Pod.
4. The container scheduling system according to claim 1, characterized in that: After rendering the preset application template to obtain a resource file for any target Pod according to the user configuration information corresponding to the target Pod, the rendering engine is further used to: For the target Pod set, a batch information custom resource definition CRD corresponding to the target Pod set is created by the rendering engine and submitted to the API Server; the batch information CRD includes a set CRD, a front Pod CRD, and a front persistent declaration PVC CRD; the set CRD includes at least information related to the number of target Pods in the target Pod set; the front Pod CRD is at least used to abstract the target Pod; the front PVC CRD is at least used to abstract hardware resources; Before determining the initial scheduling result for the target Pod set, the batch scheduler is further used to: The batch information CRD is obtained by using a List-Watch mechanism, and batch scheduling conditions are determined to be met according to the set CRD; After obtaining the target scheduling result corresponding to the target Pod set determined according to the genetic algorithm, the batch scheduler is further used to: Instantiating the front Pod CRD and the front PVC CRD according to the target scheduling result, and submitting the front Pod CRD and the front PVC CRD to the API Server; The native scheduler is specifically used for: For any target Pod, obtain the target scheduling result corresponding to the target Pod, the front Pod CRD corresponding to the target Pod, and the front PVC CRD corresponding to the target Pod from the API Server; bind the target Pod to the front Pod CRD, and bind the PVC corresponding to the target Pod to the front PVC CRD.
5. The container scheduling system according to claim 4, characterized in that: The container scheduling system also includes: an application program interface service API Server; The batch scheduler is specifically used for: Perform the preset rounds of scheduling result optimization, where each round of scheduling result optimization performs the following steps in sequence: The current scheduling result is scored according to the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running status of each working node; the more the current scheduling result meets the requirements of the scheduling configuration information, and the better the adaptability between the current scheduling result and the running status of each working node, the higher the score of the current scheduling result; the current scheduling result of the first round scheduling result optimization process is the initial scheduling result, and the current scheduling result of the non-first round scheduling result optimization process is the scheduling result obtained after the previous round of scheduling result optimization process is completed; the initial scheduling result is a scheduling result randomly determined for the target Pod set; retaining at least part of the current scheduling results according to the scores respectively corresponding to the current scheduling results; Performing natural evolution on the retained current scheduling result; wherein the natural evolution includes at least one of the following: a crossover operation and a mutation operation; Wherein, the batch scheduler includes: The pre-initialization plug-in is used to obtain the scheduling configuration information of any target Pod according to the resource file corresponding to the target Pod before optimizing the first round of scheduling results; An initialization plug-in is used to randomly determine the initial scheduling result for the target Pod set before optimizing the first round of scheduling results; A scoring plug-in is used to score the current scheduling result according to the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running status of each working node; A selection plug-in is used to retain at least part of the current scheduling results according to the scores respectively corresponding to the current scheduling results; At least one natural evolution plug-in, used to use at least some of the at least one natural evolution plug-in to sequentially perform corresponding natural evolution on the retained current scheduling results; wherein each natural evolution plug-in corresponds to a natural evolution operation; A resource confirmation plug-in, used to occupy the hardware resources corresponding to the target scheduling result; A binding plug-in is used to submit the target scheduling result to the API Server; the binding plug-in includes a first binding plug-in and a second binding plug-in, wherein: The first binding plug-in is used to instantiate the front PVC CRD according to the target scheduling result, and submit the front PVC CRD to the API Server; The second binding plug-in is used to instantiate the front Pod CRD according to the target scheduling result, and submit the front Pod CRD to the API Server.
6. A container batch scheduling method, characterized in that: Applicable to batch scheduler, including: An initial scheduling result is determined for a target Pod set that needs to be scheduled, and a genetic algorithm is used to optimize the initial scheduling result for at least one round, taking the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running state of each working node as the evolution direction of the scheduling result, to obtain a target scheduling result corresponding to the target Pod set determined by the genetic algorithm; wherein the target Pod set includes multiple target Pods; for any target Pod, the scheduling configuration information is information contained in a resource file corresponding to the target Pod, and the resource file is obtained by rendering a preset application template by a rendering engine according to user configuration information corresponding to the target Pod; Providing the target scheduling result to the native scheduler, so that the native scheduler binds the target Pod to the target scheduling result corresponding to the target Pod for any target Pod; The scheduling result includes the hardware resources corresponding to each target Pod in the target Pod set.
7. The method according to claim 6, characterized in that The initial scheduling result is determined for the target Pod set that needs to be scheduled, and the adaptation between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptation between the scheduling result and the running state of each working node are used as the evolution direction of the scheduling result. The initial scheduling result is optimized by using a genetic algorithm for at least one round, specifically including: Perform the preset rounds of scheduling result optimization, where each round of scheduling result optimization performs the following steps in sequence: The current scheduling result is scored according to the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running status of each working node; the more the current scheduling result meets the requirements of the scheduling configuration information, and the better the adaptability between the current scheduling result and the running status of each working node, the higher the score of the current scheduling result; the current scheduling result of the first round scheduling result optimization process is the initial scheduling result, and the current scheduling result of the non-first round scheduling result optimization process is the scheduling result obtained after the previous round of scheduling result optimization process is completed; the initial scheduling result is a scheduling result randomly determined for the target Pod set; retaining at least part of the current scheduling results according to the scores respectively corresponding to the current scheduling results; The retained current scheduling result is naturally evolved; wherein the natural evolution includes at least one of the following: a crossover operation and a mutation operation.
8. The method according to claim 7, characterized in that: Before optimizing the first round of scheduling results through the batch scheduler, the method further includes: for any target Pod, using the pre-initialization plug-in of the batch scheduler to obtain the scheduling configuration information of the target Pod according to the resource file corresponding to the target Pod; using the initialization plug-in of the batch scheduler to randomly determine the initial scheduling result for the target Pod set; The scoring of the current scheduling result according to the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running state of each working node, specifically includes: using the scoring plug-in of the batch scheduler to score the current scheduling result according to the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running state of each working node; The retaining at least part of the current scheduling results according to the scores respectively corresponding to the current scheduling results specifically includes: using the selection plug-in of the batch scheduler to retain at least part of the current scheduling results according to the scores respectively corresponding to the current scheduling results; The performing natural evolution on the retained current scheduling results specifically includes: using at least one natural evolution plug-in of the batch scheduler to perform corresponding natural evolution on the retained current scheduling results in sequence; After determining the target scheduling result corresponding to the target Pod set, the method further includes: Using the resource confirmation plug-in of the batch scheduler to occupy the hardware resources corresponding to the target scheduling result; The target scheduling result is submitted to the application program interface service API Server by using the binding plug-in of the batch scheduler; so that the native scheduler obtains the target scheduling result corresponding to the target Pod from the API Server for any target Pod; and binds the target Pod with the target scheduling result corresponding to the target Pod.
9. The method according to claim 6 or 8, characterized in that Before determining the initial scheduling result for the target Pod set to be scheduled, the method further includes: The List-Watch mechanism is used to obtain the batch information CRD corresponding to the target Pod set created by the rendering engine from the API Server, and the batch scheduling condition is determined according to the set CRD; wherein the batch information CRD includes the set CRD, the front Pod CRD, and the front PVC CRD; the set CRD at least includes information related to the number of target Pods in the target Pod set; the front Pod CRD is at least used to abstract the target Pod; the front PVC CRD is at least used to abstract the hardware resources; After obtaining the target scheduling result corresponding to the target Pod set determined according to the genetic algorithm, the method further includes: The front Pod CRD and the front PVC CRD are instantiated according to the target scheduling result, and the front Pod CRD and the front PVC CRD are submitted to the API Server; so that the native scheduler obtains the target scheduling result corresponding to the target Pod, the front Pod CRD corresponding to the target Pod, and the front PVC CRD corresponding to the target Pod from the API Server for any target Pod; binds the target Pod with the front Pod CRD, and binds the PVC corresponding to the target Pod with the front PVC CRD.
10. The method according to claim 9, characterized in that Instantiating the front Pod CRD and the front PVC CRD according to the target scheduling result, and submitting the front Pod CRD and the front PVC CRD to the API Server specifically includes: Instantiating the front-end PVC CRD according to the target scheduling result through the first binding plug-in of the batch scheduler, and submitting the front-end PVC CRD to the API Server; The front Pod CRD is instantiated according to the target scheduling result through the second binding plug-in of the batch scheduler, and the front Pod CRD is submitted to the API Server.
11. A container batch scheduling method, characterized in that: Applicable to native scheduler, including: For any target Pod in the target Pod set, the target Pod is bound to a target scheduling result corresponding to the target Pod; the target Pod set includes multiple target Pods; The scheduling result includes the hardware resources corresponding to each target Pod in the target Pod set; The target scheduling result is that the batch scheduler uses a genetic algorithm to optimize the initial scheduling result for at least one round for the target Pod set, taking the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running state of each working node as the evolution direction of the scheduling result, to obtain a scheduling result determined according to the genetic algorithm; For any target Pod, the scheduling configuration information is information contained in a resource file corresponding to the target Pod, and the resource file is obtained by rendering a preset application template by a rendering engine according to user configuration information corresponding to the target Pod.
12. The method according to claim 11, characterized in that The method specifically comprises: For any target Pod, obtain the target scheduling result corresponding to the target Pod, the front Pod CRD corresponding to the target Pod, and the front PVC CRD corresponding to the target Pod from the API Server; Bind the target Pod to the front Pod CRD, and bind the PVC corresponding to the target Pod to the front PVC CRD; The front Pod CRD corresponding to the target Pod and the front PVC CRD corresponding to the target Pod are created by the rendering engine and instantiated by the batch scheduler according to the target scheduling result, the front Pod CRD is at least used to abstract the target Pod, and the front PVC CRD is at least used to abstract hardware resources.
13. A container batch scheduling method, characterized in that: Applicable to rendering engines, including: Obtain user configuration information corresponding to the target Pod sets that need to be scheduled; wherein the target Pod set includes multiple target Pods; For any target Pod, render the preset application template according to the user configuration information corresponding to the target Pod to obtain a resource file; wherein the resource file includes the scheduling configuration information of the target Pod; Submit the resource file to the batch scheduler so that the batch scheduler determines an initial scheduling result for the target Pod set, and uses the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running status of each working node as the evolution direction of the scheduling result; uses a genetic algorithm to perform at least one round of optimization on the initial scheduling result to obtain a target scheduling result corresponding to the target Pod set determined by the genetic algorithm; so that the native scheduler binds the target Pod to the target scheduling result corresponding to the target Pod for any target Pod.
14. The method according to claim 13, characterized in that After rendering a preset application template to obtain a resource file for any target Pod through a rendering engine according to user configuration information corresponding to the target Pod, the method further includes: For the target Pod set, create a batch information CRD corresponding to the target Pod set and submit it to the API Server, so that the batch scheduler obtains the batch information CRD corresponding to the target Pod set from the API Server using the List-Watch mechanism, determines the initial scheduling result for the target Pod set after determining that the batch scheduling conditions are met according to the set CRD, and takes the adaptability between the scheduling configuration information corresponding to the target Pod set and the scheduling result, and the adaptability between the scheduling result and the running status of each working node as the evolution direction of the scheduling result; uses a genetic algorithm to optimize the initial scheduling result for at least one round to obtain the target scheduling result corresponding to the target Pod set determined according to the genetic algorithm; instantiates the front Pod CRD and the front PVC CRD according to the target scheduling result, and submits the front Pod CRD and the front PVC CRD to the API Server; so that the native scheduler obtains the target scheduling result corresponding to the target Pod, the front Pod CRD corresponding to the target Pod, and the front PVC CRD corresponding to the target Pod from the API Server for any target Pod; binds the target Pod to the front Pod CRD, and binds the PVC corresponding to the target Pod to the front PVC CRD; The batch information CRD includes the set CRD, the front Pod CRD, and the front PVC CRD; the set CRD includes at least information related to the number of target Pods in the target Pod set; the front Pod CRD is at least used to abstract the target Pod; and the front PVC CRD is at least used to abstract hardware resources.
Citation Information
Patent Citations
Micro-service scheduling method and device and electronic equipment
CN112685153A
Container dynamic balance scheduling method
CN112799837A
Container-based workflow scheduling method, apparatus, system, and storage medium
CN113225269B
Container cluster scheduling method and device, equipment and storage medium
CN115408100A
Batch scheduling method and device
CN115617482A
