Disk monitoring method in k8s cluster, k8s cluster, device and equipment
By introducing listeners and controllers in the k8s cluster, and using custom resource definitions (CRDs) to manage disk resources, the problem of manual disk complexity is solved, automated disk management and monitoring is realized, and cluster management efficiency is improved.
Patent Information
- Application Number
- CN202410967464.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-18
- Publication Date
- 2024-11-05
AI Technical Summary
In Kubernetes (k8s) clusters, the existing technology requires operation and maintenance personnel to manually initialize and manage disks on each node, resulting in large workloads and prone to misoperation, especially in larger clusters, especially when nodes When disks are not unified, management is complex and inefficient.
By introducing listeners and controllers in the k8s cluster, we can monitor disk change events in real time, create and manage disk resource information based on custom resource definitions (CRDs), and realize automatic detection and management, reducing manual intervention and learning and maintenance costs, and simplifying Operation and maintenance process.
It realizes automatic discovery, management and monitoring of disks in k8s clusters, improves the efficiency of disk and partition management, and provides a powerful tool for resource management of large-scale clusters.
Smart Images

Figure CN118897772A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of cloud computing technology, and in particular to a disk monitoring method, a k8s cluster, a device and equipment in a k8s cluster. Background Art
[0002] K8s is an open source container orchestration engine that supports automated deployment, large-scale scalability, and containerized application management. In a Kubernetes container cluster, when using LVM (Logical Volume Manager) to provide storage for pods, the current technical solution requires planning the disks of each node in advance and converting the disks into physical volumes to complete the entire LVM storage setting.
[0003] However, the above setting process requires the user to first complete various disk initialization, physical volume setting and other operations on the host in the form of commands. This solution is out of the management scope of the k8s cluster and requires operation and maintenance personnel to operate on the underlying operating system. When the k8s cluster is large in scale and the disks of each node are large and not uniform, the operation and maintenance personnel need to operate on each node one by one, which is a lot of work and prone to misoperation. Summary of the invention
[0004] Based on this, it is necessary to provide a disk monitoring method, k8s cluster, device and equipment in a k8s cluster that can manage and monitor disks on Linux through k8s to address the above technical problems.
[0005] A disk monitoring method in a k8s cluster, wherein the k8s cluster is provided with a listener and a controller, and the method is applied to the controller. The disk monitoring method in the k8s cluster includes:
[0006] Receive disk change events of the k8s cluster reported by the listener;
[0007] When the disk change event is a new event of the target disk, the disk information of the target disk and at least one disk characteristic parameter pre-set according to the custom resource definition of k8s are obtained;
[0008] Obtain the value of the disk characteristic parameter according to the disk information, and create the k8s resource information corresponding to the target disk according to the disk characteristic parameter and the value of the disk characteristic parameter;
[0009] Monitor the target disk based on k8s resource information.
[0010] In some embodiments, the k8s cluster includes at least one node, the node is provided with a listener, the node is also provided with a volume group, the disk information includes the volume group to which the target disk belongs, the controller pre-creates a storage pool and a binding relationship between the storage pool and the volume group, and the disk monitoring method in the k8s cluster also includes:
[0011] Add the target disk to the corresponding storage pool according to the volume group to which the target disk belongs and the binding relationship between the storage pool and the volume group;
[0012] In response to a storage volume creation instruction, extracting a storage pool corresponding to the storage volume from the creation instruction;
[0013] Determine the volume group corresponding to the storage volume according to the binding relationship between the storage pool and the volume group;
[0014] Determine the disk that matches the storage volume based on the k8s resource information of each disk in the volume group corresponding to the storage volume;
[0015] Create a storage volume based on the disks that match the storage volume.
[0016] In some of the embodiments, the disk monitoring method in the k8s cluster further includes:
[0017] When the disk change event is a partition creation event of the target disk, obtain the k8s resource information pre-created for the target disk;
[0018] Update the k8s resource information created in advance for the target disk according to the information of the newly created partition in the partition creation event.
[0019] In some of the embodiments, the disk monitoring method in the k8s cluster further includes:
[0020] Obtain the permission information of the target disk. When the permission of the target disk is not occupied, execute the steps of obtaining the disk information of the target disk and defining at least one disk characteristic parameter pre-set according to the custom resource of k8s.
[0021] In some embodiments, the disk characteristic parameters include any one or more of the following:
[0022] Disk name, capacity, type, node, volume group, whether the disk has partitions, and whether it has been added to a storage pool.
[0023] A k8s cluster, the k8s cluster includes at least one node, the node is provided with a listener, and the k8s cluster is also provided with a controller, wherein:
[0024] The listener is used to monitor the changes of the disk on the node. When the target disk sends a change, it reports the disk change event to the controller.
[0025] The controller is used to obtain the disk information of the target disk and at least one disk characteristic parameter pre-set according to the custom resource definition of k8s when the disk change event is a new event of the target disk;
[0026] The controller is also used to obtain the value of the disk characteristic parameter according to the disk information, and to create the k8s resource information corresponding to the target disk according to the disk characteristic parameter and the value of the disk characteristic parameter, and to monitor the target disk according to the k8s resource information.
[0027] In some of the embodiments, the listener is used to monitor changes of the disk on the node through the device manager.
[0028] A disk monitoring device in a k8s cluster, wherein the k8s cluster is provided with a listener and a controller, the disk monitoring device in the k8s cluster is applied to the controller, and the disk monitoring device in the k8s cluster includes:
[0029] The receiving module is used to receive the disk change events of the k8s cluster reported by the listener;
[0030] An acquisition module, used for acquiring disk information of the target disk and at least one disk characteristic parameter pre-set according to the custom resource definition of k8s when the disk change event is a new event of the target disk;
[0031] A creation module is used to obtain the value of the disk characteristic parameter according to the disk information, and to create the k8s resource information corresponding to the target disk according to the disk characteristic parameter and the value of the disk characteristic parameter;
[0032] The monitoring module is used to monitor the target disk based on k8s resource information.
[0033] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0034] Receive disk change events of the k8s cluster reported by the listener;
[0035] When the disk change event is a new event of the target disk, the disk information of the target disk and at least one disk characteristic parameter pre-set according to the custom resource definition of k8s are obtained;
[0036] Obtain the value of the disk characteristic parameter according to the disk information, and create the k8s resource information corresponding to the target disk according to the disk characteristic parameter and the value of the disk characteristic parameter;
[0037] Monitor the target disk based on k8s resource information.
[0038] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0039] Receive disk change events of the k8s cluster reported by the listener;
[0040] When the disk change event is a new event of the target disk, the disk information of the target disk and at least one disk characteristic parameter pre-set according to the custom resource definition of k8s are obtained;
[0041] Obtain the value of the disk characteristic parameter according to the disk information, and create the k8s resource information corresponding to the target disk according to the disk characteristic parameter and the value of the disk characteristic parameter;
[0042] Monitor the target disk based on k8s resource information.
[0043] The above-mentioned disk monitoring method, k8s cluster, device and equipment in the k8s cluster create a disk feature parameter that records the disk or partition information on the server based on the custom resource definition (Custom Resource Definitions, CRD) in k8s, so that the management of the disk is consistent with the management method of k8s native resources, reducing the cost of learning and maintenance. The application also defines a monitor that can be automatically deployed on all k8s cluster nodes to detect disk changes on the node in real time, and generate disk change events to report to the controller, and automatically create corresponding k8s resource information through the controller, so that the disk on the server can be managed through the k8s cluster. It can be seen that the application can automatically detect newly added disks and create corresponding k8s resource information, reducing manual intervention, simplifying the operation and maintenance process, and improving the efficiency and convenience of disk and partition management in the k8s cluster. It provides a powerful tool for resource management in large-scale clusters, and realizes automatic discovery, management and monitoring of disks on servers through k8s. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 A schematic diagram of a process of a disk monitoring method in a k8s cluster in an embodiment;
[0045] Figure 2 A schematic diagram of the correspondence between volume groups, physical volumes, and storage pools on each node in a k8s cluster in an embodiment;
[0046] Figure 3 A schematic diagram of a flow chart of a disk monitoring method in a k8s cluster in another embodiment;
[0047] Figure 4 This is a structural block diagram of a k8s cluster in an embodiment;
[0048] Figure 5 It is a structural block diagram of a disk monitoring device in a k8s cluster in an embodiment;
[0049] Figure 6 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0051] In some embodiments, such as Figure 1 As shown, a disk monitoring method in a k8s cluster is provided. The k8s cluster is provided with a listener and a controller. The method is applied to the controller. The method includes the following steps:
[0052] Step S11, receiving the disk change event of the k8s cluster reported by the listener.
[0053] Among them, k8s, the full name of which is kubernetes, is an open source platform for managing containers. It allows users to deploy, expand and manage containerized applications more conveniently, and realize load balancing, service discovery and automatic elastic scaling functions in an automated way.
[0054] The listener is a component set in k8s to listen to disk change events. The controller is a component set in k8s to process disk change events.
[0055] Disk change events refer to events in which disk information changes, such as events in which the number of disks changes.
[0056] Specifically, the listener monitors the changes of each disk in the k8s cluster in real time. When a disk change is detected, a disk change event is generated and reported to the controller.
[0057] Step S12, when the disk change event is a new event of the target disk, obtain the disk information of the target disk and at least one disk characteristic parameter pre-set according to the custom resource definition of k8s.
[0058] Disk information refers to the detailed information of the disk, such as the disk name, path, capacity, type, manufacturer, and whether there is a partition.
[0059] Disk characteristic parameters refer to resources customized in k8s according to the provisions of CRD. They are data that conforms to the CRD specification and are used to record disk or partition information on the server in k8s. Among them, CRD is a powerful extension mechanism in k8s, which allows users to create and manage custom resources. Through CRD, users can define their own resource types. This application customizes disk characteristic parameters based on CRD to achieve consistency in disk management with k8s native resource management, reducing learning and maintenance costs.
[0060] Specifically, the controller defines each disk characteristic parameter according to the provisions of CRD, which generally needs to include the following parameters: such as apiVersion (version number of the interface), kind (type of disk) and spec (characteristics of the disk), where the characteristics included in spec are the above-mentioned disk characteristic parameters.
[0061] The disk characteristic parameters are specifically disk characteristic parameters related to the basic attributes of the disk and the disk status. Specifically, the disk attributes refer to some basic attributes of the disk, such as the name, path, capacity, type, manufacturer and other information of the disk. The disk status refers to information related to the status of the disk, such as the binding status of the disk.
[0062] Specifically, the controller can pre-define the above disk feature parameters from multiple dimensions of the disk based on the CRD in k8s. When a disk is added to the k8s cluster, the controller can obtain the disk information and the pre-defined disk feature parameters.
[0063] This application uses k8s custom resources to centrally manage and monitor the status of disks on all nodes in the cluster. This provides administrators with a unified view, which helps with resource management and planning.
[0064] Step S13, obtain the value of the disk characteristic parameter according to the disk information, and create the k8s resource information corresponding to the target disk according to the disk characteristic parameter and the value of the disk characteristic parameter.
[0065] Among them, k8s resource information is information used to describe the resources used in the k8s cluster. In this application, k8s resource information is specifically used to describe the status of the disk in the k8s cluster.
[0066] When a new disk is added, the disk information needs to be converted into k8s resource information based on the pre-defined disk characteristic parameters. Only data that conforms to the k8s custom resource definition (CRD) can be stored in the k8s resource database and can be uniformly managed in the k8s cluster.
[0067] Among them, obtaining the value of the disk characteristic parameter according to the disk information, and creating the k8s resource information corresponding to the target disk according to the disk characteristic parameter and the value of the disk characteristic parameter, may include:
[0068] The controller matches the name of the field with the information in the disk information. When the match is successful, the corresponding information is obtained as the value of the field. For example, when the field name is disk capacity, the capacity keyword is matched from the disk information according to the disk capacity, and the specific value of the capacity is obtained when the match is successful. Furthermore, the value of the corresponding field is obtained from the disk information according to the disk characteristic parameters, and the k8s resource information corresponding to the target disk is created according to each field and the value of each field.
[0069] Step S14, monitor the target disk according to the k8s resource information.
[0070] Specifically, the resource usage and operation status of the target disk can be monitored based on the k8s resource information.
[0071] In some of the embodiments, the k8s cluster includes at least one node, the node is provided with a listener, the node is also provided with a volume group, the disk information includes the volume group to which the target disk belongs, the controller pre-creates a storage pool and a binding relationship between the storage pool and the volume group, and the disk monitoring method in the k8s cluster also includes: adding the target disk to the corresponding storage pool according to the volume group to which the target disk belongs and the binding relationship between the storage pool and the volume group, in response to a storage volume creation instruction, extracting the storage pool corresponding to the storage volume from the creation instruction, determining the volume group corresponding to the storage volume according to the binding relationship between the storage pool and the volume group, determining the disk matching the storage volume according to the k8s resource information of each disk in the volume group corresponding to the storage volume, and creating a storage volume according to the disk matching the storage volume.
[0072] A volume group (VG) is a storage space in LVM (Logical Volume Manager), which is composed of one or more physical volumes (PV). VG allows users to combine multiple physical volumes to form a virtual, larger storage space.
[0073] LVM is the abbreviation of Logical Volume Management, which is a mechanism for managing disk partitions in Linux environment.
[0074] A physical volume (PV) is used to register underlying physical devices for use in a volume group (VG). These physical devices can be block devices such as disk partitions, entire disks, RAID (Redundant Arrays of Independent Disks) or SAN (Storage Area Network) disks. In order to be used in conjunction with LVM, these devices must first be initialized as LVM physical volumes.
[0075] A storage volume (Persistent Volume Claim, PVC) is a resource on k8s. It is a declaration of information about the storage space that may be needed in k8s. Its function is to make a declaration on the disk space that needs to be used in k8s, for example, declaring how much space is needed on a disk on a server.
[0076] Storage pool refers to StorgeClass (sc), which is a resource type in Kubernetes that is mainly used to manage the creation and properties of persistent volumes (PV). StorageClass is a category (logical group) created on demand by the administrator to manage PV.
[0077] Specifically, the k8s cluster includes at least one node, wherein each node is provided with a listener for monitoring changes in the disks on each node. The controller may be provided at one of the nodes of the k8s cluster for processing disk change events reported by the listeners on each node.
[0078] Wherein, each node is also provided with a volume group, each volume group is bound to at least one physical volume, and the above disk information may include the volume group to which the target disk belongs.
[0079] Please refer to Figure 2 , Figure 2 In one embodiment, a schematic diagram of the correspondence between volume groups, physical volumes, and storage pools (StorgeClass) on each node in a k8s cluster is shown. Figure 2In the figure, the k8s cluster includes three nodes, namely node1, node2 and node3. A storage pool (StorgeClass) is also created in the k8s cluster. Each node is provided with a volume group and the physical volumes PV-sda, PV-sdb and PV-sdc included in each volume group. The volume group is provided with VG-name, the volume group name. The volume groups of the three nodes are bound to the storage pool (StorgeClass). The storage pool (StorgeClass) pre-declares the volume group name of the bound volume group, and establishes a binding relationship with each volume group by declaring the volume group name.
[0080] Please refer to Figure 3 , Figure 3 In one embodiment, a flowchart of a disk monitoring method in a k8s cluster is shown. Figure 3 In the process, the listener load of each node monitors the changes of the disk on each node, and reports the corresponding disk change event to the controller when the disk change is detected. The controller converts the corresponding disk information into the corresponding k8s resource information according to the disk change event. The controller further obtains the volume group to which the target disk that has changed in the disk information belongs, and adds the target disk to the corresponding storage pool (StorgeClass) according to the binding relationship between the volume group and the storage pool (StorgeClass).
[0081] Furthermore, the present application can also create a storage volume based on the k8s resource information. Specifically, the process of creating a storage volume in the present application may include:
[0082] Receive a storage volume creation instruction, which carries a storage pool (StorgeClass) corresponding to the storage volume. According to the storage pool (StorgeClass) corresponding to the storage volume and the disks added to the storage pool (StorgeClass), obtain a disk matching the storage volume. Specifically, the capacity required by the storage volume can be compared with the capacity of each disk, and the disk matching the storage volume and the node where the disk is located can be obtained. According to the disk matching the storage volume and the node where the disk is located, create a corresponding storage volume. Specifically, the storage volume can declare how much storage space is required on a disk of a certain node to complete the creation of the storage volume.
[0083] Furthermore, when the controller reads the storage volume, it can allocate a portion of space in the corresponding physical volume (such as a disk) of the corresponding node as a logical volume (Logical Volume, LV) through the volume group according to the information declared by the storage volume. Among them, the logical volume refers to a storage space divided by the volume group in the physical volume. It can be seen that this application can declare a storage volume in the k8s cluster based on multiple dimensions, and then divide a real disk space on the physical volume of the node as a logical volume through the volume group.
[0084] The beneficial effects of this embodiment are as follows: storage volumes can be created from multiple dimensions through the created k8s resource information, and disks suitable for creating storage volumes can be quickly found based on the k8s resource information, thereby achieving faster creation of suitable storage volumes.
[0085] In some of the embodiments, the disk monitoring method in the k8s cluster may also include: when the disk change event is a partition creation event of the target disk, obtaining the k8s resource information created in advance for the target disk, and updating the k8s resource information created in advance for the target disk according to the information of the newly created partition in the partition creation event.
[0086] Among them, the information of the newly created partition may include the identification information and number of the newly created partition. When the disk change event is a new disk event, the k8s resource information corresponding to the target disk has not been created in the k8s cluster in advance. At this time, it is necessary to create the k8s resource information corresponding to the target disk. When creating the k8s resource information, it is necessary to obtain each field in the disk characteristic parameters one by one, and extract the value of each field from the disk information to create the k8s resource information corresponding to the target disk.
[0087] When the disk change event is a partition creation event, the k8s resource information corresponding to the target disk is pre-created in the k8s cluster. In this case, you only need to update the k8s resource information corresponding to the target disk according to the information of the newly created partition.
[0088] Specifically, updating the k8s resource information pre-created for the target disk according to the information of the newly created partition in the partition creation event may include:
[0089] Get predefined disk characteristic parameters;
[0090] Obtain the disk information of the target disk according to the partition creation event, extract the values of each disk characteristic parameter according to the disk information, and update the k8s resource information created by the target disk according to the values of each disk characteristic parameter extracted.
[0091] For example, a new partition M is created on the target disk, and information related to partition M is extracted from the disk information, and the information related to partition M is updated to the k8s resource information corresponding to the target disk.
[0092] The beneficial effects of this embodiment are: it can realize automatic discovery of new events of disk partitions in the k8s cluster, and automatically update the k8s resource information corresponding to the target disk of the newly created partition, realize real-time discovery and automatic management of disk management on the server in the form of k8s custom resources, and achieve the purpose of managing and using physical disks or partitions on the server through k8s.
[0093] In some of the embodiments, the disk monitoring method in the k8s cluster may further include: obtaining permission information of the target disk, and when the permissions of the target disk are not occupied, executing the steps of obtaining disk information of the target disk and defining at least one disk characteristic parameter pre-set according to the custom resource definition of k8s.
[0094] Specifically, after receiving a disk change event, the permission information of the target disk is obtained, and whether the permissions of the target disk are occupied is determined based on the permission information. When the permissions of the target disk are not occupied, the steps of obtaining the disk information of the target disk and defining at least one disk characteristic parameter in advance according to the custom resource definition of k8s are executed.
[0095] The beneficial effect of this embodiment is that it realizes the conversion of disk information of the disk into k8s resource information while ensuring that the target disk permissions are available.
[0096] In some embodiments, the disk parameters include any one or more of the following:
[0097] Disk name, capacity, type, node, volume group, whether the disk has partitions, and whether it has been added to a storage pool.
[0098] The binding status of the disk and the volume group refers to whether the disk is bound to the volume group and to which volume group the disk is bound. The partition status refers to whether a partition is created on the disk.
[0099] In addition, this application can also be flexibly expanded based on CRD, and more fields and attributes can be added according to actual needs or actual application scenarios to meet specific needs. For example, information such as disk type and file system can be added.
[0100] It can be seen that this application makes full use of the CRD and API (Application Programming Interface) extension capabilities of k8s, and can customize the required fields in the disk feature parameters according to actual needs or actual application scenarios. At the same time, it makes the management of disks and partitions consistent with the management method of k8s native resources, reducing learning and maintenance costs.
[0101] In one embodiment, Figure 4 As shown, a k8s cluster is provided, the k8s cluster includes at least one node, the node is provided with a listener, and the k8s cluster is also provided with a controller, wherein,
[0102] The listener is used to monitor the changes of the disk on the node. When the target disk sends a change, it reports the disk change event to the controller.
[0103] The controller is used to obtain the disk information of the target disk and at least one disk characteristic parameter pre-set according to the custom resource definition of k8s when the disk change event is a new event of the target disk;
[0104] The controller is also used to obtain the value of the disk characteristic parameter according to the disk information, and to create the k8s resource information corresponding to the target disk according to the disk characteristic parameter and the value of the disk characteristic parameter, and to monitor the target disk according to the k8s resource information.
[0105] In this application, based on the CRD in k8s, a disk characteristic parameter for converting disk information into k8s resource information is defined, so as to create corresponding k8s resource information according to the disk characteristic parameter, which is used to record the disk or partition information on the server into k8s for management.
[0106] This application also defines a monitor that is automatically deployed on each node of the k8s cluster to monitor the disks or partitions of each node in the cluster and dynamically report disk change events.
[0107] This application also defines a controller, which converts the specific information of the disk or partition into custom resource information in k8s based on various disk change events reported by the monitor, and associates the corresponding disk with the storage pool in k8s, thereby completing the management of the underlying layer by the k8s cluster.
[0108] It can be seen that the present application can monitor the changes of the disk through the monitor, and respond to the changes of the disk on the node in real time through the controller, thereby improving the dynamic adaptability of the system.
[0109] In some of the embodiments, the listener is used to monitor changes of the disk on the node through the device manager.
[0110] The device manager can be udev, which mainly manages the device nodes in the / dev directory. When hardware is added or removed, udev processes the / dev directory and all related user space behaviors, and can dynamically update device files according to the status of hardware devices in the system, including the creation and deletion of device files.
[0111] Specifically, udev is a device management framework in the Linux system, which is used to manage events such as device insertion, removal, and property changes. The corresponding udev framework runs by default on each node (Linux server). The framework monitors the Linux kernel and can report specific disk change events of devices in Linux in real time. The listener receives events sent by udev, thereby obtaining all events of all devices on the entire server in real time and filtering events that do not need to be processed. For example, this application only needs to monitor storage devices, and can filter events of devices such as optical drives. Through udev, the corresponding disk change events can be accurately obtained.
[0112] In one embodiment, Figure 5 As shown, a disk monitoring device in a k8s cluster is provided. The k8s cluster is provided with a listener and a controller. The disk monitoring device in the k8s cluster is applied to the controller. The disk monitoring device in the k8s cluster includes a receiving module 51, an acquisition module 52, a creation module 53 and a monitoring module 54, wherein: the receiving module 51 is used to receive the disk change event of the k8s cluster reported by the listener, the acquisition module 52 is used to obtain the disk information of the target disk and at least one disk characteristic parameter pre-set according to the custom resource definition of k8s when the disk change event is a new event of the target disk, the creation module 53 is used to obtain the value of the disk characteristic parameter according to the disk information, and create the k8s resource information corresponding to the target disk according to the disk characteristic parameter and the value of the disk characteristic parameter, and the monitoring module 54 is used to monitor the target disk according to the k8s resource information.
[0113] In one of the embodiments, the above-mentioned k8s cluster includes at least one node, the node is provided with a listener, the node is also provided with a volume group, the disk information includes the volume group to which the target disk belongs, the controller pre-creates a storage pool and a binding relationship between the storage pool and the volume group, and the creation module 53 can also add the target disk to the corresponding storage pool according to the volume group to which the target disk belongs and the binding relationship between the storage pool and the volume group, and in response to the creation instruction of the storage volume, extract the storage pool corresponding to the storage volume from the creation instruction, determine the volume group corresponding to the storage volume according to the binding relationship between the storage pool and the volume group, determine the disk matching the storage volume according to the k8s resource information of each disk in the volume group corresponding to the storage volume, and create the storage volume according to the disk matching the storage volume.
[0114] In one of the embodiments, the creation module 53 can also obtain the k8s resource information created in advance for the target disk when the disk change event is a partition creation event of the target disk, and update the k8s resource information created in advance for the target disk according to the information of the newly created partition in the partition creation event.
[0115] In one of the embodiments, the acquisition module 52 can also obtain permission information of the target disk. When the permission of the target disk is not occupied, the steps of obtaining disk information of the target disk and defining at least one disk characteristic parameter pre-set according to the custom resource of k8s are executed.
[0116] In one of the embodiments, the disk parameters include any one or more of the following: disk name, capacity, type, node, volume group, whether the disk has partitions, and whether it has been added to a storage pool.
[0117] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. . The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a disk monitoring method in a k8s cluster is implemented.
[0118] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented: receiving a disk change event of a k8s cluster reported by a listener, and when the disk change event is a new event of a target disk, obtaining disk information of the target disk and at least one disk characteristic parameter pre-set according to a custom resource definition of k8s, obtaining a value of the disk characteristic parameter according to the disk information, and creating k8s resource information corresponding to the target disk according to the disk characteristic parameter and the value of the disk characteristic parameter, and monitoring the target disk according to the k8s resource information.
[0119] In one embodiment, a k8s cluster includes at least one node, the node is provided with a listener, the node is also provided with a volume group, the disk information includes the volume group to which the target disk belongs, the controller pre-creates a storage pool and a binding relationship between the storage pool and the volume group, and when the processor executes a computer program, the following steps are specifically implemented: according to the volume group to which the target disk belongs and the binding relationship between the storage pool and the volume group, the target disk is added to the corresponding storage pool, in response to a storage volume creation instruction, the storage pool corresponding to the storage volume is extracted from the creation instruction, the volume group corresponding to the storage volume is determined according to the binding relationship between the storage pool and the volume group, the disk matching the storage volume is determined according to the k8s resource information of each disk in the volume group corresponding to the storage volume, and the storage volume is created according to the disk matching the storage volume.
[0120] In one embodiment, when the processor executes the computer program, the following steps are specifically implemented: when the disk change event is a partition creation event of the target disk, the k8s resource information created in advance for the target disk is obtained, and the k8s resource information created in advance for the target disk is updated according to the information of the newly created partition in the partition creation event.
[0121] In one embodiment, when the processor executes the computer program, the following steps are specifically implemented: obtaining permission information of the target disk, and when the permissions of the target disk are not occupied, executing the steps of obtaining disk information of the target disk and defining at least one disk characteristic parameter pre-set according to the custom resource definition of k8s.
[0122] In one embodiment, the disk parameters include any one or more of the following: disk name, capacity, type, node, volume group, whether the disk has partitions, and whether it has been added to a storage pool.
[0123] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: receiving a disk change event of a k8s cluster reported by a listener, and when the disk change event is a new event of a target disk, obtaining disk information of the target disk and at least one disk characteristic parameter pre-set according to a custom resource definition of k8s, obtaining a value of the disk characteristic parameter according to the disk information, and creating k8s resource information corresponding to the target disk according to the disk characteristic parameter and the value of the disk characteristic parameter, and monitoring the target disk according to the k8s resource information.
[0124] In one embodiment, a k8s cluster includes at least one node, the node is provided with a listener, the node is also provided with a volume group, the disk information includes the volume group to which the target disk belongs, the controller pre-creates a storage pool and a binding relationship between the storage pool and the volume group, and when the computer program is executed by the processor, the following steps are specifically implemented: according to the volume group to which the target disk belongs and the binding relationship between the storage pool and the volume group, the target disk is added to the corresponding storage pool, in response to a storage volume creation instruction, the storage pool corresponding to the storage volume is extracted from the creation instruction, the volume group corresponding to the storage volume is determined according to the binding relationship between the storage pool and the volume group, the disk matching the storage volume is determined according to the k8s resource information of each disk in the volume group corresponding to the storage volume, and the storage volume is created according to the disk matching the storage volume.
[0125] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented: when the disk change event is a partition creation event of the target disk, the k8s resource information created in advance for the target disk is obtained, and the k8s resource information created in advance for the target disk is updated according to the information of the newly created partition in the partition creation event.
[0126] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented: obtaining permission information of the target disk, and when the permissions of the target disk are not occupied, executing the steps of obtaining disk information of the target disk and defining at least one disk characteristic parameter pre-set according to the custom resource definition of k8s.
[0127] In one of the embodiments, the disk parameters include any one or more of the following: disk name, capacity, type, node, volume group, whether the disk has partitions, and whether it has been added to a storage pool.
[0128] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing related hardware through a computer program, and the above-mentioned computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0129] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0130] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A disk monitoring method in a k8s cluster, characterized in that: The k8s cluster is provided with a listener and a controller, and the method is applied to the controller, and the method includes: Receive the disk change event of the k8s cluster reported by the listener; When the disk change event is a new event of the target disk, the disk information of the target disk and at least one disk characteristic parameter pre-set according to the custom resource definition of k8s are obtained; Obtain the value of the disk characteristic parameter according to the disk information, and create the k8s resource information corresponding to the target disk according to the disk characteristic parameter and the value of the disk characteristic parameter; The target disk is monitored according to the k8s resource information.
2. The method according to claim 1, characterized in that The k8s cluster includes at least one node, the node is provided with the listener, the node is also provided with a volume group, the disk information includes the volume group to which the target disk belongs, the controller pre-creates a storage pool and a binding relationship between the storage pool and the volume group, and the method further includes: Adding the target disk to the corresponding storage pool according to the volume group to which the target disk belongs and the binding relationship between the storage pool and the volume group; In response to a storage volume creation instruction, extracting a storage pool corresponding to the storage volume from the creation instruction; Determining the volume group corresponding to the storage volume according to the binding relationship between the storage pool and the volume group; Determine a disk that matches the storage volume according to the k8s resource information of each disk in the volume group corresponding to the storage volume; and create the storage volume according to the disk that matches the storage volume.
3. The method according to claim 1, characterized in that: The method further comprises: When the disk change event is a partition creation event of the target disk, obtaining k8s resource information pre-created for the target disk; Update the k8s resource information pre-created for the target disk according to the information of the newly created partition in the partition creation event.
4. The method according to claim 1, characterized in that: The method further comprises: Obtain the permission information of the target disk. When the permission of the target disk is not occupied, execute the steps of obtaining the disk information of the target disk and defining at least one disk characteristic parameter pre-set according to the custom resource of k8s.
5. The method according to claim 2, characterized in that: The disk characteristic parameters include any one or more of the following: Disk name, capacity, type, node, volume group, whether the disk has partitions, and whether it has been added to a storage pool.
6. A k8s cluster, characterized in that: The k8s cluster includes at least one node, the node is provided with a listener, and the k8s cluster is also provided with a controller, wherein, The listener is used to monitor the changes of the disk on the node, and when the target disk sends a change, it reports the disk change event to the controller; The controller is used for obtaining disk information of the target disk and at least one disk characteristic parameter pre-set according to a custom resource definition of k8s when the disk change event is a new event of the target disk; The controller is also used to obtain the value of the disk characteristic parameter according to the disk information, and create the k8s resource information corresponding to the target disk according to the disk characteristic parameter and the value of the disk characteristic parameter, and monitor the target disk according to the k8s resource information.
7. The k8s cluster according to claim 1, characterized in that: The monitor is used to monitor the change of the disk on the node through the device manager.
8. A disk monitoring device in a k8s cluster, characterized in that: The k8s cluster is provided with a listener and a controller, the device is applied to the controller, and the device includes: A receiving module, used to receive the disk change event of the k8s cluster reported by the listener; An acquisition module, used for acquiring disk information of the target disk and at least one disk characteristic parameter pre-set according to a custom resource definition of k8s when the disk change event is a new event of the target disk; A creation module, used to obtain the value of the disk characteristic parameter according to the disk information, and create the k8s resource information corresponding to the target disk according to the disk characteristic parameter and the value of the disk characteristic parameter; A monitoring module is used to monitor the target disk according to the k8s resource information.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
