Method and system suitable for vertical capacity expansion and contraction of Kubernetes namespace
By allocating resource quotas for Namespace in Kubernetes and setting vertical scaling strategies, and dynamically updating resource quotas, the problem that traditional scaling mechanisms are difficult to manage resource competition and isolation between multiple Namespaces is solved, and intelligent scheduling and efficient utilization of resources are achieved.
Patent Information
- Application Number
- CN202510004161.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-02
- Publication Date
- 2025-05-02
AI Technical Summary
The traditional scaling mechanism is difficult to effectively manage resource competition and isolation needs between multiple Namespaces, resulting in waste or insufficient resources and affecting system performance.
By allocating resource quotas for Namespace in Kubernetes and setting a vertical scaling strategy, monitoring the actual resource usage, dynamically updating resource quotas, and realizing Namespace-level intelligent resource scheduling.
It realizes the rationality and flexibility of resource allocation, avoids resource waste, improves resource utilization, and ensures the stable operation of the system when load changes.
Smart Images

Figure CN119917217A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and system suitable for vertical expansion and contraction of a Kubernetes namespace. Background Art
[0002] With the rapid development of cloud computing and containerization technology, resource management and scheduling have become key issues to ensure efficient operation of systems in cloud environments. Kubernetes, as a mainstream container orchestration platform, implements multi-tenant resource isolation and management through Namespace. However, with the dynamic changes in application loads, static resource allocation alone is often difficult to meet actual business needs. In this case, dynamic scaling technology has emerged to expand resources when resource usage peaks and reduce resources when the load decreases, so as to improve resource utilization and reduce operating costs.
[0003] Traditional scaling mechanisms are mostly applied to a single Pod or service level, increasing or decreasing the number of Pod instances through horizontal scaling (Horizontal Scaling), or adjusting the resource allocation of a single Pod through vertical scaling. However, with the increasing complexity of cloud environments, resource competition between multiple services and the need for resource isolation at the Namespace level have become increasingly prominent. Namespace-level scaling management has gradually become a new trend. It not only ensures that the resource requirements of each Namespace at different times are met, but also requires intelligent scheduling of resources between multiple Namespaces to avoid resource waste or system performance degradation caused by insufficient resources. Summary of the invention
[0004] The purpose of the present invention is to provide a method and system suitable for vertical expansion and contraction of Kubernetes namespaces, which effectively solves the problem of low efficiency in traditional manual management of Namespace resource allocation, can intelligently adjust the resource usage of each Namespace, ensure the rationality and flexibility of resource allocation, and avoid resource waste.
[0005] In order to solve the above technical problems, the present invention provides a method suitable for vertical expansion and contraction of Kubernetes namespace, comprising:
[0006] Allocate resource quotas to Namespace;
[0007] Set the Namespace vertical expansion and contraction strategy;
[0008] Monitor the actual resource usage of Namespace;
[0009] Update the resource quota of the Namespace based on the actual resource usage of the Namespace and the vertical scaling policy.
[0010] Preferably, setting the Namespace vertical expansion and contraction strategy specifically includes the following steps:
[0011] Generate a vertical scaling policy associated with the Namespace according to user needs or predefined rules; the vertical scaling policy includes a scaling threshold, a scaling threshold, and a scaling instance range.
[0012] Preferably, the resource quota of the Namespace is updated according to the actual resource usage of the Namespace and the vertical scaling strategy, which specifically includes the following steps:
[0013] Monitor the actual resource usage of Namespace and obtain monitoring indicators;
[0014] When the monitoring indicator exceeds the expansion threshold, the resource quota is expanded according to the scaling instance range;
[0015] When the monitoring indicator is lower than the scaling-in threshold, the resource quota is scaled down according to the scaling instance range.
[0016] Preferably, the method further comprises the following steps:
[0017] Set the priority for Namespace;
[0018] When the resource quota of a Namespace needs to be expanded, the Namespace is used as the Namespace to be expanded to determine whether the resources in the resource pool are sufficient.
[0019] If there are sufficient resources in the resource pool, the resource quota of the namespace to be extended is extended according to the scope of the scaling instance;
[0020] If the resources in the resource pool are insufficient, determine whether there are other namespaces with a lower priority than the namespace to be expanded.
[0021] If there are other namespaces with lower priorities than the namespace to be expanded, the resource quota of the corresponding low-priority namespaces will be reduced according to the scaling instance scope until the resources in the resource pool are sufficient, and then the resource quota of the namespace to be expanded will be expanded according to the scaling instance scope.
[0022] Preferably, the vertical expansion and contraction strategy also includes a stable window, an expansion rate strategy and a contraction rate strategy;
[0023] When the monitoring indicator exceeds the expansion threshold all the time within the set stability window, the number of instances is increased according to the expansion rate strategy.
[0024] When the monitoring indicator remains below the scaling-in threshold within the set stability window, the number of instances is reduced according to the scaling-in rate policy.
[0025] Preferably, allocating resource quotas to Namespace specifically includes the following steps:
[0026] Based on the prediction algorithm and historical data, a resource quota is set for each Namespace; the resource quota includes CPU and memory resource quotas.
[0027] Preferably, the maximum expansion calculation formula is:
[0028] Maximum CPU expansion ratio = (total CPU resources of the resource pool to which the namespace belongs - total CPU resources of other namespaces under the resource pool) / total CPU resources of the namespace * 100%
[0029] Maximum memory expansion ratio = (total memory resources of the resource pool to which the namespace belongs - total memory resources of other namespaces under the resource pool) / total memory resources of the namespace * 100%
[0030] Capacity expansion limit = project resource pool quota - total resource allocation of other Namespaces except this Namespace.
[0031] Preferably, the resource quota is not less than a minimum quota.
[0032] Preferably, the method further comprises the following steps:
[0033] When the resource consumption of a Namespace approaches its resource quota, an alarm message is sent to remind the administrator to take action.
[0034] The present invention also provides a system suitable for vertical expansion and contraction of Kubernetes namespace, including:
[0035] Resource quota allocation module, used to allocate resource quota to Namespace;
[0036] The scaling setting module is used to set the Namespace vertical scaling strategy;
[0037] The monitoring module is used to monitor the actual resource usage of the Namespace;
[0038] The scheduling module is used to update the resource quota of the Namespace according to the actual resource usage of the Namespace and the vertical scaling policy.
[0039] Compared with the prior art, the present invention has the following beneficial effects:
[0040] The present invention predicts through historical data and performs advance capacity expansion to avoid the problem of insufficient resources when the load suddenly arrives.
[0041] The present invention uses a global resource pool to share and preempt resources, and each Namespace can dynamically share idle resources to improve resource utilization.
[0042] The present invention dynamically adjusts the priority according to the importance, load and historical behavior of the Namespace, ensuring that the key Namespace obtains resources first.
[0043] The present invention protects the system through a cooling mechanism to avoid instability caused by frequent expansion and contraction, thereby ensuring stable operation of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The specific implementation modes of the present invention are further described in detail below with reference to the accompanying drawings.
[0045] Figure 1 This is a flow chart of the method for vertical scaling of Kubernetes namespaces.
[0046] Figure 2 Schematic diagram of the process of expanding the capacity of a single partition;
[0047] Figure 3 This is a flowchart for shrinking a single partition.
[0048] Figure 4 This is a flowchart of the resource pool exhaustion scenario;
[0049] Figure 5 This is a flowchart for calculating the maximum expansion ratio of a namespace. DETAILED DESCRIPTION
[0050] Many specific details are set forth in the following description to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present invention, so the present invention is not limited to the specific implementation disclosed below.
[0051] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.
[0052] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0053] The present invention is further described in detail below in conjunction with the accompanying drawings:
[0054] The present invention provides a method for vertically scaling a Kubernetes namespace, comprising the following steps:
[0055] Create a Namespace and allocate resource quotas;
[0056] Create a Namespace vertical scaling policy;
[0057] Update the Namespace quota according to the Namespace vertical expansion and contraction policy;
[0058] Determine whether the actual CPU and Memory are expanded or reduced;
[0059] If the expansion threshold is exceeded, the capacity is expanded to the expected threshold;
[0060] If it is less than the shrinking threshold, shrink the capacity to the expected threshold.
[0061] Preferably, the method specifically comprises the following steps:
[0062] Create resource quotas for Namespace allocation: Set initial CPU and memory resource quotas for each Namespace;
[0063] Create a Namespace vertical scaling policy: Generate a scaling policy associated with the Namespace based on user needs or predefined rules. The policy defines the expansion threshold, reduction threshold, and scaling instance range.
[0064] Expansion strategy: When the Namespace quota is insufficient, dynamically increase the CPU or memory resource quota;
[0065] Scaling strategy: When resource usage continues to be below the threshold, reduce the CPU or memory resource quota to avoid resource waste.
[0066] Dynamically update Namespace quotas based on scaling policies: Based on the created scaling policies, adjust the CPU and memory resource quotas of the Namespace in real time;
[0067] Determine the actual resource usage of the Namespace: Monitor to determine whether expansion or reduction operations are required;
[0068] Preferably, a scaling strategy is set, the strategy including:
[0069] Set the range of scaling instances;
[0070] Set expansion thresholds, and trigger expansion operations when monitoring indicators exceed the thresholds;
[0071] Set a reduction threshold. When the monitoring indicator is lower than the threshold, the reduction operation is triggered.
[0072] Optional advanced configuration strategies:
[0073] Set a stable window. When scaling is needed, continuous detection will be performed within the set stable window time. If scaling is always required within this time period, it will be performed to avoid abnormalities caused by short-term indicator jitter.
[0074] Set the expansion rate strategy. After the expansion or contraction operation is triggered, the number of instances will be increased or decreased according to the specified expansion rate strategy.
[0075] Set the scaling rate strategy. After the scaling operation is triggered, increase or decrease the number of instances according to the specified scaling rate strategy.
[0076] Automatically adjust Nmaespce quotas based on real-time monitoring data to meet load requirements.
[0077] During the expansion process, ensure the startup time and health check mechanism of new instances to ensure high availability of the application.
[0078] During the scaling-in process, instances with lower traffic are preferentially deleted to ensure the continuity of application services.
[0079] Perform expansion and contraction operations:
[0080] When the actual CPU or memory usage of Namesoce exceeds the expansion threshold, increase the resource quota and expand the resources to the expected value;
[0081] When the actual CPU or memory usage of Namespace is lower than the reduction threshold, reduce the resource quota and shrink the resources to the expected value.
[0082] Preferably, the system further includes a monitoring module for monitoring the CPU and memory usage of the Pod in real time, and comparing the monitoring data with the thresholds in the expansion and contraction strategy.
[0083] Preferably, the system supports concurrent management of multiple Namespaces and adopts independent expansion and contraction strategies for different Namespaces.
[0084] Preferably, the system provides an alarm function. When the resource consumption of a Namespace approaches its allocated quota, an alarm message is sent to remind the administrator to take measures.
[0085] Preferably, the system supports integration with automated deployment tools, and can automatically create or destroy container instances when scaling policies are triggered.
[0086] Preferably, the system can adaptively adjust the expansion and contraction strategy according to the historical resource usage data configured by the user to optimize the resource allocation efficiency.
[0087] Preferably, the system will consider the minimum quota of resources during the scaling-down operation to avoid the risk of system unavailability due to excessive scaling-down.
[0088] Preferably, cross-Namespace resource sharing and preemptive scheduling,Namespaces in a cluster are not isolated, and a resource pool concept is introduced, allowing dynamic resource sharing between Namespaces.,Specifically, the algorithm divides the resource quota of each Namespace into two parts:,Basic quota: Meets the minimum demand of the current Namespace and always maintains allocation.
[0089] Elastic quota: It comes from the global resource pool. When the load of a Namespace is low, its unused elastic quota will be put back into the resource pool for other Namespaces to use on demand. By designing a preemptive scheduling mechanism, a high-priority Namespace can temporarily obtain resources from a low-priority Namespace when resources are scarce.
[0090] Preferably, the maximum expansion calculation formula is:
[0091] Maximum CPU expansion ratio = (total CPU resources of the resource pool to which the namespace belongs - total CPU resources of other namespaces under the resource pool) / total CPU resources of the namespace * 100%
[0092] Maximum memory expansion ratio = (total memory resources of the resource pool to which the namespace belongs - total memory resources of other namespaces under the resource pool) / total memory resources of the namespace * 100%
[0093] Capacity expansion limit = project resource pool quota - total resource allocation of other Namespaces except this Namespace. Preferably, the dual trigger mechanism predicts triggering:
[0094] Based on historical data and prediction algorithms, the resource quota allocated to the Namespace is adjusted in advance. This mechanism ensures that capacity expansion is carried out in advance and shortens the response time for Pod startup or insufficient resources.
[0095] Real-time load triggering: If the actual load suddenly surges and exceeds the predicted resource demand, the algorithm will react quickly based on real-time monitoring by requesting additional resources from the global resource pool.
[0096] Preferably, based on the dynamic allocation of priority weights, each Namespace will be assigned a dynamic priority weight, whose value is adjusted according to the actual importance, load and historical usage records of the Namespace:
[0097] Importance: System administrators can preset the weights of certain key namespaces so that these namespaces can be given priority in expansion opportunities when resources are tight.
[0098] Real-time load: The algorithm will monitor the load of each Namespace in real time, and the weight of the Namespace with higher load will be automatically increased. Dynamic priority can prevent resources from being too biased towards certain Namespaces, and also prevent long-term occupation of inefficient resources.
[0099] The present invention discloses a method suitable for vertical expansion and contraction of Kubernetes namespace. The method allocates resource quotas when creating Namespace; creates a vertical expansion and contraction policy for Namespace; updates the Namespace quota according to the vertical expansion and contraction policy for Namespace; determines whether the actual CPU and Memory are expanded or contracted; if exceeded, expands and expands to the expected threshold; if less than the contraction threshold, contracts and contracts to the expected threshold. Based on the native HPA of Kubernetes, the Namespace vertical expansion and contraction indicators (CPU and Memory) are configured separately, and the expansion or contraction indicator Namespace quota can be configured separately for regulation; and the resource expansion and contraction sensitivity function is added. The present invention also provides a system suitable for elastic expansion and contraction of Kubernetes single cluster applications. Real-time monitoring of the resource usage of Namespace. When the application is at a resource peak or resource valley, the resource quota of the Namespace is automatically expanded or contracted according to the scheduling strategy. Dynamic scheduling and management of Namespace quotas are realized, effectively improving the utilization rate of cluster resources and the horizontal scaling capability of Pods.
[0100] In order to better illustrate the technical effect of the present invention, the present invention provides the following specific embodiments to illustrate the above technical process:
[0101] Embodiment 1: A method for vertical scaling of Kubernetes namespaces, first creating resource quotas for each Namespace and monitoring them according to a preset vertical scaling strategy. The scaling strategy includes monitoring the usage of CPU and memory. Once it is found that the preset threshold is exceeded, the system will automatically expand or shrink until the resource usage reaches the expected ideal state.
[0102] The present invention aims to realize intelligent scheduling and dynamic management of resource quotas of multiple Namespaces, thereby optimizing the utilization efficiency of cluster resources. Compared with the traditional static resource allocation method, the present invention can flexibly respond to the dynamic fluctuation of business load, automatically adjust the resource quota of Namespace through resource sharing, priority scheduling and dual trigger mechanism, and realize elastic scaling in Kubernetes environment.
[0103] 1. Cross-Namespace Resource Sharing and Preemption Scheduling Mechanism
[0104] In the present invention, each Namespace in the cluster is no longer isolated. In order to solve the problem of resource competition between multiple Namespaces, the present invention designs a global resource pool concept to allow dynamic resource sharing between different Namespaces.
[0105] The system divides the resource quota of each Namespace into two parts:
[0106] Basic quota: This part of resources is used to meet the minimum requirements of the namespace and is always allocated without being affected by preemption from other namespaces.
[0107] Elastic quota: When the load of a Namespace is low, its unused elastic quota will be recycled into the global resource pool for other Namespaces to dynamically obtain when needed.
[0108] By introducing a preemptive scheduling mechanism, a high-priority Namespace can temporarily obtain the elastic quota of a low-priority Namespace when resources are scarce, ensuring that key businesses are given priority in resource support. This mechanism allows resources in the cluster to be scheduled flexibly and efficiently, avoiding resource waste and performance bottlenecks.
[0109] 2. Scheduling with dynamic priority weights
[0110] To achieve more accurate resource allocation, this paper introduces a dynamic priority weight calculation algorithm. Each Namespace is assigned a dynamic priority weight, and the system adjusts the weight in real time based on the following three aspects:
[0111] Importance: System administrators can set higher priorities for certain key namespaces in advance so that they can be expanded first when resources are tight, ensuring resource supply for critical tasks.
[0112] Real-time load: The system monitors the CPU and memory usage of each Namespace. The priority weight of the Namespace with higher load will be automatically increased to ensure that more resources are available during peak load periods.
[0113] Historical usage records: Based on the past resource usage of a Namespace, the system will gradually increase the future priority of the Namespace based on the frequency of its resource requests and the history of over-quota usage, so that it can be expanded first during subsequent load peaks.
[0114] Through this dynamic priority scheduling mechanism, the system can effectively prevent resources from being tilted towards certain namespaces for a long time, and prevent inefficient namespaces from continuously occupying a large amount of resources. This mechanism ensures the fairness and flexibility of resource allocation and improves the overall operation efficiency of the cluster.
[0115] 3. Double trigger expansion and contraction mechanism
[0116] The present invention proposes a capacity expansion and contraction method based on a dual trigger mechanism to cope with the dynamic changes in Namespace load. The dual trigger mechanism includes:
[0117] Prediction trigger: Based on the historical resource usage data of the Namespace, the system uses a time series prediction model to predict future load demand and adjust the quota for the Namespace in advance. Before the peak load period arrives, the system will expand the resources of the Namespace based on the prediction results to shorten the response time when the Pod is started or when resources are insufficient.
[0118] Real-time load triggering: When the actual load suddenly surges and exceeds the predicted resource demand, the system can respond quickly through the real-time monitoring module and apply for additional elastic resources from the global resource pool to ensure that the load can be processed in time and avoid system performance degradation.
[0119] Through the dual trigger mechanism, the system can achieve a combination of advance planning and rapid response, effectively cope with complex and changing business loads, and improve the flexibility and accuracy of resource management.
[0120] 4. Eco-friendly cooling mechanism and protection period
[0121] In order to avoid the adverse effects of frequent expansion and contraction operations on system stability, the present invention also designs a set of cooling mechanisms and protection period strategies. When the system detects that the Namespace has undergone multiple expansion and contraction operations in a short period of time, the system will enter a cooling period. During the cooling period, the system will increase the threshold for expansion and contraction triggering to avoid frequent resource fluctuations that lead to system instability.
[0122] At the same time, after large-scale expansion operations, the system will delay resource recovery operations to prevent performance problems caused by premature resource release when the load fluctuates. This cooling mechanism can significantly reduce resource jitter caused by frequent expansion and contraction operations and improve system stability and reliability.
[0123] 5. Resource sharing based on priority weights
[0124] In high-load scenarios, the present invention allows multiple Namespaces to share the global resource pool in the cluster. Through the dynamic priority scheduling mechanism, the system can dynamically allocate elastic resources according to the weight of each Namespace, ensuring that important businesses and tasks can be given priority in resource allocation during peak load periods.
[0125] 6. The overall operation process of the system
[0126] First, the system allocates a basic quota to each Namespace and manages unused elastic quotas through a global resource pool.
[0127] Then, the system dynamically schedules resources based on the load, priority weight, and historical resource usage records of each Namespace. During peak load periods, the system will temporarily allocate resources from low-priority Namespaces through a preemptive scheduling mechanism to ensure that tasks in high-priority Namespaces run smoothly.
[0128] The system uses a dual trigger mechanism to achieve early prediction and real-time response to future loads, ensuring the accuracy and timeliness of expansion and contraction operations. At the same time, the cooling mechanism effectively avoids frequent resource fluctuations and ensures the stability of cluster operation.
[0129] 7. Consider HPA
[0130] When the application CPU increases rapidly in a short period of time, HPA will use Pod to quickly expand the capacity, and the corresponding resource usage rate will immediately reach the threshold, or even exceed the resource quota, so that the application may not be able to respond to business changes (the newly created Pod cannot be started), so the speed of quota expansion must be guaranteed to be faster than HPA. This situation is taken into account in step 4. If the direct expansion cannot be allocated, there is no need to wait to increase the quota immediately to ensure that HPA can get resources as soon as possible.
[0131] 8. Resource pool exhaustion
[0132] By default, the upper limit of the resource pool is calculated during capacity planning, but there is still a probability that the resource pool will be exhausted. If the namespace resources reach the threshold, but the resource pool has no resources to provide expansion, if no priority is set, the namespace will no longer be expanded until another namespace is reduced to free up resources. If there is a namespace with a low priority, the low-priority namespace will be forced to shrink and the current namespace will be expanded.
[0133] This embodiment effectively solves the problem of low efficiency in traditional manual management of Namespace resource allocation, and can intelligently adjust the resource usage of each Namespace to ensure the rationality and flexibility of resource allocation while avoiding resource waste.
[0134] With the rapid development of cloud computing and containerization technologies, especially Kubernetes as a mainstream container orchestration platform, resource management and scheduling have become key issues to ensure efficient operation of the system. Existing scaling technologies are mostly applied to horizontal or vertical expansion of a single Pod or service level, but these methods are difficult to solve the resource competition and isolation requirements between multiple namespaces in complex cloud environments.
[0135] The algorithm of this embodiment has the following advantages:
[0136] Proactive capacity expansion: Use historical data prediction to avoid resource shortages when load suddenly arrives.
[0137] Resource sharing and preemption mechanism: Through the global resource pool, idle resources can be dynamically shared between namespaces to improve resource utilization.
[0138] Intelligent priority scheduling: Dynamically adjusts the priority based on the importance, load, and historical behavior of the Namespace to ensure that critical Namespaces get resources first.
[0139] Cooling mechanism: protects the system from instability caused by frequent expansion and contraction, and ensures smooth operation of the system.
[0140] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the modules, modules or units is only a logical function division, and there may be other division methods in actual implementation, for example, multiple units, modules or components can be combined or integrated into another device, or some features can be ignored or not executed.
[0141] The units may or may not be physically separated, and the components displayed as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0142] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0143] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part, and / or installed from a removable medium. When the computer program is executed by the central processing unit (CPU), the above-mentioned functions defined in the method of the present invention are executed. It should be noted that the above-mentioned computer-readable medium of the present invention can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, but not limited to, a system, device or device of an electrical, magnetic, optical, electromagnetic, infrared segment, or semiconductor, or any combination of the above.
[0144] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession 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 square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0145] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A method suitable for vertical expansion and contraction of Kubernetes namespace, characterized in that: include: Allocate resource quotas to Namespace; Set the Namespace vertical expansion and contraction strategy; Monitor the actual resource usage of Namespace; Update the resource quota of the Namespace based on the actual resource usage of the Namespace and the vertical scaling policy.
2. The method for vertical expansion and contraction of a Kubernetes namespace according to claim 1, characterized in that: Setting the Namespace vertical scaling policy includes the following steps: Generate a vertical scaling policy associated with the Namespace according to user needs or predefined rules; the vertical scaling policy includes a scaling threshold, a scaling threshold, and a scaling instance range.
3. The method for vertical expansion and contraction of Kubernetes namespace according to claim 2, characterized in that: Update the resource quota of the Namespace based on the actual resource usage of the Namespace and the vertical scaling policy. The specific steps include: Monitor the actual resource usage of Namespace and obtain monitoring indicators; When the monitoring indicator exceeds the expansion threshold, the resource quota is expanded according to the scaling instance range; When the monitoring indicator is lower than the scaling-in threshold, the resource quota is scaled down according to the scaling instance range.
4. The method for vertical expansion and contraction of Kubernetes namespace according to claim 3, characterized in that: The following steps are also included: Set the priority for Namespace; When the resource quota of a Namespace needs to be expanded, the Namespace is used as the Namespace to be expanded to determine whether the resources in the resource pool are sufficient. If there are sufficient resources in the resource pool, the resource quota of the namespace to be extended is extended according to the scope of the scaling instance; If the resources in the resource pool are insufficient, determine whether there are other namespaces with a lower priority than the namespace to be expanded. If there are other namespaces with lower priorities than the namespace to be expanded, the resource quota of the corresponding low-priority namespaces will be reduced according to the scaling instance scope until the resources in the resource pool are sufficient, and then the resource quota of the namespace to be expanded will be expanded according to the scaling instance scope.
5. The method for vertical expansion and contraction of a Kubernetes namespace according to claim 4, characterized in that: The vertical expansion and contraction strategy also includes a stable window, an expansion rate strategy and a contraction rate strategy; When the monitoring indicator exceeds the expansion threshold all the time within the set stability window, the number of instances is increased according to the expansion rate strategy. When the monitoring indicator remains below the scaling-in threshold within the set stability window, the number of instances is reduced according to the scaling-in rate policy.
6. The method for vertical expansion and contraction of Kubernetes namespace according to claim 5, characterized in that: Allocating resource quotas to a Namespace includes the following steps: Based on the prediction algorithm and historical data, a resource quota is set for each Namespace; the resource quota includes CPU and memory resource quotas.
7. The method for vertical expansion and contraction of Kubernetes namespace according to claim 6, characterized in that: Maximum expansion calculation formula: Maximum CPU expansion ratio = (total CPU resources of the resource pool to which the namespace belongs - total CPU resources of other namespaces under the resource pool) / total CPU resources of the namespace * 100% Maximum memory expansion ratio = (total memory resources of the resource pool to which the namespace belongs - total memory resources of other namespaces under the resource pool) / total memory resources of the namespace * 100% Capacity expansion limit = project resource pool quota - total resource allocation of other Namespaces except this Namespace.
8. The method for vertical expansion and contraction of Kubernetes namespace according to claim 7, characterized in that: The resource quota is not less than the minimum quota.
9. The method for vertical expansion and contraction of Kubernetes namespace according to claim 8, characterized in that: The following steps are also included: When the resource consumption of a Namespace approaches its resource quota, an alarm message is sent to remind the administrator to take action.
10. A system suitable for vertical expansion and contraction of Kubernetes namespace, used to implement the method suitable for vertical expansion and contraction of Kubernetes namespace as described in any one of claims 1-9, characterized in that: include: Resource quota allocation module, used to allocate resource quota to Namespace; The scaling setting module is used to set the Namespace vertical scaling strategy; The monitoring module is used to monitor the actual resource usage of the Namespace; The scheduling module is used to update the resource quota of the Namespace according to the actual resource usage of the Namespace and the vertical scaling policy.
Citation Information
Cited By
Method and device for automatically expanding Kubernetes static Pod
CN121255366A