Stateful service migration method, device and server

By determining the cluster to migrate and destination migration cluster in the container cluster, create a corresponding instance copy, and when listening to the storage volume statement, determine the target virtual storage volume, solve the problem of manual participation in the existing technology, It has achieved efficient unmanned intervention relocation.

CN114090179BActive Publication Date: 2025-01-28BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111395207.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-23
Publication Date
2025-01-28
Estimated Expiration
2041-11-23

AI Technical Summary

Technical Problem

The prior art requires manual participation in the migration process of stateful service, and the operation time is long, and the general migration solution cannot be applied to some stateful services, resulting in low migration efficiency.

Method used

By determining the migration cluster to migration clusters and the purpose of migration cluster in the container cluster, create a corresponding instance copy, and when the storage volume statement is heard, the target virtual storage volume is determined, so as to realize the migration of unmanned intervention.

Benefits of technology

The migration of state services with unmanned intervention has improved the migration efficiency, and the dependence on its own backup and recovery mechanism is avoided.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114090179B_ABST
    Figure CN114090179B_ABST
Patent Text Reader

Abstract

The present invention provides a migration method, device and server for stateful services, including: determining a cluster to be migrated and a destination migration cluster from a container cluster; wherein a storage subcluster is deployed in the cluster to be migrated, the storage subcluster includes at least one first instance replica, and the cluster to be migrated provides a stateful service for each first instance replica; creating a second instance replica corresponding to each first instance replica in the destination migration cluster; if the destination migration cluster generates a storage volume declaration corresponding to the second instance replica, determining a target virtual storage volume matching the storage volume declaration in the existing virtual storage volumes corresponding to the first instance replica, so as to provide the stateful service for each second instance replica through the destination migration cluster according to the target virtual storage volume. The present invention can complete the migration operation of the stateful service without human intervention, and can effectively improve the migration efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Internet technology, and in particular to a migration method, device and server for stateful services. Background Art

[0002] Container cluster management technology refers to providing automated deployment, automatic scaling, maintenance and other functions for containerized applications, such as the Kubernetes cluster management platform. In scenarios such as cluster resource shortage, cluster upgrade and transformation, and failover, stateful service migration operations are involved. Among them, the migration operation involves migrating the data stored in the physical storage volume of the stateful service. At present, most general migration solutions rely on the backup and recovery mechanism provided by the stateful service itself. However, there are problems such as the need for manual participation and long operation time during the migration operation. Summary of the invention

[0003] In view of this, an object of the present invention is to provide a method, device and server for migrating a stateful service, which can complete the migration operation of the stateful service without human intervention and can effectively improve the migration efficiency.

[0004] In a first aspect, an embodiment of the present invention provides, in one implementation, a method for migrating a stateful service, the method being applied to a server, the server being communicatively connected to at least one container cluster, comprising: determining a cluster to be migrated and a destination migration cluster from the container cluster; wherein a storage subcluster is deployed in the cluster to be migrated, the storage subcluster comprising at least one first instance replica, the cluster to be migrated providing a stateful service for each of the first instance replicas; creating a second instance replica corresponding to each of the first instance replicas in the destination migration cluster; if it is monitored that the destination migration cluster generates a storage volume declaration corresponding to the second instance replica, determining a target virtual storage volume matching the storage volume declaration in the existing virtual storage volumes corresponding to the first instance replica, so as to provide the stateful service for each of the second instance replicas through the destination migration cluster according to the target virtual storage volume.

[0005] In one embodiment, the server is configured with a primary storage provider, and the destination migration cluster is configured with a sub-storage provider; if it is monitored that the destination migration cluster generates a storage volume declaration corresponding to the second instance copy, the step of determining a target virtual storage volume that matches the storage volume declaration in the existing virtual storage volumes corresponding to the first instance copy includes: receiving the storage volume declaration sent by the sub-storage provider through the primary storage provider; based on the declaration identifier of the storage volume declaration, searching for a target virtual storage volume that matches the storage volume declaration in the existing virtual storage volumes corresponding to the first instance copy; wherein the target virtual storage volume includes a storage instance and an access path to the storage instance.

