PV management method and device, electronic equipment and storage medium
By responding to the creation operation of the target Pod in K8S, creating a PVC and binding the pre-created target PV, the problems of high PV management cost and poor performance in the existing technology are solved, and efficient and flexible PV management is achieved.
Patent Information
- Application Number
- CN202411766701.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-04
- Publication Date
- 2025-03-11
AI Technical Summary
In the prior art, dynamic PV management requires a distributed storage system, resulting in high operation and maintenance costs, complex architecture and poor performance; while static PV management requires a large amount of manual creation and management of PVs, resulting in high costs and poor performance.
By responding to the creation operation of the target Pod, a PVC is created for the target Pod, and the target Pod is scheduled to the target node, and the service data is stored based on the pre-created target PV, and the PVC and the target PV are bound to achieve storage.
It reduces the cost of PV management, improves the efficiency and flexibility of PV management, and avoids the need for manual participation and introduction of distributed storage systems.
Smart Images

Figure CN119597222A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a PV management method, device, electronic device and storage medium. Background Art
[0002] Kubernetes (abbreviated as K8S) is a container orchestration platform that is widely used in the deployment and management of modern cloud-native applications. In K8S, persistent volumes (PV) and persistent volume claims (PVC) are used to implement persistent storage of containers, where PVC refers to the user's request for PV, and PV refers to the actual storage resource. PVC meets the application's demand for persistent storage through a binding relationship with PV.
[0003] At present, PV management methods usually include dynamic PV management and static PV management. Dynamic PV management refers to creating PV on demand. Specifically, the K8S cluster administrator can define multiple storage class objects according to needs and specify a volume plug-in for each storage class object. The volume plug-in is used to dynamically create and bind PV to PVC based on the relevant information of PV as needed. Static PV management refers to the cluster administrator manually creating PV and associating it with PVC through tags.
[0004] However, the above dynamic PV management usually requires the use of a distributed storage system, which brings high operation and maintenance costs and increases the complexity of K8S architecture. In addition, the distributed storage system needs to interact through the network, so the performance of dynamic PV management is poor. The above static PV management requires a lot of manual creation of PVs and management of the PV life cycle, resulting in high PV management costs and poor performance. Summary of the invention
[0005] The embodiments of the present application provide a PV management method, device, electronic device, and storage medium to reduce the management cost of PV and manage PV efficiently and flexibly.
[0006] In a first aspect, an embodiment of the present application provides a PV management method, the method comprising:
[0007] In response to the Pod creation operation of the target container group Pod, a PVC is created for the target Pod; the PVC is used to request storage resources for the target Pod in the corresponding node;
[0008] Schedule the target Pod to the target node and store the business data generated during the use of the target Pod based on the target PV created in advance on the target node;
[0009] Bind PVC and target PV to obtain the target PV bound to PVC.
[0010] In an optional embodiment, the number of PVs created in the target node is determined according to the node type of the target node; wherein the node type is used to indicate the number of disks of the target node.
[0011] In an optional embodiment, after binding the PVC and the target PV and obtaining the target PV bound to the PVC, the following further includes:
[0012] In response to the Pod deletion operation of the target Pod, based on the storage resource processing policy set for the target Pod, the binding relationship between the PVC and the target PV is released.
[0013] In an optional embodiment, based on the storage resource processing policy set for the target Pod, releasing the binding relationship between the PVC and the target PV includes:
[0014] If the storage resource processing policy indicates that the storage resources corresponding to the target Pod should be retained, the binding relationship is released and the PVC and the target PV are retained;
[0015] If the storage resource processing policy indicates releasing the storage resources corresponding to the target Pod, the binding relationship is released and the PVC and target PV are deleted.
[0016] In an optional embodiment, deleting the PVC and the target PV includes:
[0017] The change information of the target PV is continuously obtained through the first thread; the change information is used to indicate whether the target PV has a recycling tag;
[0018] When it is determined that the change information indicates that the target PV has a recycling tag and the target PV meets the preset PV recycling condition, the target PV is deleted.
[0019] In an optional embodiment, the process of deleting the PVC and the target PV further includes:
[0020] Determine the node directory corresponding to the target PV, and back up the business data stored in the storage resources associated with the node directory to obtain the corresponding backup data;
[0021] The backup data is stored in the storage resources associated with the backup directory set for the business data.
[0022] In an optional embodiment, backing up the business data stored in the storage resource associated with the node directory, after obtaining the corresponding backup data, further includes:
[0023] Obtain the change time of the backup directory through the second thread;
[0024] If the change time is greater than or equal to the set time threshold, the backup data and backup directory are deleted.
[0025] In a second aspect, an embodiment of the present application further provides a PV management device, the device comprising:
[0026] A creation module is used to create a PVC for the target Pod in response to the Pod creation operation of the target Pod; the PVC is used to request storage resources for the target Pod in the corresponding node;
[0027] The scheduling module is used to schedule the target Pod to the target node and store the business data generated during the use of the target Pod based on the target PV pre-created on the target node;
[0028] The binding module is used to bind PVC and target PV and obtain the target PV of the bound PVC.
[0029] In an optional embodiment, the number of PVs created in the target node is determined by the creation module according to the node type of the target node; wherein the node type is used to indicate the number of disks of the target node.
[0030] In an optional embodiment, after binding the PVC and the target PV and obtaining the target PV bound to the PVC, the device further includes an unbinding module, and the unbinding module is specifically used to:
[0031] In response to the Pod deletion operation of the target Pod, based on the storage resource processing policy set for the target Pod, the binding relationship between the PVC and the target PV is released.
[0032] In an optional embodiment, when releasing the binding relationship between the PVC and the target PV based on the storage resource processing policy set for the target Pod, the unbinding module is specifically used to:
[0033] If the storage resource processing policy indicates that the storage resources corresponding to the target Pod should be retained, the binding relationship is released and the PVC and the target PV are retained;
[0034] If the storage resource processing policy indicates releasing the storage resources corresponding to the target Pod, the binding relationship is released and the PVC and target PV are deleted.
[0035] In an optional embodiment, when deleting the PVC and the target PV, the unbinding module is specifically used to:
[0036] The change information of the target PV is continuously obtained through the first thread; the change information is used to indicate whether the target PV has a recycling tag;
[0037] When it is determined that the change information indicates that the target PV has a recycling tag and the target PV meets the preset PV recycling condition, the target PV is deleted.
[0038] In an optional embodiment, during the process of deleting the PVC and the target PV, the unbinding module is further used to:
[0039] Determine the node directory corresponding to the target PV, and back up the business data stored in the storage resources associated with the node directory to obtain the corresponding backup data;
[0040] The backup data is stored in the storage resources associated with the backup directory set for the business data.
[0041] In an optional embodiment, after backing up the business data stored in the storage resource associated with the node directory and obtaining the corresponding backup data, the unbinding module is further used to:
[0042] Obtain the change time of the backup directory through the second thread;
[0043] If the change time is greater than or equal to the set time threshold, the backup data and backup directory are deleted.
[0044] In a third aspect, an embodiment of the present application further provides an electronic device, including:
[0045] Processor; and
[0046] Memory for storing programs,
[0047] The program includes instructions, and when the instructions are executed by the processor, the processor executes the PV management method as described in the first aspect.
[0048] In a fourth aspect, an embodiment of the present application further provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the PV management method as described in the first aspect.
[0049] In a fifth aspect, the present application provides a computer program product, which, when called by a computer, enables the computer to execute the steps of the PV management method as described in the first aspect.
[0050] The beneficial effects of this application are as follows:
[0051] In the PV management method provided in the embodiment of the present application, in response to the Pod creation operation of the target Pod, a PVC is created for the target Pod; the PVC is used to request storage resources for the target Pod in the corresponding node; then, the target Pod is scheduled to the target node, and based on the target PV pre-created on the target node, the business data generated during the use of the target Pod is stored; finally, the PVC and the target PV are bound to obtain the target PV bound to the PVC.
[0052] In this way, when creating a target Pod, a PVC can be created for the target Pod, and in the process of using the target Pod, the business data is stored through the PV created in advance on the target node, and an association or binding relationship between the PVC and the PV is established. In this way, since there is no need for human participation and the introduction of new components (such as distributed storage systems), the management cost of PV is reduced and PV can be managed efficiently and flexibly.
[0053] In addition, other features and advantages of the present application will be described in the subsequent description, and partly become apparent from the description, or be understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described here are used to provide a further understanding of the present application, constitute a part of the present application, and do not constitute an improper limitation on the present application. In the drawings:
[0055] Figure 1 A schematic diagram of an optional system architecture applicable to the embodiments of the present application;
[0056] Figure 2 A schematic diagram of an implementation flow of a PV management method provided in an embodiment of the present application;
[0057] Figure 3 A logical schematic diagram of PV management in K8S provided in an embodiment of the present application;
[0058] Figure 4 A schematic diagram of a scenario for cleaning backup data provided in an embodiment of the present application;
[0059] Figure 5 A schematic diagram of the structure of a PV management device provided in an embodiment of the present application;
[0060] Figure 6A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0061] The embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be construed as being limited to the embodiments described herein. Instead, these embodiments are provided to provide a more thorough and complete understanding of the present application. It should be understood that the drawings and embodiments of the present application are only for exemplary purposes and are not intended to limit the scope of protection of the present application.
[0062] It should be understood that the various steps described in the method implementation of the present application can be performed in different orders and / or performed in parallel. In addition, the method implementation may include additional steps and / or omit the steps shown. The scope of the present application is not limited in this respect.
[0063] The term "including" and its variations used in this document are open inclusions, that is, "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one other embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions of other terms will be given in the description below. It should be noted that the concepts of "first", "second", etc. mentioned in this application are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0064] It should be noted that the modifications of "one" and "plurality" mentioned in the present application are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0065] The names of the messages or information exchanged between multiple devices in the embodiments of the present application are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0066] Some of the terms used in the embodiments of the present application are explained below to facilitate understanding by those skilled in the art.
[0067] (1) PV: Also known as persistent data volume or persistent volume, it is a resource object definition in K8S that describes various storage resource types (block storage, network attached storage (NAS) NAS, and object storage, etc.). It is also the application programming interface (API) object used for persistent storage in K8S, which is a storage resource in K8S. It allows users to provide persistent data storage for containerized applications so that data does not depend on the life cycle of the container (ie docker). Among them, persistence is a mechanism for converting program data between persistent state and transient state. In layman's terms, it means persisting transient data as persistent data.
[0068] (2) PVC: Also known as a persistent data volume claim or persistent volume claim, it is a user's request for a PV.
[0069] (3) Storage class: It is a type of resource in K8S. It is a category (or logical group) created by the administrator on demand to manage PV. For example, it can be classified according to the performance of the storage system, or according to the comprehensive service quality level, according to the backup strategy, or even directly according to the administrator's customized standards.
[0070] One of the benefits of storage classes is that they support dynamic creation of PVs. When users use persistent storage, they need to create PVCs to bind matching PVs. This type of operation requires a large amount of work, or when the administrator manually creates PVs that cannot meet all the requirements of PVCs, dynamically creating an adaptive PV based on the PVC's requirements will bring great flexibility to storage management.
[0071] Based on the above-mentioned nouns and related terminology explanations, the design concept of the embodiments of the present application is briefly introduced below:
[0072] PV management is a common management requirement in the allocation and management of server resources. Data in containers is not persistent by default. Once the container is destroyed, the corresponding data storage will be automatically recycled. However, for some businesses (such as databases, etc.), it is usually required that the data in the container can be stored and shared.
[0073] With the development of operation and maintenance technology and cloud computing technology, containers and clusters have gradually become mainstream, so there is an urgent need for a PV management method that adapts to user needs. In particular, in K8S, PV management methods can usually include dynamic PV management and static PV management. Among them, dynamic PV management refers to creating PV on demand.
[0074] Specifically, the K8S cluster administrator can define multiple storage class objects according to demand and specify a volume plug-in for each storage class object. The volume plug-in provides the user (for example, the data volume provider) with the PV information and related parameters required when creating the PV, thereby dynamically creating and binding the PV for the PVC. The volume plug-in usually needs to be associated with an external distributed storage system, for example, it can be a network file system (NFS) and a distributed file system (Ceph). Static PV management refers to the K8S cluster administrator manually creating PV and associating it with the PVC through labels.
[0075] It can be seen that the above dynamic PV management usually requires the use of a distributed storage system, which introduces new components, brings higher operation and maintenance costs, and increases the complexity of K8S architecture. In addition, since distributed storage systems generally need to interact through the network, their performance is orders of magnitude different from that of storage that interacts directly on local hard disks.
[0076] The above-mentioned static PV management requires a lot of manual creation of PVs and management of the PV life cycle, resulting in high PV management costs and poor performance. It is not suitable for the use scenario of K8S large-scale creation and destruction of containers.
[0077] In response to the above problems, an embodiment of the present application proposes a management method for PVs that are container-oriented and support storage on local disks (such as storage resources on nodes in K8S), which may specifically include: in response to a Pod creation operation of a target Pod, creating a PVC for the target Pod; the PVC is used to request storage resources for the target Pod in the corresponding node; then, the target Pod is scheduled to the target node, and based on the target PV pre-created on the target node, the business data generated during the use of the target Pod is stored; finally, the PVC and the target PV are bound to obtain the target PV bound to the PVC.
[0078] In this way, when creating a target Pod, a PVC can be created for the target Pod, and in the process of using the target Pod, the business data is stored through the PV created in advance on the target node, and an association or binding relationship between the PVC and the PV is established. In this way, since there is no need for human participation and the introduction of new components (such as distributed storage systems), the management cost of PV is reduced and PV can be managed efficiently and flexibly.
[0079] In particular, the preferred embodiments of the present application are described below in conjunction with the drawings in the specification. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application, and are not used to limit the present application, and the embodiments of the present application and the features in the embodiments may be combined with each other if there is no conflict.
[0080] See also Figure 1 As shown, it is a schematic diagram of an optional system architecture applicable to an embodiment of the present application, and the system architecture may include: a terminal device (101a, 101b) and K8S102. The terminal device (101a, 101b) and K8S102 can exchange information through a communication network, wherein the communication method adopted by the aforementioned communication network may include: a wireless communication method and a wired communication method. Exemplarily, the terminal device (101a, 101b) can access the network through cellular mobile communication technology and communicate with K8S102. Wherein, the cellular mobile communication technology, for example, includes the fifth generation mobile communication (5th generation mobile networks, 5G) technology or the next generation mobile communication technology. Optionally, the terminal device (101a, 101b) can access the network through a short-range wireless communication method and communicate with K8S102. Wherein, the short-range wireless communication method, for example, includes wireless fidelity (wireless fidelity, Wi-Fi) technology.
[0081] The embodiment of the present application does not impose any restriction on the number of communication devices involved in the above system architecture. For example, the above system architecture may include more terminal devices, or may include fewer terminal devices, or may also include other network devices. Figure 1 As shown, only the terminal devices (101a, 101b) and K8S102 are described as examples, and the above-mentioned communication devices and their respective functions are briefly introduced below.
[0082] The terminal device (101a, 101b) is a device that can provide voice and / or data connectivity to users, and can be a device that supports wired and / or wireless connection.
[0083] Exemplarily, the terminal devices (101a, 101b) may include, but are not limited to: mobile phones, tablet computers, laptop computers, PDAs, mobile internet devices (MID), wearable devices, virtual reality (VR) devices, augmented reality (AR) devices, wireless terminal devices in industrial control, wireless terminal devices in unmanned driving, wireless terminal devices in smart grids, wireless terminal devices in transportation safety, wireless terminal devices in smart cities, or wireless terminal devices in smart homes, etc.
[0084] In addition, a related client may be installed on the terminal device (101a, 101b), and the client may be software, for example, an application (APP), a browser, a short video software, etc., or a web page, a mini-program, etc.; it should be noted that the terminal device (101a, 101b) in the embodiment of the present application may enable the client related to the management of PV to send the Pod creation and / or deletion operation of the target Pod to K8S102, so as to perform subsequent method steps such as PV management.
[0085] K8S102 is an open source container cluster management system that can be used to deploy, expand and manage containerized applications. A cluster refers to a group of working nodes. Specifically, multiple Pods can be deployed in each Node. Pod is the smallest deployment unit for K8S102 application scheduling. A Pod can contain one or more containers.
[0086] In addition, the physical machine can be used as the working node of K8S102. During the process of deploying the Pod, the various components inside K8S102 collaborate to complete the deployment. First, the master node selects the working node after listening to the Pod deployment request, and then schedules the Pod to the working node, and finally pulls up the container in the Pod on the working node. It should be noted that the aforementioned deployment of the container on the physical machine, because the resource isolation capability is not guaranteed by the virtual machine (VM), and the isolation is only completed through the Pod, if the container in the Pod only sets the central processing unit (CPU) and memory size, and does not fix the CPU number and memory address, when the CPU is switched during the operation of the container, all CPUs and physical memory blocks on the physical machine may be switched, thereby affecting the performance of the container operation.
[0087] It is worth mentioning that in an embodiment of the present application, K8S102 can create a PVC for the target Pod in response to the Pod creation operation of the target Pod, wherein the PVC can be used to request storage resources for the target Pod in the corresponding node; then, the target Pod is scheduled to the target node, and based on the target PV pre-created on the target node, the business data generated during the use of the target Pod is stored; finally, the PVC and the target PV are bound to obtain the target PV bound to the PVC.
[0088] The following describes the PV management method provided by the exemplary embodiment of the present application in combination with the above-mentioned system architecture and with reference to the accompanying drawings. It should be noted that the above-mentioned system architecture is only shown to facilitate understanding of the spirit and principles of the present application, and the implementation of the present application is not limited in this regard.
[0089] See also Figure 2 As shown, it is a schematic diagram of the implementation process of a PV management method provided in an embodiment of the present application. The execution subject takes K8S as an example. The specific implementation process of the method is as follows:
[0090] S201: In response to a Pod creation operation of a target Pod, create a PVC for the target Pod.
[0091] The PVC can be used to request storage resources for the target Pod in the corresponding node, that is, the user can subsequently request storage resources (eg, PV) according to the PVC.
[0092] Exemplarily, when executing step S201, the terminal device can send a Pod creation instruction for the target Pod to K8S. After receiving the Pod creation instruction, K8S can start creating the target Pod, and create PVC for the target Pod, so that the user can subsequently quickly obtain the storage resources configured or allocated for the target Pod directly based on the PVC, and then read the business data generated during the use of the target Pod stored in the aforementioned storage resources.
[0093] Optionally, in order to reduce the signaling transmission overhead between the terminal device and K8S, K8S can also sense in real time whether a target Pod needs to be created. Once it is determined that a target Pod needs to be created, a PVC can be created for the target Pod.
[0094] S202: Schedule the target Pod to the target node, and store the business data generated during the use of the target Pod based on the target PV pre-created on the target node.
[0095] Optionally, the number of PVs created in the target node can be determined by K8S based on the node type of the target node; the node type is used to indicate the number of disks of the target node, and the disk is also a data disk or storage area. Generally speaking, different node types correspond to different numbers of disks. For example, the number of disks corresponding to different node types is shown in Table 1:
[0096] Table 1 Examples of the number of disks corresponding to different node types
[0097] Node Type Node.Type.1 Node.Type.2 Node.Type.3 Node.Type.4 Number of disks 2 4 3 5
[0098] Based on the correspondence between the number of disks and the node type recorded in the above table, K8S can quickly determine the number of disks of the target node after determining the node type of the target node. For example, assuming that K8S determines that the node type of the target node is Node.Type.3, the number of disks of the target node can be determined to be 3 based on the above correspondence.
[0099] Further, assuming that 3 PVs can be created on each disk, 9 PVs can be created on the target node. Optionally, different numbers of PVs can be created for different disks. For example, 2 PVs can be created on the first disk on the target node, 5 PVs can be created on the second disk on the target node, and 4 PVs can be created on the third disk on the target node, that is, a total of 9 PVs can be created on the 3 disks of the target node.
[0100] Of course, other methods may also be used to create PVs corresponding to the number of PVs on one or more disks of the target node, and this embodiment of the present application does not specifically limit this.
[0101] In order to improve the management efficiency of PV, K8S can start creating a set number of PVs according to the node type of the target node when it senses that the target node has joined K8S. Optionally, K8S can also create a node directory (or main directory) corresponding to the PV during the process of creating the PV. The node directory is used to indicate the storage space or storage path of the corresponding data. In other words, the timing of creating the PV is when the target node is sensed to join or be connected to K8S.
[0102] For example, if there is only folder 1 under a disk of the target node, and folder 1 contains folder 2, folder 3 and folder 4, and folder 2, folder 3 and folder 4 each have a certain number of folders, then the aforementioned folder 1 can be the main directory or node directory of all folders under the disk.
[0103] In addition, the above-mentioned target node can be a node selected arbitrarily from multiple nodes in K8S that meet the storage resource requirements, or can be selected based on certain node selection rules, which is not limited in the embodiments of the present application. For example, the target node can be the node with the largest amount of remaining storage resources or the lowest storage resource utilization in K8S.
[0104] S203: Bind the PVC and the target PV to obtain the target PV bound to the PVC.
[0105] That is, the created PVC is associated with the target PV. In this way, when the subsequent terminal device sends the PVC to K8S, it can obtain the corresponding business data from the target PV, thereby meeting the user's data acquisition needs. In addition, based on the method steps recorded in the above steps S201 to S203, it can be known that the binding time of PVC and target PV is: the creation of target Pod and PVC, and the use of target PV. That is, when creating the target Pod and its corresponding PVC, and using the target PV to store the business data generated during the use of the target Pod, the target PV and the PVC can be bound.
[0106] Moreover, based on the above PV management method, by using the local PV (i.e., target PV) mechanism, the binding of PVC and target PV is guaranteed to be compatible with the Pod scheduling strategy.
[0107] In an optional implementation, after executing step S203, K8S can also release the binding relationship between the PVC and the target PV based on the storage resource processing policy set for the target Pod in response to the Pod deletion operation of the target Pod. The aforementioned Pod deletion operation is used to indicate the deletion of the target Pod.
[0108] For example, the terminal device can send a Pod deletion or recycling instruction for the target Pod to K8S. After receiving the Pod deletion or recycling instruction, K8S can start to delete or recycle the target Pod. Optionally, in order to reduce the signaling transmission overhead between the terminal device and K8S, K8S can also sense in real time whether the target Pod needs to be deleted or recycled. Once it is determined that the target Pod needs to be deleted or recycled, it can delete or recycle the target Pod.
[0109] In this way, after the target Pod is deleted, the storage resources configured for the target Pod on the K8S node can be released; and the binding relationship between PVC and target PV can be released, which can further reduce the load of K8S.
[0110] The above storage resource processing strategy may represent the reservation of the storage resources corresponding to the target Pod, or may represent the release of the storage resources corresponding to the target Pod (ie, the storage resources allocated to the target Pod are not reserved).
[0111] Therefore, when K8S releases the binding relationship between PVC and target PV based on the storage resource processing policy set for the target Pod, if the aforementioned storage resource processing policy indicates that the storage resources corresponding to the target Pod should be retained, K8S can release the binding relationship between PVC and target PV and retain PVC and target PV.
[0112] Based on the above method, since the target PV and its corresponding PVC are not deleted when the target Pod is deleted, the next time the same PV identifier (i.e. PV ID) is used to request storage resources, this PVC will be mounted and reused, so that the PV corresponding to the PVC (i.e. target PV) can be quickly used as the storage resource for this storage resource request. In other words, the reuse method of PVC and PV is specified, and a unique PV identifier is used to identify the PV that can be reused.
[0113] If the above storage resource processing strategy indicates the release of the storage resources corresponding to the target Pod, K8S can release the binding relationship between PVC and target PV, and delete PVC and target PV. In this way, the storage resources of the node in K8S can be released in a timely manner. It should be understood that the aforementioned deletion of the target PV also releases the storage resources allocated or configured for the target PV.
[0114] In order to avoid high load or overload in K8S and improve the safety of target PV recycling, K8S can add a recycling tag to the target PV, so as to obtain the update information of the target PV according to the thread, and then recycle the target PV when it is determined that the target PV is marked with a recycling tag based on the update information and that the target PV can be safely recycled at this time.
[0115] Therefore, in an optional implementation method, K8S can continuously obtain change information of the target PV through a first thread (such as thread a); wherein the change information can be used to indicate whether the target PV has a recycling tag; when it is determined that the change information indicates that the target PV has a recycling tag and the target PV meets the preset PV recycling conditions, the target PV is deleted.
[0116] For example, the above-mentioned preset PV recycling condition can be that the log collection task corresponding to the target PV has been completed. When it is determined that the target PV has a recycling tag and the log collection task corresponding to the target PV has been completed, K8S can delete or recycle the target PV. Of course, the above-mentioned preset PV recycling condition can also be other, and this application does not limit this.
[0117] In addition, during the process of deleting PVC and target PV, K8S can also determine the node directory corresponding to the target PV, and back up the business data stored in the storage resources associated with the node directory to obtain the corresponding backup data, thereby storing the backup data in the storage resources associated with the backup directory set for the business data.
[0118] Optionally, if there are multiple PVs with recycling labels, then after determining that a PV is labeled with recycling labels, the first thread can also determine which data disk the PV corresponds to. That is, the first thread can determine which data disk on the target node the PV belongs to.
[0119] In this way, when K8S deletes the target PV, it can ensure that when the user needs to temporarily recall the business data, it can quickly obtain or restore the business data by asynchronously backing up the business data stored in the target PV.
[0120] For example, see Figure 3As shown, it is a logical diagram of PV management in K8S provided by an embodiment of the present application. The K8S may include: API Server, PV Controller, Node, Job and PV. Among them, API Server is the control plane component of K8S, which plays the role of a bridge connecting users and the entire K8S. It is mainly responsible for receiving and processing requests from users or other components, and then converting these requests into operations on K8S internal resources. The core functions of API Server mainly include: resource management, authentication and authorization, and recording events and logs.
[0121] PV Controller can obtain and monitor the update events of Node, PVC, PV, Job, Pod and other objects in K8S through the List-Watch mechanism, and can also process the stored business data, such as backup or deletion. In particular, in K8S, the Job object can be used to execute one-time tasks, such as batch tasks or scheduled tasks. In addition, the interaction between Node, Job, PV and PV Controller is as follows: Figure 3 As shown, the details are as follows:
[0122] When the API Server determines that the Node has joined K8S, it can send the Node joining event to the PV Controller. After receiving the Node joining event, the PV Controller can create PV and Job, and can send the created Job to the Node to initialize the Node. In addition, during the asynchronous backup and recovery of PV, the PV Controller can continuously obtain the update event (i.e., update information) of the PV through thread a (i.e., the first thread). When it is found that a PV is marked with a recovery tag, the following operations can be performed: 1. Determine the node to which the PV belongs and its corresponding data disk; 2. Check whether the PV can be safely recovered; 3. Send a Job to the corresponding Node, execute a backup script, and copy the business data in the node directory corresponding to the PV to the backup directory; 4. Delete or recycle the PV. Therefore, the above-mentioned Job object can include a backup script, which is used to back up the business data stored in the PV.
[0123] In an optional implementation, K8S backs up the business data stored in the storage resources associated with the above-mentioned node directory. After obtaining the corresponding backup data, it can also obtain the change time of the backup directory through a second thread (such as thread b); if the aforementioned change time is greater than or equal to the set time threshold, the backup data and the backup directory can be deleted. If the aforementioned change time is less than the aforementioned set time threshold, the backup data and the backup directory can be retained. In this way, it can be avoided that there will be more and more backup data on the target node, while most of the backup data does not need to be retained, resulting in a waste of storage resources. In other words, K8S can avoid the problem of waste of storage resources due to the continuous accumulation of backup data by regularly cleaning up the storage space of the (data) disk on the target node.
[0124] Exemplarily, if the above-mentioned preset time threshold is 3 days, and the change time of the backup directory is obtained to be 3.2 days, it can be determined that the change time of 3.2 days is greater than the preset time threshold of 3 days, and the backup data and backup directory are deleted. For another example, if the above-mentioned preset time threshold is still 3 days, and the change time of the backup directory is obtained to be 2.8 days, it can be determined that the change time of 2.8 days is less than the preset time threshold of 3 days, and the backup data and backup directory are retained. It should be noted that the above-mentioned preset time threshold can be pre-defined or determined by other methods, and this application does not limit this.
[0125] Optionally, K8S can detect the change time of the backup directory in real time. Once it is determined that the change time of the backup directory reaches the above preset time threshold, the backup data and backup directory can be deleted. Figure 4 As shown, it is a schematic diagram of a scenario for cleaning backup data provided by an embodiment of the present application. If 5 backup data (for example, Backup.Data.1, Backup.Data.2, Backup.Data.3, Backup.Data.4 and Backup.Data.5) are stored on the target node, and the backup directories corresponding to the above 5 backup data have the most recent change time of 1.7 days, 3.5 days, 2.9 days, 3 days and 4.2 days respectively. Then, assuming that the above preset time threshold is 3 days, the target node can delete or recycle the backup data Backup.Data.2, Backup.Data.4 and Backup.Data.5 whose change time is greater than or equal to 3 days and their corresponding backup directories Backup.Dir.2, Backup.Dir.4 and Backup.Dir.5.
[0126] Therefore, based on the above backup data recovery method, Figure 3In the asynchronous backup cleanup process, the PV Controller can trigger thread b (i.e., the second thread) according to the set trigger period (e.g., 1 day), obtain the Node list of K8S from the cache, traverse the Node list, and issue a Job to each Node so that the corresponding Node executes the recycling script. Specifically, the corresponding Node can delete the backup directory in the recycling directory whose most recent change time is greater than or equal to the above-mentioned preset time threshold, and delete the corresponding backup data.
[0127] It can be seen that the above-mentioned Job object may also include a recycling script, which is used to clean up the backup data and backup directories whose change time exceeds a preset time threshold, and release the storage resources of the Node.
[0128] In summary, in the PV management method provided in the embodiment of the present application, a PVC can be created for a target Pod when a target Pod is created, and in the process of using the target Pod, business data is stored through the PV pre-created on the target node, and an association or binding relationship between the PVC and the PV is established. In this way, since there is no need for human participation and the introduction of new components, the management cost of the PV is reduced and the PV can be managed efficiently and flexibly.
[0129] In addition, the PV management method can support automatic management of the life cycle of the disk (i.e., local disk) on the target node, including creation, recycling, backup, cleanup (or deletion), and support automatic binding and unbinding along with the life cycle of the container, thereby ensuring the security of the container's persistent data and the performance of data access, and reducing the management cost of the administrator.
[0130] Further, based on the same technical concept, the embodiment of the present application provides a PV management device, which is used to implement the above method flow of the embodiment of the present application. Figure 5 As shown, the PV management device 500 may include: a creation module 501, a scheduling module 502, a binding module 503 and an unbinding module 504, wherein:
[0131] A creation module 501 is used to create a PVC for the target Pod in response to a Pod creation operation of the target Pod; the PVC is used to request storage resources for the target Pod in the corresponding node;
[0132] The scheduling module 502 is used to schedule the target Pod to the target node and store the business data generated during the use of the target Pod based on the target PV pre-created on the target node;
[0133] The binding module 503 is used to bind the PVC and the target PV to obtain the target PV bound to the PVC.
[0134] In an optional embodiment, the number of PVs created in the target node is determined by the creation module 501 according to the node type of the target node; wherein the node type is used to indicate the number of disks of the target node.
[0135] In an optional embodiment, after binding the PVC and the target PV and obtaining the target PV bound to the PVC, the PV management device 500 further includes an unbinding module 504, and the unbinding module 504 is specifically used to:
[0136] In response to the Pod deletion operation of the target Pod, based on the storage resource processing policy set for the target Pod, the binding relationship between the PVC and the target PV is released.
[0137] In an optional embodiment, when releasing the binding relationship between the PVC and the target PV based on the storage resource processing policy set for the target Pod, the unbinding module 504 is specifically used to:
[0138] If the storage resource processing policy indicates that the storage resources corresponding to the target Pod should be retained, the binding relationship is released and the PVC and the target PV are retained;
[0139] If the storage resource processing policy indicates releasing the storage resources corresponding to the target Pod, the binding relationship is released and the PVC and target PV are deleted.
[0140] In an optional embodiment, when deleting the PVC and the target PV, the unbinding module 504 is specifically used to:
[0141] The change information of the target PV is continuously obtained through the first thread; the change information is used to indicate whether the target PV has a recycling tag;
[0142] When it is determined that the change information indicates that the target PV has a recycling tag and the target PV meets the preset PV recycling condition, the target PV is deleted.
[0143] In an optional embodiment, during the process of deleting the PVC and the target PV, the unbinding module 504 is further configured to:
[0144] Determine the node directory corresponding to the target PV, and back up the business data stored in the storage resources associated with the node directory to obtain the corresponding backup data;
[0145] The backup data is stored in the storage resources associated with the backup directory set for the business data.
[0146] In an optional embodiment, after backing up the business data stored in the storage resource associated with the node directory and obtaining the corresponding backup data, the unbinding module 504 is further used to:
[0147] Obtain the change time of the backup directory through the second thread;
[0148] If the change time is greater than or equal to the set time threshold, the backup data and backup directory are deleted.
[0149] Based on the description of the above method embodiment and device embodiment, the exemplary embodiment of the present invention further provides an electronic device, including: at least one processor; and a memory connected to the at least one processor in communication. The memory stores a computer program that can be executed by the at least one processor, and the computer program is used to enable the electronic device to perform the method according to the embodiment of the present invention when executed by the at least one processor.
[0150] An embodiment of the present application also provides a non-transitory computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor of a computer, is used to cause the computer to execute a method according to an embodiment of the present application.
[0151] An embodiment of the present application also provides a computer program product, including a computer program, wherein the computer program, when executed by a processor of a computer, is used to cause the computer to execute a method according to an embodiment of the present application.
[0152] See also Figure 6 As shown, the structured block diagram of the electronic device 600 that can be used as the server or client of the present application will now be described, which is an example of the hardware device that can be applied to various aspects of the present application. The electronic device is intended to represent the computer device of various forms of digital electronics, such as, laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as, personal digital processing, cellular phones, smart phones, wearable devices and other similar computing devices. The components shown herein, their connections and relationships, and their functions are only used as examples, and are not intended to limit the implementation of the present application described herein and / or required.
[0153] like Figure 6As shown, the electronic device 600 includes a computing unit 601, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 602 or a computer program loaded from a storage unit 608 to a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the device 600 can also be stored. The computing unit 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0154] A plurality of components in the electronic device 600 are connected to the I / O interface 605, including: an input unit 606, an output unit 607, a storage unit 608, and a communication unit 609. The input unit 606 may be any type of device capable of inputting information to the electronic device 600, and the input unit 606 may receive input digital or character information, and generate key signal inputs related to user settings and / or function control of the electronic device. The output unit 607 may be any type of device capable of presenting information, and may include but is not limited to a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. The storage unit 608 may include but is not limited to a disk, an optical disk. The communication unit 609 allows the electronic device 600 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks, and may include but is not limited to a modem, a network card, an infrared communication device, a wireless communication transceiver, and / or a chipset, such as a Bluetooth device, a WiFi device, a worldwide interoperability for microwave access (WiMax) device, a cellular communication device, and / or the like.
[0155] The computing unit 601 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a CPU, a graphics processing unit (GPU), various artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The computing unit 601 performs the various methods and processes described above. For example, in some embodiments, the above-mentioned PV management method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 600 via the ROM 602 and / or the communication unit 609. In some embodiments, the computing unit 601 may be configured to perform the above-mentioned PV management method by any other appropriate means (e.g., by means of firmware).
[0156] The program code for implementing the method of the present application can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, implements the functions / operations specified in the flow chart and / or block diagram. The program code can be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0157] In the context of the present application, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a RAM, a ROM, an erasable programmable read-only memory (EPROM) or a flash memory, an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0158] As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and / or device (e.g., disk, optical disk, memory, programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.
[0159] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a cathode ray tub (CRT) or a liquid crystal display (LCD) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0160] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0161] A computer system may include clients and servers. Clients and servers are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship to each other.
[0162] Furthermore, it should be understood that what is disclosed above is only a preferred embodiment of the present application, and certainly cannot be used to limit the scope of rights of the present invention. Therefore, equivalent changes made according to the claims of the present invention are still within the scope covered by the present application.
Claims
1. A method for managing a persistent volume PV, characterized in that: include: In response to a Pod creation operation of a target container group Pod, a persistent volume declaration PVC is created for the target Pod; the PVC is used to request storage resources for the target Pod in a corresponding node; The target Pod is scheduled to the target node, and based on the target PV pre-created on the target node, the business data generated during the use of the target Pod is stored; The PVC and the target PV are bound to obtain the target PV bound to the PVC.
2. The method according to claim 1, characterized in that The number of PVs created in the target node is determined according to the node type of the target node; wherein the node type is used to indicate the number of disks of the target node.
3. The method according to claim 1 or 2, characterized in that After binding the PVC and the target PV and obtaining the target PV bound to the PVC, the method further includes: In response to a Pod deletion operation of the target Pod, based on a storage resource processing policy set for the target Pod, a binding relationship between the PVC and the target PV is released.
4. The method according to claim 3, characterized in that The releasing the binding relationship between the PVC and the target PV based on the storage resource processing policy set for the target Pod includes: If the storage resource processing strategy indicates that the storage resources corresponding to the target Pod are to be retained, the binding relationship is released, and the PVC and the target PV are retained; If the storage resource processing strategy indicates releasing the storage resources corresponding to the target Pod, the binding relationship is released, and the PVC and the target PV are deleted.
5. The method according to claim 4, characterized in that The deleting the PVC and the target PV includes: Continuously acquiring change information of the target PV through the first thread; the change information is used to indicate whether the target PV has a recycling tag; When it is determined that the change information indicates that the target PV has the recycling tag and the target PV meets the preset PV recycling condition, the target PV is deleted.
6. The method according to claim 4 or 5, characterized in that The process of deleting the PVC and the target PV further includes: Determine the node directory corresponding to the target PV, and back up the business data stored in the storage resources associated with the node directory to obtain corresponding backup data; The backup data is stored in a storage resource associated with a backup directory set for the business data.
7. The method according to claim 6, characterized in that The backing up of the business data stored in the storage resource associated with the node directory, after obtaining the corresponding backup data, further includes: Obtaining the change time of the backup directory through the second thread; If the change time is greater than or equal to the set time threshold, the backup data and the backup directory are deleted.
8. A PV management device, characterized in that: include: A creation module, configured to create a persistent volume declaration PVC for the target Pod in response to a Pod creation operation of the target container group Pod; the PVC is used to request storage resources for the target Pod in a corresponding node; A scheduling module, used to schedule the target Pod to a target node, and store the business data generated during the use of the target Pod based on the target PV pre-created on the target node; The binding module is used to bind the PVC and the target PV to obtain the target PV bound to the PVC.
9. An electronic device, comprising: processor; as well as Memory for storing programs, The program includes instructions, which, when executed by the processor, cause the processor to perform the method according to any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 7.