Stateful application cluster control method and equipment

CN120029714APending Publication Date: 2025-05-23RUIJIE NETWORKS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311575081.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-23
Publication Date
2025-05-23

AI Technical Summary

Technical Problem

When stateful application cluster changes, the binding relationship between the instance and the persistent volume causes most instances to be unable to be enabled, affecting the availability of stateful applications.

Method used

By removing the order identification of instances in a stateful application cluster, changing the target node and instance in response to the cluster change instruction, and calling multiple instances when receiving the call instruction to avoid the binding problem between the instance and the persistent volume.

Benefits of technology

It effectively avoids the problem that most instances cannot be enabled due to binding of instances and persistent volumes, and reduces application service jitter, ensuring the availability of stateful applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120029714A_ABST
    Figure CN120029714A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of cloud computing, discloses a stateful application cluster control method and equipment, and is used for solving the problem that the availability of stateful applications is affected due to the fact that most instances cannot be enabled when a cluster is changed in the related technology. According to the embodiment of the invention, the sequence identifier of the instance of the stateful application cluster is removed, the target node in the stateful application cluster and the target instance running based on the target node are changed in response to the cluster change instruction when the cluster is changed, and if the calling instruction is received, the target instance running based on the target node is called. And if yes, calling a plurality of instances of the stateful applications in the stateful application cluster. According to the embodiment of the invention, the problem that most instances cannot be started due to binding of the instances and the persistent volume when the stateful application cluster is changed is avoided, meanwhile, the problem that service jitter exists in the application due to binding of the instances and the persistent volume is avoided, and the availability of the stateful application is guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of cloud computing technology, and in particular to a stateful application cluster control method and device. Background Art

[0002] In the related technology, the stateful application cluster management method can meet the needs of stateful applications for stable fixed identification and persistent storage. However, when the cluster is changed and upgraded, due to the order between the instance Pods of the stateful application cluster and the binding of the local persistent volumes (Local Persistent Volumes, local_pv) of the instances and nodes, changes in nodes and instances may cause most instances to be unable to be enabled. If most instances are not started, the application service will be unavailable, thereby affecting the availability of the stateful application.

[0003] Stateful applications refer to applications that require persistent data, such as databases, distributed caches, and message queues.

[0004] Pod is the smallest deployable computing unit that can be created and managed in Kubernetes. Summary of the invention

[0005] The purpose of each embodiment of the present application is to provide a stateful application cluster control method and device to solve the problem in the related art that when the cluster is changed, most instances may not be enabled, thereby affecting the availability of the stateful application.

[0006] In a first aspect, the present application provides a stateful application cluster control method, the method comprising:

[0007] In response to a cluster change instruction, a target node in a stateful application cluster and a target instance running based on the target node are changed; wherein the stateful application cluster includes a plurality of nodes; each of the plurality of nodes has an instance of a stateful application running based on the node, and the instance of the stateful application corresponding to each node does not include a sequence identifier; the target node is one of the plurality of nodes;

[0008] If a calling instruction is received, multiple instances of the stateful application in the stateful application cluster are called.

[0009] In a possible implementation, if the stateful application cluster is a localized storage cluster; in response to the cluster change instruction, changing the target node in the stateful application cluster and the target instance running based on the target node includes:

[0010] If the cluster change instruction is a cluster extension instruction, then in response to the cluster extension instruction, a first extension node and a first extension instance running based on the first extension node are generated in the stateful application cluster, and the first extension instance is bound to a local persistent volume; the local persistent volume is in a binding relationship with the first extension node;

[0011] Alternatively, if the cluster change instruction is a cluster shrinking instruction, then in response to the cluster shrinking instruction, the first target deletion node in the stateful application cluster and the first target deletion instance running based on the first target deletion node are deleted.

[0012] In a possible implementation, if the stateful application cluster is a distributed storage cluster; in response to the cluster change instruction, changing the target node in the stateful application cluster and the target instance running based on the target node includes:

[0013] If the cluster change instruction is a cluster extension instruction, then in response to the cluster extension instruction, a second extension node and a second extension instance running based on the second extension node are generated in the stateful application cluster, and the second extension instance is bound to a persistent volume; there is no binding relationship between the persistent volume and the second extension node;

[0014] Alternatively, if the cluster change instruction is a cluster shrinking instruction, then in response to the cluster shrinking instruction, a second target deletion node in the stateful application cluster and a second target deletion instance running based on the second target deletion node are deleted.

[0015] In a possible implementation, the method further includes:

[0016] In response to the cluster upgrade or downgrade instruction, respectively obtain the instance type corresponding to each instance in the multiple instances;

[0017] According to the instance type corresponding to each instance and the preset upgrade and upgrade order corresponding to each instance type, multiple nodes in the stateful application cluster and multiple instances running based on the multiple nodes are upgraded and upgraded.

[0018] In a possible implementation, the instance types include master instances and slave instances; the preset upgrade and downgrade order includes: first upgrading and downgrading the instances whose instance types are slave instances and the corresponding nodes, and then upgrading and downgrading the instances whose instance types are master instances and the corresponding nodes.