[0006] In one embodiment, the method further includes: if there is no target virtual storage volume matching the storage volume declaration in the existing virtual storage volumes, sending a storage volume creation request to the file storage system so that the file storage system creates a target virtual storage volume matching the storage volume declaration.

[0007] In one embodiment, after the step of determining a target virtual storage volume that matches the storage volume declaration in the existing virtual storage volumes corresponding to the first instance copy, the method further includes: establishing a binding relationship between the target virtual storage volume and the storage volume declaration; and determining the storage resources corresponding to the second instance copy based on the target virtual storage volume and the binding relationship.

[0008] In one embodiment, the step of determining the cluster to be migrated and the destination migration cluster from the container cluster includes: determining the cluster to be migrated from the container cluster, and randomly determining the destination migration cluster from the container clusters other than the cluster to be migrated.

[0009] In one embodiment, the step of creating a second instance replica in the destination migration cluster corresponding to each of the first instance replicas includes: based on the instance type of the first instance replica, creating a second instance replica in the destination migration cluster corresponding to each of the first instance replicas.

[0010] In one implementation, the method further includes: deleting the first instance copy of the storage subcluster deployed in the cluster to be migrated.

[0011] In a second aspect, an embodiment of the present invention further provides a migration device for a stateful service, the device being applied to a server, the server being communicatively connected to at least one container cluster, and comprising: a cluster determination module, for determining a cluster to be migrated and a destination migration cluster from the container cluster; wherein a storage subcluster is deployed in the cluster to be migrated, the storage subcluster comprising at least one first instance replica, the cluster to be migrated providing a stateful service for each of the first instance replicas; a replica creation module, for creating a second instance replica corresponding to each of the first instance replicas in the destination migration cluster; and a migration module, for determining a target virtual storage volume matching the storage volume declaration in the existing virtual storage volumes corresponding to the first instance replica if it is monitored that the destination migration cluster generates a storage volume declaration corresponding to the second instance replica, so as to provide the stateful service for each of the second instance replicas according to the target virtual storage volume through the destination migration cluster.

[0012] In a third aspect, an embodiment of the present invention further provides a server, comprising a processor and a memory, wherein the memory stores computer-executable instructions that can be executed by the processor, and the processor executes the computer-executable instructions to implement any one of the methods provided in the first aspect.

[0013] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement any one of the methods provided in the first aspect.

[0014] An embodiment of the present invention provides a migration method, device and server for a stateful service. First, a cluster to be migrated and a destination migration cluster are determined from a container cluster. A storage subcluster is deployed in the cluster to be migrated. The storage subcluster includes at least one first instance copy. The cluster to be migrated provides a stateful service for each first instance copy. Then, a second instance copy corresponding to each first instance copy is created in the destination migration cluster. If it is monitored that the destination migration cluster generates a storage volume declaration corresponding to the second instance copy, a target virtual storage volume matching the storage volume declaration is determined from the existing virtual storage volumes corresponding to the first instance copies, so that the stateful service is provided for each second instance copy through the destination migration cluster according to the target virtual storage volume. In the above method, a second instance copy corresponding to each first instance copy contained in the storage sub-instance is created in the destination migration cluster, and when the destination migration cluster generates a storage volume declaration corresponding to the second instance copy, a target virtual storage volume matching the storage volume declaration is determined in the existing virtual storage volume instance. The destination migration cluster can provide stateful services for the second instance copy on this basis, thereby realizing cross-cluster migration of stateful services. Compared with the physical storage method used in the prior art, the storage volumes corresponding to the instance copies in the embodiments of the present invention are all virtual storage volumes. During the stateful migration process, there is no need to rely on its own backup and recovery mechanism. By making the storage subclusters use the same virtual storage volumes before and after the stateful service is moved forward, the cross-cluster migration operation of the stateful service can be completed without human intervention, and the migration efficiency can be effectively improved.

[0015] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention are realized and obtained by the structures particularly pointed out in the description, claims and drawings.

[0016] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0018] Figure 1 A schematic diagram of a migration process of a stateful service provided in an embodiment of the present invention;

[0019] Figure 2 A schematic diagram of a container cluster architecture provided by an embodiment of the present invention;

