Container group deployment method, device and server
By traversing the node list in the kubernetes cluster, selecting and migrating resources to meet the needs of container group, the problem of insufficient resource fragmentation is solved, and efficient deployment and resource management of container group is achieved.
Patent Information
- Application Number
- CN202010967555.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-15
- Publication Date
- 2024-10-08
- Estimated Expiration
- 2040-09-15
AI Technical Summary
In a kubernetes cluster, when deploying container groups, the deployment suspends indefinitely because the remaining resources of the node do not meet the needs. Adding nodes may cause resource waste and the resource fragmentation cannot be effectively utilized.
By traversing the node list, determine whether there are nodes that meet resource requirements. If not, select the second and third nodes from the node list, migrate the resources of the second node to the third node to satisfy resource requirements, and then complete the resource requirements of the second node. The container group is deployed to the second node. If the resource arrangement cannot be deployed, notify the operation and maintenance personnel to add new nodes.
It realizes the sorting of existing node resources to avoid resource waste, and actively notifies the addition of new nodes when resources are insufficient to ensure the successful deployment of container groups.
Smart Images

Figure CN112230936B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of cluster management, and more specifically, to a container group deployment method, a container group deployment device, a server, and a computer-readable storage medium. Background Art
[0002] Kubernetes (k8s) is a container-based cluster management platform. Figure 1 As shown, the kubernetes cluster includes a master node and multiple computing nodes (nodes) that communicate with the master node. The master node is used to manage and control multiple computing nodes. Computing nodes are workload nodes. Multiple container groups (pods) are deployed in each computing node. Each container group encapsulates one or more containers (containers) for carrying software programs. Pod is the basic operation unit of kubernetes and the smallest deployment unit that can be created, debugged and managed. Multiple containers in the same pod share network resources. For example, a pod has only one IP address, and multiple containers in the same pod share the IP address.
[0003] In a k8s cluster, each node has a certain amount of CPU and memory resources. When deploying a container group, the k8s scheduler will traverse the node list according to the resource requirements defined in the container group's request attributes, determine whether the remaining available resources of the node can meet the resources required by the container group, and select candidate nodes for deploying the container group. If the remaining available resources of each node in the node list cannot meet the resources required by the container group, the deployment of the container group will enter a pending state indefinitely. At this time, the operation and maintenance personnel need to manually add new nodes to provide sufficient resources to the container group so that the container group can be deployed to the new node.
[0004] However, in actual applications, it is often the case that most nodes have remaining available resources, but none of them meet the resource requirements of the container group, resulting in the inability to deploy the container group. If new nodes are added, it will cause a waste of resources. Summary of the invention
[0005] An object of an embodiment of the present invention is to provide a new technical solution for deploying a container group.
[0006] According to a first aspect of the present invention, a method for deploying a container group is provided, the method comprising:
[0007] receiving a container group deployment request, wherein the container group deployment request includes at least a first resource required by a first container group;
[0008] Traversing the nodes in the node list to determine whether there is a first node whose remaining available resources satisfy the first resource;
[0009] If the first node does not exist in the node list, determining a second node and a third node from the node list;
[0010] Migrate the second container group in the second node to the third node so that the remaining available resources of the second node meet the first resources;
[0011] Deploy the first container group to a second node on which the migration operation of the second container group has been completed.
[0012] Optionally, the method further comprises:
[0013] If the first node exists in the node list, respond to the container group deployment request to deploy the first container group in the first node.
[0014] Optionally, the determining the second node and the third node from the node list includes:
[0015] Determine a node in the node list that meets a preset node selection condition as a first candidate node;
[0016] When there is a container group to be moved that meets a preset moving condition on the first candidate node, determining the first candidate node as the second node;
[0017] And, when the remaining available resources of any node in the node list meet the resources required by the to-be-moved container group, the node is determined as the third node.
[0018] Optionally, determining that there is a to-be-moved container group that meets a preset moving condition on the first candidate node includes:
[0019] Determine whether a second resource occupied by any container group deployed on the first candidate node is smaller than the first resource;
[0020] If the second resource is less than the first resource, determining whether the sum of the second resource and the remaining available resources of the first candidate node is greater than or equal to the first resource;
[0021] If the sum of the second resource and the remaining available resource of the first candidate node is greater than or equal to the first resource, it is determined that there is a container group that meets a preset movement condition on the first candidate node.
[0022] Optionally, the determining whether the second resource occupied by any container group deployed on the first candidate node is smaller than the first resource includes:
[0023] All container groups deployed on the first candidate node are traversed until the second resource occupied by any container group is smaller than the first resource.
[0024] Optionally, the method further comprises:
[0025] When there is no node in the node list whose remaining available resources satisfy the second resource, determining whether the number of moves of the container group to be moved is less than a preset number of moves;
[0026] If the number of moves of the container group to be moved is not less than the preset number of moves, a new node notification message is generated to notify the operation and maintenance personnel to add a new node for deploying the first container group.
[0027] Optionally, the preset node selection condition includes:
[0028] The total resource of the node is greater than or equal to the first resource; and
[0029] Among the container groups deployed on the node, there exists a container group whose required resources are less than the first resources.
[0030] Optionally, after determining the node in the node list that meets the preset node selection condition as the first candidate node, the method further includes:
[0031] A skip table is generated for the first candidate node, wherein the skip table stores information on resources required by all container groups deployed on the node.
[0032] Optionally, the container groups in the skip list are sorted from small to large according to required resources.
[0033] Optionally, the traversing the nodes in the node list to determine whether the first node exists includes:
[0034] Traversing the nodes in the node list, and determining nodes meeting the pre-selection condition as pre-selected nodes;
[0035] Determining whether the pre-selected node meets the preset optimization strategy;
[0036] If yes, determining the pre-selected node as the first node;
[0037] If not, it is determined that there is no first node in the node list with remaining available resources that meet the requirements of the first resource.
[0038] Optionally, the pre-selected conditions include:
[0039] The node is in an available state, the current disk input and output pressure of the node is less than a preset pressure threshold, the current load of the node is less than a preset load threshold, and the remaining available resources of the node are greater than or equal to the first resources.
[0040] Optionally, the preset optimization strategy includes:
[0041] The consumption of resources on the node is minimal, the utilization rate of various resources on the node is most balanced, the node tendency information indicates whether it is suitable for deploying the first container group, the matching degree of the tolerance of the first container group on the node and the taint list item of the node; the number of matching items of the affinity items on the node; try not to be on the same node as other container groups on the server, select the node with the largest consumption, the score of the node label, or the score of the image required by the node.
[0042] According to a second aspect of the present invention, there is provided a container group deployment device, the device comprising:
[0043] A receiving module, configured to receive a container group deployment request, wherein the container group deployment request includes at least a first resource required by a first container group;
[0044] A determination module, configured to traverse the nodes in the node list, determine whether there is a first node, and the remaining available resources of the first node satisfy the first resource; if the first node does not exist in the node list, determine the second node and the third node from the node list;
[0045] a migration module, configured to migrate the second container group in the second node to the third node, so that the remaining available resources of the second node meet the first resources;
[0046] A deployment module is used to deploy the first container group to a second node on which the migration operation of the second container group has been completed.
[0047] According to a third aspect of the present invention, there is provided a server, comprising the container group deployment device as described in the second aspect of the present invention, or the server comprises:
[0048] A memory for storing executable commands;
[0049] The processor is configured to execute, under the control of the executable command, the method for deploying a container group as described in any one of the first aspects of the present invention.
[0050] According to a fourth aspect of the present invention, a computer-readable storage medium is provided, storing executable instructions, and when the executable instructions are executed by a processor, the method for deploying a container group as described in any one of the first aspect of the present invention is executed.
[0051] According to one embodiment of the present invention, a container group deployment request including at least the first resource required by the first container group is received; the nodes in the node list are traversed to determine whether there is a first node, and the remaining available resources of the first node meet the first resource; if the first node does not exist in the node list, the second node and the third node are determined from the node list; the second container group in the second node is migrated to the third node so that the remaining available resources of the second node meet the first resource; and the first container group is deployed to the second node on which the migration operation of the second container group has been completed. The resource fragments on the existing nodes can be sorted to deploy a new container group to avoid resource waste due to the existence of resource fragments. At the same time, if it is impossible to deploy a new container group through resource fragmentation, that is, when the remaining available resources are indeed insufficient, the operation and maintenance personnel can be actively notified to add new nodes to complete the deployment of the new container group.
[0052] Further features and advantages of the present invention will become apparent from the following detailed description of exemplary embodiments of the present invention with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the invention and, together with the description, serve to explain the principles of the invention.
[0054] Figure 1 This is a schematic diagram of the structure of the kubernetes cluster;
[0055] Figure 2 A schematic diagram of the structure of a server to which the method for deploying a container group according to an embodiment of the present invention can be applied;
[0056] Figure 3 A schematic diagram of a process for deploying a container group provided in an embodiment of the present disclosure;
[0057] Figure 4 A schematic diagram of the structure of a deployment device for a container group provided in an embodiment of the present disclosure;
[0058] Figure 5 A schematic diagram of the structure of a server provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0059] Various exemplary embodiments of the present invention will now be described in detail with reference to the accompanying drawings. It should be noted that the relative arrangement of components and steps, numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present invention unless otherwise specifically stated.
[0060] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the invention, its application, or uses.
[0061] Technologies, methods, and apparatuses known to persons of ordinary skill in the relevant art may not be discussed in detail, but where appropriate, such technologies, methods, and apparatuses should be considered part of the specification.
[0062] In all examples shown and discussed herein, any specific values should be interpreted as merely exemplary and not limiting. Therefore, other examples of the exemplary embodiments may have different values.
[0063] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.
[0064] <Hardware Configuration>
[0065] Figure 2 The diagram is a schematic diagram of the structure of a server to which the method for deploying a container group according to an embodiment of the present invention can be applied.
[0066] like Figure 2 As shown, the server 101 may be in the form of a blade server, a rack-mounted server, or a server cluster deployed in the cloud. In some embodiments, each server may include hardware, software, or an embedded logic component or a combination of two or more such components for executing appropriate functions supported or implemented by the server.
[0067] In an example, the server 101 may also be a computer. The server 101 may be a physical machine or a virtual machine.
[0068] The specific configuration of the server 101 may include, but is not limited to: a processor 1011, a memory 1012, an interface device 1013, a communication device 1014, an input device 1015, and an output device 1016. The processor 1011 may include, but is not limited to, a central processing unit CPU, a microprocessor MCU, etc. The memory 1012 may include, but is not limited to, a ROM (read-only memory), a RAM (random access memory), a non-volatile memory such as a hard disk, etc. The interface device 1013 may include, but is not limited to, a USB interface, a serial interface, a parallel interface, etc. The communication device 1014 may, for example, be capable of wired communication or wireless communication, and may specifically include WiFi communication, Bluetooth communication, 2G / 3G / 4G / 5G communication, etc. The input device 1015 includes, but is not limited to, a keyboard, a mouse, a touch screen, etc. The output device 1016 includes, but is not limited to, a display screen, etc. Although the server may also include a speaker, a microphone, etc., these components are irrelevant to the embodiments of the present disclosure and are therefore omitted here.
[0069] In the embodiments of the present disclosure, the memory 1012 of the server 101 is used to store instructions, and the instructions are used to control the processor 1011 to operate to execute any one of the container group deployment methods provided in the embodiments of the present disclosure.
[0070] Figure 1 The server shown is merely illustrative and does not in any way imply any limitation on the embodiments of the present disclosure, its application or use. It should be understood by those skilled in the art that although multiple devices of the server are described above, the embodiments of the present disclosure may only involve some of the devices.
[0071] Those skilled in the art can design instructions according to the scheme disclosed in the embodiments of the present disclosure. How instructions control the processor to operate is a well-known technology in the art, so it will not be described in detail here.
[0072] <Method>
[0073] This embodiment provides a method for deploying a container group. For example, the method can be Figure 2 The k8s scheduler running in the server 101 shown is executed. Specifically, the server 101 can be the master node in the k8s cluster, and the k8s scheduler runs on the master node.
[0074] like Figure 3 As shown, the method includes the following steps 2100 to 2500:
[0075] Step 2100: Receive a container group deployment request, where the container group deployment request includes at least a first resource required by a first container group.
[0076] Step 2200, traverse the nodes in the node list to determine whether there is a first node whose remaining available resources meet the first resources.
[0077] In this step, the k8s scheduler can traverse the nodes in the node list, determine the nodes that meet the pre-selection conditions as pre-selected nodes, and determine whether the pre-selected nodes meet the preset optimization strategy. If yes, the pre-selected node is determined as the first node; if not, it is determined that there is no first node in the node list with remaining available resources that meet the first resource.
[0078] Among them, the pre-selected conditions include: the node is in an available state, the current disk input and output pressure of the node is less than a preset pressure threshold, the current load of the node is less than a preset load threshold, and the remaining available resources of the node are greater than or equal to the first resources.
[0079] The preset optimization strategy includes: minimum consumption of resources on the node, most balanced utilization of various resources on the node, node tendency information indicating whether the first container group is suitable for deployment, tolerance of the first container group on the node and matching degree of the taint list item of the node; number of matching items of affinity items on the node; trying not to be on the same node as other container groups on the server, selecting the node with the largest consumption, node label score, or node required image score.
[0080] It should be noted that the preset optimization strategy is predetermined based on the specific needs of the project. For example, if the project level is very high, it is necessary to try to ensure that the project can run normally without failure. At this time, the preset optimization strategy can be to select the node with the lowest resource consumption. Specifically, the resource consumption of the node is evaluated based on the idle ratio of the node, that is, cpu (total capacity-sum (used)*10 / total capacity). The load of such a node is relatively low, which can better ensure the stability of the project operation. If it is an edge project, the preset optimization strategy can be to select the node with the largest resource consumption.
[0081] It can be seen that in this example, if there are nodes in the node list that can be used to deploy the first container group, there is no need to perform the operation of defragmenting resources, but a node that meets the preset preferred strategy can be selected from the pre-selected nodes that meet the pre-selected conditions as the first node for deploying the first container group. If there are no nodes in the node list that can be used to deploy the first container group, the operation of defragmenting resources will be triggered.
[0082] It should be noted that if there are multiple pre-selected nodes that meet the preset preferred strategy, the k8s scheduler can randomly select one from the multiple pre-selected nodes as the first node for deploying the first container group.
[0083] Step 2300: If the first node does not exist in the node list, determine the second node and the third node from the node list.
[0084] It can be understood that in this embodiment, if the first node exists in the node list, the k8s scheduler responds to the container group deployment request to deploy the first container group in the first node. If the first node does not exist in the node list, the k8s scheduler executes this step 2300.
[0085] In this step, the k8s scheduler determines the second node and the third node from the node list, which can specifically include: determining the node in the node list that meets the preset node selection condition as the first candidate node; when there is a container group to be moved that meets the preset movement condition on the first candidate node, determining the first candidate node as the second node; and when the remaining available resources of any node in the node list meet the resources required by the container group to be moved, determining the node as the third node.
[0086] The k8s scheduler can determine whether there is a container group to be moved that meets the preset moving condition on the first candidate node by determining whether the second resource occupied by any container group deployed on the first candidate node is less than the first resource. For example, the k8s scheduler can traverse all container groups deployed on the first candidate node until the second resource occupied by any container group is less than the first resource.
[0087] Specifically, if the second resource is less than the first resource, it is determined whether the sum of the second resource and the remaining available resources of the first candidate node is greater than or equal to the first resource; if the sum of the second resource and the remaining available resources of the first candidate node is greater than or equal to the first resource, it is determined that there is a container group on the first candidate node that meets the preset movement condition.
[0088] The preset node selection condition includes: the total resources of the node are greater than or equal to the first resources; and, among the container groups deployed on the node, there exists a container group whose required resources are less than the first resources.
[0089] Optionally, after determining the node in the node list that meets the preset node selection condition as the first candidate node, the k8s scheduler can also generate a jump table for the first candidate node, and the jump table stores information on the resources required by all container groups deployed on the node. Furthermore, the k8s scheduler can also sort the container groups in the jump table from small to large according to the required resources.
[0090] It should be noted that a skip list is an ordered linear data structure that stores elements in a hierarchical linked list in an ordered manner. The search time complexity of a skip list is O(logn), the complexity of insertion and deletion is also O(logn), and the space complexity is O(n). The bottom-level linked list contains all elements. Therefore, in this example, a skip list is generated and used to improve the search efficiency.
[0091] For example, if the resources required by the first container group in the jump table of the first candidate node are greater than or equal to the first resources, it is obvious that moving the first container group in the jump table in order to deploy the first container group will only cause problems in deploying a larger container group. Therefore, it is meaningless to replace the container group with the first container group. Since the container groups are sorted in the jump table from small to large according to the required resources, the k8s scheduler can directly determine that there is no container group to be moved that meets the preset moving conditions on the first candidate node. This improves the efficiency of the search.
[0092] Furthermore, when there is no node in the node list whose remaining available resources satisfy the second resource, the k8s scheduler determines whether the number of moves of the container group to be moved is less than the preset number of moves; if the number of moves of the container group to be moved is not less than the preset number of moves, a new node notification message is generated to notify the operation and maintenance personnel to add a new node for deploying the first container group. Optionally, the k8s scheduler can send an email to the mailbox specified by the operation and maintenance personnel, or send a text message to a specified mobile phone number, or send a message to a specified communication software number to notify the operation and maintenance personnel to add a new node to complete the deployment of the first container group. This embodiment does not specifically limit the notification method.
[0093] Step 2400: Migrate the second container group in the second node to the third node, so that the remaining available resources of the second node meet the first resources.
[0094] Step 2500: deploy the first container group to a second node on which the migration operation of the second container group has been completed.
[0095] <Example>
[0096] The deployment method of the container group provided in this example can be specifically Figure 2 The k8s scheduler running in the server 101 shown is executed. Specifically, the server 101 can be the master node in the k8s cluster, and the k8s scheduler runs on the master node.
[0097] The method in this example may include:
[0098] The k8s scheduler receives a container group deployment request, where the container group deployment request includes at least a first resource required by the first container group.
[0099] The k8s scheduler traverses the nodes in the node list based on the received container group deployment request and determines the nodes that meet the pre-selection conditions as pre-selected nodes.
[0100] Specifically, the k8s scheduler checks whether the nodes in the node list are in an available state. If they are in an unavailable state, the node is excluded, and the k8s scheduler continues to check whether the next node in the node list is in an available state.
[0101] If it is in the available state, the k8s scheduler continues to determine whether the current disk input and output pressure of the node is less than the preset pressure threshold. If the current disk input and output pressure of the node is not less than the preset pressure threshold, the node is excluded, and the k8s scheduler continues to check whether the next node in the node list is in the available state.
[0102] If the current disk input and output pressure of the node is less than the preset pressure threshold, the k8s scheduler continues to determine whether the current load of the node is less than the preset load threshold. If the current load of the node is not less than the preset load threshold, the node is excluded, and the k8s scheduler continues to check whether the next node in the node list is available.
[0103] If the current load of the node is less than the preset load threshold, the k8s scheduler continues to determine whether the remaining available resources of the node are greater than or equal to the first resource. If the remaining available resources of the node are less than the first resource, the node is excluded, and the k8s scheduler continues to check whether the next node in the node list is in an available state. If the remaining available resources of the node are greater than or equal to the first resource, k8s can add the node to the pre-selected node list.
[0104] After the k8s scheduler traverses the node list, it determines whether the pre-selected node list is empty. If the pre-selected node list is not empty, the k8s scheduler determines whether the pre-selected nodes in the pre-selected node list meet the preset optimization strategy.
[0105] Specifically, the k8s scheduler selects the pre-selected nodes in the pre-selected node list according to a preset optimization strategy to determine the first node for deploying the first container group.
[0106] Among them, the preset optimization strategies may include the following 9 types:
[0107] 1. least_requested, that is, the node with the least resource consumption, evaluated based on the idle ratio: cpu(total capacity - sum(used)*10 / total capacity).
[0108] 2. balanced_resource_allocation, that is, the most balanced utilization of various resources. Specifically, the k8s scheduler can obtain the resource utilization of each node, and use the similarity of CPU and memory utilization as the evaluation standard. The closer the two utilizations are, the higher the score.
[0109] 3. node_prefer_avoid_pods, that is, node preference information, indicating whether the node is suitable for deploying the first container group.
[0110] 4. taint_toleration, that is, the matching degree of the tolerance of the first container group (spec.toleration) and the taints list items of the node; the more matching items, the lower the score of the node.
[0111] 5. interpod_affinity, that is, the number of matches of affinity entries on the node; more matches give a higher score.
[0112] 6. selector_spreading, that is, try not to be on the same node as other container groups on the server. The fewer container groups on the same server on the node, the higher the score.
[0113] 7. most_requested, that is, select the node with the largest consumption to try to use up the resources on one node.
[0114] 8. node_label, that is, the score of the node label. If there is a label, there is a score, and if there is no label, there is no score. The more labels a node has, the higher its score.
[0115] 9. image_locality, that is, the required image score. The required image score is determined based on the sum of the sizes of the existing images. The more images required, the higher the score.
[0116] It should be noted that the preset preferred strategy is predetermined according to the specific needs of the project. If there are multiple pre-selected nodes that meet the preset preferred strategy, the k8s scheduler can randomly select one from the multiple pre-selected nodes as the first node for deploying the first container group.
[0117] If the pre-selected node list is empty, the k8s scheduler triggers resource defragmentation until resources are freed up for the first container group.
[0118] When sorting out fragmented resources, the k8s scheduler traverses the node list and determines the second node and the third node from the node list.
[0119] Specifically, the k8s scheduler generates a corresponding skip table (podinfoskiptable) for each node in the node list. The skip table stores information about the resources required by all container groups deployed on the node, and the trivial container groups in the skip table are sorted from small to large according to the required resources.
[0120] It should be noted that a skip list is an ordered linear data structure that stores elements in a hierarchical linked list in an ordered manner. The search time complexity of a skip list is O(logn), the complexity of insertion and deletion is also O(logn), and the space complexity is O(n). The bottom-level linked list contains all elements. Therefore, in this example, a skip list is generated and used to improve the search efficiency.
[0121] After generating the jump table, the k8s scheduler starts trying to move as few pods as possible to integrate memory resources. That is, it traverses the nodes in the node list and determines the node that meets the preset node selection condition as the first candidate node. The preset node selection condition includes: the total resources of the node are greater than or equal to the first resource; and, among the container groups deployed on the node, there is a container group whose required resources are less than the first resource.
[0122] Specifically, after the k8s scheduler determines the node in the node list that meets the preset node selection condition as the first candidate node, it determines whether there is a container group to be moved that meets the preset movement condition in the jump table of the candidate node. If so, the first candidate node is determined as the second node; and when the remaining available resources of any node in the node list meet the resources required by the container group to be moved, the node is determined as the third node.
[0123] When the k8s scheduler determines that there is a container group to be moved that meets the preset moving condition on the first candidate node, it can first determine whether the second resource occupied by any container group deployed on the first candidate node is less than the first resource. For example, the k8s scheduler traverses all container groups deployed on the first candidate node until the second resource occupied by any container group is less than the first resource.
[0124] If the second resource occupied by any container group deployed on the first candidate node is less than the first resource, it is further determined whether the sum of the second resource and the remaining available resources of the first candidate node is greater than or equal to the first resource; if so, it is determined that there is a container group to be moved that meets the preset movement condition on the first candidate node.
[0125] If there is no node whose remaining available resources satisfy the second resource, it is determined whether the number of moves of the container group to be moved is less than the preset number of moves; if the number of moves of the container group to be moved is not less than the preset number of moves, a new node notification message is generated to notify the operation and maintenance personnel to add a new node for deploying the first container group.
[0126] In a specific example, the k8s scheduler can define a solution space tree for the problem, and search the solution space tree from the root node in the solution space tree of the problem by backtracking, according to the depth-first strategy, and traverse the nodelist to obtain a feasible solution. The root node of the solution space tree is the problem of "moving the second container group (pod) as little as possible, that is, the container group to be moved to deploy the first container group (newpod)", and the problem of each subset tree is "moving countofmovednode pods to deploy newpod", where the value of countofmovednode starts from 1 and gradually increases until the maximum number of pods.
[0127] It should be noted that, in the problem of finding a subset tree corresponding to a feasible solution, the value of countofmovednode is the number of second container groups that need to be moved.
[0128] The specific process of finding a feasible solution is as follows:
[0129] According to the depth-first algorithm, the k8s scheduler first tries to find a feasible solution for the first subset tree under the root node, "moving a pod to deploy a newpod". At this time, countofmovednode=1.
[0130] The first layer of the subset tree is the node list. The k8s scheduler polls the container groups on each node in the node list until it ends.
[0131] If the total resources of the current node are smaller than the size of the first resource required by the newpod, the current node is skipped.
[0132] If the total resources of the current node are greater than or equal to the size of the first resource required by the new pod, try to move the existing pods in the current node to accommodate the new pod.
[0133] First, the k8s scheduler tries to replace the newpod with the first pod in the podinfoskiptable of the current node. Since the pods in the podinfoskiptable are arranged from small to large according to the required resources, the first pod is considered for replacement here.
[0134] If the second resource required by the pod is greater than or equal to the first resource required by the newpod, moving it to place the newpod will only cause bigger problems. It is obviously meaningless to replace it with the newnode, so backtrack to the ancestor node and start trying to replace it with the next pod of the first pod in the current node.
[0135] If the second resource required by the pod is less than the first resource required by the newpod, consider whether the sum of the second resource required by the pod and the remaining available resources of the current node meets the first resource required by the newpod. If not, go back to the ancestor node and start trying to replace the next pod of the first pod in the current node.
[0136] If the conditions are met, the pod is moved out of the current container and the newpod is placed in the current node. The replacement is successful and the number of pod moves increases by one.
[0137] At this point, the original pod placed in the container is replaced by the newly inserted pod and becomes the new newpod.
[0138] The k8s scheduler determines whether there is a node in the node list whose remaining available resources are greater than or equal to the second resource required by the new pod. If so, it means that a feasible solution for the subset tree has been found, which is the optimal solution, and the search ends.
[0139] If there is no node in the node list whose remaining available resources are greater than or equal to the second resource required by the new pod, the pod cannot be moved to place the new pod because the number of pod moves is equal to countofmovednode, indicating that there is no feasible solution for the subset tree. Then, backtracking to the root node, the k8s scheduler starts looking for a feasible solution for the second subset tree "move two pods to deploy the new pod", and countofmovednode=2.
[0140] Then repeat the above process until a feasible solution is found, or until all subset trees of the solution space tree are traversed.
[0141] If the k8s scheduler finds a feasible solution to the subset tree by backtracking and integrating resources, it moves the pod to the corresponding node according to the feasible solution and starts the newpod. If the k8s scheduler fails to find a feasible solution to the solution space tree by backtracking and integrating resources, it sends a notification message of the newly added node to the operation and maintenance personnel through email or other means to notify the operation and maintenance personnel to add a new node to deploy the newpod.
[0142] The above has been described in conjunction with the accompanying drawings and examples to describe the container group deployment method of this embodiment. The method includes at least a container group deployment request for the first resource required by the first container group; traversing the nodes in the node list to determine whether there is a first node, and the remaining available resources of the first node meet the first resource; if the first node does not exist in the node list, determine the second node and the third node from the node list; migrate the second container group in the second node to the third node so that the remaining available resources of the second node meet the first resource; and deploy the first container group to the second node where the migration operation of the second container group has been completed. The resource fragments on the existing nodes can be sorted to deploy a new container group to avoid resource waste due to the existence of resource fragments. At the same time, if it is impossible to deploy a new container group through resource fragmentation, that is, if the remaining available resources are indeed insufficient, the operation and maintenance personnel can also be actively notified to add new nodes to complete the deployment of the new container group.
[0143] <Device>
[0144] This embodiment provides a container group deployment device, the device is, for example, Figure 4 The container group deployment device 4000 shown is applied in a server.
[0145] like Figure 4 As shown, the container group deployment device 4000 may include: a receiving module 4100 , a determining module 4200 , a migration module 4300 and a deployment module 4400 .
[0146] The receiving module 4100 is configured to receive a container group deployment request, where the container group deployment request includes at least a first resource required by the first container group;
[0147] A determination module 4200 is used to traverse the nodes in the node list to determine whether there is a first node whose remaining available resources satisfy the first resource; if the first node does not exist in the node list, determine a second node and a third node from the node list;
[0148] A migration module 4300, configured to migrate the second container group in the second node to the third node, so that the remaining available resources of the second node meet the first resources;
[0149] The deployment module 4400 is configured to deploy the first container group to a second node on which the migration operation of the second container group has been completed.
[0150] Optionally, the deployment module 4400 may also be configured to respond to the container group deployment request if the first node exists in the node list, so as to deploy the first container group in the first node.
[0151] Optionally, the determination module 4200 can be specifically used to determine a node in the node list that meets a preset node selection condition as a first candidate node; when there is a container group to be moved that meets a preset movement condition on the first candidate node, determine the first candidate node as the second node; and when the remaining available resources of any node in the node list meet the resources required by the container group to be moved, determine the node as the third node.
[0152] Optionally, the determination module 4200 can be specifically used to determine whether the second resource occupied by any container group deployed on the first candidate node is less than the first resource; if the second resource is less than the first resource, determine whether the sum of the second resource and the remaining available resources of the first candidate node is greater than or equal to the first resource; if the sum of the second resource and the remaining available resources of the first candidate node is greater than or equal to the first resource, determine that there is a container group on the first candidate node that meets the preset movement condition.
[0153] Optionally, the determining module 4200 may be specifically configured to traverse all container groups deployed on the first candidate node until the second resource occupied by any container group is smaller than the first resource.
[0154] Optionally, the determination module 4200 can also be used to determine whether the number of moves of the container group to be moved is less than a preset number of moves when there is no node in the node list whose remaining available resources meet the second resource; if the number of moves of the container group to be moved is not less than the preset number of moves, a new node notification message is generated to notify the operation and maintenance personnel to add a new node for deploying the first container group.
[0155] The preset node selection condition includes: the total resources of the node are greater than or equal to the first resources; and, among the container groups deployed on the node, there exists a container group whose required resources are less than the first resources.
[0156] Furthermore, the container group deployment device 4000 may also include a generation module, which is used to generate a skip table for the first candidate node, wherein the skip table stores information on resources required by all container groups deployed on the node, wherein the container groups in the skip table are sorted from small to large according to the required resources.
[0157] Optionally, the determination module 4200 can be specifically used to traverse the nodes in the node list, determine the nodes that meet the pre-selection conditions as pre-selected nodes; determine whether the pre-selected nodes comply with a preset preferred strategy; if so, determine the pre-selected nodes as the first nodes; if not, determine that there is no first node in the node list with remaining available resources that meet the requirements of the first resources.
[0158] Among them, the pre-selected conditions include: the node is in an available state, the current disk input and output pressure of the node is less than a preset pressure threshold, the current load of the node is less than a preset load threshold, and the remaining available resources of the node are greater than or equal to the first resources.
[0159] Among them, the preset optimization strategy includes: the consumption of resources on the node is minimal, the utilization rate of various resources on the node is the most balanced, the node tendency information indicates whether it is suitable for deploying the first container group, the tolerance of the first container group on the node and the matching degree of the taint list item of the node; the number of matching items of the affinity item on the node; other container groups on the server are not on the same node as much as possible, and the node with the largest consumption is selected, the score of the node label, or the score of the mirror required by the node.
[0160] The container group deployment device of this embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effect are similar and will not be repeated here.
[0161] <Server>
[0162] In this embodiment, a server is also provided, which includes the container group deployment device 4000 described in the device embodiment of the present invention; or the server is Figure 5 The server 5000 shown includes:
[0163] The memory 5100 is used to store executable commands.
[0164] The processor 5200 is used to execute the method described in any method embodiment of the present disclosure under the control of the executable instructions stored in the memory 5100.
[0165] <Computer Readable Storage Medium Embodiment>
[0166] This embodiment provides a computer-readable storage medium, in which executable commands are stored. When the executable commands are executed by a processor, the method described in any method embodiment of the present disclosure is executed.
[0167] The embodiments of the present disclosure may be an apparatus, a device, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the embodiments of the present disclosure.
[0168] A computer-readable storage medium may be a tangible device that can hold and store instructions used by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples of computer-readable storage media (a non-exhaustive list) include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination of the foregoing. As used herein, a computer-readable storage medium is not to be interpreted as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through a wire.
[0169] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0170] The computer program instructions for performing the operation of the embodiments of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages such as Smalltalk, C++, etc., and conventional procedural programming languages such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by utilizing the state information of a computer-readable program instruction, and the electronic circuit may execute a computer-readable program instruction, thereby realizing various aspects of the embodiments of the present disclosure.
[0171] Here, various aspects of the disclosed embodiments are described with reference to the flowchart and / or block diagram of the method and computer program product according to the disclosed embodiments. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer-readable program instructions.
[0172] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0173] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0174] The flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, equipment, methods and computer program products according to multiple embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of an instruction, and the module, a program segment or a part of an instruction contains one or more executable instructions for realizing the specified logical function. In some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of the boxes in the block diagram and / or the flowchart can be implemented by a dedicated hardware-based system that performs the specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions. It is well known to those skilled in the art that it is equivalent to implement it by hardware, implement it by software, and implement it by combining software and hardware.
[0175] The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.
Claims
1. A method for deploying a container group, the method comprising: receiving a container group deployment request, wherein the container group deployment request includes at least a first resource required by a first container group; Traversing the nodes in the node list to determine whether there is a first node whose remaining available resources satisfy the first resource; If the first node does not exist in the node list, determining a second node and a third node from the node list; Migrate the second container group in the second node to the third node so that the remaining available resources of the second node meet the first resources; Deploy the first container group to a second node on which the migration operation of the second container group has been completed; Wherein, determining the second node and the third node from the node list includes: Determine a node in the node list that meets a preset node selection condition as a first candidate node; When there is a container group to be moved that meets a preset moving condition on the first candidate node, determining the first candidate node as the second node; And, when the remaining available resources of any node in the node list meet the resources required by the container group to be moved, the node is determined as the third node; Determining that there is a to-be-moved container group that meets a preset moving condition on the first candidate node includes: Determine whether a second resource occupied by any container group deployed on the first candidate node is smaller than the first resource; If the second resource is less than the first resource, determining whether the sum of the second resource and the remaining available resources of the first candidate node is greater than or equal to the first resource; If the sum of the second resource and the remaining available resource of the first candidate node is greater than or equal to the first resource, it is determined that there is a to-be-moved container group that meets a preset moving condition on the first candidate node.
2. The method according to claim 1, wherein: The method further comprises: If the first node exists in the node list, respond to the container group deployment request to deploy the first container group in the first node.
3. The method according to claim 1, wherein: The determining whether the second resource occupied by any container group deployed on the first candidate node is less than the first resource includes: All container groups deployed on the first candidate node are traversed until the second resource occupied by any container group is smaller than the first resource.
4. The method according to claim 1, wherein: The method further comprises: When there is no node in the node list whose remaining available resources satisfy the second resource, determining whether the number of moves of the container group to be moved is less than a preset number of moves; If the number of moves of the container group to be moved is not less than the preset number of moves, a new node notification message is generated to notify the operation and maintenance personnel to add a new node for deploying the first container group.
5. The method according to claim 1, wherein: The preset node selection conditions include: The total resource of the node is greater than or equal to the first resource; and Among the container groups deployed on the node, there exists a container group whose required resources are less than the first resources.
6. The method according to claim 1, wherein: After determining the node in the node list that meets the preset node selection condition as the first candidate node, the method further includes: A skip table is generated for the first candidate node, wherein the skip table stores information on resources required by all container groups deployed on the node.
7. The method according to claim 6, wherein: The container groups in the skip list are sorted in ascending order according to the required resources.
8. The method according to claim 1, wherein: The traversing the nodes in the node list to determine whether the first node exists includes: Traversing the nodes in the node list, and determining nodes meeting the pre-selection condition as pre-selected nodes; Determining whether the pre-selected node meets the preset optimization strategy; If yes, determining the pre-selected node as the first node; If not, it is determined that there is no first node in the node list with remaining available resources that meet the requirements of the first resource.
9. The method according to claim 8, wherein: The pre-selected conditions include: The node is in an available state, the current disk input and output pressure of the node is less than a preset pressure threshold, the current load of the node is less than a preset load threshold, and the remaining available resources of the node are greater than or equal to the first resources.
10. The method according to claim 8, wherein: The preset optimization strategy includes: The consumption of resources on the node is minimal, the utilization rate of various resources on the node is most balanced, the node tendency information indicates whether it is suitable for deploying the first container group, the matching degree of the tolerance of the first container group on the node and the taint list item of the node; the number of matching items of the affinity items on the node; try not to be on the same node as other container groups on the server, select the node with the largest consumption, the score of the node label, or the score of the image required by the node.
11. A container group deployment device, the device comprising: A receiving module, configured to receive a container group deployment request, wherein the container group deployment request includes at least a first resource required by a first container group; A determination module, configured to traverse the nodes in the node list to determine whether there is a first node whose remaining available resources satisfy the first resource; If the first node does not exist in the node list, determining a second node and a third node from the node list; a migration module, configured to migrate the second container group in the second node to the third node, so that the remaining available resources of the second node meet the first resources; A deployment module, configured to deploy the first container group to a second node on which the migration operation of the second container group has been completed; The determination module is further configured to determine a node in the node list that meets a preset node selection condition as a first candidate node; When there is a container group to be moved that meets a preset moving condition on the first candidate node, determining the first candidate node as the second node; And, when the remaining available resources of any node in the node list meet the resources required by the container group to be moved, the node is determined as the third node; wherein, determining whether there is a container group to be moved that meets the preset movement condition on the first candidate node includes: determining whether the second resource occupied by any container group deployed on the first candidate node is less than the first resource; if the second resource is less than the first resource, determining whether the sum of the second resource and the remaining available resources of the first candidate node is greater than or equal to the first resource; if the sum of the second resource and the remaining available resources of the first candidate node is greater than or equal to the first resource, determining that there is a container group to be moved that meets the preset movement condition on the first candidate node.
12. A server, comprising the container group deployment device as claimed in claim 11, or the server comprises: A memory for storing executable commands; A processor, configured to execute, under the control of the executable command, the method for deploying a container group according to any one of claims 1 to 10.
13. A computer-readable storage medium storing executable instructions, wherein when the executable instructions are executed by a processor, the container group deployment method according to any one of claims 1 to 10 is executed.
Citation Information
Patent Citations
Method and device for acquiring system resource deployment strategy, electronic equipment
CN107341029A
Resource shared using method and system based on preemptive scheduling and equipment
CN108769254A
Edge computing platform container deployment method and system based on load prediction
CN110231976A
Container deployment method and device
CN110704175A
Container deployment method and device of network function virtualization NVF system
CN111443984A