[0019] In a possible implementation, the calling of multiple instances of the stateful application in the stateful application cluster includes:

[0020] Obtaining an instance type corresponding to each of a plurality of instances of a stateful application in the stateful application cluster;

[0021] The calling instance is a primary instance.

[0022] An instance whose instance type is a master instance calls an instance whose instance type is a slave instance, so as to implement the calling of multiple instances of a stateful application.

[0023] In a possible implementation, the stateful application cluster includes a controller; the controller is used to name the instance using a preset naming format so that the instance does not contain a sequence identifier.

[0024] In a second aspect, the present application provides a stateful application cluster control method.

[0025] Applied to a stateful application cluster, the stateful application cluster includes an application controller, the application controller includes multiple instance controllers, each of the multiple nodes corresponds to an instance controller, the method includes:

[0026] In response to a cluster change instruction, the target node and the target instance running based on the target node are changed through the target instance controller corresponding to the target node; each of the nodes has an instance of a stateful application running based on the node, the target node is one of the multiple nodes; the target instance controller is one of the multiple instance controllers;

[0027] If a calling instruction is received, multiple instances of the stateful application in the stateful application cluster are called through the multiple instance controllers.

[0028] In a third aspect, the present application provides a stateful application cluster control device, the device comprising:

[0029] A cluster change module is configured to change a target node in a stateful application cluster and a target instance running based on the target node in response to a cluster change instruction; wherein the stateful application cluster includes a plurality of nodes; each of the plurality of nodes has an instance of a stateful application running based on the node, and the instance of the stateful application corresponding to each node does not contain a sequence identifier; the target node is one of the plurality of nodes;

[0030] The cluster calling module is configured to call multiple instances of the stateful application in the stateful application cluster if a calling instruction is received.

[0031] In a possible implementation, if the stateful application cluster is a localized storage cluster; in response to the cluster change instruction, the target node in the stateful application cluster and the target instance running based on the target node are changed, and the cluster change module is configured as follows:

[0032] If the cluster change instruction is a cluster extension instruction, then in response to the cluster extension instruction, a first extension node and a first extension instance running based on the first extension node are generated in the stateful application cluster, and the first extension instance is bound to a local persistent volume; the local persistent volume is in a binding relationship with the first extension node;

[0033] Alternatively, if the cluster change instruction is a cluster shrinking instruction, then in response to the cluster shrinking instruction, the first target deletion node in the stateful application cluster and the first target deletion instance running based on the first target deletion node are deleted.

[0034] In a possible implementation, if the stateful application cluster is a distributed storage cluster; in response to the cluster change instruction, the target node in the stateful application cluster and the target instance running based on the target node are changed, and the cluster change module is configured as follows:

[0035] If the cluster change instruction is a cluster extension instruction, then in response to the cluster extension instruction, a second extension node and a second extension instance running based on the second extension node are generated in the stateful application cluster, and the second extension instance is bound to a persistent volume; there is no binding relationship between the persistent volume and the second extension node;

[0036] Alternatively, if the cluster change instruction is a cluster shrinking instruction, then in response to the cluster shrinking instruction, a second target deletion node in the stateful application cluster and a second target deletion instance running based on the second target deletion node are deleted.

[0037] In a possible implementation manner, the method device further includes a cluster upgrading and downgrading module configured to:

[0038] In response to the cluster upgrade or downgrade instruction, respectively obtain the instance type corresponding to each instance in the multiple instances;

[0039] According to the instance type corresponding to each instance and the preset upgrade and upgrade order corresponding to each instance type, multiple nodes in the stateful application cluster and multiple instances running based on the multiple nodes are upgraded and upgraded.

[0040] In a possible implementation, the instance types include master instances and slave instances; the preset upgrade and downgrade order includes: first upgrading and downgrading the instances whose instance types are slave instances and the corresponding nodes, and then upgrading and downgrading the instances whose instance types are master instances and the corresponding nodes.

[0041] In a possible implementation, the calling of multiple instances of the stateful application in the stateful application cluster, the cluster calling module is configured as follows:

[0042] Obtaining an instance type corresponding to each of a plurality of instances of a stateful application in the stateful application cluster;

[0043] The calling instance is a primary instance.

[0044] An instance whose instance type is a master instance calls an instance whose instance type is a slave instance, so as to implement the calling of multiple instances of a stateful application.

[0045] In a possible implementation, the stateful application cluster includes a controller; the controller is used to name the instance using a preset naming format so that the instance does not contain a sequence identifier.

[0046] In a fourth aspect, the present application provides a stateful application cluster control device, which is applied to a stateful application cluster, wherein the stateful application cluster includes an application controller, the application controller includes multiple instance controllers, each of the multiple nodes corresponds to an instance controller, and the device includes:

[0047] A second cluster change module is configured to change the target node and the target instance running based on the target node through the target instance controller corresponding to the target node in response to the cluster change instruction; each of the nodes has an instance of a stateful application running based on the node, the target node is one of the multiple nodes; the target instance controller is one of the multiple instance controllers;