[0020] Figure 3 A flowchart of the collaboration between StorageClass and Provisioner provided in an embodiment of the present invention;

[0021] Figure 4 A schematic diagram of another process flow of stateful service migration provided by an embodiment of the present invention;

[0022] Figure 5 A schematic diagram of the structure of a stateful service migration device provided by an embodiment of the present invention;

[0023] Figure 6 A schematic diagram of the structure of a server provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0024] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution of the present invention will be clearly and completely described in combination with the embodiments below. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0025] At present, most general migration solutions rely on the backup and recovery functions provided by the stateful service itself, such as MySQL's mysqldump (logical backup tool) and source (database import) commands. However, the backup and recovery mechanism functions are manually involved, resulting in a long stateful service migration operation time, which in turn causes the container cluster to be down for a long time. In addition, in actual applications, some services cannot support backup and recovery functions, that is, the general migration solution cannot be well applied to the migration of some stateful services. Based on this, the present invention implements a migration method, device and server for a stateful service, which can complete the cross-cluster migration operation of the stateful service without human intervention, and can effectively improve the migration efficiency.

[0026] To facilitate understanding of this embodiment, a migration method for a stateful service disclosed in an embodiment of the present invention is first described in detail. The method is applied to a server, and the server is connected to at least one container cluster for communication. Figure 1 The schematic diagram of a migration process of a stateful service is shown, and the method mainly includes the following steps S102 to S106:

[0027] Step S102, determine the cluster to be migrated and the target migration cluster from the container cluster. Among them, stateful service generally refers to a cluster service in which each instance requires independent persistent storage. The container cluster may include a Kubernetes (abbreviated as k8s) cluster. The cluster to be migrated can be understood as a container cluster that needs to be statefully migrated, and the target migration cluster can be understood as a container cluster for backing up the above-mentioned cluster to be migrated. A storage subcluster is deployed in the above-mentioned cluster to be migrated, and the storage subcluster may include one or more of a Redis Sentinel cluster, a Redis Cluster (master-slave) cluster, a MySQL (relational database management system) cluster, and an ES (ELasticSearch) cluster. In actual applications, the required storage subcluster can be deployed in the K8s cluster through StatefulSet. In addition, the above-mentioned storage subcluster includes at least one first instance (Pod) copy, and the cluster to be migrated provides a stateful service for each first instance copy. Taking the MySQL subcluster deployed in the k8s cluster as an example, 3 first instance copies are deployed in the MySQL subcluster, including: Amysql-0 Pod, Amysql-1Pod, and Amysql-2 Pod.

[0028] In one implementation, the cluster to be migrated may be a container cluster with limited cluster resources, or a container cluster that needs to be transformed and upgraded, or a container cluster that has failed. The cluster to be migrated may be selected based on actual needs, and then the target migration cluster may be determined from the remaining container clusters by random or manual designation.

[0029] Step S104, creating a second instance replica corresponding to each first instance replica in the destination migration cluster. The instance type of the second instance replica is the same as the replica type of the first instance replica. For example, if the first instance replica is of MySQL type, a second instance replica of MySQL type needs to be created in the destination migration cluster. In one embodiment, the creation of the second instance replica can be achieved by calling a related interface in the destination migration cluster.

[0030] Step S106, if the destination migration cluster is monitored to generate a storage volume declaration corresponding to the second instance replica, a target virtual storage volume matching the storage volume declaration is determined in the existing virtual storage volumes corresponding to the first instance replica, so as to provide a stateful service for each second instance replica through the destination migration cluster according to the target virtual storage volume. Among them, the storage volume declaration (PVC, Persistent Volume Claim) is used to describe the relevant information of the virtual storage volume required for the second instance replica, the virtual storage volume (PV, Persistent Volume) includes a storage instance and an access path to the storage instance, and the storage instance can be an Fs (file system, file system) instance. The existing virtual storage volume (abbreviated as existing PV) is the storage volume mounted by the first Pod replica before stateful migration, and the target virtual storage volume (abbreviated as target PV) is the storage volume mounted by the second Pod replica after stateful migration. It can be seen that the storage volumes mounted by the Pod replicas before and after stateful migration are the same, so cross-container cluster migration can be achieved. In one embodiment, when a second instance copy is created in the destination migration cluster, a corresponding PVC is generated. The sub-storage provider (Provisioner) configured in the destination migration cluster forwards the PVC to the main storage provider (Global Provisioner) configured in the server, and the Global Provisioner searches for a target PV that matches the PVC in the existing PVs.

