Snapshot creation method and equipment based on container arrangement platform, and storage medium
By setting up a snapshot component in the container orchestration platform and creating a snapshot after performing preprocessing operations, the problem of inaccurate snapshot data is solved and consistency after data recovery is ensured.
Patent Information
- Application Number
- CN202511122067.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-12
- Publication Date
- 2025-09-19
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The snapshot function provided by existing container orchestration platforms is not perfect, resulting in inaccurate snapshot data. As a result, when data is restored, the restored data is inconsistent with the data at the snapshot time point.
A snapshot component is set up in the container orchestration platform. After receiving a snapshot request, preprocessing operations are performed first, including controlling the target application to pause initiating write requests to the target storage volume, waiting for the write request to be completed, writing the data in the memory and cache to the storage volume, and then creating a snapshot for the target storage volume.
It ensures the stability and integrity of the target storage volume data during the snapshot operation, ensures that the snapshot data is the complete application data of the target application at the snapshot time point, solves the problem of inaccurate snapshot data, and achieves consistency after data recovery.
Smart Images

Figure CN120670091A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of storage technology, and in particular to a snapshot creation method, device, and storage medium based on a container orchestration platform. Background Art
[0002] Containerization technology encapsulates applications, their dependencies, and configuration items into independent, portable containers. This not only isolates resources for different applications but also enables cross-platform application operation, significantly improving operational efficiency.
[0003] With the development of containerization technology, the coordination and management of multiple containers through container orchestration platforms (such as Kubernetes) can solve the management challenges of large-scale containerized applications. However, the snapshot functions provided by some container orchestration platforms are not perfect, and the resulting snapshot data is not accurate. Consequently, when restoring data based on the snapshot data, the restored data is inconsistent with the data at the time of the snapshot. Summary of the Invention
[0004] The present application provides a snapshot creation method, snapshot creation device, electronic device, computer-readable storage medium, and computer program product based on a container orchestration platform, to at least solve the problem of inaccurate snapshot data in related technologies.
[0005] The present application provides a snapshot creation method based on a container orchestration platform. The container orchestration platform includes a pre-created snapshot resource template, at least one application deployed in a containerized manner, and a snapshot component. The method is applied to the snapshot component and includes: receiving a snapshot request, the snapshot request being generated based on the snapshot resource template, the snapshot request including a target application and a target storage volume associated with the target application; performing a preprocessing operation, the preprocessing operation including controlling the target application to suspend initiating a write request to the target storage volume, waiting for completion of an executing write request initiated by the target application, and writing data of the target application in the memory and cache to the target storage volume; After the pre-processing operation is completed, a snapshot is created for the data in the target storage volume.
[0006] The present application also provides a snapshot creation device based on a container orchestration platform, wherein the container orchestration platform includes a pre-created snapshot resource template and at least one application deployed in a containerized manner, and the device includes: a triggering module, configured to receive a snapshot request, wherein the snapshot request is generated based on the snapshot resource template, and the snapshot request includes a target application and a target storage volume associated with the target application; an agent module configured to perform a preprocessing operation, wherein the preprocessing operation includes controlling the target application to suspend initiating a write request to the target storage volume, waiting for completion of an ongoing write request initiated by the target application, and writing data of the target application in memory and cache to the target storage volume; The storage module is configured to create a snapshot for the data in the target storage volume when the preprocessing operation is completed.
[0007] The present application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of any of the above-mentioned snapshot creation methods based on a container orchestration platform when executing the computer program.
[0008] The present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the steps of any of the above-mentioned snapshot creation methods based on the container orchestration platform.
[0009] The present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of any of the above-mentioned snapshot creation methods based on the container orchestration platform.
[0010] In the technical solutions of some embodiments of the present application, a snapshot component is set on the container orchestration platform, and after receiving a snapshot request, the snapshot component first performs pre-processing operations based on the target application and target storage volume in the snapshot request, and then creates a snapshot for the data in the target storage volume. In this way, it can be ensured that when the snapshot operation is performed, the data of the target storage volume is stable, and the data of the target application located in the memory and cache has been written to the disk, and then the snapshot data obtained can be the complete application data of the target application at the snapshot time point. In this way, the problem of inaccurate snapshot data in some technologies can be solved, and it can be ensured that after the recovery operation is performed on the target application based on the snapshot data, the recovered target application data is consistent with the application data at the snapshot time point. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0012] Figure 1 Diagram of creating data snapshots for some container orchestration platforms; Figure 2 A schematic diagram of a module of a container orchestration platform provided for some embodiments of the present application; Figure 3A flowchart of a snapshot creation method provided in some embodiments of the present application; Figure 4 A schematic diagram of a module of a snapshot component provided for some embodiments of the present application; Figure 5 A schematic diagram illustrating the connection between the container orchestration platform and the storage system provided in some embodiments of the present application; Figure 6 A schematic diagram of a module of an agent component provided for some embodiments of the present application; Figure 7 A schematic diagram of a module of a snapshot creation device provided in some embodiments of the present application; Figure 8 A schematic diagram of a module of an electronic device provided for some embodiments of the present application. DETAILED DESCRIPTION
[0013] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0014] It should be noted that, in the description of this application, the terms "comprises," "includes," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. The terms "first," "second," etc., in this application are used to distinguish similar objects, and are not used to describe a particular order or sequence.
[0015] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0016] In some container orchestration platforms (such as Kubernetes), resources refer to objects with a lifecycle that can be managed through an API (Application Programming Interface). For example, Pods, Nodes, Services, and instantiated objects in the container orchestration platform.
[0017] Resources can be categorized as native resources and custom resources. Native resources are managed by the container orchestration platform's core APIs and built-in controllers. The core APIs provide native resource operations (such as resource creation, update, and deletion). Built-in controllers monitor native resource change events (such as creation, update, and deletion) and trigger corresponding operations. Custom resources, also known as CRs, are resources defined using the container orchestration platform's extended APIs. Generally, before defining a custom resource (CR), you need to first define a Custom Resource Definition (CRD) and deploy the controller corresponding to the CRD. The CRD declares the structure of the custom resource CR (such as fields and field types). A custom resource CR is an instantiation of the CRD (e.g., the object obtained by assigning values to fields in the CRD). The extended APIs provide custom resource operations (such as resource creation, update, and deletion). The controllers corresponding to the CRD monitor custom resource CR change events (such as creation, update, and deletion) and trigger corresponding operations.
[0018] Based on the container orchestration platform's custom mechanism, you can predefine custom resource definitions (CRs) related to data snapshots. Based on these CRDs, you can create custom resource CRs as needed. The controller corresponding to the CRD can trigger a data snapshot operation upon detecting the creation of a custom resource CR.
[0019] For example, in a CRD, you can pre-specify the field persistentVolumeClaimName to indicate the storage volume for which a data snapshot is to be created. Based on the CRD, in one custom resource, CR1, the value of the field persistentVolumeClaimName is set to mysql-pvc, indicating that a snapshot operation will be performed on the data in the storage volume mysql-pvc. The data in the storage volume mysql-pvc is MySQL application data. After monitoring the creation operation of custom resource CR1, the controller corresponding to the CRD can trigger a snapshot operation on the data in the storage volume mysql-pvc. For another example, in another custom resource, CR2, the value of the field persistentVolumeClaimName is set to oracle-pvc, indicating that a snapshot operation will be performed on the data in the storage volume oracle-pvc. The data in the storage volume oracle-pvc is Oracle application data. After monitoring the creation operation of custom resource CR2, the controller corresponding to the CRD can trigger a snapshot operation on the data in the storage volume oracle-pvc.
[0020] See also Figure 1 , a schematic diagram of creating data snapshots for some container orchestration platforms. Figure 1 In the container orchestration platform, the container orchestration platform is connected to the storage system. The container orchestration platform includes at least one business container and at least one auxiliary container. The business container, also known as the primary container or application container, is used to run containerized applications. The auxiliary container, also known as the sidecar container, provides auxiliary functions required for application operation, such as log collection, monitoring, and network proxy. The controller corresponding to the aforementioned CRD resides on the container orchestration platform as an auxiliary container. The storage system includes a storage interface, a storage plug-in developed based on the CSI (Container Storage Interface) protocol, and at least one storage volume. The storage interface is a data operation interface provided by the storage system that can be called by third parties, such as a data deletion interface and a data creation interface. The storage volume is used to store the business data of the container orchestration platform. Business data may include, but is not limited to, application data of various applications deployed in a containerized manner on the container orchestration platform.
[0021] After the sidecar container detects the creation of a custom resource (CR) associated with a data snapshot, it can send a snapshot request to the storage plug-in based on the CSI protocol. The storage plug-in parses the snapshot request based on the CSI protocol and calls the storage system's storage interface to create a snapshot of the storage volume data specified by the custom resource (CR).
[0022] exist Figure 1 In the illustrated technology, snapshot operations can only be performed on application data that has already been written to disk, not on application data located in memory or cache. Therefore, the resulting snapshot data is inaccurate. Furthermore, after performing a restore operation on the application based on the snapshot data, the restored application data may be inconsistent with the application data at the time of the snapshot. For example, assume that at time point 1, application A's data D1 and D2 are saved to storage volume P1 (i.e., already written to disk), but data D3 and D4 are stored in memory (i.e., not yet written to disk). In this case, performing a snapshot operation on application A's data only yields snapshot data for data D1 and D2, not for data D3 and D4. Thus, when a restore operation is performed on application A based on the snapshot data obtained at time point 1, the restored application A will have data differences from application A at time point 1. That is, application A at time point 1 has data D3 and D4, but the restored application A does not have data D3 and D4.
[0023] In view of this, this application first provides a container orchestration platform with a new architecture. Figure 2 , which is a module diagram of the container orchestration platform provided in some embodiments of the present application. Figure 2 and Figure 1 Basically similar, the main difference is that the container orchestration platform includes a pre-created snapshot resource template, at least one application deployed in a containerized manner, and a snapshot component. Among them, the application runs on the container orchestration platform in the form of a business container, and the snapshot component resides on the container orchestration platform in the form of an auxiliary container (i.e., a sidecar container). The snapshot resource template refers to the CRD related to the snapshot operation. In the snapshot resource template, you can declare at least one field related to the snapshot logic and the field type of each field. For example, in the snapshot resource template, you can declare the following fields: name: Indicates the target application for which the snapshot operation is to be performed. The target application can be any application in the container orchestration platform.
[0024] persistentVolumeClaimName: Used to indicate the target storage volume associated with the target application. The target application's application data is stored in the target storage volume.
[0025] In a snapshot resource template, there may only be field definitions but no field values.
[0026] Specifically, you can create a snapshot resource template, snapshot component, and target application using the following methods: 1) Define the snapshot resource template and snapshot component in a YAML (YetAnotherMarkupLanguage) file, then call the core API or extended API of the container orchestration platform to create the snapshot resource template and snapshot component. The APIs used to create the snapshot resource template and snapshot component can be different.
[0027] 2) Define one or more instances of the target application in a YAML file, call the core API or extended API of the container orchestration platform, and create an instance of the target application. In this way, the target application can be run on the container orchestration platform.
[0028] based on Figure 2 The container orchestration platform shown in the figure, this application provides a snapshot creation method based on the container orchestration platform, which can solve the problem of inaccurate snapshot data in some technologies. Specifically, the snapshot creation method can be applied to Figure 2 Snapshot components in . See also Figure 3 , which is a flowchart of a snapshot creation method provided in some embodiments of the present application. Figure 3 In the snapshot creation method, the following steps are included: Step S301: receiving a snapshot request, where the snapshot request is generated based on a snapshot resource template and includes a target application and a target storage volume associated with the target application.
[0029] Specifically, users or modules that perform snapshot operations (such as modules that perform data backup operations) can create snapshot-related custom resources CRs based on actual needs and the structure declared in the snapshot resource template. For example, assuming user U1 wants to perform a snapshot operation on the application data of application A1, and application A1's application data is stored in storage volume S1, user U1 can create a custom resource CR similar to the following: name=A1; persistentVolumeClaimName=S1.
[0030] For another example, assuming that module U2 performing data backup operations wants to perform a snapshot operation on the application data of application A2, and the application data of application A2 is stored in storage volume S2, then module U2 can create a custom resource CR similar to the following: name=A2; persistentVolumeClaimName=S2.
[0031] After the snapshot component detects the creation event of a custom resource CR related to the snapshot, it indicates that it has received a snapshot request. The information in the custom resource CR can be regarded as the information in the snapshot request.
[0032] Step S302 , performing preprocessing operations, including controlling the target application to suspend initiating write requests to the target storage volume, waiting for the completion of the write request being executed by the target application, and writing the target application's data in the memory and cache to the target storage volume.
[0033] Specifically, controlling the target application to pause initiating write requests to the target storage volume ensures that the data in the target storage volume is stable during the snapshot operation, thereby ensuring the accuracy of the snapshot data. Waiting for the completion of the target application's ongoing write requests and writing the target application's data in memory and cache to the target storage volume ensures that all the target application's data has been written to disk when the snapshot operation is executed, thereby ensuring that the data in the target storage volume is complete and accurate.
[0034] Step S303: When the pre-processing operation is completed, a snapshot is created for the data in the target storage volume.
[0035] Specifically, with Figure 1Similarly, the snapshot component can send a snapshot request for the target storage volume to the storage plug-in of the storage system via the CSI protocol based on the monitored custom resource CR. The storage plug-in parses the snapshot request based on the CSI protocol and calls the storage interface of the storage system to create a snapshot of the data of the target storage volume. It can be understood that after the preprocessing operation is completed, the data in the memory and cache of the target application has been written to the disk, and the data in the target storage volume can be temporarily kept stable. Therefore, the obtained snapshot data can be the complete application data of the target application at the snapshot time point, thereby avoiding the problem of inaccurate snapshot data.
[0036] In summary, in the technical solutions of some embodiments of the present application, a snapshot component is set on the container orchestration platform, and after receiving a snapshot request, the snapshot component first performs a pre-processing operation based on the target application and target storage volume in the snapshot request, and then creates a snapshot for the data in the target storage volume. In this way, it can be ensured that when the snapshot operation is performed, the data of the target storage volume is stable, and the data of the target application located in the memory and cache has been written to the disk, and then, the snapshot data obtained can be the complete application data of the target application at the snapshot time point. In this way, the problem of inaccurate snapshot data in some technologies can be solved, and it can be ensured that after the recovery operation is performed on the target application based on the snapshot data, the recovered target application data is consistent with the application data at the snapshot time point.
[0037] See also Figure 4 , which is a module diagram of the snapshot component provided in some embodiments of the present application. Figure 4 In the example, the snapshot component includes a control component, a trigger component, a storage component, and an agent component deployed in a containerized manner. Specifically, the control component, the trigger component, the storage component, and the agent component can reside in the container orchestration platform in the form of auxiliary containers. The trigger component is used to receive a snapshot request and send the snapshot request to the control component. The control component is used to call the agent component to perform preprocessing operations, and in response to the agent component completing the preprocessing operations, the control component is also used to call the storage component to create a snapshot for the data in the target storage volume. In simple terms, the trigger component is used to monitor the creation events of custom resources CR related to the snapshot, and based on the monitored creation events, send a snapshot request to the control component. The control component can be used to control the overall process of snapshot creation, that is, first call the agent component to perform preprocessing operations, and then call the storage component to create a snapshot for the data in the target storage volume.
[0038] exist Figure 4In the illustrated embodiment, the snapshot component is divided into a control component, a trigger component, a storage component, and a proxy component, and snapshot creation is accomplished through interaction between these components. This allows for decoupling between components, meaning that changes to the processing logic of one component do not affect the processing logic of other components, thereby reducing the workload associated with logic changes. For example, to add or subtract preprocessing steps, only the processing logic of the proxy component needs to be modified, without having to modify the processing logic of the control component, trigger component, or storage component.
[0039] In some embodiments, after receiving the snapshot request, the trigger component is further configured to perform at least one of the following verifications and, if the verification passes, send the snapshot request to the control component: Verify whether the target application has been deployed on the container orchestration platform, and if the target application has been deployed, continue to verify whether the target application is in a running state; Verify that the target storage volume exists, and if so, continue to verify that the target storage volume is in an available state.
[0040] Specifically, when defining a target application instance in a YAML file, you are actually defining the target application's workload resources within the YAML file. Workload resources refer to a set of objects used in the container orchestration platform to deploy and manage the lifecycle of target application instances. The trigger component can call the container orchestration platform's API to query whether the workload resources corresponding to the target application exist. If so, the container orchestration platform has deployed the target application. If not, the container orchestration platform has not deployed the target application.
[0041] Furthermore, the target application usually runs in a Pod. A Pod refers to the smallest computing unit that can be scheduled and managed in a container orchestration platform. Each Pod can include at least one application container. If the target application has been deployed, you can continue to call the API of the container orchestration platform to query whether the Pod where the target application is located is in a running state. If so, you can continue to call the API of the container orchestration platform to query whether the application container in the Pod is in a ready state. If so, it means that the target application is in a running state; if not, it means that the target application is not in a running state.
[0042] Furthermore, the trigger component can call the storage plug-in in the storage system based on the CSI protocol, and the storage plug-in calls the storage interface of the storage system to verify whether the target storage volume exists in the storage system and whether the target storage volume is in an available state.
[0043] In the above embodiment, after receiving a snapshot request, the trigger component first verifies the target application and target storage volume. If verification passes, it sends the snapshot request to the control component. This ensures that subsequent snapshot creation processes will not fail due to abnormalities in the target application or target storage volume.
[0044] See also Figure 5 , which is a schematic diagram of the connection between the container orchestration platform and the storage system provided in some embodiments of the present application. Figure 5 In [1], the container orchestration platform interfaces with multiple storage systems of different types. The target storage volume resides in one of these storage systems (for example, storage system n). Each storage system includes a storage plug-in. The storage plug-in in each storage system is developed by the storage system manufacturer based on the CSI protocol and can vary from storage system to storage system. To communicate with different storage plug-ins, the snapshot component can include multiple storage components, each corresponding to a storage system. Each storage component is used to communicate with the storage plug-in of its corresponding storage system.
[0045] exist Figure 5 In the illustrated embodiment, the snapshot resource template may specifically declare the following fields: name: Used to indicate the target application for which the snapshot operation is to be performed.
[0046] persistentVolumeClaimName: used to indicate the target storage volume associated with the target application.
[0047] storageProvider: used to represent the target storage component corresponding to the storage system where the target storage volume is located.
[0048] Correspondingly, by assigning a value to the field storageProvider, the snapshot request (i.e., custom resource CR) generated based on the snapshot resource template can also include a target storage component. In response to the proxy component completing the preprocessing operation, the control component calls the target storage component, and in response to the call of the control component, the target storage component calls the storage plug-in of the corresponding storage system to create a snapshot for the data in the target storage volume. For example, suppose that user U1 wants to perform a snapshot operation on the application data of application A1. If the application data of application A1 is stored in the storage volume S1 of storage system 1, the storage plug-in of storage system 1 is storage plug-in F1, and the storage component corresponding to storage system 1 in the container orchestration platform is storage component Z1, then user U1 can create a custom resource CR similar to the following: name=A1; persistentVolumeClaimName=S1; storageProvider = Z1.
[0049] For another example, suppose user U2 wants to perform a snapshot operation on the application data of application A2. If the application data of application A2 is stored in storage volume S2 of storage system 2, the storage plug-in of storage system 2 is storage plug-in F2, and the storage component corresponding to storage system 2 in the container orchestration platform is storage component Z2, then user U2 can create a custom resource CR similar to the following: name=A2; persistentVolumeClaimName=S2; storageProvider = Z2.
[0050] The control component can call the target storage component in the snapshot request to perform a data snapshot operation.
[0051] In this way, it can be ensured that the storage plug-in called by the control component is correct. In addition, by specifying the storage component in the control request, the logical judgment on the control component side can be reduced.
[0052] In some embodiments, after receiving the snapshot request, the trigger component is further configured to perform the following verification and, if the verification passes, send the snapshot request to the control component: Verify that the target storage component has been created on the container orchestration platform. If the target storage component has been created, verify that the target storage component is running.
[0053] Specifically, the target storage component can be verified using a similar verification method as the target application, which will not be detailed here. After the target storage component has been verified, the snapshot request is sent to the control component. This ensures that subsequent snapshot creation processes will not fail due to abnormalities in the target storage component.
[0054] See also Figure 6 , which is a module diagram of the proxy component provided in some embodiments of the present application. Figure 6In the case where multiple applications are deployed in the container orchestration platform, each application can have its own corresponding proxy component. The preprocessing logic of different proxy components can be different. For example, assume that proxy component T1 corresponds to application A1, and proxy component T2 corresponds to application A2. When creating a snapshot of the application data of application A1, proxy component T1 controls application A1 to suspend initiating write requests to the associated storage volume based on command C1. When creating a snapshot of the application data of application A2, proxy component T2 controls application A2 to suspend initiating write requests to the associated storage volume based on command C2. In this way, the preprocessing operations of different applications can be decoupled, making it easier to customize the preprocessing operations of each application.
[0055] exist Figure 6 In the illustrated embodiment, the snapshot resource template may specifically declare the following fields: name: Used to indicate the target application for which the snapshot operation is to be performed.
[0056] persistentVolumeClaimName: used to indicate the target storage volume associated with the target application.
[0057] storageProvider: used to represent the target storage component corresponding to the storage system where the target storage volume is located.
[0058] agent: used to indicate the target agent component corresponding to the target application.
[0059] Accordingly, by assigning a value to the field agent, the snapshot request generated based on the snapshot resource template may include a target agent component corresponding to the target application. The control component may call the target agent component to perform pre-processing operations.
[0060] In some embodiments, after receiving a snapshot request, the trigger component is further configured to verify whether the target proxy component has been created on the container orchestration platform. If the target proxy component has been created, the trigger component further verifies whether the target proxy component is running. If verification is successful, the trigger component sends the snapshot request to the control component. This ensures that subsequent snapshot creation processes will not fail due to abnormalities in the target proxy component.
[0061] In some embodiments, the target application may include an application log, which is used to record the running information of the target application. Normally, the application log is first saved in the memory. At preset time intervals, the application log can be written to the disk, that is, the application log in the memory is written to the target storage volume associated with the target application. During the execution of the snapshot operation, the target application may update the application log in the memory. Since the target application suspends initiating write requests to the target storage volume, these updated log data cannot be written to the target storage volume. In this way, the log data in the snapshot data will be inconsistent with the log data at the snapshot time point. In view of this, in these embodiments, the preprocessing operation may also include: setting the application log to a frozen state, so that the target application suspends writing new log data to the application log. In this way, the log data in the snapshot data is guaranteed to be consistent with the log data at the snapshot time point, thereby ensuring the accuracy of the snapshot data.
[0062] In some embodiments, the snapshot resource template may specifically declare the following fields: name: Used to indicate the target application for which the snapshot operation is to be performed.
[0063] persistentVolumeClaimName: used to indicate the target storage volume associated with the target application.
[0064] storageProvider: used to represent the target storage component corresponding to the storage system where the target storage volume is located.
[0065] agent: used to indicate the target agent component corresponding to the target application.
[0066] freezeDuration: indicates the maximum freezing duration.
[0067] Accordingly, by assigning a value to the freezeDuration field, the snapshot request generated based on the snapshot resource template may include the maximum freeze duration. After performing the preprocessing operation, the method of the present application may further include: If the target application's suspension of initiating write requests to the target storage volume reaches the maximum freeze duration, the target application's permission to initiate write requests to the target storage volume is restored; If the freezing time of the application log reaches the maximum freezing time, the application log will be unfrozen.
[0068] Specifically, the maximum freeze duration can be greater than the target storage volume's snapshot creation duration. This ensures that, during the snapshot creation process, the application log remains frozen and the target application's write access to the target storage volume remains suspended, thus ensuring the accuracy of the snapshot data. Furthermore, after the snapshot is created, the target application's permission to initiate write requests to the target storage volume and application log can be promptly restored, ensuring the normal operation of the target application.
[0069] In some embodiments, the snapshot resource template may specifically declare the following fields: name: Used to indicate the target application for which the snapshot operation is to be performed.
[0070] persistentVolumeClaimName: used to indicate the target storage volume associated with the target application.
[0071] storageProvider: used to represent the target storage component corresponding to the storage system where the target storage volume is located.
[0072] agent: used to indicate the target agent component corresponding to the target application.
[0073] freezeDuration: indicates the maximum freezing duration.
[0074] preProcess: used to indicate preprocessing operation configuration.
[0075] -command1: used to indicate the preprocessing operation command.
[0076] -timeout1: indicates the preprocessing timeout period.
[0077] Specifically, in the above snapshot resource template, the field preProcess represents the preprocessing operation configuration. The fields command1 and timeout1 are subfields of the field preProcess, that is, the preprocessing operation configuration includes the preprocessing operation command and the preprocessing timeout duration.
[0078] Accordingly, by assigning values to the command1 and timeout1 fields, the snapshot request can include a preprocessing operation command and a preprocessing timeout period. If the preprocessing operation configuration includes a preprocessing operation command, when executing the preprocessing operation in step S302 above, the preprocessing operation can be completed by executing the preprocessing operation command. If the execution time of the preprocessing operation reaches the preprocessing timeout period, the preprocessing operation is suspended and a prompt message indicating that the preprocessing operation failed is generated.
[0079] In the above embodiment, based on the preprocessing operation configuration, the preprocessing logic of different applications can be customized, which is more flexible.
[0080] In some embodiments, the snapshot resource template may specifically declare the following fields: name: Used to indicate the target application for which the snapshot operation is to be performed.
[0081] persistentVolumeClaimName: used to indicate the target storage volume associated with the target application.
[0082] storageProvider: used to represent the target storage component corresponding to the storage system where the target storage volume is located.
[0083] agent: used to indicate the target agent component corresponding to the target application.
[0084] freezeDuration: indicates the maximum freezing duration.
[0085] preProcess: used to indicate preprocessing operation configuration.
[0086] -path1: used to indicate the first script path.
[0087] -timeout1: indicates the preprocessing timeout period.
[0088] Specifically, in the above-mentioned snapshot resource template, the fields path1 and timeout1 are subfields of the field preProcess, that is, the preprocessing operation configuration includes the first script path and the preprocessing timeout period. Among them, the first script path is the script path for performing the preprocessing operation. By assigning a value to the field path1, the snapshot request can include the first script path. In the case where the preprocessing operation configuration includes the first script path, when performing the preprocessing operation in the above-mentioned step S302, the preprocessing operation can be completed by executing the first script under the first script path. In this way, corresponding preprocessing scripts can be developed for different applications, which is more flexible.
[0089] In some embodiments, the snapshot resource template may specifically declare the following fields: name: Used to indicate the target application for which the snapshot operation is to be performed.
[0090] persistentVolumeClaimName: used to indicate the target storage volume associated with the target application.
[0091] storageProvider: used to represent the target storage component corresponding to the storage system where the target storage volume is located.
[0092] agent: used to indicate the target agent component corresponding to the target application.
[0093] freezeDuration: indicates the maximum freezing duration.
[0094] preProcess: used to indicate preprocessing operation configuration.
[0095] -command: used to indicate the preprocessing operation command.
[0096] -timeout: used to indicate the preprocessing timeout period.
[0097] postProcess: used to indicate post-processing operation configuration.
[0098] -command2: used to indicate post-processing operation commands.
[0099] -timeout2: used to indicate the post-processing timeout period.
[0100] Specifically, in the above snapshot resource template, the postProcess field represents the post-processing operation configuration. The command2 and timeout2 fields are subfields of the postProcess field, that is, the post-processing operation configuration includes the post-processing operation command and the post-processing timeout duration.
[0101] Accordingly, by assigning values to the command2 and timeout2 fields, a snapshot request can include a post-processing command and a post-processing timeout. After creating a snapshot of the data in the target storage volume, you can execute the post-processing command to complete the post-snapshot post-processing. If the post-processing timeout is reached, the post-processing operation is suspended and a message indicating the post-processing failure is generated.
[0102] In some embodiments, the snapshot resource template may specifically declare the following fields: name: Used to indicate the target application for which the snapshot operation is to be performed.
[0103] persistentVolumeClaimName: used to indicate the target storage volume associated with the target application.
[0104] storageProvider: used to represent the target storage component corresponding to the storage system where the target storage volume is located.
[0105] agent: used to indicate the target agent component corresponding to the target application.
[0106] freezeDuration: indicates the maximum freezing duration.
[0107] preProcess: used to indicate preprocessing operation configuration.
[0108] -command: used to indicate the preprocessing operation command.
[0109] -timeout: used to indicate the preprocessing timeout period.
[0110] postProcess: used to indicate post-processing operation configuration.
[0111] -path2: used to indicate the second script path.
[0112] -timeout2: used to indicate the post-processing timeout period.
[0113] Specifically, in the above snapshot resource template, the fields path2 and timeout2 are subfields of the field postProcess, that is, the post-processing operation configuration includes the second script path and the post-processing timeout period.
[0114] Accordingly, by assigning values to the path2 and timeout2 fields, the snapshot request can include the second script path and the post-processing timeout. After creating a snapshot of the data in the target storage volume, the second script under the second script path can be executed to complete the post-snapshot post-processing operations.
[0115] In some embodiments, when creating a snapshot for data in the target storage volume, the method of the present application may further include: In the created snapshot, metadata information related to the application state of the target application is recorded, wherein when a recovery operation is performed on the target application based on the created snapshot, the metadata information is used to determine the initial state to which the target application needs to be restored.
[0116] For example, before executing a snapshot, the last location of the target application's application logs on the target storage volume can be recorded as metadata in the created snapshot. This allows you to restore the target application to the last location when restoring the application based on the snapshot data.
[0117] In some embodiments, in a distributed system, multiple applications are grouped together, and the application agents of the multiple applications are coordinated by a control component to perform preprocessing operations (for example, controlling multiple application agents to perform preprocessing operations at the same time). This allows for a consistency group snapshot in the distributed system, thereby ensuring data consistency across containers and nodes.
[0118] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method.
[0119] The embodiment of the present application also provides a snapshot creation device based on a container orchestration platform. The container orchestration platform includes a pre-created snapshot resource template and at least one application deployed in a containerized manner. Figure 7 , which is a module diagram of a snapshot creation device provided in some embodiments of the present application. Figure 7 In the example, the snapshot creation device includes: Trigger module 701 receives a snapshot request, where the snapshot request is generated based on a snapshot resource template and includes a target application and a target storage volume associated with the target application; The proxy module 702 is configured to perform pre-processing operations, including controlling the target application to suspend initiating write requests to the target storage volume, waiting for the completion of the write request being executed by the target application, and writing the target application's data in the memory and cache to the target storage volume; The storage module 703 is configured to create a snapshot for the data in the target storage volume after the pre-processing operation is completed.
[0120] In some embodiments, the snapshot creation apparatus further includes a control module 704, wherein: The trigger module 701 receives the snapshot request and sends the snapshot request to the control module 704. The control module 704 is used to call the proxy module 702 to perform preprocessing operations. In response to the proxy module 702 completing the preprocessing operations, the control module 704 is also used to call the storage module 703 to create a snapshot for the data in the target storage volume.
[0121] In some embodiments, after receiving the snapshot request, the trigger module 701 is further configured to perform at least one of the following verifications and, if the verification passes, send the snapshot request to the control module 704: Verify whether the target application has been deployed on the container orchestration platform, and if the target application has been deployed, continue to verify whether the target application is in a running state; Verify that the target storage volume exists, and if so, continue to verify that the target storage volume is in an available state.
[0122] In some embodiments, the container orchestration platform is connected to multiple storage systems of different types, the target storage volume is located in one of the storage systems, and each storage system includes a storage plug-in; The snapshot creation device includes a plurality of storage modules 703, each of which corresponds to a storage plug-in. The snapshot request also includes a target storage component corresponding to the storage system where the target storage volume is located. In response to the agent module 702 completing the preprocessing operation, the control module 704 calls the target storage module 703, and in response to the call of the control module 704, the storage plug-in of the storage system corresponding to the target storage module 703 creates a snapshot for the data in the target storage volume.
[0123] In some embodiments, after receiving the snapshot request, the trigger module 701 is further configured to perform the following verification and, if the verification passes, send the snapshot request to the control module 704: Verify whether the target storage module 703 has been created on the container orchestration platform, and if the target storage module 703 has been created, continue to verify whether the target storage module 703 is in a running state.
[0124] In some embodiments, each application of the container orchestration platform has a corresponding proxy module 702 , and the snapshot request further includes a target proxy module 702 corresponding to the target application; After receiving the snapshot request, the trigger module 701 is further used to verify whether the target proxy module 702 has been created on the container orchestration platform. If the target proxy module 702 has been created, the trigger module 701 further verifies whether the target proxy module 702 is in a running state. If the verification is successful, the trigger module 701 sends the snapshot request to the control module 704: The control module 704 is used to call the target agent module 702 to perform pre-processing operations.
[0125] In some embodiments, when creating a snapshot for data in the target storage volume, the storage module 703 is further configured to: In the created snapshot, metadata information related to the application state of the target application is recorded, wherein when a recovery operation is performed on the target application based on the created snapshot, the metadata information is used to determine the initial state to which the target application needs to be restored.
[0126] In some embodiments, the target application includes an application log, which is used to record the running information of the target application; the agent module 702 is further used to: Set the application log to a frozen state to stop the target application from writing new log data to the application log.
[0127] In some embodiments, the snapshot request includes a maximum freezing duration, and the maximum freezing duration is greater than a snapshot creation duration of the target storage volume; After performing the pre-processing operation, the proxy module 702 is further configured to: If the target application's suspension of initiating write requests to the target storage volume reaches the maximum freeze duration, the target application's permission to initiate write requests to the target storage volume is restored; If the freezing time of the application log reaches the maximum freezing time, the application log will be unfrozen.
[0128] In some embodiments, the snapshot request further includes a pre-processing operation configuration, which includes one of a pre-processing operation command and a first script path; the proxy module 702 is specifically configured to: In a case where the preprocessing operation configuration includes a preprocessing operation command, completing the preprocessing operation by executing the preprocessing operation command; In a case where the pre-processing operation configuration includes a first script path, the pre-processing operation is completed by executing a first script under the first script path.
[0129] In some embodiments, the pre-processing operation configuration further includes a pre-processing timeout period, and the agent module 702 is further configured to: If the duration of the preprocessing operation reaches the preprocessing timeout, the preprocessing operation is suspended and a prompt message indicating that the preprocessing operation failed is generated.
[0130] In some embodiments, the snapshot request further includes a post-processing operation configuration, the post-processing operation configuration including one of a post-processing operation command and a second script path; After creating a snapshot for the data in the target storage volume, the storage module 703 is further configured to: Execute the post-processing operation command, or execute the second script in the second script path to complete the post-processing operation after the snapshot is created.
[0131] For descriptions of features in the embodiments corresponding to the snapshot creation apparatus based on the container orchestration platform, please refer to the descriptions of the embodiments corresponding to the snapshot creation method based on the container orchestration platform, and will not be repeated here.
[0132] See also Figure 8 An embodiment of the present application also provides an electronic device, including a memory 10 and a processor 20, wherein the memory 10 stores a computer program, and the processor 20 is configured to run the computer program to execute the steps in any of the above-mentioned embodiments of the snapshot creation method based on the container orchestration platform.
[0133] An embodiment of the present application further provides a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps of any of the above-mentioned embodiments of the snapshot creation method based on the container orchestration platform when running.
[0134] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.
[0135] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps of any of the above-mentioned snapshot creation method embodiments based on a container orchestration platform are implemented.
[0136] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any of the above-mentioned embodiments of the snapshot creation method based on the container orchestration platform are implemented.
[0137] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0138] The above is a detailed introduction to the snapshot creation method, device and storage medium based on the container orchestration platform provided by this application. This article uses specific examples to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method of this application and its core idea. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of this application, several improvements and modifications can be made to this application, and these improvements and modifications also fall within the scope of protection of the claims of this application.
Claims
1. A snapshot creation method based on a container orchestration platform, characterized in that: The container orchestration platform includes a pre-created snapshot resource template, at least one application deployed in a containerized manner, and a snapshot component. The method is applied to the snapshot component, including: receiving a snapshot request, the snapshot request being generated based on the snapshot resource template, the snapshot request including a target application and a target storage volume associated with the target application; performing a preprocessing operation, the preprocessing operation including controlling the target application to suspend initiating a write request to the target storage volume, waiting for completion of an executing write request initiated by the target application, and writing data of the target application in the memory and cache to the target storage volume; After the pre-processing operation is completed, a snapshot is created for the data in the target storage volume.
2. The method according to claim 1, characterized in that The snapshot component includes a control component, a trigger component, a storage component, and an agent component deployed in a containerized manner, wherein: The trigger component is used to receive the snapshot request and send the snapshot request to the control component. The control component is used to call the agent component to perform the preprocessing operation. In response to the agent component completing the preprocessing operation, the control component is also used to call the storage component to create a snapshot of the data in the target storage volume.
3. The method according to claim 2, characterized in that After receiving the snapshot request, the trigger component is further configured to perform at least one of the following verifications, and send the snapshot request to the control component if the verification passes: Verifying whether the target application has been deployed on the container orchestration platform, and if the target application has been deployed, further verifying whether the target application is in a running state; Verify whether the target storage volume exists, and if the target storage volume exists, continue to verify whether the target storage volume is in an available state.
4. The method according to claim 2, characterized in that The container orchestration platform is connected to a plurality of storage systems of different types, the target storage volume is located in one of the storage systems, and each of the storage systems includes a storage plug-in; The snapshot component includes a plurality of storage components, each of which corresponds to the storage system in a one-to-one manner, and the snapshot request further includes a target storage component corresponding to the storage system where the target storage volume is located; In response to the agent component completing the preprocessing operation, the control component calls the target storage component, and in response to the call of the control component, the target storage component calls the storage plug-in of the corresponding storage system to create a snapshot for the data in the target storage volume.
5. The method according to claim 4, characterized in that After receiving the snapshot request, the trigger component is further configured to perform the following verification and, if the verification passes, send the snapshot request to the control component: Verify whether the target storage component has been created on the container orchestration platform, and if the target storage component has been created, continue to verify whether the target storage component is in a running state.
6. The method according to claim 2, characterized in that Each application of the container orchestration platform has a corresponding proxy component, and the snapshot request further includes a target proxy component corresponding to the target application; After receiving the snapshot request, the trigger component is further configured to verify whether the target proxy component has been created on the container orchestration platform, and if the target proxy component has been created, to continue verifying whether the target proxy component is in a running state, and to send the snapshot request to the control component if the verification passes: The control component is used to call the target agent component to perform the preprocessing operation.
7. The method according to any one of claims 1 to 6, characterized in that: When creating a snapshot for the data in the target storage volume, the method further includes: In the created snapshot, metadata information related to the application state of the target application is recorded, wherein when a recovery operation is performed on the target application based on the created snapshot, the metadata information is used to determine the initial state to which the target application needs to be restored.
8. The method according to any one of claims 1 to 6, characterized in that: The target application includes an application log, and the application log is used to record the running information of the target application; The pre-processing operation further includes: The application log is set to a frozen state so that the target application stops writing new log data into the application log.
9. The method according to claim 8, characterized in that The snapshot request includes a maximum freezing duration, where the maximum freezing duration is greater than a snapshot creation duration of the target storage volume; After performing the preprocessing operation, the method further includes: If the target application is suspended from initiating write requests to the target storage volume for a period of time that reaches the maximum freeze period, restoring the target application's permission to initiate write requests to the target storage volume; If the freezing time of the application log reaches the maximum freezing time, a thawing operation is performed on the application log.
10. The method according to any one of claims 1 to 6, characterized in that: The snapshot request further includes a pre-processing operation configuration, wherein the pre-processing operation configuration includes one of a pre-processing operation command and a first script path; The performing of the pre-processing operation includes: In a case where the pre-processing operation configuration includes the pre-processing operation command, completing the pre-processing operation by executing the pre-processing operation command; In a case where the pre-processing operation configuration includes the first script path, the pre-processing operation is completed by executing the first script under the first script path.
11. The method according to claim 10, characterized in that The pre-processing operation configuration further includes a pre-processing timeout period, and the method further includes: If the duration of executing the preprocessing operation reaches the preprocessing timeout duration, the preprocessing operation is suspended, and a prompt message indicating that the preprocessing operation has failed is generated.
12. The method according to any one of claims 1 to 6, characterized in that: The snapshot request further includes a post-processing operation configuration, wherein the post-processing operation configuration includes one of a post-processing operation command and a second script path; After creating a snapshot for the data in the target storage volume, the method further includes: Execute the post-processing operation command, or execute the second script under the second script path, to complete the post-processing operation after the snapshot is created.
13. A computer-readable storage medium, characterized in that The computer-readable storage medium is used to store a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 12 is implemented.
14. An electronic device, characterized in that: The electronic device includes a processor and a memory, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, the method according to any one of claims 1 to 12 is implemented.
15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 12 is implemented.
Citation Information
Patent Citations
method and system for storing snapshots in combination with Kubernetes and Ceph
CN109828951A
Snapshot creating method, system, storage medium and equipment
CN113609075A
Application aware snapshots
US10140303B1
Rolling Back Kubernetes Applications
US20210103499A1