[0048] The second cluster calling module is configured to call multiple instances of the stateful application in the stateful application cluster through the multiple instance controllers if a calling instruction is received.

[0049] In a fifth aspect, the present application provides an electronic device, including:

[0050] Processor and memory;

[0051] The memory is used to store executable instructions of the processor;

[0052] The processor is used to execute the executable instructions to implement the stateful application cluster control method as described in the first aspect and the second aspect.

[0053] In a sixth aspect, the present application provides a computer-readable storage medium. When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device can execute the stateful application cluster control method as described in the first and second aspects above.

[0054] In a seventh aspect, the present application provides a computer program product, including a computer program:

[0055] When the computer program is executed by a processor, the stateful application cluster control method described in the first aspect and the second aspect is implemented.

[0056] The technical solution provided in the first aspect of the embodiment of the present application brings at least the following beneficial effects:

[0057] In the embodiment of the present application, the instances of the stateful application cluster do not include sequential identifiers. When the stateful application cluster is changed, the problem of the majority of instances being unable to be enabled due to the binding of the instances to the persistent volumes is avoided. At the same time, the problem of service jitter in the application due to the binding of the instances to the persistent volumes is avoided, thereby ensuring the availability of the stateful application.

[0058] The technical solution provided in the second aspect of the embodiment of the present application brings at least the following beneficial effects:

[0059] In the embodiment of the present application, multiple instances of a stateful application cluster are controlled one-to-one through multiple instance controllers. When the stateful application cluster is changed, the problem of most instances being unable to be enabled due to the binding of instances to persistent volumes is avoided. At the same time, the problem of service jitter in the application due to the binding of instances to persistent volumes is avoided, thereby ensuring the availability of stateful applications.

[0060] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. Obviously, the drawings introduced below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0062] Figure 1A schematic diagram of a stateful application cluster using local storage in the related technology provided in an embodiment of the present application;

[0063] Figure 2 A schematic diagram of a stateful application cluster using distributed storage in the related technology provided in an embodiment of the present application;

[0064] Figure 3 A schematic diagram of a stateful application cluster using local storage to perform cluster changes in the related technology provided in an embodiment of the present application;

[0065] Figure 4 A schematic diagram of a stateful application cluster using distributed storage to perform cluster changes in the related technology provided in an embodiment of the present application;

[0066] Figure 5 A schematic diagram of a stateful application cluster using local storage to upgrade or downgrade a cluster in the related technology provided in an embodiment of the present application;

[0067] Figure 6 A schematic diagram of the overall process of the stateful application cluster control method provided in the embodiment of the present application;

[0068] Figure 7 A schematic diagram of a stateful application cluster using local storage provided in an embodiment of the present application;

[0069] Figure 8 A schematic diagram of a stateful application cluster using distributed storage provided in an embodiment of the present application;

[0070] Fig. 9 A schematic diagram of the process of performing cluster upgrade and downgrade in the stateful application cluster control method provided in the embodiment of the present application;

[0071] Fig.10 A schematic diagram of the process of cluster calling for the stateful application cluster control method provided in an embodiment of the present application;

[0072] Fig.11 Another flowchart of the stateful application cluster control method provided in the embodiment of the present application;

[0073] Fig.12 A schematic diagram of a stateful application cluster provided for an embodiment of the present application including three instance controllers;

[0074] Fig.13 A schematic diagram of the structure of a stateful application cluster control device 1300 provided in an embodiment of the present application;

[0075] Fig.14 A schematic diagram of the structure of a stateful application cluster control device 1400 provided in an embodiment of the present application;

[0076] Fig.15 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0077] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Among them, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0078] Furthermore, in the description of the embodiments of the present application, unless otherwise specified, “ / ” means or. For example, A / B can mean A or B. The “and / or” in the text is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, “multiple” refers to two or more than two.

[0079] In the following, the terms "first" and "second" are used for descriptive purposes only and should not be understood as suggesting or implying relative importance or implicitly indicating the number of technical features indicated. Thus, features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present application, unless otherwise specified, "multiple" means two or more.

[0080] The following is an explanation of the relevant terms or devices involved in the embodiments of the present application:

[0081] Stateful applications: applications that require persistent data, such as databases, distributed caches, message queues, etc.

[0082] Kubernetes: Also known as K8s, it is an open source system for automatically deploying, scaling, and managing containerized applications. PaaS: Platform as a service.

[0083] Pvc: abbreviation of PersistentVolumeClaim, which means a persistent volume declaration.

[0084] Pv: Persistent Volumes, short for persistent volumes.

[0085] local_pv: short for Local Persistent Volumes.

[0086] Pod: A Pod is the smallest deployable computing unit that can be created and managed in Kubernetes, i.e., an instance in this application.

[0087] StatefulSet: StatefulSet is a workload API object used to manage stateful applications. StatefulSet is used to manage the deployment and scaling of a set of Pods and provide persistent storage and persistent identifiers for these Pods.

[0088] Headless Service: Each Endpoint of the Headless Service, that is, each Pod, will have a corresponding DNS domain name, so that the Pods can access each other.