[0031] In one implementation, the target virtual storage volume can be bound to the storage volume declaration, which is equivalent to determining the storage resources within the target virtual storage volume as the storage resources corresponding to the second replica instance. By determining the storage resources corresponding to each second instance replica, it is possible to provide stateful services for each second instance replica through the destination migration cluster.

[0032] The above-mentioned stateful service migration method provided by an embodiment of the present invention creates a second instance copy corresponding to each first instance copy contained in the storage sub-instance in the destination migration cluster, and when monitoring the destination migration cluster to generate a storage volume declaration corresponding to the second instance copy, the storage sub-cluster is migrated from the to-be-migrated cluster to the destination migration cluster by determining the target virtual storage volume matching the storage volume declaration in the existing virtual storage volume instance. Compared with the physical storage method used in the prior art, the storage volumes corresponding to the instance copies in the embodiment of the present invention are all virtual storage volumes. During the stateful migration process, there is no need to rely on its own backup and recovery mechanism. By making the storage sub-clusters use the same virtual storage volume before and after the stateful service is moved forward, the cross-cluster migration operation of the stateful service can be completed without human intervention, and the migration efficiency can be effectively improved.

[0033] To facilitate understanding of the foregoing embodiments, the embodiments of the present invention provide Figure 2 The diagram of a container cluster architecture shown in the figure includes a cluster A to be migrated and a destination migration cluster B. StorageClass with the same name is deployed in the cluster A to be migrated and the destination migration cluster B. Provisioner corresponding to the StorageClass is also deployed. Global Provisioner is deployed on the server side. Provisioner only provides proxy service for forwarding PVC generated in its container cluster to Global Provisioner. Global Provisioner is used to provide logic for allocating storage volumes.

[0034] Please continue to see Figure 2 , assuming that the storage subcluster deployed in the to-be-migrated cluster A is a MySQL subcluster, and the MySQL subcluster includes three first instance replicas: Amysql-0 Pod, Amysql-1Pod, and Amysql-2 Pod, then corresponding second instance replicas Bmysql-0 Pod, Bmysql-1 Pod, and Bmysql-2Pod will also be generated in the target migration cluster B. In addition, a virtual storage volume is provided for each instance replica through the IaaS (Infrastructure as a Service) platform, and the virtual storage volume corresponding to each replica instance is determined through Global Provisioner. For example, Amysql-0 Pod and Bmysql-0 Pod are both bound to " / data-mysql-0" in the storage instance FS-1, so that the instance replicas before and after the stateful service migration can be mounted with the same virtual storage volume.

[0035] In the aforementioned Figure 2 Based on this, the embodiments of the present invention respectively provide implementation methods of the aforementioned steps S102 to S108:

[0036] For the aforementioned step S102, when determining the cluster to be migrated and the destination migration cluster from the container cluster, the cluster to be migrated can be determined from the container cluster, and the destination migration cluster can be randomly determined from the container clusters other than the cluster to be migrated. Taking the failover scenario as an example, the failed container cluster can be determined as the cluster to be migrated, and then an available container cluster can be randomly selected from the remaining container clusters as the destination migration cluster. In actual applications, other methods can also be used to determine the destination migration cluster, such as according to the container cluster name, container cluster priority, container cluster resource tension, etc., which can be set based on actual conditions, and the embodiments of the present invention do not limit this.

[0037] For the aforementioned step S104, when creating a second instance replica respectively corresponding to each first instance replica, a second instance replica respectively corresponding to each first instance replica may be created in the destination migration cluster based on the instance type of the first instance replica. Considering that the purpose of the embodiment of the present invention is to migrate the storage subcluster from the cluster to be migrated to the destination migration cluster, it is necessary to ensure that the number and type of instance replicas of the storage subcluster in the destination migration cluster remain unchanged.

