Cluster data sharing method, apparatus, device, and medium
By identifying the target cluster and obtaining its data storage address in a cloud-native multi-cluster environment, and creating a persistent volume pointing to that address, the data sharing problem between Kubernetes clusters is solved, enabling cross-cluster data sharing and transparent use of storage resources.
Patent Information
- Application Number
- CN202310627194.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-30
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2043-05-30
AI Technical Summary
In existing cloud-native multi-cluster environments, data sharing between Kubernetes clusters is not possible, leading to cross-cluster data sharing issues for business applications. Furthermore, existing methods are complex and prone to errors.
Upon receiving a persistent volume request, the target cluster is identified and its data storage address is obtained. A first persistent volume pointing to that address is then created, enabling data sharing between the cluster to be shared and the target cluster based on the data storage address.
It enables cross-cluster data sharing, simplifies the data sharing process, improves cluster resource management capabilities, and supports businesses to transparently use storage resources across different clusters.
Smart Images

Figure CN116614518B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computers, and in particular to a cluster data sharing method and device, equipment and medium. BACKGROUND
[0002] At present, more and more Internet companies are turning to cloud native. Cloud native is essentially a software development and deployment method that aims to use cloud computing, containerization, microservices, and other technologies to build highly available, reliable, and scalable application services. Kubernetes (container cluster management system, referred to as k8s) is currently the largest open source architecture platform for cloud native services, and more and more companies are introducing Kubernetes service clusters to improve the efficiency of server resources and reduce costs.
[0003] Existing cloud native multi-clusters, such as k8s clusters, are deployed according to clusters, and business deployment applications are also deployed according to k8s clusters. If a business declares a PVC (Persistent Volume Claim) in k8s cluster A, cluster A will call the storage interface to automatically create a persistent volume in the cluster, so that the PV (Persistent Volume) in any k8s cluster is newly created. Since clusters are independent of each other, there is a problem of not being able to meet the cross-cluster data sharing of businesses between k8s clusters. SUMMARY
[0004] The present application provides a cluster data sharing method, device, equipment and medium, so that businesses can share data in different clusters, realize cross-cluster data sharing, solve the data sharing problem existing in the existing cloud native multi-cluster, and achieve the transparency of the cluster to the business.
[0005] In a first aspect, the present application provides a cluster data sharing method, comprising:
[0006] In the case of receiving a persistent volume request corresponding to a to-be-shared cluster, determining a target cluster corresponding to the to-be-shared cluster;
[0007] Obtaining a data storage address corresponding to the target cluster;
[0008] Creating a first persistent volume corresponding to the to-be-shared cluster based on the data storage address, wherein the first persistent volume points to the data storage address, so that the to-be-shared cluster and the target cluster realize data sharing based on the data storage address.
[0009] Optionally, before the obtaining a data storage address corresponding to the target cluster, the method further comprises:
[0010] extracting cluster retrieval information of the target cluster from the persistent volume request, the cluster retrieval information comprising a cluster name and a storage pool name of the target cluster;
[0011] generating a storage address acquisition request based on the cluster name and the storage pool name.
[0012] Optionally, the obtaining of the data storage address corresponding to the target cluster comprises:
[0013] obtaining preset cluster creation record information;
[0014] retrieving the cluster creation record information based on the storage address acquisition request through a preset control center to obtain creation information of the target cluster;
[0015] if the creation information is target cluster created information, extracting a data storage address of the target cluster from the cluster creation record information through a preset interface.
[0016] Optionally, after the creating of the first persistent volume corresponding to the to-be-shared cluster based on the data storage address, the method further comprises:
[0017] determining a first persistent volume claim of the to-be-shared cluster;
[0018] sending a storage information update request based on the first persistent volume, the first persistent volume claim and the cluster name of the to-be-shared cluster to the monitoring center, and recording and updating the cluster creation record information based on the storage information update request.
[0019] Optionally, before the determining of the target cluster corresponding to the to-be-shared cluster, the method further comprises:
[0020] when receiving an initial cluster creation request, determining a cluster corresponding to the initial cluster creation request as the target cluster;
[0021] performing business creation based on the initial cluster creation request to obtain a second persistent volume claim and cluster creation information corresponding to the target cluster;
[0022] performing storage creation based on the cluster creation information and in combination with the second persistent volume claim to obtain a second persistent volume and a data storage address corresponding to the target cluster, wherein the second persistent volume points to the data storage address.
[0023] Optionally, the cluster creation information includes storage pool designation information of the target cluster and a target cluster name, and the second persistent volume is created based on the cluster creation information and the second persistent volume request to obtain the second persistent volume corresponding to the target cluster and a data storage address.
[0024] An initial cluster creation record is obtained;
[0025] It is determined whether the initial cluster creation record information includes the target cluster name;
[0026] If the initial cluster creation record does not include the target cluster name, the second persistent volume of the target cluster is created based on the second persistent volume request, and a data storage address of the target cluster is created in the storage pool corresponding to the storage pool designation information.
[0027] Optionally, after obtaining the second persistent volume corresponding to the target cluster and the data storage address, the method further includes:
[0028] Cluster update information is generated based on the target cluster name, the data storage address and the second persistent volume of the target cluster;
[0029] The initial cluster creation record is updated based on the cluster update information to obtain cluster creation record information.
[0030] In a second aspect, the present application provides a cluster data sharing device, which includes:
[0031] A target cluster determination module is configured to determine a target cluster corresponding to a to-be-shared cluster when receiving a persistent volume request corresponding to the to-be-shared cluster;
[0032] A data storage address acquisition module is configured to acquire a data storage address corresponding to the target cluster;
[0033] A first persistent volume creation module is configured to create a first persistent volume corresponding to the to-be-shared cluster based on the data storage address, wherein the first persistent volume points to the data storage address, so that the to-be-shared cluster and the target cluster realize data sharing based on the data storage address.
[0034] In a third aspect, the present application provides an electronic device, which includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete communication with each other through the communication bus.
[0035] The memory is configured to store a computer program.
[0036] A processor is configured to implement the steps of the cluster data sharing method according to any one of the first aspect.
[0037] In a fourth aspect, the present application provides a computer readable storage medium, having stored thereon a computer program, which, when executed by a processor, implements the steps of the cluster data sharing method according to any one of the first aspect.
[0038] In summary, the embodiments of the present application, by receiving the request of the persistent volume corresponding to the to-be-shared cluster, determining the target cluster corresponding to the to-be-shared cluster, obtaining the data storage address corresponding to the target cluster, creating the first persistent volume corresponding to the to-be-shared cluster based on the data storage address, and making the first persistent volume of the to-be-shared cluster point to the data storage address of the target cluster, so that the to-be-shared cluster and the target cluster realize data sharing based on the data storage address, thereby enabling the business to share data in different clusters, realizing cross-cluster data sharing, solving the problem of data sharing in the existing cloud native multi-cluster, and achieving the transparency of the cluster to the business. BRIEF DESCRIPTION OF DRAWINGS
[0039] The accompanying drawings, which are incorporated herein and constitute part of the specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced. Obviously, those skilled in the art can obtain other drawings according to these drawings without any creative effort.
[0041] Figure 1 A flowchart of a cluster data sharing method provided by an embodiment of the present application;
[0042] Figure 2 A step flowchart of a cluster data sharing method provided by an optional embodiment of the present application;
[0043] Figure 3 A cluster data sharing system diagram provided by an optional embodiment of the present application;
[0044] Figure 4 A structure block diagram of a cluster data sharing device provided by an embodiment of the present application;
[0045] Figure 5 A structure diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0046] To make the purposes, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work belong to the scope of protection of the present application.
[0047] In the related art, the construction of a cloud native platform cannot be separated from the persistence of data, because the core of the cloud native idea is containerization, and after containerization, the running of a service is stateless, and once a container of a service is accidentally killed, the data in the container will not exist. The k8s platform specially provides a storage solution, PV and PVC, which is the most popular and general storage method at present. PV represents a persistent volume, which represents a piece of storage in a storage system, and the storage system is independent of the k8s platform and is a cluster specially used for storing data; PVC is a persistent volume claim, that is, when deploying an application service, a specific PV to be used is written in a configuration file, and this claim behavior is called PVC, which is the origin of the name. The reason why k8s introduces these two resource names is to abstract the storage resource, so that the business only needs to care about the PVC claim. However, the specific PV is usually not written in the PVC, and the real PV is automatically created by the storage system in real time, which can simplify the storage usage of the application, and the user only needs to care about how much capacity of storage is needed, and write the demand in the PVC, without needing to care about the underlying PV information.
[0048] The existing k8s cluster mainly has two problems, one is that the deployment of k8s is according to the cluster deployment, and the deployment of the business application is also according to the k8s cluster deployment, if the business claims a PVC in k8s cluster A, then cluster A will call the storage interface to automatically create a PV in the cluster, so that the PV in any k8s cluster is newly created. This cannot meet the problem of cross-cluster data sharing of the business. The second is that the k8s system focuses on the problem of data persistence in the cluster, and cannot balance the data sharing scenario of different k8s clusters. When data sharing is performed, it can only be realized by the cloud native storage system. However, the method of cross-k8s cluster data sharing is basically manually modifying the PV binding information in different clusters to realize, which is complex and prone to container errors.
[0049] To solve the above problems, the embodiment of the present application provides a cluster data sharing method, device, equipment and medium. In the case that a persistent volume request corresponding to a to-be-shared cluster is received, a target cluster corresponding to the to-be-shared cluster is determined, a data storage address corresponding to the target cluster is obtained, a first persistent volume corresponding to the to-be-shared cluster is created based on the data storage address, and the first persistent volume of the to-be-shared cluster is directed to the data storage address of the target cluster, so that the to-be-shared cluster and the target cluster realize data sharing based on the data storage address, thereby enabling the business to share data in different clusters, realizing cross-cluster data sharing, and simplifying the implementation process. The existing cloud native multi-cluster data sharing problem is solved, and the transparency of the cluster to the business is achieved.
[0050] For the convenience of understanding the embodiments of the present application, further explanation and description will be made in combination with the drawings and specific embodiments, and the embodiments do not constitute a limitation on the embodiments of the present application.
[0051] Figure 1 A flowchart of a cluster data sharing method provided by the embodiment of the present application is shown in FIG. 1. As shown in FIG. 1, the cluster data sharing method provided by the embodiment of the present application can specifically include the following steps: Figure 1
[0052] Step 110, in the case that a persistent volume request corresponding to a to-be-shared cluster is received, a target cluster corresponding to the to-be-shared cluster is determined.
[0053] Specifically, the target cluster can be a cluster created before the to-be-shared cluster, and the target cluster can be a cluster that needs to share data with the to-be-shared cluster, which is not limited by the embodiment of the present application. The persistent volume request can be used to create the to-be-shared cluster and can be used to share data between the to-be-shared cluster and the target cluster. The persistent volume request can include but is not limited to the cluster name of the to-be-shared cluster, the PVC of the to-be-shared cluster, the cluster name of the target cluster, the storage pool, etc., which is not limited by the embodiment of the present application.
[0054] In a specific implementation, a user can specify the to-be-shared cluster to be built through the persistent volume request, and can specify the cluster (including but not limited to the cluster name and the cluster storage pool, etc.) that needs to share data with the to-be-shared cluster as the target cluster.
[0055] Step 120, a data storage address corresponding to the target cluster is obtained.
[0056] Specifically, the data storage address can be the real storage address of the target cluster, which is not limited by the embodiment of the present application.
[0057] In a specific implementation, the embodiment can pre-create a control center, obtain creation information of a target cluster by pre-creating the target cluster, wherein the creation information includes but is not limited to a target cluster name, a PVC and a storage pool of the target cluster. Then the creation information can be sent to the control center, and the control center is used to create a real storage address (also called subpath) corresponding to the target cluster in the storage pool by using the PVC of the target cluster, and then the real storage address is used to create a PV corresponding to the target cluster. Then the control center can store the storage pool, the PVC, the PV, the target cluster name and the real storage address of the target cluster to obtain a cluster creation record. After determining the target cluster corresponding to the cluster to be shared, the cluster name corresponding to the target cluster can be extracted from the persistent volume request, and then the listening service can search the target cluster from the cluster creation record and obtain the real storage address corresponding to the target cluster as a data storage address.
[0058] Step 130, creating a first persistent volume corresponding to the cluster to be shared based on the data storage address, wherein the first persistent volume points to the data storage address, so that the cluster to be shared and the target cluster realize data sharing based on the data storage address.
[0059] In a specific implementation, the embodiment can create a first persistent volume corresponding to the cluster to be shared by using the data storage address, that is, the PV of the cluster to be shared, so that the PV of the cluster to be shared can point to the real storage address of the target cluster, so as to realize that the cluster to be shared and the target cluster can share data based on the real storage address, and then in the cloud native k8s service cluster, the business can share data in different k8s clusters.
[0060] As an example, assuming that the target cluster name is k8s cluster A, and the cluster to be shared is k8s cluster B, the example does not limit the cluster name. The business can pre-set a listening service for listening to the creation of a cluster. When the creation of cluster A is listened to, k8s first creates a persistent volume claim (i.e., PVC A) of cluster A, and then transmits the creation operation of cluster A (including but not limited to the name of cluster A, PVC A, and a storage pool (Storage Pool A), etc.) to the control center. The control center can be used to record various creation information of the cluster, including but not limited to PVC A of cluster A and other associated data of the cluster. Subsequently, the control center determines whether the PVC A exists in k8s. If not, the creation can be continued. The control center transmits Storage Pool A to the storage cluster to create the real storage address (i.e., subpath A) of cluster A. The subpath A is used to create the persistent volume (i.e., PV A) of cluster A. The control center stores Storage Pool A, PVC A, PV A, k8s A, and subpath A to obtain a cluster creation record, which can be recorded as [storage pool A], [pvcA], [pv A], [k8s A], [subpath A], which is not limited in the example.
[0061] It can be seen that, by receiving a persistent volume request corresponding to a cluster to be shared, determining a target cluster corresponding to the cluster to be shared, obtaining a data storage address corresponding to the target cluster, creating a first persistent volume corresponding to the cluster to be shared based on the data storage address, and pointing the first persistent volume of the cluster to be shared to the data storage address of the target cluster, the cluster to be shared and the target cluster can share data based on the data storage address, so that the business can share data in different clusters, cross-cluster data sharing is achieved, the existing data sharing problem in the cloud native multi-cluster is solved, and the transparency of the cluster to the business is achieved.
[0062] Referring to Figure 2 , a step flow diagram of a cluster data sharing method provided by an optional embodiment of the present application is shown. The cluster data sharing method can specifically include the following steps:
[0063] In step 210, in the case of receiving a persistent volume request corresponding to a cluster to be shared, a target cluster corresponding to the cluster to be shared is determined.
[0064] In a specific implementation, the embodiment can pre-construct a cluster data sharing system to realize data sharing between clusters through the cluster data sharing system. For example, referring to Figure 3For example, the business needs to share and associate k8s cluster A and cluster B. A certain number of devices can be pre-built to realize cluster data sharing, which can include but is not limited to device A, device B, and device C. Device A can be an attached function of the Container Storage Interface (CSI) in the k8s cluster, which is identified as Hub in Figure 3 Device B can be a monitoring device for all resource operations in the k8s cluster. Various resource operations in the k8s cluster will be notified to device B, including but not limited to PV creation, and device B can obtain all key information such as subpath information. Device B will also pass the information to device C for record keeping. Device C can be a control center. When device A requests device C for a real storage address, if it is the first time that the business creates a PV, device C will request Storage Cluster A to create a subpath and return it to device C. Otherwise, the existing subpath will be directly returned to ensure that multiple clusters of the business share a storage address. The listening message of device B will also be passed to this device to record the associated information of the real PV creation.
[0065] In actual processing, for example, when the business needs to use the storage service, a storage pool A can be pre-applied to the storage service system. The storage pool name can be unique, and the use of the storage pool can depend on the secret key to provide security for the storage system. The storage service system can inject the storage pool into the k8s cluster, so that the k8s cluster can support the business declaration to automatically create the corresponding PV after the creation of the PVC in the cluster. The PVC can include the name and key of the storage pool to indicate that the PVC and PV are created under the business's own storage pool.
[0066] In an optional embodiment, before determining the target cluster corresponding to the cluster to be shared, the embodiment of the application can further include: determining the cluster corresponding to the initial cluster creation request as the target cluster when receiving the initial cluster creation request; creating the business based on the initial cluster creation request to obtain second persistent volume claims and cluster creation information corresponding to the target cluster; and creating storage based on the cluster creation information in combination with the second persistent volume claims to obtain a second persistent volume and a data storage address corresponding to the target cluster, wherein the second persistent volume points to the data storage address.
[0067] Specifically, the initial cluster creation request can be used to create the target cluster, which can carry the cluster creation information of the target cluster, including but not limited to the target cluster name of the target cluster and the storage pool specification information, etc., which is not limited by the embodiments of the present application. The embodiments of the present application can use the initial cluster creation request to create the persistent volume claim of the target cluster, and can extract the cluster creation information from the initial cluster creation request, and then use the cluster creation information and the persistent volume claim to create the persistent volume in the storage pool corresponding to the storage pool specification information, to obtain the real storage address and the persistent volume of the target cluster, and make the persistent volume of the target cluster point to the real storage address.
[0068] In an optional embodiment, the cluster creation information of the embodiments of the present application can include the storage pool specification information and the target cluster name of the target cluster, based on the cluster creation information, the second persistent volume claim is combined to create the storage, to obtain the second persistent volume and the data storage address corresponding to the target cluster. Specifically, it can include: obtaining a preset initial cluster creation record; judging whether the target cluster name is included in the initial cluster creation record information; if the target cluster name is not included in the cluster creation record, the second persistent volume of the target cluster is created based on the second persistent volume claim, and the data storage address of the target cluster is created in the storage pool corresponding to the storage pool specification information.
[0069] In an optional embodiment, after the embodiments of the present application obtain the second persistent volume and the data storage address corresponding to the target cluster, it can also specifically include: generating cluster update information based on the target cluster name, the data storage address and the second persistent volume of the target cluster; updating the initial cluster creation record based on the cluster update information to obtain the cluster creation record information.
[0070] As an example, refer to Figure 3With k8s cluster A as the target cluster, the creation of k8s cluster A mainly includes the following steps: first, when the user deploys the business to k8s cluster A, the user can input the creation information of cluster A in the k8s cluster through a command line or a view operation. The creation information can include but is not limited to the storage pool information (StoragePool A) of cluster A and the cluster name (k8s A) of cluster A. The k8s cluster first performs PVC creation of cluster A to obtain PVC A, and then calls the device A (Hub) in the CSI to generate a storage address acquisition request for obtaining the real storage address information. The storage address acquisition request carries the information such as the StoragePool A, PVC A and k8s A name of cluster A. Subsequently, device A (Hub) can interact with device C, and device A can send the storage address acquisition request to device A, that is, device A transmits the StoragePool A, PVC A and k8s A name to device C. After receiving the storage address acquisition request, device C extracts the information such as the StoragePool A, PVC A and k8s A name from the storage address acquisition request, and determines whether there is a creation record of k8s cluster A in the record according to the information. Specifically, device C can store an initial cluster creation record in advance, and the initial cluster creation record contains the creation information of each k8s cluster. Device C compares the information such as the StoragePool A, PVC A and k8s A name with the initial cluster creation record to determine whether k8s cluster A has been created. If it is determined that k8s cluster A is created for the first time, device C transmits the StoragePool A to the storage cluster request of the storage service system to create a real subpath A. After the storage service system successfully creates the subpath A, the storage service system returns the subpath A as the real storage address of k8s cluster A to device C. Subsequently, device C can return the subpath A to device A, so that k8s cluster A can obtain the real storage address subpath A from the Hub in the CSI to directly call k8s to create the PVC A of cluster A. After the creation of PVC A is successful, device B can be notified of the creation success information, and device B can further notify device C to record all storage usage information on k8s cluster A. Thus, the creation of k8s cluster A is realized.
[0071] In step 220, cluster retrieval information of the target cluster is extracted from the persistent volume request, and the cluster retrieval information includes a cluster name and a storage pool name of the target cluster.
[0072] In a specific implementation, the user can specify the target cluster through the persistent volume request, and can input the cluster name and storage pool name of the target cluster. When performing cluster data sharing, the cluster name and storage pool name of the target cluster can be extracted from the persistent volume request as cluster retrieval information, so that the target cluster can be determined to be created or not by searching using the cluster retrieval information.
[0073] In step 230, a storage address acquisition request is generated based on the cluster name and the storage pool name.
[0074] Specifically, the storage address acquisition request can be used to acquire the real storage address of the target cluster. In this embodiment, the cluster name and the storage pool name of the target cluster can be carried in the storage address acquisition request, so that the control center can be used for cluster retrieval.
[0075] As an example, refer to Figure 3 For example, when the user deploys a business to the k8s cluster B, the k8s cluster will perform PVC creation of the cluster B to obtain PVC B, and then the k8s cluster will acquire the real storage address of the cluster A through the device A. Specifically, the device A can generate a storage address acquisition request for acquiring the real storage address of the cluster A according to the cluster name and the StoragePool A of the cluster A input by the user.
[0076] In step 240, preset cluster creation record information is acquired.
[0077] Specifically, the cluster creation record information can include the creation information of each k8s cluster, such as but not limited to the storage pool name, PVC, PV, cluster name and real storage address of the target cluster, which is not limited in this embodiment.
[0078] In a specific implementation, the control center can collect the creation information in the creation process of each cluster during the creation process of the cluster, and aggregate the cluster creation record.
[0079] In step 250, the control center searches the cluster creation record information based on the storage address acquisition request to obtain the creation information of the target cluster.
[0080] Specifically, the creation information can be divided into cluster created information and cluster not created information. For the target cluster, the creation information can be divided into target cluster created information and target cluster not created information, which is not limited in this embodiment.
[0081] In actual processing, the control center can perform cluster retrieval according to the obtained storage address acquisition request. For example, the cluster name and the storage pool name of the target cluster can be extracted from the storage address acquisition request, the cluster name and the storage pool name are searched in the cluster creation record information, it is determined whether there is cluster creation information with the same cluster name and storage pool name, if there is, it is determined that the target cluster has been created, and target cluster creation information is obtained; if not, it is determined that the target cluster has not been created, target cluster creation information is obtained, and an exception information can be thrown for reminding the sharing operation.
[0082] In step 260, if the creation information is target cluster creation information, the data storage address of the target cluster is extracted from the cluster creation record information through a preset interface.
[0083] In this embodiment, when the creation information is target cluster creation information, the real storage address of the target cluster is extracted from the cluster creation record information through a preset CSI interface, and is used as the data storage address.
[0084] As an example, referring to Figure 3 , after the k8s cluster generates a storage address acquisition request for obtaining the real storage address of cluster A through device A, device A can interact with device C, and send the storage address acquisition request to device C. After device C receives the storage address acquisition request, it can extract the StoragePool A, PVC A and cluster A name and other information of cluster A from the storage address acquisition request, search the stored cluster creation record based on these information, determine that cluster A has been created, obtain the subpath A of cluster A, and return the subpath A to device A in k8s cluster B as the real storage address of cluster A. Device A can obtain the real storage address subpath A through the Hub in CSI, and then call the k8s to create the persistent volume of cluster B, and obtain PV B.
[0085] In step 270, a first persistent volume corresponding to the to-be-shared cluster is created based on the data storage address.
[0086] The first persistent volume points to the data storage address, so that the to-be-shared cluster and the target cluster realize data sharing based on the data storage address.
[0087] In a specific implementation, the embodiment of the present application can make the persistent volume of the cluster to be shared point to the data storage address of the target cluster, so that the cluster to be shared and the target cluster can jointly use the same storage address for storage, realizing the cross-cluster data sharing function. When there are more k8s clusters that need to share data, the operation process can be consistent with that of the cluster to be shared, thereby providing a data sharing method for PV and PVC of business on cloud-native multi-cluster, providing diversified needs of business, and providing a fast and efficient method for seamless cluster migration of business, greatly improving the cluster resource allocation management capability, and providing an effective unified method for cross-cluster data sharing business, so that the business can be more transparent when using storage resources, without needing to know the cluster information, but only needing to focus on the use of business data, thereby solving the problem of massive migration of business data caused by the offline of k8s cluster, so that the business no longer needs to perform PV-level data migration, but can directly use the original data storage after redeploying the business in the new cluster.
[0088] Further, the embodiment of the present application can also abstract the data storage address of the target cluster and associate the data storage addresses of multiple clusters to the same underlying storage path function, so that when performing cross-cluster data sharing operation, only the underlying association needs to be changed to realize cross-cluster data sharing.
[0089] Step 280, determine the first persistent volume claim of the cluster to be shared.
[0090] In a specific implementation, the embodiment of the present application can create the persistent volume claim corresponding to the cluster to be shared when the cluster to be shared is created.
[0091] Step 290, send a storage information update request to the monitoring center based on the first persistent volume, the first persistent volume claim, and the cluster name of the cluster to be shared, and the monitoring center records and updates the cluster creation record information based on the storage information update request.
[0092] In a specific implementation, the embodiment of the present application can update the cluster creation record of the control center after creating the cluster to be shared, and update the creation information of the cluster to be shared to the cluster creation record. Specifically, a storage information update request can be generated based on the PV, PVC of the cluster to be shared, and the cluster name of the cluster to be shared, and sent to the monitoring center, so that the monitoring center can record and update the cluster creation record information using the information carried by the storage information update request. By updating the creation information of the cluster to be shared to the cluster creation record, when other clusters are added subsequently, data sharing between the added cluster and the cluster to be shared can also be realized.
[0093] As an example, the updated cluster creation record can be [storage pool A], [pvc B], [pvB], [k8s B], [subpath A], and the example is not limited thereto
[0094] To sum up, in the case that the persistent volume request corresponding to the to-be-shared cluster is received, the target cluster corresponding to the to-be-shared cluster is determined, the cluster search information of the target cluster is extracted from the persistent volume request, the storage address acquisition request is generated based on the cluster name and the storage pool name of the target cluster contained in the cluster search information, so that the cluster creation record information can be searched based on the storage address acquisition request through the preset control center to obtain the creation information of the target cluster, and when the creation information is the created information of the target cluster, the data storage address of the target cluster can be extracted from the cluster creation record information through the preset interface, the first persistent volume corresponding to the to-be-shared cluster is created based on the data storage address, the cluster creation of the to-be-shared cluster is implemented, and the first persistent volume of the to-be-shared cluster is pointed to the data storage address of the target cluster, so that the to-be-shared cluster and the target cluster can use the same data storage address, the cross-k8s cluster data sharing function is realized, and thus the business can share data in different clusters, the existing data sharing problem in the cloud native multi-cluster is solved, and the cluster transparency to the business is achieved. After the to-be-shared cluster is created, the first persistent volume of the to-be-shared cluster is determined, the storage information update request is sent to the monitoring center based on the first persistent volume, the first persistent volume claim, and the cluster name of the to-be-shared cluster, the cluster creation record information is recorded and updated based on the storage information update request by the monitoring center, so that when other clusters are added subsequently, the data sharing between the added clusters and the to-be-shared cluster can also be realized.
[0095] It should be noted that for the method embodiment, in order to simply describe, it is expressed as a series of action combinations, but those skilled in the art should know that the embodiments of the present application are not limited by the order of the described actions, because according to the embodiments of the present application, certain steps can be performed in other order or simultaneously.
[0096] As shown in Figure 4 The embodiments of the present application also provide a cluster data sharing device 400, which comprises:
[0097] The target cluster determination module 410 is configured to determine the target cluster corresponding to the to-be-shared cluster in the case that the persistent volume request corresponding to the to-be-shared cluster is received;
[0098] The data storage address acquisition module 420 is configured to acquire the data storage address corresponding to the target cluster;
[0099] The first persistent volume creation module 430 is configured to create a first persistent volume corresponding to the to-be-shared cluster based on the data storage address, where the first persistent volume points to the data storage address, so that the to-be-shared cluster and the target cluster realize data sharing based on the data storage address.
[0100] Optionally, the cluster data sharing apparatus 400 further includes:
[0101] The cluster search information extraction module is configured to extract cluster search information of the target cluster from the persistent volume request, where the cluster search information includes a target cluster name and a storage pool name of the target cluster.
[0102] The storage address acquisition request generation module is configured to generate a storage address acquisition request based on the target cluster name and the storage pool name.
[0103] Optionally, the data storage address acquisition module 420 includes:
[0104] The cluster creation record information acquisition submodule is configured to acquire preset cluster creation record information.
[0105] The search submodule is configured to search the cluster creation record information based on the storage address acquisition request through a preset control center, to obtain creation information of the target cluster.
[0106] The data storage address extraction submodule is configured to extract a data storage address of the target cluster from the cluster creation record information through a preset interface when the creation information is target cluster created information.
[0107] Optionally, the cluster data sharing apparatus 400 further includes:
[0108] The first persistent volume claim determination module is configured to determine a first persistent volume claim of the to-be-shared cluster.
[0109] The storage information update module is configured to send a storage information update request to the monitoring center based on the first persistent volume, the first persistent volume claim, and a cluster name of the to-be-shared cluster, and the monitoring center records and updates the cluster creation record information based on the storage information update request.
[0110] Optionally, the cluster data sharing apparatus 400 further includes:
[0111] The initial cluster creation request receiving module is configured to determine a cluster corresponding to an initial cluster creation request as the target cluster when the initial cluster creation request is received.
[0112] The service creation module is configured to create a service based on the initial cluster creation request, and obtain second persistent volume claims and cluster creation information corresponding to the target cluster.
[0113] The storage creation module is configured to create a storage based on the cluster creation information and the second persistent volume claims, and obtain a second persistent volume and a data storage address corresponding to the target cluster, wherein the second persistent volume points to the data storage address.
[0114] Optionally, the cluster creation information includes storage pool designation information of the target cluster and a target cluster name, and the storage creation module includes:
[0115] The initial cluster creation record obtaining submodule is configured to obtain a preset initial cluster creation record.
[0116] The judgment submodule is configured to judge whether the target cluster name is included in the initial cluster creation record information.
[0117] The second persistent volume creation submodule is configured to, when the target cluster name is not included in the cluster creation record, create a second persistent volume of the target cluster based on the second persistent volume claims, and create a data storage address of the target cluster in a storage pool corresponding to the storage pool designation information.
[0118] Optionally, the cluster data sharing device 400 further includes:
[0119] The cluster update information generation module is configured to generate cluster update information based on the target cluster name, the data storage address, and the second persistent volume of the target cluster.
[0120] The update module is configured to update the initial cluster creation record based on the cluster update information, and obtain cluster creation record information.
[0121] It should be noted that the cluster data sharing device provided by the embodiments of the present application can execute the cluster data sharing method provided by any embodiment of the present application, and has the corresponding functions and advantages of executing the cluster data sharing method.
[0122] In a specific implementation, the cluster data sharing apparatus can be integrated in a device, so that the device can create a first persistent volume corresponding to a to-be-shared cluster based on a data storage address corresponding to a target cluster, so that the first persistent volume points to the data storage address, as an electronic device, data sharing of the to-be-shared cluster and the target cluster is achieved, and the existing data sharing problem in the cloud-native multi-cluster is solved. The electronic device can be composed of two or more physical entities, or can be composed of one physical entity, such as a personal computer (PC), a computer, a server, etc., and the embodiments of the present application do not make specific limitations thereto.
[0123] As shown in Figure 5 The embodiments of the present application provide an electronic device, which includes a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112 and the memory 113 complete mutual communication through the communication bus 114; the memory 113 is used for storing a computer program; the processor 111 is used for executing the program stored on the memory 113, and the steps of the cluster data sharing method provided by any one of the preceding method embodiments are implemented. Exemplarily, the steps of the cluster data sharing method can include the following steps: in the case that a persistent volume request corresponding to a to-be-shared cluster is received, a target cluster corresponding to the to-be-shared cluster is determined; a data storage address corresponding to the target cluster is acquired; a first persistent volume corresponding to the to-be-shared cluster is created based on the data storage address, wherein the first persistent volume points to the data storage address, so that the to-be-shared cluster and the target cluster achieve data sharing based on the data storage address.
[0124] The embodiments of the present application also provide a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the steps of the cluster data sharing method provided by any one of the preceding method embodiments.
[0125] It should be noted that, in this document, relational terms such as "first" and "second", and the like, are used solely to distinguish one entity or action from another entity or action, without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises", "comprising", or any other variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without more limitations, an element defined by the statement "comprising a" does not exclude the existence of additional identical elements in the process, method, article, or apparatus that includes the element.
[0126] The foregoing detailed description of the application has been presented for purposes of illustration and description. Various modifications and changes can be made to these embodiments without departing from the spirit and scope of the application. It is intended that the scope of the application should not be limited by the particular representative embodiments described in this application. Rather, the scope of the application should be determined only by reference to the appended claims and equivalents thereof.
Claims
1. A cluster data sharing method, characterized by, The method comprises the following steps: In the case of receiving a request for a persistent volume corresponding to a cluster to be shared, a target cluster corresponding to the cluster to be shared is determined, the target cluster being a cluster created before the cluster to be shared and needing to share data with the cluster to be shared; A data storage address corresponding to the target cluster is obtained; A first persistent volume corresponding to the cluster to be shared is created based on the data storage address, wherein the first persistent volume points to the data storage address, so that the cluster to be shared and the target cluster realize data sharing based on the data storage address; Before the step of obtaining the data storage address corresponding to the target cluster, the method further comprises the following steps:
2. The method of claim 1, wherein, Extracting cluster search information of the target cluster from the request for the persistent volume, the cluster search information containing a target cluster name and a storage pool name of the target cluster; Based on the target cluster name and the storage pool name, a storage address obtaining request is generated. The step of obtaining the data storage address corresponding to the target cluster comprises the following steps: Obtaining preset cluster creation record information; 3. The method of claim 2, wherein, Retrieving the cluster creation record information based on the storage address obtaining request through a preset control center to obtain creation information of the target cluster; If the creation information is target cluster created information, the data storage address of the target cluster is extracted from the cluster creation record information through a preset interface. After the step of creating the first persistent volume corresponding to the cluster to be shared based on the data storage address, the method further comprises the following steps:
4. The method of claim 1, wherein, Determining a first persistent volume claim of the cluster to be shared; Based on the first persistent volume, the first persistent volume claim, and the cluster name of the cluster to be shared, a storage information update request is sent to a monitoring center, and the monitoring center records and updates the cluster creation record information based on the storage information update request. Before the step of determining the target cluster corresponding to the cluster to be shared, the method further comprises the following steps: When an initial cluster creation request is received, a cluster corresponding to the initial cluster creation request is determined as the target cluster; 5. The method of claim 4, wherein, Based on the initial cluster creation request, a business is created to obtain a second persistent volume claim and cluster creation information corresponding to the target cluster; Based on the cluster creation information, storage is created in combination with the second persistent volume claim to obtain a second persistent volume and a data storage address corresponding to the target cluster, wherein the second persistent volume points to the data storage address. The cluster creation information contains storage pool designation information and a target cluster name of the target cluster, and the step of creating the second persistent volume and the data storage address corresponding to the target cluster based on the cluster creation information in combination with the second persistent volume claim comprises the following steps: Obtaining preset initial cluster creation record information; Determining whether the target cluster name is contained in the initial cluster creation record information; If the target cluster name is not contained in the cluster creation record, a second persistent volume of the target cluster is created based on the second persistent volume claim, and a data storage address of the target cluster is created in a storage pool corresponding to the storage pool designation information.
6. The method of claim 1, wherein, After the second persistent volume and the data storage address corresponding to the target cluster are obtained, the method further includes: generating cluster update information based on the target cluster name, the data storage address, and the second persistent volume of the target cluster; updating the initial cluster creation record based on the cluster update information to obtain cluster creation record information.
7. A cluster data sharing apparatus characterized by comprising: The method comprises: a target cluster determination module configured to, in response to receiving a persistent volume request corresponding to a to-be-shared cluster, determine a target cluster corresponding to the to-be-shared cluster, the target cluster being a cluster created before the to-be-shared cluster and needing to share data with the to-be-shared cluster; a data storage address acquisition module configured to acquire a data storage address corresponding to the target cluster; a first persistent volume creation module configured to create a first persistent volume corresponding to the to-be-shared cluster based on the data storage address, wherein the first persistent volume points to the data storage address, so that the to-be-shared cluster and the target cluster achieve data sharing based on the data storage address; Before the data storage address corresponding to the target cluster is acquired, the method further comprises extracting cluster search information of the target cluster from the persistent volume request, the cluster search information including a target cluster name and a storage pool name of the target cluster; and generating a storage address acquisition request based on the target cluster name and the storage pool name.
8. An electronic device, comprising: The device comprises a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus. The memory is configured to store a computer program. The processor is configured to execute the program stored on the memory to implement the steps of the cluster data sharing method according to any one of claims 1-6.
9. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the cluster data sharing method according to any one of claims 1-6.
Citation Information
Patent Citations
Service data hierarchical storage method and device based on container cloud
CN112181317A
Model training system, method and device based on multiple clusters and storage medium
CN112257736A
Cross-cluster backup method and system for stateful applications, medium and electronic equipment
CN114546725A
Inter-cluster persistent storage synchronization method and device, equipment and storage medium
CN115757633A