[0089] At present, container technology has solved the problem of underlying resource supply and spawned the cloud-native trend. As Kubernetes becomes the de facto standard for container orchestration, the scalability of application platforms built on Kubernetes continues to be enriched, and more capabilities are being transferred to the infrastructure, making it possible for applications to be lightweight and migrate to the cloud. With the empowerment of cloud-native technology, more and more stateful applications are being deployed to the cloud (such as public clouds, private clouds, and hybrid clouds). Stateful applications are provided to the outside world in a PaaS-based, out-of-the-box form, which simplifies the deployment and management of stateful applications, facilitates the expansion and contraction of stateful applications, and reduces the development and operation costs of users.

[0090] Considering the dynamic nature of container Pods, the primary consideration in the process of migrating stateful applications to the cloud is how to deploy and manage stateful applications in the cloud.

[0091] In related technologies, stateful application cluster instances (Pods, i.e. instances) have the following characteristics:

[0092] 1) There are dependent topological relationships between instances, such as master-slave relationships, which requires that the identity of the application instance is stable and unique.

[0093] 2) Support data storage, which requires the instance to support docking with different, stable, and persistent storage.

[0094] In response to the above two requirements, Kubernetes provides the StatefulSet controller to manage stateful applications. StatefulSet has the following capabilities:

[0095] 1. Stable, unique network identifier.

[0096] 2. Stable and persistent storage.

[0097] 3. Orderly and rapid deployment and expansion.

[0098] 4. Orderly and automatic rolling updates.

[0099] For the deployment of stateful application clusters, in related technologies, a custom resource is generally developed based on Operator, and the custom resource uses a StatefulSet controller to implement the formation of stateful application clusters. The overall structure of the stateful application cluster docking with local storage and distributed storage is as follows: Figure 1 and Figure 2 shown.

[0100] Based on the structure of the above stateful application cluster, the technical solution of using the StatefulSet controller to manage the stateful application cluster has the following problems:

[0101] 1) When stateful applications use local storage, there are scenarios where service instances cannot be started when nodes are deleted or replicas are scaled down. For services that ensure high data availability, if most instances are not started, the service will be unavailable. Figure 3 As shown, there is a binding relationship between the instance Pod and the local persistent volume local_pv, and there is a binding relationship between local_pv and the node node. In this way, the binding of Pod-->local_pv-->node is completed, so that the Pod is still scheduled to the original node when it is rescheduled, and the data of the stateful application is not lost. However, when the node node-B is deleted and the instance is reduced by 1, since the instances of StatefulSet are expanded in order, the instance sts-pod-2 with the largest sequence number will be destroyed first. The instance sts-pod-1 will be destroyed first and then rescheduled to the node node-C due to the deletion of the node node-B. Since the instance sts-pod-1 is bound to the local_pv of the node node-B and cannot use the local_pv of the node node-C, the instance sts-pod-1 will not be able to start. In addition, deleting the node node-B will cause 2 of the 3 instances of the application to fail to start. For stateful applications that ensure data consistency, the application will be unavailable if most instances are not started.

[0102] 2) When stateful applications use distributed storage, the service can eventually return to the running state when nodes are deleted and instances are scaled down. However, the pods will be rebuilt during the instance scaling down, which affects the service availability. Figure 4As shown in the figure, the three instances run on different nodes and connect to the distributed storage through related protocols. When the node node-B is deleted and the instance is reduced by 1, the instance sts-pod-2 will be destroyed. Due to the deletion of the node node-B, the instance sts-pod-1 will be rescheduled to the node node-C after the destruction. Since the persistent volume storing data is not bound to a specific node at this time, the sts-pod-1 on the node node-C can still use pv1 through related protocols. In summary, when StatefulSet uses distributed storage, cluster changes can ensure the ultimate availability of the application. However, due to the destruction and reconstruction of the instance during the change, the entire stateful application has service jitter.

[0103] 3) The instance Pod under the StatefulSet controller can only be upgraded or downgraded according to the Pod sequence number, and cannot be upgraded or downgraded according to the role instance type (including master / replicas) of the application itself in the Pod. Therefore, there is a scenario where the master instance is upgraded or downgraded multiple times during the upgrade or downgrade process, which in turn affects the service availability. Figure 5 As shown in the figure, since the rolling update is performed according to the Pod sequence number, the instance sts-pod-2 will be updated first. Since the instance type in sts-pod-2 is master at this time, the entire stateful application will enter the master re-election state at this time, and the entire stateful application will be unavailable. By analogy, if sts-pod-1 is the master after the re-election, then when sts-pod-2 is updated and sts-pod-1 is updated, it will cause the entire application to be unavailable. In summary, the entire upgrade process will generate a maximum of 3 master re-elections (related to the number of instances), that is, the application will be unavailable for 3 times during the entire upgrade process (the single duration is related to the specific application master election time).

[0104] In view of this, the present application provides a stateful application cluster control method and device to solve the problem in the related art that when the cluster is changed, most instances may not be enabled, thereby affecting the availability of the stateful application.