[0038] In actual applications, k8s dynamic volume provisioning refers to dynamically creating and mounting storage volumes for Pod replicas on demand, and providing k8s dynamic volume provisioning through StorageClass and corresponding Provisioner. For ease of understanding, the embodiment of the present invention provides the following Figure 3 A flow chart of the collaboration between StorageClass and Provisioner includes the following steps 1 to 6:

[0039] Step 1: If Provisioner is not deployed in the k8s cluster, the administrator deploys Provisioner corresponding to the target migration cluster.

[0040] In step 2, the administrator creates one or more StorageClasses and sets them as default.

[0041] In step 3, the user creates a PVC and references one of the StorageClasses.

[0042] Step 4: The k8s cluster searches for the StorageClass and the Provisioner corresponding to the StorageClass, and uses the Provisioner to determine the new PV based on the access path, storage size, and parameters in the StorageClass of the PVC.

[0043] Step 5: Provisioner provides actual storage and binds the PV to the PVC.

[0044] In step 6, the user creates a Pod replica and references the PVC.

[0045] Related technologies propose that VolumeClaimTemplates generates a PVC for each Pod of StatefulSet, and the Provisioner specified by storageClassName dynamically allocates PV to the PVC. In an embodiment of the present invention, when a user creates a PVC and specifies that it should be processed by a StorageClass, the Provisioner will monitor the PVC and forward it to the Global Provisioner on the server side, which will allocate PV to the PVC, thereby realizing cross-cluster migration of stateful services based on the Global Provisioner.

[0046] In an optional implementation, after determining to migrate the storage subcluster in the cluster to be migrated to the destination migration cluster, the first instance copy of the storage subcluster deployed in the cluster to be migrated can be deleted. Specifically, the k8s related interface can be called to reclaim the first instance copy in the cluster to be migrated.

[0047] For the aforementioned step S106, when determining the target virtual storage volume that matches the storage volume declaration, refer to the following steps a to c:

[0048] Step a: receiving the storage volume declaration sent by the sub-storage provider through the primary storage provider. In one embodiment, after the PVC corresponding to the second instance replica is generated in the destination migration cluster, the Provisioner of the destination migration cluster sends the PVC to the Global Provisioner.

[0049] Step b, based on the declaration identifier of the storage volume declaration, determine the target virtual storage volume that matches the storage volume declaration in the existing virtual storage volumes corresponding to the first instance replica. The declaration identifier may include the Namespace and name of the PVC. In one embodiment, the PVC corresponding to each first instance replica in the cluster to be migrated is bound to an existing PV, so the existing PV bound to the PVC with the same Namespace and name can be found, and the existing PV is used as the target PV.

[0050] Step c, if there is no target virtual storage volume matching the storage volume declaration in the existing virtual storage volumes, send a storage volume creation request to the file storage system so that the file storage system creates a target virtual storage volume matching the storage volume declaration. Considering that there may not be a target virtual storage volume matching the PVC in the PVC to which the existing virtual storage volume is bound, the IaaS platform can be requested to provide a file storage function, thereby creating the required target virtual storage volume (FS instance and access path), determining the binding relationship between the target virtual storage volume and the above PVC, and creating a PV resource (i.e., storage resource) based on the FS instance and access path. The file storage relied on by the embodiment of the present invention can be a corresponding function provided by any IaaS platform. Through the file storage and dynamic volume provisioning mechanism provided by the IaaS platform, the same storage is allocated to multiple clusters, thereby realizing cross-cluster migration of stateful services.

[0051] To facilitate understanding of the above step S106, the embodiment of the present invention further provides another stateful service migration method, see Figure 4 The flowchart of another stateful service migration method shown in FIG. 4 mainly includes the following steps S402 to S410:

[0052] Step S402: Global Provisioner monitors the PVC.

[0053] Step S404: query the database to see if there is a matching FS instance and access path according to the Namespace and name of the PVC. If yes, execute step S408; if not, execute step S406. The database is used to store the mapping relationship between the PVC and the PV corresponding to the first instance copy.

[0054] Step S406: Request the IaaS platform to create a FS instance and access path.

