A method and device for realizing cross-cluster container quantity elastic scaling
By initializing distributed scaling service instances in multiple Kubernetes clusters and maintaining a mapping table using the Raft protocol, elastic scaling of the number of containers across clusters is achieved, solving the problem of limited resource scheduling in existing technologies and improving the availability and load balancing of application systems.
Patent Information
- Application Number
- CN202111141780.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-28
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2041-09-28
AI Technical Summary
Existing technologies lack a mechanism for elastic scaling of container numbers across clusters, resulting in limited resource scheduling. Application availability and elastic scaling are limited to a single cluster, failing to meet disaster recovery requirements and traffic demands.
A cross-cluster container number elastic scaling method under a distributed architecture is adopted. Multiple scaling service instances are initialized in multiple Kubernetes clusters. The Raft protocol is used to maintain a mapping table to perform cross-cluster container number scaling. A weighted average calculation is performed based on monitoring metrics and preset thresholds to ensure a reasonable replica number configuration.
It improves the automation of container scaling when business systems are deployed in multiple clusters, ensuring that application systems always have appropriate capacity to meet current traffic demands and achieve load balancing and reliability.
Smart Images

Figure CN113867957B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of cloud-native technology, and in particular, to a method and apparatus for elastic scaling of the number of containers across clusters based on a distributed architecture in a cloud-native Kubernetes environment. Background Technology
[0002] With the advancement of enterprise digital transformation, cloud-native has become an important engine driving business growth. As the de facto industry standard for cloud-native applications, Kubernetes (hereinafter referred to as k8s) provides an efficient and unified management mechanism for the containerized deployment, overall planning, construction, and upgrade of enterprise resource applications.
[0003] Currently, the simultaneous deployment and operation of multiple Kubernetes clusters is unavoidable. On the one hand, hybrid cloud or multi-cloud architectures necessitate multiple clusters; on the other hand, if there is only one cluster and it fails, all services will be affected. However, resource scheduling, application availability, and elastic scaling are currently limited by the cluster, and there is no mechanism for elastic scaling of the number of containers across clusters.
[0004] Therefore, how can we better improve the availability of business systems while meeting disaster recovery requirements, and ensure that application systems always have appropriate capacity to meet current traffic demands? Summary of the Invention
[0005] In view of the problems mentioned above, this application provides a method and apparatus for elastic scaling of the number of containers across clusters, which can improve the availability of business systems while meeting disaster recovery requirements and ensure that application systems always have appropriate capacity to meet current traffic demands.
[0006] To achieve the above objectives, this application provides the following technical solution:
[0007] A method for elastic scaling of containers across clusters involves initializing multiple scaling service instances into multiple Kubernetes clusters to form a distributed cluster. A leader scaling service instance provides an API with a list of applications to be processed and corresponding scaling strategies. The leader scaling service instance maintains a mapping table in memory between the applications to be processed and the scaling service instances executing the tasks, and updates the mapping table to a Raft database. The method includes:
[0008] The API of the leader scaling service instance is invoked to configure the application to be scaled and the corresponding scaling strategy; the leader scaling service instance dispatches scaling tasks to other scaling service instances;
[0009] The instance executing the scaling task obtains the monitoring metrics of the application in its cluster from the monitoring service, performs a weighted average based on the number of replicas, and calculates the comprehensive metric value.
[0010] Instances executing the scaling task determine whether the comprehensive index value is within a preset scaling threshold range;
[0011] When the comprehensive index value is not within the preset scaling threshold range, the reasonable number of replicas in each cluster is calculated based on the preset weight of each cluster and the maximum and minimum values of the number of replicas.
[0012] An instance executing the scaling task calls the API of the scaling strategy to scale the number of replicas of the application to be processed in the corresponding cluster.
[0013] Furthermore, the API configuration of the scaling service instance in the leader role requires scaling applications and corresponding scaling strategies, including:
[0014] Based on the preset application and the corresponding scaling policy, the scaling service instance of the leader role determines the node that executes the scaling task of the preset application, and calls the configuration API to dispatch the scaling task to the corresponding node.
[0015] Furthermore, the instance executing the scaling task obtains the monitoring metrics of the application in its cluster from the monitoring service, performs a weighted average based on the number of replicas, and calculates a comprehensive metric value, including:
[0016] Based on the scaling service instance dispatched by the scaling task, the average value of monitoring indicators within a specified time period is obtained from the monitoring service of each cluster where the application is deployed. The monitoring indicator values are weighted and averaged according to the number of replicas to calculate the comprehensive indicator value.
[0017] Furthermore, it also includes:
[0018] After each scaling operation, a cooldown period is set for the application, during which no further elastic scaling is performed to avoid excessive fluctuations in the number of replicas.
[0019] A device for elastic scaling of containers across clusters initializes multiple scaling service instances into multiple Kubernetes clusters to form a distributed cluster. A leader scaling service instance provides an API with a list of applications to be processed and corresponding scaling strategies. The leader scaling service instance maintains a mapping table in memory between the applications to be processed and the scaling service instances executing the tasks, and updates the mapping table to a Raft database. The device includes:
[0020] The first processing unit is used to call the API of the scaling service instance in the leader role to configure the application to be scaled and the corresponding scaling strategy; the scaling service instance in the leader role dispatches the scaling task to other scaling service instances;
[0021] The second processing unit is used to execute the instance of the scaling task to obtain the monitoring metrics of the application in its cluster from the monitoring service, and calculate the comprehensive metric value by weighting the average based on the number of replicas.
[0022] The third processing unit is used to perform an instance determination of the scaling task to determine whether the comprehensive index value is within a preset scaling threshold range;
[0023] The fourth processing unit is used to calculate the reasonable number of replicas in each cluster based on the preset weights of each cluster and the maximum and minimum values of the number of replicas when the comprehensive index value is not within the preset scaling threshold range.
[0024] The fifth processing unit is used to execute instances of the scaling task, call the API of the scaling strategy, and scale the number of replicas of the application to be processed in the corresponding cluster.
[0025] Furthermore, the first processing unit is specifically used for:
[0026] Based on the preset application and the corresponding scaling policy, the scaling service instance of the leader role determines the node that executes the scaling task of the preset application, and calls the configuration API to dispatch the scaling task to the corresponding node.
[0027] Furthermore, the second processing unit is specifically used for:
[0028] Based on the scaling service instance dispatched by the scaling task, the average value of monitoring indicators within a specified time period is obtained from the monitoring service of each cluster where the application is deployed. The monitoring indicator values are weighted and averaged according to the number of replicas to calculate the comprehensive indicator value.
[0029] Furthermore, it also includes:
[0030] The sixth processing unit is used to set a cooling period for the application after performing a scaling operation. During the cooling period, no further elastic scaling is performed to avoid excessive fluctuations in the number of replicas.
[0031] A storage medium comprising a stored program, wherein, when the program is executed, the device on which the storage medium resides executes the cross-cluster container elastic scaling implementation method as described above.
[0032] An electronic device includes at least one processor, at least one memory and a bus connected to the processor; wherein the processor and the memory communicate with each other through the bus; the processor is used to call program instructions in the memory to execute the cross-cluster container elastic scaling implementation method as described above.
[0033] The cross-cluster container elastic scaling method and apparatus described in this application configures the applications to be scaled and the corresponding scaling strategies by calling the API of a scaling service instance in the leader role; the leader scaling service instance dispatches scaling tasks to other scaling service instances; the instances executing the scaling tasks obtain monitoring metrics of the applications in their respective clusters from the monitoring service, calculate a comprehensive metric value by performing a weighted average based on the number of replicas; when the comprehensive metric value is not within a preset scaling threshold range, the instances executing the scaling tasks calculate a reasonable number of replicas in each cluster based on the preset weights of each cluster and the maximum and minimum values of the number of replicas; the instances executing the scaling tasks call the API of the scaling strategy to scale the number of replicas of the application to be processed in the corresponding cluster. This application improves the availability of business systems while meeting disaster recovery requirements, ensuring that application systems always have appropriate capacity to meet current traffic demands. Attached Figure Description
[0034] To more clearly illustrate the technical solutions in the embodiments of this application 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 this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0035] Figure 1 This is a schematic diagram of a method for implementing elastic scaling of the number of containers across a cluster, as disclosed in an embodiment of this application.
[0036] Figure 2 This is a schematic diagram of the component structure disclosed in an embodiment of this application;
[0037] Figure 3 This is a flowchart illustrating the new scaling strategy disclosed in the embodiments of this application;
[0038] Figure 4 This is a flowchart illustrating the change scaling strategy disclosed in an embodiment of this application;
[0039] Figure 5 This is a flowchart illustrating the deletion scaling strategy disclosed in an embodiment of this application;
[0040] Figure 6This is a schematic diagram of a device for implementing elastic scaling of the number of containers across a cluster, as disclosed in an embodiment of this application.
[0041] Figure 7 This is a schematic diagram of the structure of an electronic device disclosed in an embodiment of this application. Detailed Implementation
[0042] This application provides a method and apparatus for elastic scaling of container numbers across clusters. Its design concept stems from the increasing focus on BIA (Business Impact Analysis) metrics for critical application systems in cloud-native environments during enterprise cloud-native transformation. Simultaneous deployment and operation of applications across multiple clusters has become unavoidable. However, existing elastic scaling technologies for container numbers are all single-cluster-based, lacking cross-cluster elastic scaling capabilities.
[0043] This application implements cross-cluster container elastic scaling based on the Raft protocol's distributed architecture, effectively improving the automation of container scaling when the business system is deployed in multiple clusters, ensuring that the application system always has appropriate capacity to meet current traffic demands; the distributed architecture implementation also guarantees the reliability of the scaling service; at the same time, multiple scaling service instances can perform elastic scaling detection and implementation of the application in parallel, achieving load balancing to a certain extent.
[0044] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0045] Please see the appendix Figure 1 This is a schematic diagram illustrating a method for elastic scaling of the number of containers across a cluster, provided in an embodiment of this application. Figure 1 As shown in the figure, this application embodiment provides a method for implementing elastic scaling of the number of containers across clusters. First, multiple scaling service instances are initialized into multiple Kubernetes clusters to form a distributed cluster, as follows: Figure 2 As shown; the leader scaling service instance provides an API with a list of pending applications and corresponding scaling strategies; the leader scaling service instance maintains a mapping table in memory between the pending applications and the scaling service instances executing the tasks, and updates the mapping table to the Raft database. This method includes the following steps:
[0046] S101: Call the API of the scaling service instance in the leader role to configure the application to be scaled and the corresponding scaling strategy; the scaling service instance in the leader role dispatches the scaling task to other scaling service instances; the instance executing the scaling task obtains the monitoring metrics of the application in its cluster from the monitoring service, performs a weighted average based on the number of replicas, and calculates the comprehensive metric value.
[0047] like Figure 2 As shown, the scaling service system in this embodiment uses the Raft protocol to ensure data consistency. Raft is a leader-follower type consensus protocol. There is only one leader in the cluster, and all transaction requests are handled by the leader. The leader consults with the followers to reach a consensus within the cluster and decides whether to execute the transaction. When the leader fails, the followers in the cluster elect a new leader through voting to maintain cluster operation.
[0048] The application includes namespace and deployment name, scaling policy is the weight of the number of POD replicas in each cluster, minimum and maximum number of replicas, and threshold of application monitoring metrics.
[0049] It's important to note that external system calls to the scaling service's API require an application with auto-scaling capabilities and corresponding scaling strategies. The instance acting as the Leader is responsible for updating configuration data. Upon receiving this request, the Follower instance forwards it to the Leader's service. The Leader instance updates its local data and synchronizes it to the Follower instances using the Raft protocol, ensuring data consistency.
[0050] In this step, based on the received application list and corresponding scaling policies, the scaling service instance in the Leader role determines the node to execute the scaling task for that application and calls the API to dispatch the task to the appropriate node. The scaling service instance in the Leader role maintains a mapping table between applications and the scaling service instances executing the tasks and updates it in the Raft database.
[0051] It's important to note that the leader scaling service instance is responsible for maintaining a mapping table in memory between applications and the instances executing scaling tasks. Related processing includes: when the Raft protocol detects that a scaling task instance has left the cluster or is in a faulty state, the applications handled by that instance are reassigned to other scaling service instances; when an application is deleted, the corresponding scaling instance is notified to stop the scaling task for that application. The list of applications handled by each scaling instance is periodically polled and compared with the currently maintained in-memory mapping table to ensure data consistency in the mapping table.
[0052] S102: The instance executing the scaling task obtains the monitoring metrics of the application in its cluster from the monitoring service, performs a weighted average based on the number of replicas, and calculates the comprehensive metric value.
[0053] In this step, the scaling service instance that receives the task dispatch periodically obtains the average value of monitoring metrics within a specified time period from the monitoring service (such as Prometheus) of each cluster where the application is deployed. Then, after obtaining the monitoring metric values of the application in each cluster, a weighted average is calculated based on the number of replicas and the metric values to obtain the comprehensive metric value of the application.
[0054] S103: Execute the instance of the scaling task to determine whether the comprehensive index value is within the preset scaling threshold range.
[0055] S104: When the comprehensive index value is not within the preset scaling threshold range, the reasonable number of replicas in each cluster is calculated based on the preset weight of each cluster and the maximum and minimum values of the number of replicas.
[0056] In steps S103 and S104, the instance executing the scaling task determines whether the above comprehensive index value is within the specified scaling threshold range. If it exceeds the threshold, the reasonable number of replicas in each cluster is calculated based on the set weights and the minimum and maximum values of the replica count, and the subsequent step S105 is executed. If not, the next cycle continues.
[0057] S105: Execute the instance of the scaling task, call the API of the scaling strategy, and scale the number of replicas of the application to be processed in the corresponding cluster.
[0058] In this embodiment of the application, when a role switch occurs in the cluster, the newly switched instance as the leader performs the following processing: reading application scaling policy data from the Raft database; polling each normal scaling service instance to obtain the application list responsible for each instance; performing a differential comparison between the obtained application list and the application list obtained from the database to construct a mapping table; if there is an application that is not responsible for by any scaling instance, it is assigned to the instance with the least load.
[0059] It should be noted that the methods for implementing elastic scaling of the number of containers across clusters, such as... Figures 3-5 As shown, this can include adding scaling policies, changing scaling policies, and deleting scaling policies.
[0060] S106: After performing a scaling operation, a cooling-off period is set for the application. During this cooling-off period, no further elastic scaling is performed to avoid excessive fluctuations in the number of replicas.
[0061] This application provides a method for elastic scaling of containers across clusters. It involves configuring the application to be scaled and the corresponding scaling strategy by calling the API of a leader scaling service instance. The leader instance dispatches scaling tasks to other scaling service instances. Instances executing the scaling tasks obtain monitoring metrics of the application in their respective clusters from a monitoring service, calculate a comprehensive metric value by performing a weighted average based on the number of replicas. When the comprehensive metric value is outside a preset scaling threshold range, the instance executing the scaling task calculates a reasonable number of replicas in each cluster based on the preset weights of each cluster and the maximum and minimum replica counts. Finally, the instance executing the scaling task calls the API of the scaling strategy to scale the number of replicas of the application to be processed in the corresponding cluster. This application can improve the availability of business systems while meeting disaster recovery requirements, ensuring that application systems always have appropriate capacity to meet current traffic demands.
[0062] Please see Figure 6 Based on the cross-cluster container elastic scaling implementation method disclosed in the above embodiments, this embodiment correspondingly discloses a cross-cluster container elastic scaling implementation device. Multiple scaling service instances are initialized into multiple Kubernetes clusters to form a distributed cluster. The scaling service instance in the leader role provides an API with a list of applications to be processed and corresponding scaling strategies. The leader scaling service instance is used to maintain a mapping table between the applications to be processed and the scaling service instances executing tasks in memory, and to update the mapping table to the Raft database. The device includes:
[0063] The first processing unit 601 is used to call the API of the scaling service instance in the leader role to configure the application that needs to be scaled and the corresponding scaling strategy; the scaling service instance in the leader role dispatches the scaling task to other scaling service instances;
[0064] The second processing unit 602 is used to execute the instance of the scaling task to obtain the monitoring indicators of the application in the cluster from the monitoring service, and calculate the comprehensive indicator value by weighting the average based on the number of replicas.
[0065] The third processing unit 603 is used to perform an instance determination of the scaling task to determine whether the comprehensive index value is within a preset scaling threshold range.
[0066] The fourth processing unit 604 is used to calculate the reasonable number of replicas in each cluster based on the preset weight of each cluster and the maximum and minimum values of the number of replicas when the comprehensive index value is not within the preset scaling threshold range.
[0067] The fifth processing unit 605 is used to execute an instance of the scaling task, call the API of the scaling strategy, and scale the number of replicas of the application to be processed in the corresponding cluster.
[0068] Furthermore, the first processing unit 601 is specifically used for:
[0069] Based on the preset application and the corresponding scaling policy, the scaling service instance of the leader role determines the node that executes the scaling task of the preset application, and calls the configuration API to dispatch the scaling task to the corresponding node.
[0070] Furthermore, the second processing unit 602 is specifically used for:
[0071] Based on the scaling service instance dispatched by the scaling task, the average value of monitoring indicators within a specified time period is obtained from the monitoring service of each cluster where the application is deployed. The monitoring indicator values are weighted and averaged according to the number of replicas to calculate the comprehensive indicator value.
[0072] Furthermore, the device also includes:
[0073] The sixth processing unit 606 is used to set a cooling period for the application after performing a scaling operation. During the cooling period, no more elastic scaling is performed to avoid excessive fluctuations in the number of replicas.
[0074] The cross-cluster container elastic scaling implementation device includes a processor and a memory. The first processing unit, the second processing unit, the third processing unit, the fourth processing unit, the fifth processing unit, and the sixth processing unit are all stored in the memory as program units. The processor executes the program units stored in the memory to implement the corresponding functions.
[0075] The processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured, and by adjusting kernel parameters, the availability of the business system can be improved while meeting disaster recovery requirements, ensuring that the application system always has adequate capacity to meet current traffic demands.
[0076] This application provides a storage medium storing a program that, when executed by a processor, implements the method for elastic scaling of the number of containers across a cluster.
[0077] This application provides a processor for running a program, wherein the program executes the method for elastic scaling of the number of containers across a cluster.
[0078] This application provides an electronic device, such as... Figure 7As shown, the electronic device 70 includes at least one processor 701, and at least one memory 702 and bus 703 connected to the processor; wherein the processor 701 and the memory 702 communicate with each other through the bus 703; the processor 701 is used to call program instructions in the memory 702 to execute the above-described cross-cluster container number elastic scaling implementation method.
[0079] The electronic devices mentioned in this article can be servers, PCs, tablets, mobile phones, etc.
[0080] This application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program that initializes the following method steps:
[0081] The API of the leader scaling service instance is invoked to configure the application to be scaled and the corresponding scaling strategy; the leader scaling service instance dispatches scaling tasks to other scaling service instances;
[0082] The instance executing the scaling task obtains the monitoring metrics of the application in its cluster from the monitoring service, performs a weighted average based on the number of replicas, and calculates the comprehensive metric value.
[0083] Instances executing the scaling task determine whether the comprehensive index value is within a preset scaling threshold range;
[0084] When the comprehensive index value is not within the preset scaling threshold range, the reasonable number of replicas in each cluster is calculated based on the preset weight of each cluster and the maximum and minimum values of the number of replicas.
[0085] An instance executing the scaling task calls the API of the scaling strategy to scale the number of replicas of the application to be processed in the corresponding cluster.
[0086] Furthermore, the API configuration of the scaling service instance in the leader role requires scaling applications and corresponding scaling strategies, including:
[0087] Based on the preset application and the corresponding scaling policy, the scaling service instance of the leader role determines the node that executes the scaling task of the preset application, and calls the configuration API to dispatch the scaling task to the corresponding node.
[0088] Furthermore, the instance executing the scaling task obtains the monitoring metrics of the application in its cluster from the monitoring service, performs a weighted average based on the number of replicas, and calculates a comprehensive metric value, including:
[0089] Based on the scaling service instance dispatched by the scaling task, the average value of monitoring indicators within a specified time period is obtained from the monitoring service of each cluster where the application is deployed. The monitoring indicator values are weighted and averaged according to the number of replicas to calculate the comprehensive indicator value.
[0090] Furthermore, it also includes:
[0091] After each scaling operation, a cooldown period is set for the application, during which no further elastic scaling is performed to avoid excessive fluctuations in the number of replicas.
[0092] This application is described with flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowcharts and / or block diagrams, and combinations of blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create a machine for implementing the flowcharts and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0093] In a typical configuration, the device includes one or more processors (CPUs), memory, and a bus. The device may also include input / output interfaces, network interfaces, etc.
[0094] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, like read-only memory (ROM) or flash RAM, and memory includes at least one memory chip. Memory is an example of computer-readable media.
[0095] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0096] It should also be noted that 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 process, method, article, or apparatus. Unless otherwise specified, 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 that element.
[0097] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0098] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A method for elastically scaling the number of containers across a cluster, characterized in that, Multiple scaling service instances are initialized into multiple Kubernetes clusters to form a distributed cluster. One Kubernetes cluster initializes a leader scaling service instance, while other Kubernetes clusters initialize follower scaling service instances. The leader scaling service instance provides an API with a list of applications to be processed and corresponding scaling strategies. The leader scaling service instance maintains a mapping table in memory between the applications to be processed and the scaling service instances executing the tasks, and updates the mapping table to the Raft database. This method includes: The API of the leader scaling service instance is invoked to configure the application to be scaled and the corresponding scaling strategy; the leader scaling service instance dispatches scaling tasks to other scaling service instances; Based on the scaling service instance dispatched by the scaling task, the average value of monitoring indicators within a specified time period is obtained from the monitoring service of each cluster where the application is deployed at regular intervals. The average value of the monitoring indicators is weighted according to the number of replicas to calculate the comprehensive indicator value. Instances executing the scaling task determine whether the comprehensive index value is within a preset scaling threshold range; When the comprehensive index value is not within the preset scaling threshold range, the reasonable number of replicas in each cluster is calculated based on the preset weight of each cluster and the maximum and minimum values of the number of replicas. An instance executing the scaling task calls the API of the scaling strategy to scale the number of replicas of the application to be processed in the corresponding cluster.
2. The method according to claim 1, characterized in that, The API configuration for calling the scaling service instance in the leader role includes the application to be scaled and the corresponding scaling strategy, including: Based on the application that needs to be scaled and the corresponding scaling strategy, the scaling service instance of the leader role determines the node that will execute the scaling task of the application that needs to be scaled and dispatches the scaling task to the corresponding node.
3. The method according to claim 1, characterized in that, Also includes: After each scaling operation, a cooldown period is set for the application, during which no further elastic scaling is performed to avoid excessive fluctuations in the number of replicas.
4. A device for elastically scaling the number of containers across a cluster, characterized in that, Multiple scaling service instances are initialized into multiple Kubernetes clusters to form a distributed cluster. One Kubernetes cluster initializes a leader scaling service instance, while the other Kubernetes clusters initialize follower scaling service instances. The leader scaling service instance provides an API with a list of applications to be processed and corresponding scaling strategies. The leader scaling service instance maintains a mapping table in memory between the applications to be processed and the scaling service instances executing the tasks, and updates the mapping table to a Raft database. This apparatus includes: The first processing unit is used to call the API of the scaling service instance in the leader role to configure the application to be scaled and the corresponding scaling strategy; the scaling service instance in the leader role dispatches the scaling task to other scaling service instances; The second processing unit is used to periodically obtain the average value of monitoring indicators within a specified time period from the monitoring services of each cluster where the application is deployed, based on the scaling service instance dispatched by the scaling task; and to calculate the comprehensive indicator value by weighting the average value of the monitoring indicators according to the number of replicas. The third processing unit is used to perform an instance determination of the scaling task to determine whether the comprehensive index value is within a preset scaling threshold range; The fourth processing unit is used to calculate the reasonable number of replicas in each cluster based on the preset weights of each cluster and the maximum and minimum values of the number of replicas when the comprehensive index value is not within the preset scaling threshold range. The fifth processing unit is used to execute instances of the scaling task, call the API of the scaling strategy, and scale the number of replicas of the application to be processed in the corresponding cluster.
5. The apparatus according to claim 4, characterized in that, The first processing unit is specifically used for: Based on the application that needs to be scaled and the corresponding scaling strategy, the scaling service instance of the leader role determines the node that will execute the scaling task of the application that needs to be scaled and dispatches the scaling task to the corresponding node.
6. The apparatus according to claim 4, characterized in that, Also includes: The sixth processing unit is used to set a cooling period for the application after performing a scaling operation. During the cooling period, no further elastic scaling is performed to avoid excessive fluctuations in the number of replicas.
7. A storage medium, characterized in that, The storage medium includes a stored program, wherein, when the program is running, it controls the device where the storage medium is located to execute the cross-cluster container number elastic scaling implementation method as described in any one of claims 1 to 3.
8. An electronic device, characterized in that, The electronic device includes at least one processor, and at least one memory and bus connected to the processor; wherein the processor and the memory communicate with each other through the bus; the processor is used to call program instructions in the memory to execute the cross-cluster container elastic scaling implementation method as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Elastic expanding-shrinking method and device for container cluster
CN108762912A
Resource scheduling method and device based on kubernetes, equipment and storage medium
CN112199194A