[0105] The inventive concept of the present application can be summarized as follows: removing the sequential identification of the instances of the stateful application cluster, and when the cluster is changed, in response to the cluster change instruction, changing the target node in the stateful application cluster and the target instance running based on the target node, and if a call instruction is received, calling multiple instances of the stateful application in the stateful application cluster. When the stateful application cluster is changed, the problem of the inability to enable most instances due to the binding of instances to persistent volumes is avoided, and the problem of service jitter in the application due to the binding of instances to persistent volumes is avoided, thereby ensuring the availability of the stateful application.

[0106] After introducing the main inventive ideas of the embodiments of the present application, the following briefly introduces the application scenarios to which the technical solutions of the embodiments of the present application can be applied. It should be noted that the application scenarios introduced below are only used to illustrate the embodiments of the present application and are not limited. In specific implementation, the technical solutions provided by the embodiments of the present application can be flexibly applied according to actual needs.

[0107] To facilitate understanding of the stateful application cluster control method provided in the embodiment of the present application, it is further described below with reference to the accompanying drawings.

[0108] In a possible implementation, the present application provides a stateful application cluster control method, the process of which is as follows: Figure 6 As shown, including the following:

[0109] In step 601, in response to a cluster change instruction, changes are made to a target node in a stateful application cluster and a target instance running based on the target node; wherein the stateful application cluster includes multiple nodes; each of the multiple nodes has an instance of a stateful application running based on the node, and the instance of the stateful application corresponding to each node does not contain a sequential identifier; the target node is one of the multiple nodes.

[0110] Cluster change instructions include cluster expansion instructions and cluster reduction instructions. Cluster expansion instructions are used to increase the number of nodes and instances in a cluster, and cluster reduction instructions are used to reduce the number of nodes and instances in a cluster.

[0111] In step 602, if a calling instruction is received, multiple instances of the stateful application in the stateful application cluster are called.

[0112] In one possible implementation, the node node provides an application environment for the instance pod, but there is no necessary binding relationship. The instance pod can run on any node; the instance pod is equivalent to the startup component of the stateful application, and the persistent volume PV is used to store the data of the stateful application. The instance pod and the persistent volume PV are strongly bound to each other. Only when the instance pod and the persistent volume PV are available at the same time, the data in the persistent volume PV can be called through the instance pod to realize the normal calling and running of the stateful application.

[0113] In a possible implementation, if the stateful application cluster is a localized storage cluster, such as Figure 7 As shown, the stateful application cluster includes an application controller, which corresponds to an instance controller. In the embodiment of the present application, the application controller uses a preset naming format to name the instance, such as Figure 7The preset naming format is sts-uuid, and the names of the three instances are sts-uuid1-0, sts-uuid2-0, and sts-uuid3-0, respectively. The numbers in the instance names do not indicate the order, so that the instances do not contain sequential identifiers, that is, the instances run independently and there is no sequential association relationship, so that when the cluster is changed, the node and the instance running based on the node can be changed at the same time. Based on the above stateful application cluster, in step 601, in response to the cluster change instruction, the target node in the stateful application cluster and the target instance running based on the target node are changed, which can be implemented as follows:

[0114] If the cluster change instruction is a cluster extension instruction, in response to the cluster extension instruction, a first extension node and a first extension instance running based on the first extension node are generated in the stateful application cluster, and the first extension instance is bound to the local persistent volume.

[0115] It should be noted that there is a binding relationship between the local persistent volume and the first extension node.

[0116] For example, the first extension node is Figure 7 If the node is node-C, the first extended instance is instance sts-uuid3-0, which runs based on node node-C and is bound to the local persistent volume local-pv-2, and local-pv-2 is bound to the first extended node node-C.

[0117] If the cluster change instruction is a cluster shrinking instruction, then in response to the cluster shrinking instruction, the first target deletion node in the stateful application cluster and the first target deletion instance running based on the first target deletion node are deleted.

[0118] For example, the first target deletion node is Figure 7 For node node-B in the example, since there is no sequential identifier for the instance, the embodiment of the present application can delete the instance sts-uuid2-0 as the first target deletion instance.

[0119] In another possible implementation, if the stateful application cluster is a distributed storage cluster, such as Figure 8 As shown, the stateful application cluster includes an application controller, which corresponds to an instance controller. In the embodiment of the present application, the application controller uses a preset naming format to name the instance, such as Figure 8 The preset naming format is sts-uuid, and the names of the three instances are sts-uuid1-0, sts-uuid2-0, and sts-uuid3-0, respectively. The numbers in the instance names do not indicate the order, so that the instances do not contain sequential identifiers, and there is no binding relationship between the persistent volume and the second node.

[0120] Based on the above stateful application cluster, in step 601, in response to the cluster change instruction, the target node in the stateful application cluster and the target instance running based on the target node are changed, which can be implemented as follows:

[0121] If the cluster change instruction is a cluster extension instruction, in response to the cluster extension instruction, a second extension node and a second extension instance running based on the second extension node are generated in all state application clusters, and the second extension instance is bound to the persistent volume.

[0122] For example, the second extension node is Figure 8 If the node is node-C, the second extended instance is instance sts-uuid3-0, which runs based on node node-C and is bound to the persistent volume pv-2, and there is no binding relationship between pv-2 and the second extended node node-C.