[0055] Step S408: Save the mapping relationship between the PVC, the FS instance, and the access path to the database.

[0056] Step S410: Determine PV resources and PVC resources according to the FS instance and the access path.

[0057] After determining the target virtual storage volume that matches the storage volume declaration, you can also establish a binding relationship between the target virtual storage volume and the storage volume declaration, and based on the target virtual storage volume and the binding relationship, determine the storage resources corresponding to the second instance replica. By determining the storage resources corresponding to each second instance replica, you can use the destination migration cluster to provide stateful services for the second instance replica. In actual applications, by binding the target virtual storage volume and the storage volume declaration, the second instance replica can be mounted with the same virtual storage volume as the first instance replica. Since the target virtual storage volume defines the storage instance and access path, and the storage instance stores storage resources, it is equivalent to migrating the stateful service from the cluster to be migrated to the destination migration cluster as a whole.

[0058] To facilitate understanding of the aforementioned embodiments, the embodiments of the present invention provide an application example of a migration method for a stateful service. Assume that when a stateful service needs to be migrated, the MySQL subcluster is migrated from the to-be-migrated cluster A to the destination migration cluster B. Specifically, (1) the first instance copy of the MySQL subcluster in the to-be-migrated cluster A is recovered; (2) the MySQL subcluster is opened in the destination migration cluster B, and a second instance copy of the same number and type is created; (3) the destination migration cluster B generates PVC at the same time when creating the Bmysql-0 Pod. After the Provisioner of the destination migration cluster B monitors the PVC, it sends the PVC to the Global Provisioner. The Global Provisioner finds that the PVC with the same Namespace and name already has a corresponding FS instance and access path, and directly uses the information to generate PV resources; (4) By analogy, each instance copy of the MySQL subcluster will find its corresponding FS instance and path in the to-be-migrated cluster A, thereby completing the cross-cluster migration of the stateful service.

[0059] In summary, the migration method of stateful services provided by the embodiment of the present invention no longer needs to back up and restore services during the stateful service migration process. It only needs to recycle services in one cluster (such as the above-mentioned cluster to be migrated), and then open the same service in the same namespace of another cluster (such as the above-mentioned destination migration cluster). The embodiment of the present invention is based on the dynamic volume provisioning mechanism of the k8s cluster and the file storage system of the IaaS platform, and adds certain logic so that after the StatefulSet is migrated across clusters, the virtual storage volume mounted by the corresponding Pod replica still uses the same storage as before (including storage instances and access paths), and no additional intervention measures are required. Similar to the in-place restart function, the cluster to be migrated is controlled to shut down and the destination migration cluster is controlled to start up, so that the cross-cluster migration can be completed.

[0060] For the migration method of the stateful service provided in the above-mentioned embodiment, an embodiment of the present invention provides a migration device for a stateful service, which is applied to a server, and the server is connected to at least one container cluster for communication, see Figure 5 The schematic diagram of the structure of a migration device for a stateful service is shown, and the device mainly includes the following parts:

[0061] The cluster determination module 502 is used to determine the cluster to be migrated and the target migration cluster from the container cluster; wherein a storage subcluster is deployed in the cluster to be migrated, and the storage subcluster includes at least one first instance replica;

[0062] A replica creation module 504, configured to create a second instance replica corresponding to each first instance replica in the destination migration cluster;

[0063] The migration module 506 is used to determine the target virtual storage volume that matches the storage volume declaration from the existing virtual storage volumes corresponding to the first instance copy if it is monitored that the destination migration cluster generates a storage volume declaration corresponding to the second instance copy, so as to provide the stateful service for each second instance copy according to the target virtual storage volume through the destination migration cluster.

[0064] The migration device for the stateful service provided in the embodiment of the present invention creates a second instance copy corresponding to each first instance copy included in the storage sub-instance in the destination migration cluster, and upon monitoring that the destination migration cluster generates a storage volume declaration corresponding to the second instance copy, migrates the storage sub-cluster from the cluster to be migrated to the destination migration cluster by searching for a target virtual storage volume matching the storage volume declaration in an existing virtual storage volume instance. Compared with the physical storage method used in the prior art, the storage volumes corresponding to the instance copies in the embodiment of the present invention are all virtual storage volumes. During the stateful migration process, there is no need to rely on its own backup and recovery mechanism. By making the storage sub-clusters use the same virtual storage volumes before and after the stateful service is moved forward, the cross-cluster migration operation of the stateful service can be completed without human intervention, and the migration efficiency can be effectively improved.

