Method, system and related components for adjusting the number of tolerable container groups of a container cluster
By calculating predicted CPU and memory usage values in the container cluster and automatically adjusting the number of container groups, the problem of low resource utilization of container cluster nodes is solved, achieving efficient resource utilization and adaptive adjustment to business needs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- JINAN INSPUR DATA TECH CO LTD
- Filing Date
- 2022-08-12
- Publication Date
- 2026-06-26
Smart Images

Figure CN115328652B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of cloud platform technology, and in particular to a method, system, and related components for adjusting the number of container groups that a container cluster can accommodate. Background Technology
[0002] Currently, a large number of applications are deployed based on containerization, and Kubernetes, also known as K8s, has become the de facto standard for container application orchestration. Kubernetes by default sets each node in a container cluster to run 110 Pods, i.e., 110 container groups. As a large number of applications are deployed on Kubernetes, and the number of containerized applications gradually increases, some clusters, due to high node configurations (e.g., 80 CPU cores, 1024GB memory), and the average resource usage of a Pod (e.g., 0.5 CPU cores, 2GB memory), may reach the Kubernetes limit for the number of Pods running on a node, resulting in low node resource utilization.
[0003] Currently, during Kubernetes cluster initialization, the default setting is to accommodate a maximum of 110 pods per node. When this number is found to be insufficient, staff typically adjust it manually based on experience, for example, changing 110 to 150. However, user needs are constantly evolving. As business needs increase, a node may reach 150 pods, but the node's resource utilization may still be low. Furthermore, the resource consumption of each pod may also change. That is, once a node reaches 150 pods, its resources may be insufficient to meet the resource demands of these pods, requiring staff to readjust the node's pod capacity to adapt to the user's current business needs.
[0004] In summary, how to adjust the number of container groups that can be accommodated in the nodes of a container cluster, and conveniently and effectively set this number to an appropriate value, is a technical problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0005] The purpose of this invention is to provide a method, system, and related components for adjusting the number of container groups that a container cluster can accommodate, so as to adjust the number of container groups that a node in a container cluster can accommodate, and to conveniently and effectively set the number to an appropriate value.
[0006] To solve the above-mentioned technical problems, the present invention provides the following technical solution:
[0007] A method for adjusting the number of container groups that a container cluster can accommodate includes:
[0008] Based on the CPU allocation information of each container group in each node of the container cluster, the predicted CPU usage value of a single container group is determined.
[0009] Based on the memory allocation information of each container group in each node of the container cluster, the predicted memory usage of a single container group is determined.
[0010] For any given node, determine the number of container groups that are divided when the node is divided into container groups according to the predicted CPU usage value of a single container group, and use this number as the first container group division value for the node.
[0011] For any given node, determine the number of container groups that are divided when the node is divided into container groups according to the predicted memory usage of a single container group, and use this number as the second container group division value for the node.
[0012] For any given node, the smaller of the first container group partition value and the second container group partition value of the node is taken as the target container group partition value of the node, and the number of container groups that the node can accommodate in its configuration information is adjusted to the target container group partition value.
[0013] Preferably, determining the predicted CPU usage value for a single container group based on the CPU allocation information of each container group in each node of the container cluster includes:
[0014] The sum of the initial CPU allocation values for each container group in each node of the container cluster is determined and divided by the total number of container groups in each node of the container cluster to obtain the average CPU allocation value for each container group in the container cluster.
[0015] The average CPU allocation is used as the predicted CPU usage value for a single container group.
[0016] Preferably, after determining the sum of the initial CPU allocation values for each container group in each node of the container cluster, and dividing it by the total number of container groups in each node of the container cluster to obtain the average CPU allocation value for the container groups in the container cluster, the method further includes:
[0017] Multiply the average CPU allocation of the container group in the obtained container cluster by a first preset coefficient k;
[0018] Accordingly, using the average CPU allocation as the predicted CPU usage value for a single container group includes:
[0019] After multiplying the average CPU allocation of the container group in the obtained container cluster by the first preset coefficient k, the product of the multiplication is used as the predicted CPU usage value of a single container group.
[0020] Wherein, the value of the first preset coefficient k is greater than 1.
[0021] Preferably, determining the predicted memory usage of a single container group based on the memory allocation information of each container group in each node of the container cluster includes:
[0022] The sum of the highest memory allocation values of each container group in each node of the container cluster is determined and divided by the total number of container groups in each node of the container cluster. The resulting value is used as the predicted memory usage value of a single container group.
[0023] Preferably, determining the predicted CPU usage value for a single container group based on the CPU allocation information of each container group in each node of the container cluster includes:
[0024] When a command to adjust the number of container groups is received, or whenever a preset time interval is elapsed, the CPU usage prediction value of a single container group is automatically determined based on the CPU allocation information of each container group in each node of the container cluster.
[0025] Accordingly, determining the predicted memory usage of a single container group based on the memory allocation information of each container group in each node of the container cluster includes:
[0026] When the container group number adjustment instruction is received, or whenever a preset time interval is elapsed, the memory usage prediction value of a single container group is automatically determined based on the memory allocation information of each container group in each node of the container cluster.
[0027] Preferably, determining the predicted memory usage of a single container group based on the memory allocation information of each container group in each node of the container cluster includes:
[0028] The sum of the initial memory allocation values for each container group in each node of the container cluster is determined and used as the first total memory allocation.
[0029] The sum of the highest memory allocation values of each container group in each node of the container cluster is determined as the second total memory allocation;
[0030] Calculate the average of the first total memory and the second total memory, and divide it by the total number of container groups in each node of the container cluster to obtain the average memory allocation of the container groups in the container cluster.
[0031] The average memory allocation is used as the predicted memory usage for a single container group.
[0032] Preferably, after calculating the average of the first total memory and the second total memory, and dividing it by the total number of container groups in each node of the container cluster to obtain the average memory allocation of the container groups in the container cluster, the method further includes:
[0033] Multiply the average memory allocation of the container groups in the obtained container cluster by a second preset coefficient q;
[0034] Accordingly, using the average memory allocation as the predicted memory usage value for a single container group includes:
[0035] After multiplying the average memory allocation of the container group of the obtained container cluster by the second preset coefficient q, the product of the multiplication is used as the predicted memory usage value of a single container group.
[0036] The second preset coefficient q has a value greater than 1.
[0037] A container cluster's system for adjusting the number of container groups it can accommodate includes:
[0038] The single container group CPU usage prediction module is used to determine the predicted CPU usage of a single container group based on the CPU allocation information of each container group in each node of the container cluster.
[0039] The single container group memory usage prediction module is used to determine the predicted memory usage of a single container group based on the memory allocation information of each container group in each node of the container cluster.
[0040] The first container group partitioning value calculation module is used to determine, for any one node, the number of container groups that are partitioned when the node is partitioned according to the predicted CPU usage value of a single container group, and use it as the first container group partitioning value of the node.
[0041] The second container group partitioning value calculation module is used to determine, for any one node, the number of container groups that are partitioned when the node is partitioned according to the memory usage prediction value of a single container group, and use it as the second container group partitioning value of the node.
[0042] The container group capacity adjustment module is used to, for any one node, take the smaller of the first container group partition value and the second container group partition value of the node as the target container group partition value of the node, and adjust the container group capacity in the configuration information of the node to the target container group partition value.
[0043] A device for adjusting the number of container groups that a container cluster can accommodate, comprising:
[0044] Memory, used to store computer programs;
[0045] A processor for executing the computer program to implement the steps of the method for adjusting the number of container groups that a container cluster can accommodate, as described above.
[0046] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the method for adjusting the number of container groups that a container cluster can accommodate, as described above.
[0047] By applying the technical solution provided in this invention, the predicted CPU usage value of a single container group is determined based on the CPU allocation information of each container group in each node of the container cluster. This predicted CPU usage value reflects the CPU usage required by the current business of a single pod in the container cluster. Therefore, for any given node, the number of container groups that will be created when the node is divided into container groups according to the predicted CPU usage value of a single container group can be determined. It can be seen that the first container group division value of a node can effectively adapt to the CPU usage requirements of the node's current business.
[0048] Accordingly, based on the memory allocation information of each container group on each node of the container cluster, the predicted memory usage of a single container group is determined. This predicted memory usage reflects the memory requirements of a single pod's current business within the container cluster. Therefore, for any given node, the number of container groups created when the node is partitioned according to the predicted memory usage of a single container group can be determined. It can be seen that the second container group partitioning value for a node effectively adapts to the memory usage needs of the node's current business.
[0049] When allocating the number of pods a node can accommodate, considering that both the memory and CPU usage requirements of the business must be met simultaneously, this application selects the smaller of the first and second container group allocation values for the node as the target container group allocation value. Once the target container group allocation value for the node is obtained, the number of container groups that the node's configuration information can accommodate can be automatically adjusted to match the target container group allocation value.
[0050] As can be seen, the solution in this application eliminates the need for staff to manually adjust the number of container groups that can be accommodated in the node configuration information based on experience. Instead, it can automatically adjust and determine a reasonable number of container groups that can be accommodated. In other words, this application enables a convenient and effective way to set the number of container groups that can be accommodated in the nodes of a container cluster to an appropriate value. Attached Figure Description
[0051] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0052] Figure 1 This is a flowchart illustrating the implementation of a method for adjusting the number of container groups that a container cluster can accommodate in this invention.
[0053] Figure 2 This is a schematic diagram of the structure of a container cluster's system for adjusting the number of container groups it can accommodate, as described in this invention.
[0054] Figure 3 This is a schematic diagram of the structure of a container cluster device for adjusting the number of container groups it can accommodate, as described in this invention. Detailed Implementation
[0055] The core of this invention is to provide a method for adjusting the number of container groups that a container cluster can accommodate, which can conveniently and effectively set the number of container groups that a node in a container cluster can accommodate to an appropriate value.
[0056] To enable those skilled in the art to better understand the present invention, the invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are merely some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0057] Please refer to Figure 1 , Figure 1 This is a flowchart illustrating an implementation method for adjusting the number of container groups a container cluster can accommodate according to the present invention. The method may include the following steps:
[0058] Step S101: Determine the predicted CPU usage value of a single container group based on the CPU allocation information of each container group in each node of the container cluster.
[0059] Specifically, the container group described in this application can be a Pod. A Pod is a resource object in the Kubernetes container orchestration engine, which is a collection of containers. For two or more close applications, that is, close applications that need to frequently interact and make network calls, they can usually be placed in a Pod.
[0060] It is understandable that different Pods are responsible for different services, and therefore, the CPU and memory resources required by different Pods may be different. The CPU usage prediction value of a single container group described in this application refers to the prediction of the CPU resources that a single Pod needs to be allocated based on the CPU allocation of all Pods in the container cluster. Therefore, a simple way is to determine the CPU usage prediction value of a single container group by averaging.
[0061] For any given Pod, its CPU and memory allocation information needs to be configured. When setting the CPU allocation information, a range can typically be defined. For example, a Pod's CPU allocation information could be 0.5 cores to 1.5 cores, meaning that the Pod will be allocated a minimum of 0.5 cores and a maximum of 1.5 cores. The specific allocation depends on the Pod's current business operations. Using a range-based approach to allocate CPU resources, compared to using a single value, can improve resource utilization to some extent. It reduces the likelihood of allocating too much CPU while actual usage is too low, leading to low resource utilization, or allocating too little while actual usage is too high, requiring readjustment of the allocation.
[0062] If the CPU allocation information for each Pod is a single value, then the average of these values can be used as the predicted CPU usage value for a single container group.
[0063] Of course, as described above, for a Pod, the CPU allocation information of that Pod is usually a range. The lower limit of this range can typically be called the initial CPU allocation value, and the upper limit of the range can be called the maximum CPU allocation value. In such a case, in one specific embodiment of the present invention, step S101 may include:
[0064] The sum of the initial CPU allocation values for each container group in each node of the container cluster is determined and divided by the total number of container groups in each node of the container cluster to obtain the average CPU allocation value for each container group in the container cluster.
[0065] The average CPU allocation is used as the predicted CPU usage for a single container group.
[0066] In this implementation, considering that CPUs can be superdivided and time-divided, for example, if the CPU allocation information of a certain Pod is 0.5 cores-1 core, when the workload of the Pod is high, the Pod needs to use 1 CPU core, and in other cases, the Pod may only need to use 0.6 CPU cores. Then the remaining CPU resources, i.e., 0.4 CPU cores, can be used by other Pods.
[0067] Therefore, in order to effectively improve the resource utilization of the container cluster, this implementation calculates the average CPU allocation of the container group based on the initial CPU allocation value of each Pod. That is, the initial CPU allocation values of all Pods in the container cluster are summed and then divided by the number of these Pods. The resulting value is the average CPU allocation of the container group in the container cluster.
[0068] For example, in a container cluster with 3 nodes, node 1 runs 1 Pod with an initial CPU allocation of 0.5 cores, node 2 runs 3 Pods with initial CPU allocations of 0.5, 0.8, and 1.2 cores respectively, and node 3 runs 1 Pod with an initial CPU allocation of 1 core. In this example, the sum of the initial CPU allocations for each container group in each node of the container cluster is: 0.5 + 0.5 + 0.8 + 1.2 + 1 = 4. Since the total number of Pods is 5, that is, the total number of container groups in each node of the container cluster in this example is 5, therefore 4 ÷ 5 = 0.8 cores. That is, the average CPU allocation for each container group in the container cluster obtained in this example is 0.8 cores.
[0069] Furthermore, in this implementation, the average CPU allocation is directly used as the predicted CPU usage value for a single container group. For example, in the example above, the average CPU allocation of the container cluster is 0.8 cores, therefore, the predicted CPU usage value for a single container group is also 0.8 cores. That is, it is predicted that a single Pod will require approximately 0.8 cores of CPU resources.
[0070] In addition, it should be noted that for any given Pod, the CPU allocation information of that Pod is set by the staff when the Pod is created, and can be adjusted by the staff as the business runs. For example, if the workload of a certain Pod needs to be increased, the staff will adjust the CPU allocation information of that Pod accordingly.
[0071] Furthermore, in one specific embodiment of the present invention, after determining the sum of the initial CPU allocation values of each container group in each node of the container cluster, and dividing it by the total number of container groups in each node of the container cluster to obtain the average CPU allocation of the container groups in the container cluster, the method may further include:
[0072] Multiply the average CPU allocation of the container groups in the obtained container cluster by the first preset coefficient k;
[0073] Accordingly, the average CPU allocation is used as the predicted CPU usage for a single container group, including:
[0074] After multiplying the average CPU allocation of the container group in the obtained container cluster by the first preset coefficient k, the product of the multiplication is used as the predicted CPU usage value of a single container group.
[0075] Among them, the value of the first preset coefficient k is greater than 1.
[0076] For ease of description, the sum of the initial CPU allocation values for each container group on each node of the determined container cluster is denoted as sum_cpu_request. In the example above, this sum is 4. Dividing this sum by the total number of Pods currently running in the container cluster yields the average CPU allocation for each container group. In the example above, dividing the sum of 4 by 5 gives an average CPU allocation of 0.8 cores for each container group.
[0077] In this implementation, considering the need to allow for a certain margin, i.e., some services may require more CPU resources, the average CPU allocation of the container cluster is multiplied by a first preset coefficient k, and the result is used as the predicted CPU usage value for a single container group. The specific value of the first preset coefficient k can be set and adjusted as needed, but it is understood that the value of k should be greater than 1, and the more important the system, the larger the value of k can be.
[0078] For example, if k is set to 1.2, and the average CPU allocation of the container group in the container cluster obtained in the above example is 0.8, multiply 0.8 by the first preset coefficient 1.2, and the result is 0.96 cores. Then, 0.96 cores is used as the predicted CPU usage value of a single container group.
[0079] As can be seen, this implementation does not directly use the average CPU allocation of the container group in the container cluster as the predicted CPU usage value of a single container group, but multiplies it by a certain coefficient before using it as the predicted CPU usage value of a single container group. The margin left can effectively cope with situations where the business needs a lot of CPU resources in some cases, that is, it can ensure that the final number of Pods will not be too large.
[0080] Step S102: Determine the predicted memory usage of a single container group based on the memory allocation information of each container group in each node of the container cluster.
[0081] In this application's solution, in addition to CPU, memory is also considered. Specifically, different Pods are responsible for different services, therefore, the CPU and memory resources required by different Pods may be different. The memory usage prediction value of a single container group described in this application refers to the prediction of the approximate memory resources that a single Pod needs to be allocated based on the memory allocation of all Pods in the container cluster. Therefore, a simple way is to determine the memory usage prediction value of a single container group by averaging.
[0082] For any given Pod, its memory allocation information needs to be configured. When setting this information, a range can typically be defined. For example, a Pod's memory allocation range might be 2GB-4GB, meaning that the Pod will be allocated a minimum of 2GB and a maximum of 4GB of memory resources. The specific allocation depends on the Pod's current service requirements. Similar to CPU allocation, using a range for memory resource allocation, compared to using a single value, improves resource utilization. It reduces the likelihood of allocating too much memory while actual usage is too low, leading to low resource utilization, or allocating too little memory while actual usage is too high, necessitating readjustment of the allocation.
[0083] If the memory allocation information for each Pod is a single value, then the average of these values can be used as the predicted memory usage for a single container group.
[0084] Of course, as described above, for a Pod, the memory allocation information of that Pod is usually a range. The lower limit of this range is typically called the initial memory allocation value, and the upper limit is called the maximum memory allocation value. In such a case, in one specific embodiment of the present invention, step S102 may include:
[0085] The sum of the highest memory allocation values for each container group in each node of the container cluster is determined and divided by the total number of container groups in each node of the container cluster. The resulting value is used as the predicted memory usage value for a single container group.
[0086] In this implementation, considering the difference between memory and CPU, CPU can be superdivided and time-divided, but memory cannot. Therefore, if the average memory allocation of the container cluster is calculated based on the initial memory allocation of each Pod, it may result in a large number of Pods being created. If the workload of a Pod changes slightly, the memory resources allocated to the Pod may not be able to meet the business needs, and the Pods need to be re-divided and the memory allocation information of each Pod needs to be adjusted.
[0087] Therefore, in this implementation, in order to avoid the number of Pods that will be divided in the future being too large, that is, to ensure that each Pod can be allocated enough memory resources, the sum of the highest memory allocation values of each container group in each node of the container cluster is determined, and then the average value is calculated as the predicted memory usage value of a single container group.
[0088] Taking a container cluster with 3 nodes as an example, let's say node 1 runs 1 Pod with a memory allocation of 2G-4G (initial memory allocation is 2G, maximum memory allocation is 4G). Node 2 runs 3 Pods with memory allocations of 2G-4G, 4G-8G, and 4G-8G respectively. Node 3 runs 1 Pod with a memory allocation of 2G-4G. In this example, the sum of the maximum memory allocation values for each container group across all nodes in the container cluster is: 4 + 4 + 8 + 8 + 4 = 28. Since the total number of Pods is 5, meaning the total number of container groups across all nodes in this example is 5, 28 ÷ 5 = 5.6G. Therefore, the average memory allocation for each container group in this example is 5.6G.
[0089] Furthermore, in this implementation, the sum of the highest memory allocation values of each container group in each node of the container cluster is determined and divided by the total number of container groups in each node of the container cluster. The resulting value is then used as the predicted memory usage value of a single container group. For example, in the example above, 5.6G is directly used as the predicted memory usage value of a single container group, that is, it is predicted that a single Pod will require approximately 5.6G of memory resources.
[0090] It should be noted that the above example uses 3 nodes. In actual applications, the number of nodes in a container cluster is usually much greater, and the number of Pods running on each node is usually also much larger.
[0091] In addition, for any given Pod, the memory allocation information of the Pod is set by the staff when the Pod is created, and can be adjusted by the staff as the business runs. For example, if the workload of a certain Pod needs to be increased, the staff will adjust the memory allocation information of the Pod accordingly.
[0092] In one specific embodiment of the present invention, step S102 may specifically include:
[0093] The sum of the initial memory allocation values for each container group in each node of the container cluster is determined and used as the first total memory allocation.
[0094] The sum of the highest memory allocation values of each container group in each node of the container cluster is determined as the second total memory allocation;
[0095] Calculate the average of the first total memory and the second total memory, and divide it by the total number of container groups in each node of the container cluster to obtain the average memory allocation of the container groups in the container cluster.
[0096] The average memory allocation is used as the predicted memory usage for a single container group.
[0097] In the aforementioned implementation, the sum of the highest memory allocation values of each container group in each node of the container cluster is determined, and then the average value is calculated as the predicted memory usage value of a single container group. This can avoid the subsequent division of too many Pods. However, this implementation further considers that such an implementation will reduce memory resource utilization.
[0098] Therefore, in this implementation, the sum of the initial memory allocation values of each container group in each node of the container cluster is determined as the first memory sum, for example, denoted as sum_memory_request, and the sum of the highest memory allocation values of each container group in each node of the container cluster is determined as the second memory sum, for example, denoted as sum_memory_limit. The average of the first memory sum and the second memory sum is divided by the total number of container groups to obtain the average memory allocation of the container groups in the container cluster, which can be expressed as (sum_memory_request + sum_memory_limit) ÷ 2 ÷ total number of Pods.
[0099] As can be seen, in this implementation method, the median value of the Pod's memory allocation information is selected. The average memory allocation of the container group in the container cluster determined in this way will not be too large or too small. This is beneficial to ensure the utilization of memory resources and will not result in too many Pods being created later.
[0100] Furthermore, in one specific embodiment of the present invention, after calculating the average of the first total memory and the second total memory, and dividing it by the total number of container groups in each node of the container cluster to obtain the average memory allocation of the container groups in the container cluster, the method may further include:
[0101] Multiply the average memory allocation of the container groups in the obtained container cluster by the second preset coefficient q;
[0102] Accordingly, the above description of using the average memory allocation as the predicted memory usage for a single container group is as follows:
[0103] After multiplying the average memory allocation of the container group in the obtained container cluster by the second preset coefficient q, the product of the multiplication is used as the predicted memory usage value of a single container group.
[0104] Among them, the value of the second preset coefficient q is greater than 1.
[0105] In this implementation, the predicted memory usage of a single container group can be expressed as:
[0106] (sum_memory_request+sum_memory_limit)÷2÷total number of Pods×q.
[0107] In this implementation, considering the need to allow for a certain margin, i.e., some services may require more memory resources, the average memory allocation of the container cluster is multiplied by a first preset coefficient q, and the result is used as the predicted memory usage value for a single container group. The specific value of the second preset coefficient q can be set and adjusted as needed, but it is understood that the value of q should be greater than 1, and the more important the system, the larger the value of q can be.
[0108] For example, in one scenario, q can be set to a value such as 1.2 or 1.5. Compared to the aforementioned implementation method, in this implementation method, it is multiplied by the coefficient q and then used as the predicted memory usage value for a single container group. The margin left can effectively cope with situations where business needs require a lot of memory resources in some scenarios, that is, it can ensure that the final number of Pods is not too large.
[0109] Step S103: For any one node, determine the number of container groups that are divided when the node is divided into container groups according to the predicted CPU usage value of a single container group, and use this number as the first container group division value for the node.
[0110] Step S104: For any given node, determine the number of container groups that are divided when the node is divided into container groups according to the predicted memory usage of a single container group, and use this number as the second container group division value for the node.
[0111] Specifically, the allocatable CPU of a node can be divided by the predicted CPU usage value of a single container group determined in step S101, and the result can be rounded down as the first container group partition value of the node.
[0112] Similarly, the allocatable memory of a node can be divided by the predicted memory usage of a single container group determined in step S102, and the result can be rounded down as the second container group partition value of the node.
[0113] The allocatable CPU and allocatable memory of a node can be obtained from the node's configuration information. For example, Table 1 shows the configuration information of each node in a container cluster in a specific scenario.
[0114] Table 1:
[0115]
[0116]
[0117] It should also be noted that Table 1 only shows a portion of the configuration information table. In other specific cases, the configuration information table may contain other items, which will not affect the implementation of the present invention.
[0118] Furthermore, in practical applications, the hardware resources of each node in a container cluster are usually consistent. For example, in Table 1, each node has an allocable CPU of 79,800 millicores and an allocable memory of 1055.8GB. Of course, the fact that different nodes in a container cluster have different hardware resources does not affect the implementation of this application, because in the subsequent step S105, the target container group partition value is calculated individually for each node. Additionally, the number of Pods that each node can accommodate in Table 1 is 110, indicating that the node's Pod capacity has not yet been adjusted using the scheme of this application; that is, the default Pod capacity for each node is 110.
[0119] Step S105: For any node, take the smaller of the first container group partition value and the second container group partition value of the node as the target container group partition value of the node, and adjust the number of container groups that the node can accommodate in its configuration information to the target container group partition value.
[0120] For any given node, following the steps described above, the smaller of the first and second container group partition values can be calculated. To ensure sufficient resource allocation for each Pod in the node, this application considers both CPU and memory. Specifically, the smaller of the first and second container group partition values is used as the target container group partition value for the node, thus avoiding situations where the number of Pods is too large, leading to insufficient memory or CPU resources for some Pods.
[0121] After determining the target container group partition value for a node, this application will automatically adjust the number of container groups that the node can accommodate in its configuration information to the target container group partition value. Unlike traditional solutions where staff need to manually modify this value based on experience, this application's solution can automatically partition the number of Pods that are suitable for the node's allocable resources based on the current business situation of the container cluster, and use this number as the number of Pods that the node can accommodate.
[0122] In one specific embodiment of the present invention, step S101 may include:
[0123] When a command to adjust the number of container groups is received, or whenever a preset time interval is elapsed, the CPU usage prediction value of a single container group is automatically determined based on the CPU allocation information of each container group in each node of the container cluster.
[0124] Accordingly, step S102 may include:
[0125] When a command to adjust the number of container groups is received, or whenever a preset time interval is elapsed, the system automatically determines the predicted memory usage of a single container group based on the memory allocation information of each container group in each node of the container cluster.
[0126] This implementation takes into account that user business needs are constantly changing. To ensure an appropriate number of Pods, the scheme described in this application can be executed periodically to update the number of Pods that each node can accommodate. Of course, the specific value of the preset time interval described in this implementation can be set and adjusted as needed, for example, set to one week or one month.
[0127] Furthermore, this implementation also allows for proactively triggering updates to the Pod capacity of each node. That is, when a container group quantity adjustment instruction is received, it indicates that the staff wishes to proactively trigger an update to the Pod capacity of each node. It can be seen that this implementation can be executed periodically or proactively triggered, offering high flexibility and reducing the workload of staff.
[0128] By applying the technical solution provided in this invention, the predicted CPU usage value of a single container group is determined based on the CPU allocation information of each container group in each node of the container cluster. This predicted CPU usage value reflects the CPU usage required by the current business of a single pod in the container cluster. Therefore, for any given node, the number of container groups that will be created when the node is divided into container groups according to the predicted CPU usage value of a single container group can be determined. It can be seen that the first container group division value of a node can effectively adapt to the CPU usage requirements of the node's current business.
[0129] Accordingly, based on the memory allocation information of each container group on each node of the container cluster, the predicted memory usage of a single container group is determined. This predicted memory usage reflects the memory requirements of a single pod's current business within the container cluster. Therefore, for any given node, the number of container groups created when the node is partitioned according to the predicted memory usage of a single container group can be determined. It can be seen that the second container group partitioning value for a node effectively adapts to the memory usage needs of the node's current business.
[0130] When allocating the number of pods a node can accommodate, considering that both the memory and CPU usage requirements of the business must be met simultaneously, this application selects the smaller of the first and second container group allocation values for the node as the target container group allocation value. Once the target container group allocation value for the node is obtained, the number of container groups that the node's configuration information can accommodate can be automatically adjusted to match the target container group allocation value.
[0131] As can be seen, the solution in this application eliminates the need for staff to manually adjust the number of container groups that can be accommodated in the node configuration information based on experience. Instead, it can automatically adjust and determine a reasonable number of container groups that can be accommodated. In other words, this application enables a convenient and effective way to set the number of container groups that can be accommodated in the nodes of a container cluster to an appropriate value.
[0132] Corresponding to the above method embodiments, this invention also provides a system for adjusting the number of container groups that a container cluster can accommodate, which can be referred to in conjunction with the above.
[0133] See Figure 2 The diagram shown is a structural schematic of a container cluster's system for adjusting the number of container groups it can accommodate, according to the present invention, comprising:
[0134] The single container group CPU usage prediction module 201 is used to determine the CPU usage prediction value of a single container group based on the CPU allocation information of each container group in each node of the container cluster.
[0135] The single container group memory usage prediction module 202 is used to determine the memory usage prediction value of a single container group based on the memory allocation information of each container group in each node of the container cluster.
[0136] The first container group partitioning value calculation module 203 is used to determine the number of container groups that are partitioned when the node partitions container groups according to the predicted CPU usage value of a single container group for any one node, and use it as the first container group partitioning value of the node.
[0137] The second container group partition value calculation module 204 is used to determine the number of container groups when the node is partitioned according to the memory usage prediction value of a single container group for any one node, and use it as the second container group partition value of the node.
[0138] The container group capacity adjustment module 205 is used to, for any one node, take the smaller of the first container group partition value and the second container group partition value of the node as the target container group partition value of the node, and adjust the number of container groups that can be accommodated in the node's configuration information to the target container group partition value.
[0139] In one specific embodiment of the present invention, the single container group CPU usage prediction value determination module 201 is specifically used for:
[0140] The sum of the initial CPU allocation values for each container group in each node of the container cluster is determined and divided by the total number of container groups in each node of the container cluster to obtain the average CPU allocation value for each container group in the container cluster.
[0141] The average CPU allocation is used as the predicted CPU usage for a single container group.
[0142] In one specific embodiment of the present invention, it further includes:
[0143] The first preset coefficient execution module is used to multiply the average CPU allocation of the container cluster obtained by the single container group CPU usage prediction value determination module 201 by the first preset coefficient k.
[0144] Accordingly, the single container group CPU usage prediction module 201 uses the average CPU allocation as the determined CPU usage prediction value for a single container group, specifically:
[0145] After multiplying the average CPU allocation of the container group in the obtained container cluster by the first preset coefficient k, the product of the multiplication is used as the predicted CPU usage value of a single container group.
[0146] Among them, the value of the first preset coefficient k is greater than 1.
[0147] In one specific embodiment of the present invention, the single container group memory usage prediction value determination module 202 is specifically used for:
[0148] The sum of the highest memory allocation values for each container group in each node of the container cluster is determined and divided by the total number of container groups in each node of the container cluster. The resulting value is used as the predicted memory usage value for a single container group.
[0149] In one specific embodiment of the present invention, the single container group CPU usage prediction value determination module 201 is used for:
[0150] When a command to adjust the number of container groups is received, or whenever a preset time interval is elapsed, the CPU usage prediction value of a single container group is automatically determined based on the CPU allocation information of each container group in each node of the container cluster.
[0151] Correspondingly, the single container group memory usage prediction module 202 is specifically used for:
[0152] When a command to adjust the number of container groups is received, or whenever a preset time interval is elapsed, the system automatically determines the predicted memory usage of a single container group based on the memory allocation information of each container group in each node of the container cluster.
[0153] In one specific embodiment of the present invention, the single container group memory usage prediction value determination module 202 is specifically used for:
[0154] The sum of the initial memory allocation values for each container group in each node of the container cluster is determined and used as the first total memory allocation.
[0155] The sum of the highest memory allocation values of each container group in each node of the container cluster is determined as the second total memory allocation;
[0156] Calculate the average of the first total memory and the second total memory, and divide it by the total number of container groups in each node of the container cluster to obtain the average memory allocation of the container groups in the container cluster.
[0157] The average memory allocation is used as the predicted memory usage for a single container group.
[0158] In one specific embodiment of the present invention, it further includes:
[0159] The first preset coefficient execution module is used to multiply the average container group memory allocation of the container cluster obtained by the single container group memory usage prediction value determination module 202 by the second preset coefficient q.
[0160] Accordingly, the single container group memory usage prediction module 202 uses the average memory allocation as the determined memory usage prediction value for a single container group, specifically:
[0161] After multiplying the average memory allocation of the container group in the obtained container cluster by the second preset coefficient q, the product of the multiplication is used as the predicted memory usage value of a single container group.
[0162] Among them, the value of the second preset coefficient q is greater than 1.
[0163] Corresponding to the above methods and system embodiments, this invention also provides a device for adjusting the number of container groups a container cluster can accommodate and a computer-readable storage medium, which can be referred to in conjunction with the above description. The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the method for adjusting the number of container groups a container cluster can accommodate as described in any of the above embodiments. The computer-readable storage medium referred to herein includes random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disks, removable disks, CD-ROMs, or any other form of storage medium known in the art.
[0164] The device for adjusting the number of container groups that the container cluster can accommodate may include:
[0165] Memory 301 is used to store computer programs;
[0166] Processor 302 is configured to execute a computer program to implement the steps of the method for adjusting the number of container groups that a container cluster can accommodate, as described in any of the above embodiments.
[0167] It should also be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes the element.
[0168] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0169] This article uses specific examples to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the technical solutions and core ideas of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made to the present invention without departing from the principles of the present invention, and these improvements and modifications also fall within the protection scope of the present invention.
Claims
1. A method for adjusting the number of container groups that a container cluster can accommodate, characterized in that, include: Based on the CPU allocation information of each container group in each node of the container cluster, the predicted CPU usage value of a single container group is determined. Based on the memory allocation information of each container group in each node of the container cluster, the predicted memory usage of a single container group is determined. For any given node, determine the number of container groups that are divided when the node is divided into container groups according to the predicted CPU usage value of a single container group, and use this number as the first container group division value for the node. For any given node, determine the number of container groups that are divided when the node is divided into container groups according to the predicted memory usage of a single container group, and use this number as the second container group division value for the node. For any given node, the smaller of the first container group partition value and the second container group partition value of the node is taken as the target container group partition value of the node, and the number of container groups that the node can accommodate in its configuration information is adjusted to the target container group partition value. The step of determining the predicted CPU usage value for a single container group based on the CPU allocation information of each container group in each node of the container cluster includes: The sum of the initial CPU allocation values for each container group in each node of the container cluster is determined and divided by the total number of container groups in each node of the container cluster to obtain the average CPU allocation value for each container group in the container cluster. The average CPU allocation is used as the predicted CPU usage value for a single container group; The step of determining the predicted memory usage of a single container group based on the memory allocation information of each container group in each node of the container cluster includes: The sum of the highest memory allocation values of each container group in each node of the container cluster is determined and divided by the total number of container groups in each node of the container cluster. The resulting value is used as the predicted memory usage value of a single container group.
2. The method for adjusting the number of container groups that a container cluster can accommodate according to claim 1, characterized in that, After determining the sum of the initial CPU allocation values for each container group on each node of the container cluster, and dividing it by the total number of container groups on each node of the container cluster to obtain the average CPU allocation for each container group in the container cluster, the process further includes: Multiply the average CPU allocation of the container group in the obtained container cluster by a first preset coefficient k; Accordingly, using the average CPU allocation as the predicted CPU usage value for a single container group includes: After multiplying the average CPU allocation of the container group in the obtained container cluster by the first preset coefficient k, the product of the multiplication is used as the predicted CPU usage value of a single container group. Wherein, the value of the first preset coefficient k is greater than 1.
3. The method for adjusting the number of container groups that a container cluster can accommodate according to claim 1, characterized in that, The step of determining the predicted CPU usage value for a single container group based on the CPU allocation information of each container group in each node of the container cluster includes: When a command to adjust the number of container groups is received, or whenever a preset time interval is elapsed, the CPU usage prediction value of a single container group is automatically determined based on the CPU allocation information of each container group in each node of the container cluster. Accordingly, determining the predicted memory usage of a single container group based on the memory allocation information of each container group in each node of the container cluster includes: When the container group number adjustment instruction is received, or whenever a preset time interval is elapsed, the memory usage prediction value of a single container group is automatically determined based on the memory allocation information of each container group in each node of the container cluster.
4. The method for adjusting the number of container groups that a container cluster can accommodate according to any one of claims 1 to 3, characterized in that, The step of determining the predicted memory usage of a single container group based on the memory allocation information of each container group in each node of the container cluster includes: The sum of the initial memory allocation values for each container group in each node of the container cluster is determined and used as the first total memory allocation. The sum of the highest memory allocation values of each container group in each node of the container cluster is determined as the second total memory allocation; Calculate the average of the first total memory and the second total memory, and divide it by the total number of container groups in each node of the container cluster to obtain the average memory allocation of the container groups in the container cluster. The average memory allocation is used as the predicted memory usage for a single container group.
5. The method for adjusting the number of container groups that a container cluster can accommodate according to claim 4, characterized in that, After calculating the average of the first total memory and the second total memory, and dividing it by the total number of container groups in each node of the container cluster to obtain the average memory allocation of the container groups in the container cluster, the method further includes: Multiply the average memory allocation of the container groups in the obtained container cluster by a second preset coefficient q; Accordingly, using the average memory allocation as the predicted memory usage value for a single container group includes: After multiplying the average memory allocation of the container group of the obtained container cluster by the second preset coefficient q, the product of the multiplication is used as the predicted memory usage value of a single container group. The value of the second preset coefficient q is greater than 1.
6. A system for adjusting the number of container groups that a container cluster can accommodate, characterized in that, include: The single container group CPU usage prediction module is used to determine the predicted CPU usage of a single container group based on the CPU allocation information of each container group in each node of the container cluster. The single container group memory usage prediction module is used to determine the predicted memory usage of a single container group based on the memory allocation information of each container group in each node of the container cluster. The first container group partitioning value calculation module is used to determine, for any one node, the number of container groups that are partitioned when the node is partitioned according to the predicted CPU usage value of a single container group, and use it as the first container group partitioning value of the node. The second container group partitioning value calculation module is used to determine, for any one node, the number of container groups that are partitioned when the node is partitioned according to the memory usage prediction value of a single container group, and use it as the second container group partitioning value of the node. The container group capacity adjustment module is used to, for any one node, take the smaller of the first container group partition value and the second container group partition value of the node as the target container group partition value of the node, and adjust the number of container groups that can be accommodated in the configuration information of the node to the target container group partition value. The container group CPU usage prediction module is specifically used for: The sum of the initial CPU allocation values for each container group in each node of the container cluster is determined and divided by the total number of container groups in each node of the container cluster to obtain the average CPU allocation value for each container group in the container cluster. The average CPU allocation is used as the predicted CPU usage for a single container group. The module for predicting memory usage in a single container group is specifically used for: The sum of the highest memory allocation values for each container group in each node of the container cluster is determined and divided by the total number of container groups in each node of the container cluster. The resulting value is used as the predicted memory usage value for a single container group.
7. A device for adjusting the number of container groups that a container cluster can accommodate, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the method for adjusting the number of container groups that a container cluster can accommodate as described in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method for adjusting the number of container groups that a container cluster can accommodate as described in any one of claims 1 to 5.