[0123] If the cluster change instruction is a cluster shrinking instruction, then in response to the cluster shrinking instruction, the second target deletion node in the stateful application cluster and the second target deletion instance running based on the second target deletion node are deleted.

[0124] It should be noted that the above Figure 7 and Figure 8 The application controller in is the new application controller StatefulCluster, which inherits the stable unique network identifier and stable persistent storage properties of StatefulSet while adding unordered instances. Figure 7 and Figure 8 The application controller in may also be another new application controller, which is used to name the instance with a fixed name when forming a stateful application cluster.

[0125] For example, the second target node to be deleted is Figure 8 For node node-B, since the instance does not have a sequential identifier, the embodiment of the present application can delete the instance sts-uuid2-0 as the second target deletion instance.

[0126] In a possible implementation manner, the process of upgrading and downgrading a stateful application cluster in the embodiment of the present application is as follows: Fig. 9 As shown, including the following:

[0127] In step 901, in response to a cluster upgrade or downgrade instruction, the instance type corresponding to each instance in a plurality of instances is obtained respectively.

[0128] Cluster upgrade and downgrade instructions include cluster upgrade instructions and cluster downgrade instructions. The cluster upgrade instruction is used to upgrade the version of the application in the stateful cluster to a newer version, and the cluster downgrade instruction is used to downgrade the version of the application in the stateful cluster to a version before the current version.

[0129] In step 902, multiple nodes in the stateful application cluster and multiple instances running on the multiple nodes are upgraded or downgraded according to the instance type corresponding to each instance and the preset upgrade or downgrade order corresponding to each instance type.

[0130] In a possible implementation, the instance types include master instances and slave instances, and the preset upgrade and downgrade order includes: first upgrading and downgrading the instances whose instance type is slave instances and the corresponding nodes, and then upgrading and downgrading the instances whose instance type is master instances and the corresponding nodes.

[0131] For example, Figure 7 and Figure 8 The instance types of instance sts-uuid2-0 are all replicas, that is, slave instances, and the instance types of instance sts-uuid3-0 are all masters, that is, master instances. In this embodiment of the application, instance sts-uuid1-0 and instance sts-uuid2-0 will be upgraded or downgraded first, and then instance sts-uuid3-0 will be upgraded or downgraded.

[0132] The above steps of upgrading and downgrading instances according to instance types reduce the unavailability time during the rolling update of the stateful application cluster, reduce the application jitter during the rolling update of the stateful application cluster, and improve the overall availability of the stateful application.

[0133] In a possible implementation, multiple instances of a stateful application in a stateful application cluster are called, such as Fig.10 As shown, it can be implemented as:

[0134] In step 1001, an instance type corresponding to each of a plurality of instances of a stateful application in a stateful application cluster is obtained.

[0135] In step 1002, an instance whose instance type is a primary instance is called.

[0136] In step 1003, an instance whose instance type is a master instance calls an instance whose instance type is a slave instance, so as to implement calling of multiple instances of the stateful application.

[0137] For example, for Figure 7In the stateful application cluster, in order to realize the calling of multiple instances of the stateful application, the embodiment of the present application will first call the instance sts-uuid3-0, and then call the instances sts-uuid1-0 and sts-uuid2-0 through the instance sts-uuid3-0.

[0138] It should be noted that communication between instance Pods is implemented through a Headless Service, so that the embodiment of the present application can achieve communication between Pods while controlling Pod disorder.

[0139] To sum up, in the embodiment of the present application, the instance of the stateful application cluster does not include a sequential identifier. When the stateful application cluster is changed, the problem of the majority of instances being unable to be enabled due to the binding of the instances to the persistent volumes is avoided. At the same time, the problem of service jitter in the application due to the binding of the instances to the persistent volumes is avoided, thereby ensuring the availability of the stateful application.

[0140] In another possible implementation, the present application provides a stateful application cluster control method, which is applied to a stateful application cluster. The stateful application cluster includes an application controller, and the application controller includes multiple instance controllers. Each of the multiple nodes corresponds to an instance controller. The process is as follows: Fig.11 As shown, including the following:

[0141] In step 1101, in response to a cluster change instruction, the target node and the target instance running based on the target node are changed through the target instance controller corresponding to the target node; each node has an instance of a stateful application running based on the node, and the target node is one of multiple nodes; the target instance controller is one of multiple instance controllers.

[0142] In step 1102, if a calling instruction is received, multiple instances of the stateful application in the stateful application cluster are called through multiple instance controllers.

[0143] like Fig.12 As shown, the stateful application cluster includes three instance controllers, namely instance controller 1, instance controller 2 and instance controller 3. The three instance controllers control node 1, node 2 and node 3 respectively. The three instances run based on the three nodes respectively. If the target node is node 1, node 1 and instance 1 are deleted through instance controller 1.

[0144] It should be added that the instance of the stateful application corresponding to each node contains a sequential identifier, that is, there is a sequential association relationship between the instances controlled by the same instance controller. However, the present application uses multiple instance controllers to perform one-to-one control of multiple instances of the stateful application cluster. Therefore, there is no sequential association relationship between the instances controlled by different instance controllers.