[0065] In one embodiment, the server is configured with a primary storage provider, and the target migration cluster is configured with a sub-storage provider; the migration module 506 is also used to: receive a storage volume declaration sent by the sub-storage provider through the primary storage provider; based on the declaration identifier of the storage volume declaration, search for a target virtual storage volume that matches the storage volume declaration in the existing virtual storage volumes corresponding to the first instance copy; wherein the target virtual storage volume includes a storage instance and an access path to the storage instance.

[0066] In one embodiment, the migration module 506 is further used to: if there is no target virtual storage volume matching the storage volume declaration in the existing virtual storage volumes, send a storage volume creation request to the file storage system so that the file storage system creates a target virtual storage volume matching the storage volume declaration.

[0067] In one implementation, the migration module 506 is further configured to: establish a binding relationship between the target virtual storage volume and the storage volume declaration; and determine the storage resource corresponding to the second instance copy based on the target virtual storage volume and the binding relationship.

[0068] In one implementation, the cluster determination module 502 is further configured to: determine a cluster to be migrated from the container clusters, and randomly determine a destination migration cluster from the container clusters other than the cluster to be migrated.

[0069] In one implementation, the replica creation module 504 is further configured to: create, in the destination migration cluster, second instance replicas corresponding to each first instance replica based on the instance type of the first instance replicas.

[0070] In one embodiment, the above-mentioned device further includes a deletion module, which is used to: delete the first instance copy of the storage sub-cluster deployed in the cluster to be migrated.

[0071] The device provided in the embodiment of the present invention has the same implementation principle and technical effects as those of the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the device embodiment, reference may be made to the corresponding contents in the aforementioned method embodiment.

[0072] An embodiment of the present invention provides a server. Specifically, the server includes a processor and a memory. The memory stores a computer program. When the computer program is executed by the processor, the method described in any one of the above embodiments is executed.

[0073] Figure 6 A structural diagram of a server provided in an embodiment of the present invention, the server 100 includes: a processor 60, a memory 61, a bus 62 and a communication interface 63, wherein the processor 60, the communication interface 63 and the memory 61 are connected via the bus 62; the processor 60 is used to execute an executable module stored in the memory 61, such as a computer program.

[0074] The memory 61 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk memory. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 63 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used.

[0075] The bus 62 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0076] Among them, the memory 61 is used to store programs, and the processor 60 executes the program after receiving the execution instruction. The method executed by the device for flow process definition disclosed in any embodiment of the above-mentioned embodiment of the present invention can be applied to the processor 60 or implemented by the processor 60.

[0077] The processor 60 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 60. The above processor 60 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in the embodiments of the present invention can be directly embodied as a hardware decoding processor to be executed, or the hardware and software modules in the decoding processor can be executed. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 61, and the processor 60 reads the information in the memory 61 and completes the steps of the above method in combination with its hardware.

[0078] The computer program product of the readable storage medium provided in the embodiment of the present invention includes a computer-readable storage medium storing program code, and the instructions included in the program code can be used to execute the methods described in the previous method embodiments. The specific implementation can be referred to the previous method embodiments, which will not be repeated here.

[0079] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program codes.

[0080] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims

