Kubernetes-based resource management method and device, storage medium and electronic equipment
By assigning unique attribute tags to PVs in the Kubernetes system, the problem of PVCs being unable to accurately bind to PVs was solved, achieving efficient and accurate resource management.
Patent Information
- Application Number
- CN202111329232.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-10
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2041-11-10
AI Technical Summary
In Kubernetes systems, persistent volume claims (PVCs) cannot be accurately bound to the intended persistent volume (PV), resulting in inefficient binding and a high risk of errors.
By assigning a unique attribute tag generated by the system to each PV, the PVC is bound to the target PV, ensuring uniqueness and accuracy.
It achieves precise binding between PVCs and PVs, improves binding efficiency, avoids binding non-target PVs, and simplifies user operations.
Smart Images

Figure CN114116205B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of computers, and in particular, to a kubernetes-based resource management method and device, a storage medium and an electronic device. BACKGROUND
[0002] Kubernetes, referred to as k8s, is a portable container orchestration management tool for container services, and data persistence is a rigid requirement in the container application process. To this end, k8s provides two resource types, Persistent Volume (PV) and Persistent Volume Claim (PVC), to meet the data persistence requirements of containers. Each PV can correspond to a storage space, such as a storage volume Volume on a server. Containers are a kind of resources in k8s, and the container resource specifies the PVC to be used in its own configuration. The specified PVC specifies storage size, storage mode and other storage resource configuration information in its own configuration. Finally, k8s performs pairing in the current kubernetes system according to the storage resource configuration information. If there is a PV that meets the requirements declared in the storage resource configuration information of the PVC, the PV and the PVC can be bound.
[0003] In the actual use of PV and PVC, in an environment where storage resources are insufficient or need to be strictly controlled, k8s binds the created PV according to the declaration of the storage resource configuration information of the PVC. The configuration, size and purpose of each created PV need to be planned in advance and must be used according to the plan. At this time, when selecting a PV, the PVC needs to determine the specified PV that meets the requirements declared in the storage resource configuration information of the PVC, and then perform a binding operation. If the PVC needs to bind a specified PV, the PV to be bound needs to have a label declared in the resource configuration information of the PVC. The label selector in k8s selects the label matching the PVC declaration. Only the PV with the specified label of the PVC can be bound to the PVC. When creating a PV, the user must manually set the above PV label in addition to specifying the name of the PV. When creating a PVC, the user must manually specify or select the PV label that meets the conditions in addition to specifying the name of the PVC, so that the PVC and the PV can be paired and bound. However, the PV label does not have uniqueness, and different PVs may have the same label, that is, the same name label can correspond to multiple different PVs. Therefore, in the PVC and PV matching process, there is a problem that the PVC cannot accurately bind the expected PV, and it also causes the problem of low efficiency in the binding process of the PVC and the PV. SUMMARY
[0004] The embodiment of the present application provides a kubernetes-based resource management method and device, a storage medium and an electronic device, so as to at least solve the technical problem that PVC cannot accurately bind the expected PV.
[0005] According to an aspect of the embodiment of the present application, a kubernetes-based resource management method is provided, comprising:
[0006] A persistent storage volume claim (PVC) is created, a persistent storage volume (PV) set is displayed, and the PV set includes at least one PV name; a target PV name selected from the PV set is determined; the PVC is bound to the PV with the target PV name based on a first attribute label of the PV with the target PV name, and the first attribute label is a unique identifier assigned to the PV with the target PV name by a system.
[0007] According to another aspect of the embodiment of the present application, a kubernetes-based resource management device is also provided, comprising: a first creation unit configured to create a persistent storage volume claim (PVC) and display a persistent storage volume (PV) set, wherein the PV set includes at least one PV name; a determination unit configured to determine a target PV name selected from the PV set; and a binding unit configured to bind the PVC to the PV with the target PV name based on a first attribute label of the PV with the target PV name, wherein the first attribute label is a unique identifier assigned to the PV with the target PV name by a system.
[0008] According to still another aspect of the embodiment of the present application, a computer-readable storage medium is also provided, and the computer-readable storage medium stores a computer program, wherein the computer program is configured to execute the kubernetes-based resource management method when running.
[0009] According to still another aspect of the embodiment of the present application, an electronic device is also provided, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the kubernetes-based resource management method through the computer program.
[0010] In the embodiment of the present application, by creating a persistent storage volume declaration PVC, a persistent storage volume PV set is displayed, and the PV set includes at least one PV name; the target PV name selected from the PV set is determined; and the PVC is bound to the PV with the target PV name based on the first attribute label of the PV with the target PV name, and the first attribute label is a unique identifier assigned by the system to the PV with the target PV name. Since the PV satisfying the condition is selected according to the target PV name selected from the PV set, and the PV satisfying the condition is bound to the PVC according to the coding identifier indicating the uniqueness of the target PV, the case of binding a non-target PV when multiple PVs have the same label can be avoided, the technical effect of accurately binding the PV and the PVC is achieved, the binding efficiency of the PVC and the PV is improved, and the technical problem that the PVC cannot be accurately bound to the expected PV is solved. BRIEF DESCRIPTION OF DRAWINGS
[0011] The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the present application and serve to explain the present application, and do not constitute improper limitations on the present application. In the drawings:
[0012] Figure 1 is a schematic diagram of a running environment of an optional kubernetes-based resource management method according to an embodiment of the present application;
[0013] Figure 2 is a flowchart of an optional kubernetes-based resource management method according to an embodiment of the present application;
[0014] Figure 3 is a flowchart of another optional kubernetes-based resource management method according to an embodiment of the present application;
[0015] Figure 4 is a flowchart of still another optional kubernetes-based resource management method according to an embodiment of the present application;
[0016] Figure 5 is a flowchart of another optional kubernetes-based resource management method according to an embodiment of the present application;
[0017] Figure 6 is a flowchart of another optional kubernetes-based resource management method according to an embodiment of the present application;
[0018] Figure 7 is a structural schematic diagram of an optional kubernetes-based resource management device according to an embodiment of the present application;
[0019] Figure 8 is a structural schematic diagram of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0020] In order for those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work should fall within the scope of protection of the present application.
[0021] It should be noted that the terms “first”, “second”, and the like in the specification and claims of the present application and the above-described drawings are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms “include” and “have” and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product, or device including a series of steps or units does not have to be limited to only those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.
[0022] First, the technical terms involved in the embodiments of the present application are explained as follows:
[0023] k8s: full name kubernetes, is a container orchestration and management system that can be used in production environment. The k8s system includes a k8s cluster.
[0024] PV: full name Persistent Volume, Chinese name is persistent storage volume, is a resource type in k8s, represents various storage, used for container data persistence. Containers cannot directly use PVs, and need to be bound through PVCs before use.
[0025] PVC: full name Persistent Volume Claim, Chinese name is persistent storage volume, is a resource type in k8s. Containers declare PVC, PVC binds PV, and finally containers can use PV for persistent storage of data.
[0026] POD: Chinese name for container pod, in the kubernetes cluster, POD is the basis of all business types, and is the smallest unit level managed by k8s, which is a combination of one or more containers, multiple containers can belong to the same POD. These containers share storage, network and namespace, and how to run the specification. In the POD, all containers are scheduled and dispatched by the same arrangement, and run in the context of shared storage. For specific applications (APP), POD is their logical host, and POD contains multiple application containers related to business.
[0027] NFS: Full name for Network File System, Chinese name for Network File System, which allows computers in the network to share resources through TCP / IP network. In the application of NFS, POD reads resources on NFS storage through PVC.
[0028] UUID: Full name for Universally Unique Identifier, Chinese name for Universally Unique Identifier.
[0029] According to an aspect of an embodiment of the application, a kubernetes-based resource management method is provided; as an optional implementation, the above-mentioned kubernetes-based resource management method can be applied in the environment shown in Figure 1 The application environment is composed of a k8s cluster (kubernetes cluster) and an NFS system, and the k8s cluster contains two container pods POD A and POD B, wherein POD A contains container A, and POD B contains container C and container D, each container can run an independent application, POD A accesses storage directories DIR1 and DIR2 in the NFS system through PVC1 and PVC2, and POD B accesses storage directories DIR2 and DIR3 in the NFS system through PVC2 and PVC3, PVC1 is bound to PV1 through the first attribute label (UUID) of PV1, PVC2 is bound to PV2 through the first attribute label of PV2, and PVC3 is bound to PV3 through the first attribute label of PV3. Here, the current kubernetes system generates a respective universally unique identifier (key+UUID) for PV1, PV2 and PV3; the current kubernetes system establishes an association between POD A and POD B and the storage directories in the NFS system according to the above binding relationship.
[0030] Here, the main function of a PV is to map a logical unit in NFS storage (any logical unit from DIR1 to DIR3) to a PV resource on Kubernetes. A PV is a cluster-level resource, and the relationship between a PVC and a PV is one-to-one; one PV can only correspond to one PVC. When a PV is occupied by a PVC, a "banding" message will be displayed, and other PVCs will no longer be able to use the bound PV. After a PVC is bound to a PV, it is equivalent to a storage volume on the data storage system. Whether multiple PODs can use a PVC simultaneously depends on whether the PV allows multi-way read / write, and whether the corresponding PV supports multi-way read / write depends on the data storage system. Different types of data storage systems have different access modes. There are three PV access modes: ReadWriteOnce (RWO), ReadWriteMany (RWX), and ReadOnlyMany (ROX). The above is just an example, and this embodiment does not impose any limitations on it.
[0031] In one or more embodiments, such as Figure 2 As shown, the above-mentioned Kubernetes-based resource management methods include:
[0032] S202, Create a persistent storage volume declaration PVC, displaying a persistent storage volume PV set, which includes at least one PV name.
[0033] Specifically, during the process of creating a persistent storage volume (PVC) that matches the current container pod POD in Kubernetes, if the current container pod POD wants to persistently store data in the data storage system, it needs to create a PVC to store the data in the storage space of the data storage system. When creating a PVC, the current Kubernetes system's display interface shows a collection of PVs containing one or more PVs. This collection of PVs displays the configuration information of the PVs, including but not limited to the PV's name, binding status, storage volume name, storage space, access mode, storage type, etc., without any restrictions.
[0034] The data storage systems mentioned here include, but are not limited to, NFS systems, Fibre Channel storage devices (FC), and open-source shared storage systems such as Flocker, without any specific restrictions.
[0035] S204, Determine the name of the target PV selected from the above PV set.
[0036] The PV life cycle has four stages in total: Available: available state, not yet bound by PVC. Bound: bound state, has been bound to a certain PVC. Failed: when deleting PVC to clean up resources, the automatic recycling of the volume fails, so it is in a failure state. Released: the PVC bound to it has been deleted, but the resource has not been recycled by the k8s cluster in the k8s system. In the embodiment, the current k8s system can include a PV set composed of multiple PVs, and the PV set includes multiple PVs in the above four different stages. When a user selects a PV with the name of the PV from the PV set according to the name of the PV, if the read-write mode and / or storage space of the current PV do not meet the target conditions, the k8s system will prompt the user that the current PV does not meet the requirements, or pop up the read-write mode and / or storage space prompt information of the current PV, so that the user cancels the selection of the current PV. After the user cancels the selection of the current PV, another PV that meets the target conditions can be selected, and the k8s system will take the name of the selected PV as the target PV name. The above is only an example, which is not limited in this regard.
[0037] In S206, based on the first attribute label of the PV with the target PV name, the PVC is bound to the PV with the target PV name. The first attribute label is a unique identifier assigned by the system to the PV with the target PV name.
[0038] It should be noted that the system herein can include but is not limited to the k8s system, and the first attribute label in the embodiment can be a label with a unique attribute generated by the k8s system for the current PV, including but not limited to a label in the form of key: UUID, i.e., a key-value pair label including a key and a value. The key of the first attribute label in each PV can be the same or different, but the value of the first attribute label is different. When the keys of the first attribute labels in different PVs are the same, for example, the first attribute labels of two PVs are NFS-10001 and NFS-10002 respectively; when the keys of the first attribute labels in different PVs are different, the first attribute labels of two PVs are NFS-10001 and Flocker-10003 respectively.
[0039] In the embodiment, the k8s system can associate the above-mentioned PVC with the PV with the target PV name according to the first attribute tag of the PV with the target PV name, and bind the PV with the target PV name and the current PVC. For example, the PVs in the bindable PV subset include a PV with the name PV1 (storage capacity of 1G), a PV with the name PV2 (storage capacity of 2G), and a PV with the name PV3 (storage capacity of 500M), and the current POD requires a storage capacity of 2G. Therefore, the PV with the name PV3 is the target PV with the required name, the first attribute tag of the PV3 is NFS-10001, which corresponds to a storage directory with the name NFS-10001 in the NFS system. At this time, NFS-10001 can be written into the configuration information of the current PVC. Then, the current PVC is bound to the PV3, and the current POD can persistently store data in the storage volume with the name NFS-10001.
[0040] In the related art, multiple PVs can have the same tag. For example, the tags of two PVs with the names PV-ZP and PV-PX are both NFS-HR, and the corresponding storage spaces of the PV1 and the PV2 are the same, but the functions are different. For example, the storage space corresponding to the PV-ZP is used to store recruitment data of the human resources department, and the storage space corresponding to the PV-PX is used to store training data. Therefore, if a user wants to select the storage space to store the training data, but the current PVC is bound to the PV-ZP, a binding error problem occurs.
[0041] To solve the above-mentioned problem, in the embodiment of the application, a persistent storage volume declaration PVC is created, and a persistent storage volume PV set is displayed. The PV set includes at least one PV name. A target PV name selected from the PV set is determined. The PVC is bound to the PV with the target PV name based on the first attribute tag of the PV with the target PV name. The first attribute tag is a unique identifier allocated by the system to the PV with the target PV name. Since the PV satisfying the condition is selected according to the target PV name selected from the PV set, and the PV satisfying the condition is bound to the PVC according to the coding identifier indicating the uniqueness of the target PV, the binding of the non-target PV in the case that multiple PVs have the same tag can be avoided. The technical effect of accurately binding the PV and the PVC is achieved. Moreover, the binding efficiency of the PVC and the PV is improved, and the technical problem that the PVC cannot be accurately bound to the expected PV is solved.
[0042] In one or more embodiments, before the step S202 of creating the persistent storage volume declaration PVC and displaying the persistent storage volume PV set, the method further includes:
[0043] receiving a PV creation instruction, the PV creation instruction comprising a PV name; and creating a PV with the PV name.
[0044] generating a first attribute tag for the PV, the first attribute tag being used to uniquely identify the PV.
[0045] Specifically, before creating a PVC, the k8s system needs to create a PV set comprising at least one PV for a user to select a PV meeting a target condition when creating a PVC. In the process of creating a PV, after receiving a PV creation instruction input by a user and comprising a PV name, the k8s system creates a PV with the PV name, obtains a persistent storage volume PV set, and then generates a label with a unique identifier for each created PV. It should be noted that the PV creation instruction can comprise multiple PV names, that is, one PV or multiple PVs can be generated through one creation instruction, and the embodiments of the present application do not make any limitation in this regard.
[0046] For example, the k8s system creates a corresponding PV according to the naming name of the PV input by the user, such as creating a PV with the name PV-ZP, which corresponds to a storage space in the file storage system used to store recruitment data of the human resources department, and creating a PV with the name PV-PX, which corresponds to a storage space in the data storage system used to store training data of the human resources department. For example, the k8s generates a first attribute tag NFS-10004 for the PV with the name PV-ZP, and generates a first attribute tag NFS-10004 for the PV with the name PV-PX, and then the k8s configures the PV-ZP and the PV-PX with the first attribute tags as the PV set.
[0047] In the embodiments of the present application, the PV name is defined according to the role of different storage spaces of the data storage system, and the first attribute tag indicating the uniqueness of the PV is generated, which can avoid the binding of non-target PVs when multiple PVs have the same label, and the user does not need to bind the PV and the PVC through a custom label, thereby achieving the technical effect of precisely binding the PV and the PVC, and facilitating the user to distinguish the data operation object.
[0048] In one or more embodiments, in the step S206, the PVC is bound to the PV with the target PV name based on the first attribute tag of the PV with the target PV name, and the first attribute tag is a unique identifier assigned by the system to the PV with the target PV name, comprising:
[0049] The first attribute tag of the PV with the target PV name is written into the configuration information of the PVC to establish a binding relationship between the PVC and the PV with the target PV name.
[0050] For example, in the k8s system, the PV with the name PV-ZP is a target PV meeting the requirements, the first attribute label of the PV-ZP is NFS-10001, at this time, the NFS-10001 can be written into the configuration information of the current PVC, then the current PVC establishes a binding relationship with the PV-ZP through the first attribute label, and the current POD can be mapped to the PV-ZP based on the PVC, and data can be stored in the storage volume with the name NFS-10001.
[0051] In the embodiment of the application, the PV with the target PV name is bound to the PVC according to the first attribute label used for uniquely identifying the PV, which can avoid the case that a non-target PV is bound when multiple PVs have the same label, and the technical effect of precisely binding the PV and the PVC is achieved, and the binding efficiency of the PVC and the PV is improved.
[0052] In one or more embodiments, the PV creation instruction also carries a label name of the PV, and the kubernetes-based resource management method further includes:
[0053] A second attribute label is created according to the label name, and the second attribute label includes a storage type of the PV.
[0054] The PV meeting the target storage type is screened out based on the second attribute label through a label selector.
[0055] Specifically, the second attribute label can be a custom label of the current user, which includes but is not limited to a storage type label, a version label, an environment label, an architecture label, a partition label, etc., and is not limited here; here, the custom label can be specified for the PV according to the type of the storage space, for example, the specified label of the PV of the NFS storage type is NFS-HR, and the specified label of the PV of the Flocker storage type is Flocker-HR. When the user needs to screen the PV of the NFS storage type, the label selector can be used for screening.
[0056] In the embodiment of the application, the first attribute label corresponding to the key-value pair used for indicating the uniqueness of the PV and including the combination of the key and the value is generated through the k8s system, which can avoid the case that a non-target PV is bound when multiple PVs have the same label, not only can the PV and the PVC be precisely bound, but also the PV of the target storage type can be obtained through the manually added label.
[0057] In one or more embodiments, the step S204 of determining the target PV name selected from the PV set includes: determining a subset of bindable PVs from the PV set; and determining the target PV name selected from the subset of PVs.
[0058] In the embodiment, the PV set in the current k8s system includes a plurality of PVs in four different stages. In the related art, the k8s system does not preliminarily screen the PV selected by the user, and thus the PV selected by the user may not meet the target condition. The subset of bindable PVs is determined from the PV set.
[0059] For example, there are three PVs in the subset of PVs that meet the condition in the configuration information of the current PVC. At this time, there are two PVs in the unbound state in the subset of PVs including the three PVs, and the subset of PVs in the unbound state is determined as the target subset of PVs. One or more PVs in the Avaliable state are screened as the target subset of PVs, so as to filter out the PVs that do not meet the matching condition of the PVC, and avoid the failure of the binding of the PV and the PVC. The above is only an example, which is not limited herein.
[0060] In the embodiment, the k8s preliminarily screens the plurality of PVs that meet the configuration information of the current PVC according to the configuration information, so as to filter out the PVs that do not meet the matching condition of the PVC, and thus provides the accurate PV binding object for the PVC.
[0061] In one or more embodiments, the step of determining the subset of bindable PVs from the PV set includes: determining at least one PV that meets the configuration information of the PVC from the PV set as the subset of PVs.
[0062] Specifically, the configuration information of the PVC can include but is not limited to the name, the binding state, the storage volume name, the storage space, the access mode, the storage type, and the like, which are not limited herein. The k8s system can match one or more PVs that meet the configuration according to one or more pieces of information in the configuration information, and then determine the matched PV set as the subset of PVs.
[0063] In the embodiment, the k8s preliminarily screens the plurality of PVs that meet the configuration information of the current PVC according to the configuration information, so as to filter out the PVs that do not meet the matching condition of the PVC, and thus provides the accurate PV binding object for the PVC.
[0064] In one or more embodiments, as shown in FIG. 1, Figure 3 the resource management method based on kubernetes further includes:
[0065] S302, a persistent storage volume claim (PVC) is created, and a persistent storage volume (PV) set is displayed, the PV set including at least one PV name.
[0066] S304, at least one PV that matches the storage space and the access mode from the PV set is selected as a PV subset.
[0067] In the embodiment, the k8s system can match one or more PVs that meet the conditions of the storage space and the access mode in the configuration information of the current PVC, and then take the matched PV set as the PV subset.
[0068] For example, the conditions in the configuration information of the current PVC are that the storage space is 1G, the declared access mode is ReadWriteOnce, and there are three PVs that meet the conditions, so the set of the three PVs can be taken as the PV subset.
[0069] S306, a target PV name selected from the PV subset is determined.
[0070] S308, based on the first attribute label of the PV of the target PV name, the PVC is bound to the PV of the target PV name, and the first attribute label is a unique identifier assigned by the system to the PV of the target PV name.
[0071] In the embodiment, the k8s system can preliminarily screen a plurality of PVs that meet the conditions of the storage space and the access mode in the matching conditions of the current PVC, so as to filter out the PVs that do not meet the conditions of the PVC, thereby providing an accurate PV binding object for the PVC.
[0072] In one or more instances, the first attribute label is a key-value pair including a key and a value, and the value in the key-value pair is a universal unique identifier in the kubernetes.
[0073] For example, the first attribute label can be a label including but not limited to, for example, key:UUID, that is, a key-value pair label including a key and a value, and the key of the first attribute label in each PV can be the same or different, but the value of the first attribute label is different. When the key of the first attribute label in different PVs is the same, for example, the first attribute labels of two PVs are NFS-10001 and NFS-10002 respectively; when the key of the first attribute label in different PVs is different, the first attribute labels of two PVs are NFS-10001 and Flocker-10005 respectively.
[0074] In the embodiment of the present application, the first attribute label corresponding to the key-value pair indicating the uniqueness of the PV and including the key and value combination is generated by the k8s system, which can avoid the case that the non-target PV is bound when multiple PVs have the same label, and achieve the technical effect of accurately binding the PV and the PVC, thereby improving the efficiency of the PV and the PVC binding.
[0075] In the related art, data persistence is a rigid requirement in the container application process. Therefore, the k8s system provides two resource types, PV and PVC, to meet the requirement of container data persistence. The container is also a resource in the k8s system, and the container resource specifies the required PVC in the self-configuration. The specified PVC resource specifies the required storage size, storage mode and other information in the self-configuration. Finally, the k8s system configures the storage resource according to the requirement of the PVC, and pairs it in the current k8s system. If there is a PV that meets the requirements of the PVC declaration, the PV and the PVC are successfully bound.
[0076] In the container application process, there are two use scenarios: first, the k8s system dynamically creates a PV that meets the requirements according to the declaration of the PVC, and binds the PV that meets the current PVC condition to the current PVC; second, the k8s system binds the created PV according to the PVC declaration. The second scenario usually occurs in an environment where the storage resource is not sufficient or the storage resource needs to be strictly controlled. The configuration, size and purpose of each PV are planned in advance and must be used according to the plan. At this time, the binding of the PVC and the specified PV is required.
[0077] In the k8s system, if the PVC needs to bind the specified PV, the PV needs to have the label specified in the PVC. In this way, only the PV with the specified label of the PVC can be bound to the PVC in the PVC and PV matching process. In the use process of the k8s-based business system, in addition to specifying the name of the PV, the user must manually set a label when creating the PV. In addition to specifying the name of the PVC, the user must manually specify or select the PV label when creating the PVC to pair and bind the PVC and the PV that meets the binding condition.
[0078] Since the PV label does not have uniqueness, different PVs may have the same label, so there is a case that the PVC is bound to the non-expected PV in the matching process. Moreover, when the number of PVs is large, the association relationship between the PV and the label and the use of the label need to be manually maintained, which increases the labor cost.
[0079] To solve the above technical problems, the present application provides another kubernetes-based resource management method, as follows: Figure 4As shown, the method comprises the following steps: step S402, a user inputs a PV name; step S404, a k8s system creates a PV according to the PV name; and step S406, the k8s sets a globally (k8s system) unique label (the first attribute label) for the PV.
[0080] In the embodiment of the application, by creating a persistent storage volume claim PVC, displaying a persistent storage volume PV set, the PV set comprising at least one PV name, determining a target PV name selected from the PV set, and binding the PVC to the PV with the target PV name based on a first attribute label of the PV with the target PV name, the first attribute label being a unique identifier assigned to the PV with the target PV name by the system, the PV satisfying the condition is selected according to the target PV name determined from the PV set, and the PV satisfying the condition is bound to the PVC according to the coded identifier indicating the uniqueness of the target PV, which can avoid the situation that a non-target PV is bound when multiple PVs have the same label, achieve the technical effect of accurately binding the PV and the PVC, and improve the binding efficiency of the PVC and the PV, thereby solving the technical problem that the PVC cannot be accurately bound to the expected PV.
[0081] Based on the above embodiment, in one or more embodiments, as shown in Figure 5 As shown, the method further comprises the following steps: step S502, a user inputs a PV name; step S504, the user specifies a label (the second attribute label) for the PV; step S506, a k8s system creates a PV according to the PV name; step S508, the k8s system sets the label specified by the user for the PV; and step S510, the k8s system sets a globally unique label for the PV.
[0082] In the embodiment of the application, by generating, by the k8s system, a first attribute label corresponding to a key-value pair indicating the uniqueness of the PV and comprising a key and a value combination, the situation that a non-target PV is bound when multiple PVs have the same label can be avoided, the PV and the PVC can be accurately bound, and a target storage type PV can be obtained through the manually added label.
[0083] Based on the above embodiment, in one or more embodiments, as shown in Figure 6 As shown, the method further comprises the following steps: step S602, a k8s system provides a user with the names of available PVs; step S604, the user specifies a PV by name; step S606, the k8s system sets a PVC according to a globally unique label of the selected PV; and step S608, the k8s system binds the PVC to the specified PV according to the globally unique label.
[0084] In the embodiment of the present application, by creating a persistent storage volume claim PVC, a persistent storage volume PV set is displayed, the PV set includes at least one PV name; the target PV name selected in the PV set is determined; the PVC is bound to the PV of the target PV name based on the first attribute label of the PV of the target PV name, and the first attribute label is a unique identifier assigned by the system to the PV of the target PV name. Since the PV satisfying the condition is selected according to the target PV name selected from the PV set, and the PV satisfying the condition is bound to the PVC according to the coding identifier indicating the uniqueness of the target PV, the case of binding a non-target PV when multiple PVs have the same label can be avoided, the technical effect of accurately binding the PV and the PVC is achieved, and the binding efficiency of the PVC and the PV is improved, thereby solving the technical problem that the PVC cannot be accurately bound to the expected PV.
[0085] It should be noted that, for the foregoing method embodiments, in order to simply describe, they are all expressed as a series of action combinations, but those skilled in the art should know that the present application is not limited by the action order described, because according to the present application, certain steps can be performed in other order or simultaneously. Secondly, those skilled in the art should know that the embodiments described in the specification all belong to preferred embodiments, and the actions and modules involved are not necessarily necessary for the present application.
[0086] According to another aspect of the embodiment of the present application, a kubernetes-based resource management device for implementing the above-mentioned kubernetes-based resource management method is also provided. As shown in the figure, the device comprises: Figure 7 The first creation unit 702 creates a persistent storage volume claim PVC, displays a persistent storage volume PV set, and the PV set includes at least one PV name;
[0087] The determination unit 704 is configured to determine the target PV name selected in the PV set;
[0088] The binding unit 706 is configured to bind the PVC to the PV of the target PV name based on the first attribute label of the PV of the target PV name, and the first attribute label is a unique identifier assigned by the system to the PV of the target PV name.
[0089]
[0090] In the embodiment of the present application, by creating a persistent storage volume declaration PVC, a persistent storage volume PV set is displayed, the PV set includes at least one PV name; the target PV name selected from the PV set is determined; the PVC is bound to the PV with the target PV name based on the first attribute label of the PV with the target PV name, and the first attribute label is a unique identifier assigned by the system to the PV with the target PV name. Since the PV satisfying the condition is selected according to the target PV name determined from the PV set, and the PV satisfying the condition is bound to the PVC according to the coding identifier indicating the uniqueness of the target PV, the case of binding a non-target PV when multiple PVs have the same label can be avoided, thereby achieving the technical effect of precise binding of the PV and the PVC, improving the binding efficiency of the PVC and the PV, and solving the technical problem that the PVC cannot be precisely bound to the expected PV.
[0091] In one or more embodiments, the kubernetes-based resource management apparatus further includes:
[0092] The receiving unit is configured to receive a PV creation instruction, and the PV creation instruction includes a PV name.
[0093] The second creating unit is configured to create a PV with the PV name.
[0094] The generating unit is configured to generate a first attribute label for the PV, and the first attribute label is used to uniquely identify the PV.
[0095] In one or more embodiments, the binding unit 706 specifically includes a binding module configured to write the first attribute label of the PV with the target PV name into the configuration information of the PVC, so as to establish a binding relationship between the PVC and the PV with the target PV name.
[0096] In one or more embodiments, in the kubernetes-based resource management apparatus, the PV creation instruction further carries a label name of the PV, and the apparatus further includes:
[0097] The third creating unit is configured to create a second attribute label according to the label name, and the second attribute label includes a storage type of the PV.
[0098] The screening unit is configured to screen out a PV conforming to a target storage type based on the second attribute label through a label selector.
[0099] In one or more embodiments, the determining unit 704 specifically includes:
[0100] A first determining module is configured to determine a bindable PV subset from the PV set.
[0101] A second determining module is configured to determine a selected target PV name in the PV subset.
[0102] In one or more embodiments, the first determining module specifically includes:
[0103] A first determining subunit is configured to determine at least one bindable PV from the PV set as the PV subset according to the configuration information of the PVC.
[0104] In one or more embodiments, in the kubernetes-based resource management apparatus, the configuration information includes storage space and access mode; and the first determining subunit specifically includes:
[0105] A first determining submodule is configured to filter at least one bindable PV matching the storage space and the access mode from the PV set as the PV subset.
[0106] According to another aspect of the embodiments of the present application, an electronic device for implementing the above-mentioned kubernetes-based resource management method is also provided, which can be a terminal device or a server. The terminal device includes but is not limited to at least one of the following: a mobile phone (such as an Android mobile phone, an iOS mobile phone, etc.), a notebook computer, a tablet computer, a palm computer, a MID (Mobile Internet Device), a PAD, a desktop computer, a smart television, etc. The server can be a single server, a server cluster composed of multiple servers, or a cloud server.
[0107] This embodiment takes the electronic device as a server as an example for illustration. As shown in Figure 8 The electronic device includes a memory 802 and a processor 804, the memory 802 stores a computer program, and the processor 804 is configured to execute the steps in any one of the method embodiments by the computer program.
[0108] Optionally, in this embodiment, the electronic device can be located in at least one of the multiple network devices in a computer network.
[0109] Optionally, in this embodiment, the processor can be configured to execute the following steps by the computer program:
[0110] S1, creating a persistent storage volume declaration PVC, displaying a persistent storage volume PV set, and the PV set includes at least one PV name;
[0111] S2, determine the target PV name selected from the PV set;
[0112] S3, bind the PVC with the PV of the target PV name based on the first attribute tag of the PV of the target PV name, the first attribute tag being a unique identifier assigned by the system to the PV of the target PV name.
[0113] Optionally, those skilled in the art can understand that, Figure 8 The structure shown is only schematic, and the electronic device can also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a palm computer, a Mobile Internet Device (MID), a PAD, and the like. Figure 8 It does not limit the structure of the electronic device. For example, the electronic device can further include more or less components (such as a network interface, etc.) than Figure 8 shown, or have a different configuration than Figure 8 shown.
[0114] The memory 802 can be used to store software programs and modules, such as program instructions / modules corresponding to the kubernetes-based resource management method and device in the embodiments of the present application. The processor 804 executes various functions and applications and kubernetes-based resource management by running the software programs and modules stored in the memory 802, that is, implements the kubernetes-based resource management method described above. The memory 802 can include a high-speed random access memory, and can also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some examples, the memory 802 can further include a memory remotely arranged with respect to the processor 804, which can be connected to the terminal through a network. Examples of the above network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof. Specifically, the memory 802 can be used to store, but is not limited to, information such as a PV set, a PVC, and a first attribute tag. As an example, as Figure 8 shown, the memory 802 can include, but is not limited to, the first creation unit 702, the determination unit 704, and the binding unit 706 in the kubernetes-based resource management device. In addition, it can also include, but is not limited to, other module units in the kubernetes-based resource management device, which will not be described in detail in this example.
[0115] Optionally, the transmission device 806 is configured to receive or send data via a network. Examples of the network include a wired network and a wireless network. In an example, the transmission device 806 includes a network interface controller (NIC) which can be connected to other network devices and routers through a network cable to communicate with the Internet or a local area network. In an example, the transmission device 806 is a radio frequency (RF) module which is configured to communicate with the Internet in a wireless manner.
[0116] In addition, the electronic device further includes a display 808 configured to display the bindable PV subset or PVC, and a connection bus 810 configured to connect various module components in the electronic device.
[0117] In other embodiments, the terminal device or the server can be a node in a distributed system, and the distributed system can be a blockchain system formed by the plurality of nodes connected through network communication. The nodes can form a peer-to-peer (P2P) network, and any computing device such as a server, a terminal, or other electronic device can become a node in the blockchain system by joining the P2P network.
[0118] According to an aspect of the present application, a computer program product or computer program is provided, which includes computer instructions stored in a computer readable storage medium. A processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to enable the computer device to perform the kubernetes-based resource management method described above. The computer program is configured to execute the steps in any of the method embodiments described above when executed.
[0119] Optionally, in the present embodiment, the computer readable storage medium can be configured to store a computer program for executing the following steps:
[0120] S1, creating a persistent storage volume declaration PVC, displaying a persistent storage volume PV set, and the PV set includes at least one PV name;
[0121] S2, determining a target PV name selected from the PV set;
[0122] S3, binding the PVC to the PV with the target PV name based on a first attribute tag of the PV with the target PV name, and the first attribute tag is a unique identifier assigned to the PV with the target PV name by the system.
[0123] Optionally, in the embodiment, those skilled in the art can understand that all or part of the steps in the above-mentioned embodiments can be completed by instructing the terminal device related hardware through a program, and the program can be stored in a computer readable storage medium, and the storage medium can include a flash disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0124] The serial numbers of the above-mentioned embodiments of the application are only for description, not representing the advantages and disadvantages of the embodiments.
[0125] The integrated units in the above-mentioned embodiments, if realized in the form of software function units and sold or used as independent products, can be stored in the above-mentioned computer readable storage medium. Based on such understanding, the technical solutions of the application or all or part of the technical solutions that essentially contribute to the prior art can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a plurality of instructions for causing one or more computer devices (which can be personal computers, servers or network devices, etc.) to execute all or part of the steps of the above-mentioned methods of the embodiments of the application.
[0126] In the above-mentioned embodiments of the application, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.
[0127] In several embodiments provided in the present application, it should be understood that the disclosed client can be implemented by other ways. Among them, the above-mentioned device embodiments are only schematic, for example, the division of the above-mentioned units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the shown or discussed units can be indirect coupling or communication connection through some interfaces, units or modules, which can be electrical or other forms.
[0128] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, that is, they can be located in one place, or they can be distributed on a plurality of network units. According to actual needs, part or all of the units can be selected to achieve the purpose of the embodiment.
[0129] In addition, each function unit in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software function unit.
[0130] The above merely describes the preferred embodiments of the present application, and it should be noted that, for those skilled in the art, some improvements and refinements can be made without departing from the principles of the present application, and these improvements and refinements should also be considered as falling within the protection scope of the present application.
Claims
1. A resource management method based on Kubernetes, characterized in that, include: Create a persistent storage volume declaration (PVC) that displays a persistent storage volume PV set, which includes at least one PV name; Determine the name of the target PV selected from the PV set; Based on the first attribute tag of the PV of the target PV name, the PVC is bound to the PV of the target PV name, where the first attribute tag is a unique identifier assigned by the system to the PV of the target PV name; Determining the selected target PV name in the PV set includes: determining a subset of PVs that can be bound from the PV set; The names of the target PVs selected from the subset of PVs are determined.
2. The method according to claim 1, characterized in that, Before creating the persistent storage volume declaration PVC and displaying the persistent storage volume PV collection, the following steps are also included: Receive a PV creation instruction, the PV creation instruction including the PV name; Create a PV with the name of the stated PV; A first attribute tag is generated for the PV, and the first attribute tag is used to uniquely identify the PV.
3. The method according to claim 1, characterized in that, The first attribute tag of the PV based on the target PV name binds the PVC to the PV of the target PV name, including: Write the first attribute tag of the PV with the target PV name into the configuration information of the PVC, so that the PVC and the PV with the target PV name are bound together.
4. The method according to claim 2, characterized in that, The PV creation instruction also carries the PV's tag name, and the method further includes: A second attribute tag is created based on the tag name; wherein, the second attribute tag includes the storage type of the PV; The tag selector filters out PVs that match the target storage type based on the second attribute tag.
5. The method according to claim 1, characterized in that, The step of determining a subset of PVs that can be bound from the PV set includes: Based on the configuration information of the PVC, at least one PV that can be bound is determined from the PV set and is taken as the PV subset.
6. The method according to claim 5, characterized in that, The configuration information includes storage space and access mode; determining at least one bindable PV from the PV set as a subset of the PVs based on the PVC configuration information includes: Select at least one bindable PV from the PV set that matches both the storage space and the access mode, and use it as a subset of the PVs.
7. A resource management device based on Kubernetes, characterized in that, include: The first creation unit creates a persistent storage volume declaration (PVC) and displays a persistent storage volume (PV) set, which includes at least one PV name. A determining unit is used to determine the name of the selected target PV in the PV set; A binding unit is used to bind the PVC to the PV of the target PV name based on the first attribute tag of the PV of the target PV name. The first attribute tag is a unique identifier assigned by the system to the PV of the target PV name. The determining unit includes: The first determining module is used to determine a subset of PVs that can be bound from the PV set; The second determining module is used to determine the name of the target PV selected in the PV subset.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein the program, when executed, performs the method according to any one of claims 1 to 6.
9. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to execute the method described in any one of claims 1 to 6 through the computer program.