[0145] To summarize, in the embodiments of the present application, multiple instances of a stateful application cluster are controlled one-to-one through multiple instance controllers. When the stateful application cluster is changed, the problem of most instances being unable to be enabled due to the binding of instances to persistent volumes is avoided. At the same time, the problem of service jitter in the application due to the binding of instances to persistent volumes is avoided, thereby ensuring the availability of stateful applications.

[0146] Based on the same inventive concept, the present application also provides a stateful application cluster control device, such as Fig.13 As shown, the device 1300 includes:

[0147] The cluster change module 1301 is configured to change the target node in the stateful application cluster and the target instance running based on the target node in response to the cluster change instruction; wherein the stateful application cluster includes multiple nodes; each of the multiple nodes has an instance of a stateful application running based on the node, and the instance of the stateful application corresponding to each node does not contain a sequence identifier; the target node is one of the multiple nodes;

[0148] The cluster calling module 1302 is configured to call multiple instances of the stateful application in the stateful application cluster upon receiving a calling instruction.

[0149] In a possible implementation, if the stateful application cluster is a localized storage cluster; in response to the cluster change instruction, the target node in the stateful application cluster and the target instance running based on the target node are changed, and the cluster change module is configured as follows:

[0150] If the cluster change instruction is a cluster extension instruction, then in response to the cluster extension instruction, a first extension node and a first extension instance running based on the first extension node are generated in the stateful application cluster, and the first extension instance is bound to a local persistent volume; the local persistent volume is in a binding relationship with the first extension node;

[0151] Alternatively, if the cluster change instruction is a cluster shrinking instruction, then in response to the cluster shrinking instruction, the first target deletion node in the stateful application cluster and the first target deletion instance running based on the first target deletion node are deleted.

[0152] In a possible implementation, if the stateful application cluster is a distributed storage cluster; in response to the cluster change instruction, the target node in the stateful application cluster and the target instance running based on the target node are changed, and the cluster change module is configured as follows:

[0153] If the cluster change instruction is a cluster extension instruction, then in response to the cluster extension instruction, a second extension node and a second extension instance running based on the second extension node are generated in the stateful application cluster, and the second extension instance is bound to a persistent volume; there is no binding relationship between the persistent volume and the second extension node;

[0154] Alternatively, if the cluster change instruction is a cluster shrinking instruction, then in response to the cluster shrinking instruction, a second target deletion node in the stateful application cluster and a second target deletion instance running based on the second target deletion node are deleted.

[0155] In a possible implementation manner, the method device further includes a cluster upgrading and downgrading module configured to:

[0156] In response to the cluster upgrade or downgrade instruction, respectively obtain the instance type corresponding to each instance in the multiple instances;

[0157] According to the instance type corresponding to each instance and the preset upgrade and upgrade order corresponding to each instance type, multiple nodes in the stateful application cluster and multiple instances running based on the multiple nodes are upgraded and upgraded.

[0158] In a possible implementation, the instance types include master instances and slave instances; the preset upgrade and downgrade order includes: first upgrading and downgrading the instances whose instance types are slave instances and the corresponding nodes, and then upgrading and downgrading the instances whose instance types are master instances and the corresponding nodes.

[0159] In a possible implementation, the calling of multiple instances of the stateful application in the stateful application cluster, the cluster calling module is configured as follows:

[0160] Obtaining an instance type corresponding to each of a plurality of instances of a stateful application in the stateful application cluster;

[0161] The calling instance is a primary instance.

[0162] An instance whose instance type is a master instance calls an instance whose instance type is a slave instance, so as to implement the calling of multiple instances of a stateful application.

[0163] In a possible implementation, the stateful application cluster includes a controller; the controller is used to name the instance using a preset naming format so that the instance does not contain a sequence identifier.

[0164] Based on the same inventive concept, the present application also provides a stateful application cluster control device, which is applied to a stateful application cluster. The stateful application cluster includes multiple controllers, and each of the multiple nodes corresponds to a controller, such as Fig.14 As shown, the device 1400 includes:

[0165] The second cluster change module 1401 is configured to change the target node and the target instance running on the target node through the target controller corresponding to the target node in response to the cluster change instruction; each of the nodes has an instance of a stateful application running on the node, the target node is one of the multiple nodes; the target controller is one of the multiple controllers;

[0166] The second cluster calling module 1402 is configured to call multiple instances of the stateful application in the stateful application cluster through the multiple controllers if a calling instruction is received.

[0167] like Fig.15 As shown, the electronic device 130 is in the form of a general electronic device. The components of the electronic device 130 may include but are not limited to: the at least one processor 131, the at least one memory 132, and a bus 133 connecting different system components (including the memory 132 and the processor 131).

[0168] Bus 133 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a processor, or a local bus using any of a variety of bus architectures.

[0169] The memory 132 may include a readable medium in the form of a volatile memory, such as a random access memory (RAM) 1321 and / or a cache memory 1322 , and may further include a read-only memory (ROM) 1323 .