1. A method for migrating a stateful service, characterized in that: The method is applied to a server, wherein the server is communicatively connected to at least one container cluster, and includes: Determine a cluster to be migrated and a target migration cluster from the container cluster; wherein a storage subcluster is deployed in the cluster to be migrated, the storage subcluster includes at least one first instance replica, and the cluster to be migrated provides a stateful service for each first instance replica; Creating, in the destination migration cluster, second instance replicas corresponding to each of the first instance replicas; If it is monitored that the destination migration cluster generates a storage volume declaration corresponding to the second instance replica, determine a target virtual storage volume matching the storage volume declaration from the existing virtual storage volumes corresponding to the first instance replica, so as to provide the stateful service for each second instance replica according to the target virtual storage volume through the destination migration cluster; The server is configured with a primary storage provider, and the destination migration cluster is configured with a sub-storage provider; if the destination migration cluster is monitored to generate a storage volume declaration corresponding to the second instance copy, the step of determining a target virtual storage volume matching the storage volume declaration in the existing virtual storage volumes corresponding to the first instance copy comprises: receiving, through the primary storage provider, the storage volume declaration sent by the sub-storage provider; based on the declaration identifier of the storage volume declaration, searching for a target virtual storage volume matching the storage volume declaration in the existing virtual storage volumes corresponding to the first instance copy; wherein the target virtual storage volume includes a storage instance and an access path to the storage instance; The step of providing the stateful service for each second instance copy according to the target virtual storage volume through the destination migration cluster includes: binding the target virtual storage volume with the storage volume declaration to determine the storage resources within the target virtual storage volume as the storage resources corresponding to the second instance copy, and by determining the storage resources corresponding to each second instance copy, providing the stateful service for each second instance copy through the destination migration cluster.

2. The method according to claim 1, characterized in that The method further comprises: If there is no target virtual storage volume matching the storage volume declaration in the existing virtual storage volumes, a storage volume creation request is sent to the file storage system so that the file storage system creates a target virtual storage volume matching the storage volume declaration.

3. The method according to claim 1, characterized in that After the step of determining a target virtual storage volume matching the storage volume declaration from existing virtual storage volumes corresponding to the first instance copy, the method further includes: Establishing a binding relationship between the target virtual storage volume and the storage volume declaration; Based on the target virtual storage volume and the binding relationship, a storage resource corresponding to the second instance copy is determined.

4. The method according to claim 1, characterized in that The step of determining the cluster to be migrated and the target migration cluster from the container cluster includes: A cluster to be migrated is determined from the container clusters, and a destination migration cluster is randomly determined from container clusters other than the cluster to be migrated.

5. The method according to claim 1, characterized in that The step of creating a second instance replica corresponding to each of the first instance replicas in the destination migration cluster includes: Based on the instance type of the first instance replica, a second instance replica corresponding to each of the first instance replicas is created in the destination migration cluster.

6. The method according to claim 1, characterized in that The method further comprises: The first instance copy of the storage subcluster deployed in the cluster to be migrated is deleted.

7. A migration device for a stateful service, characterized in that: The device is applied to a server, and the server is communicatively connected with at least one container cluster, and includes: A cluster determination module, used to determine a cluster to be migrated and a target migration cluster from the container cluster; wherein a storage subcluster is deployed in the cluster to be migrated, the storage subcluster includes at least one first instance replica, and the cluster to be migrated provides a stateful service for each first instance replica; A replica creation module, configured to create, in the destination migration cluster, a second instance replica respectively corresponding to each of the first instance replicas; A migration module, configured to, if monitoring that the destination migration cluster generates a storage volume declaration corresponding to the second instance replica, determine a target virtual storage volume matching the storage volume declaration from existing virtual storage volumes corresponding to the first instance replica, so as to provide the stateful service for each second instance replica according to the target virtual storage volume through the destination migration cluster; The server is configured with a main storage provider, and the destination migration cluster is configured with a sub-storage provider; the migration module is specifically used for: Receiving, through the primary storage provider, a storage volume declaration sent by the secondary storage provider; based on a declaration identifier of the storage volume declaration, searching for a target virtual storage volume matching the storage volume declaration in the existing virtual storage volumes corresponding to the first instance copy; wherein the target virtual storage volume includes a storage instance and an access path to the storage instance; The target virtual storage volume is bound to the storage volume declaration to determine the storage resources within the target virtual storage volume as the storage resources corresponding to the second instance copy. By determining the storage resources corresponding to each second instance copy, a stateful service is provided for each second instance copy through the destination migration cluster.

8. A server, characterized in that: The method comprises a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Distributed database specified node capacity reduction method

    CN112925852A

  • Resource scheduling method, device and system

    CN113535411A