[0170] The memory 132 may also include a program / utility 1325 having a set (at least one) of program modules 1324, such program modules 1324 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.

[0171] The electronic device 130 may also communicate with one or more external devices 134 (e.g., keyboards, pointing devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 130, and / or communicate with any device that enables the electronic device 130 to communicate with one or more other electronic devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 135. Furthermore, the electronic device 130 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 136. As shown, the network adapter 136 communicates with other modules for the electronic device 130 via a bus 133. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 130, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0172] In an exemplary embodiment, the present application further provides a computer-readable storage medium including instructions, such as a memory 132 including instructions, and the above instructions can be executed by the processor 131 of the electronic device 130 to complete the above stateful application cluster control method. Optionally, the computer-readable storage medium can be a non-temporary computer-readable storage medium, for example, the non-temporary computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0173] In an exemplary embodiment, a computer program product is also provided, including a computer program, and when the computer program is executed by the processor 131, the stateful application cluster control method provided in the present application is implemented.

[0174] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0175] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0176] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0177] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0178] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A stateful application cluster control method, It is characterized in that The method comprises: In response to a cluster change instruction, a target node in a stateful application cluster and a target instance running based on the target node are changed; wherein the stateful application cluster includes a plurality of nodes; each of the plurality of nodes has an instance of a stateful application running based on the node, and the instance of the stateful application corresponding to each node does not include a sequence identifier; the target node is one of the plurality of nodes; If a calling instruction is received, multiple instances of the stateful application in the stateful application cluster are called.

2. The method according to claim 1, It is characterized in that If the stateful application cluster is a localized storage cluster; The step of changing the target node in the stateful application cluster and the target instance running based on the target node in response to the cluster change instruction includes: If the cluster change instruction is a cluster extension instruction, in response to the cluster extension instruction, generating a first extension node and a first extension instance running based on the first extension node in the stateful application cluster, and binding the first extension instance to a local persistent volume; The local persistent volume is bound to the first extension node; Alternatively, if the cluster change instruction is a cluster shrinking instruction, then in response to the cluster shrinking instruction, the first target deletion node in the stateful application cluster and the first target deletion instance running based on the first target deletion node are deleted.

3. The method according to claim 1, It is characterized in that If the stateful application cluster is a distributed storage cluster; The step of changing the target node in the stateful application cluster and the target instance running based on the target node in response to the cluster change instruction includes: If the cluster change instruction is a cluster extension instruction, in response to the cluster extension instruction, generating a second extension node and a second extension instance running based on the second extension node in the stateful application cluster, and binding the second extension instance to a persistent volume; There is no binding relationship between the persistent volume and the second extension node; Alternatively, if the cluster change instruction is a cluster shrinking instruction, then in response to the cluster shrinking instruction, a second target deletion node in the stateful application cluster and a second target deletion instance running based on the second target deletion node are deleted.

4. The method according to claim 1, It is characterized in that The method further comprises: In response to the cluster upgrade or downgrade instruction, respectively obtain the instance type corresponding to each instance in the multiple instances; According to the instance type corresponding to each instance and the preset upgrade and upgrade order corresponding to each instance type, multiple nodes in the stateful application cluster and multiple instances running based on the multiple nodes are upgraded and upgraded.

5. The method according to claim 4, It is characterized in that The instance types include master instances and slave instances; The preset upgrade and downgrade sequence includes: first upgrading and downgrading the instance whose instance type is a slave instance and the corresponding node, and then upgrading and downgrading the instance whose instance type is a master instance and the corresponding node.

6. The method according to claim 1, It is characterized in that The calling of multiple instances of the stateful application in the stateful application cluster includes: Obtaining an instance type corresponding to each of a plurality of instances of a stateful application in the stateful application cluster; The calling instance is a primary instance. An instance whose instance type is a master instance calls an instance whose instance type is a slave instance, so as to implement the calling of multiple instances of a stateful application.

7. The method according to claim 1, It is characterized in that The stateful application cluster includes a controller; the controller is used to name the instance using a preset naming format so that the instance does not contain a sequence identifier.

8. A stateful application cluster control method, It is characterized in that Applied to a stateful application cluster, the stateful application cluster includes an application controller, the application controller includes multiple instance controllers, each of the multiple nodes corresponds to an instance controller, the method includes: In response to a cluster change instruction, the target node and the target instance running based on the target node are changed through the target instance controller corresponding to the target node; each of the nodes has an instance of a stateful application running based on the node, the target node is one of the multiple nodes; the target instance controller is one of the multiple instance controllers; If a calling instruction is received, multiple instances of the stateful application in the stateful application cluster are called through the multiple instance controllers.

9. A device, It is characterized in that include: Processor and memory; The memory is used to store the processor executable instructions; The processor is configured to execute the instructions to implement the stateful application cluster control method according to any one of claims 1 to 8.

10. A computer-readable storage medium, It is characterized in that When the instructions in the computer-readable storage medium are executed by a processor of a device, the device is enabled to execute the stateful application cluster control method according to any one of claims 1 to 8.