A container cluster disk management method and device
By using the disk management plug-in in the kubernetes cluster to work in a coordinated manner, it abstracts into a unified disk management interface, solving the coupling problem of disk resource management in the cluster, achieving efficient disk resource management and reducing management costs.
Patent Information
- Application Number
- CN201910163097.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-03-05
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2039-03-05
AI Technical Summary
In kubernetes clusters, the existing technology makes the service and disk types have a high degree of coupling, which makes the management of disk resources inconvenient for migration, upgrading and maintenance, and the stand-alone machine cannot support the traffic of multiple containers, resulting in high management costs.
Through the coordinated work of the disk management plug-in and kubelet, it is abstracted into a unified disk management interface to register and manage disk resources, reduce the coupling between applications and disk resources, and realize the dynamic initialization and release of disk resources.
It realizes unified management of different disk resources, reduces management costs, improves disk management efficiency, supports expansion and easy maintenance, and reduces the coupling between services and disk types.
Smart Images

Figure CN111666034B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of storage technology, and in particular to a container cluster disk management method and device. Background Art
[0002] With the maturity of technologies such as Docker, containerized applications on multiple hosts in cloud platforms (Kubernetes), and Mesos, containerization has the advantages of isolation and resource controllability. Therefore, containerization has been widely used in the Internet industry.
[0003] For most application scenarios, it is impossible for one server to support all traffic, so running Docker on a single machine to manage multiple containers is obviously not enough. Therefore, container cluster management tools are generally used now, and the most popular one is Kubernetes, because it can manage large-scale container clusters, greatly reducing the cost of container cluster management, and it is easy to scale horizontally.
[0004] Currently, it is relatively simple to manage disk resources on a Kubernetes cluster. The disk information to be used is defined by manually specifying the volume. In addition, many types of disk resources require a client for that type of disk to be installed in the container. This makes the service and disk type highly coupled, making migration, upgrading, and maintenance inconvenient. Summary of the invention
[0005] In view of this, the present application provides a container cluster disk management method and device, which can improve the efficiency of disk management.
[0006] To solve the above technical problems, the technical solution of this application is implemented as follows:
[0007] A first aspect of the present application provides a container cluster disk management method, which is applied to a network device, and the method includes:
[0008] Call kubelet to register disk information through the disk management plug-in;
[0009] Call the disk management plug-in through kubelet to obtain the available options information of the disk;
[0010] When it is determined that kubelet has created a pod with storage resources, call the disk management plug-in to initialize the disk corresponding to the pod;
[0011] Mount the initialized disk directory to the directory corresponding to the pod through kubelet, and run the pod;
[0012] When the pod ends, the disk management plug-in is called by kubelet to release the used disk resources.
[0013] A second aspect of the present application provides a container cluster disk management device, which is applied to a network device, and the device includes: a disk management plug-in and a kubelet unit;
[0014] The disk management plug-in is used to obtain disk information and send the disk information to the kubelet unit; when the kubelet unit calls the available option information of the disk, the available option information of the disk is obtained and fed back to the kubelet unit; when the kubelet unit calls this plug-in to initialize the disk, the disk corresponding to the pod is initialized; when receiving the instruction to release resources sent by the kubelet unit, the used disk resources are released;
[0015] The kubelet unit is used to register the disk information sent by the disk management plug-in; call the disk management plug-in for available option information of the disk; when it is determined that a pod with storage resources is created, call the disk management plug-in to initialize the disk corresponding to the pod; mount the initialized disk directory to the directory corresponding to the pod, and run the pod; when the pod ends running, call the disk management plug-in to release the used disk resources.
[0016] A third aspect of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the steps of the container cluster disk management method.
[0017] A fourth aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of the container cluster disk management method when the program is executed by a processor.
[0018] It can be seen from the above technical solution that in this application, the storage of different disks is abstracted into a unified disk management interface, and disk resources are registered and managed, which reduces the coupling between applications and disk resources, is easy to expand, and can improve the efficiency of disk management. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 This is a schematic diagram of the container cluster disk management process in an embodiment of the present application;
[0020] Figure 2 This is a schematic diagram of the process of processing a pod request in an embodiment of the present application;
[0021] Figure 3 Schematic diagram of the structure applied to the above device in the embodiment of the present application. DETAILED DESCRIPTION
[0022] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the technical solution of the present invention is described in detail below with reference to the accompanying drawings and embodiments.
[0023] The embodiment of the present application provides a container cluster disk management method, which abstracts the storage of different disks into a unified disk management interface, registers and manages disk resources, reduces the coupling between applications and disk resources, is easy to expand, and can improve the efficiency of disk management.
[0024] The container cluster disk management method provided in the embodiment of the present application is applied to a network device.
[0025] On each network device for container cluster disk management, a disk management plug-in is installed according to the type of disk to manage the disk. For example, for HDD disks, the installed disk management plug-in is the HDDdevice plugin, and for SSD disks, the installed disk management plug-in is the SSD device plugin.
[0026] Kubernetes (K8S) is a distributed cluster management system. A worker must be run on each network device (also called a node) to manage the life cycle of the container. This worker program is a working program (kubelet) in the distributed cluster management system.
[0027] A kubelet service is deployed on each network device to register disk resources.
[0028] In the embodiment of the present application, the master component can be deployed independently on a network device, or it can be deployed on a network device with a disk management plug-in installed.
[0029] The master components here include: K8S application interface service (APIserver), scheduler (scheduler) and database (etcd).
[0030] The following is a container cluster disk management process provided in an embodiment of the present application in conjunction with the accompanying drawings.
[0031] When the disk is initialized, the network device calls kubelet through the disk management plug-in to register the disk information; the registered information includes: what types of disks are on the current network device, and the size of the disk space.
[0032] The specific implementation of the network device is to call kubelet to register disk information through the disk management plug-in, including:
[0033] Obtain disk information through the disk management plug-in and send it to kubelet;
[0034] The disk information is sent to the K8S APIserver in the master component through kubelet and written to etcd.
[0035] When the disk management plug-in calls kubelet to register disk information, it is registered through the RegisterPlugingrpc service of kubelet.
[0036] The network device calls the disk management plug-in through kubelet to obtain the available option information of the disk;
[0037] The available options here include: disk space size, disk format, read and write methods, mount point, etc.
[0038] In specific implementation, it is obtained by calling GetPluginOptions of the disk management plug-in.
[0039] In the specific implementation of the embodiment of the present application, the disk management interface is abstracted into four unified disk management interfaces, and no matter adding or reducing disks, it will not affect the running services.
[0040] See also Figure 1 , Figure 1 This is a schematic diagram of the container cluster disk management process in the embodiment of this application. The specific steps are:
[0041] Step 101, call kubelet to register disk information through the disk management plug-in.
[0042] In this step, the disk management plug-in is used to call kubelet to register disk information. The specific implementation is as follows:
[0043] Obtain disk information through the disk management plug-in and send it to kubelet, and send it to kubelet through the Referer Plugin message;
[0044] After Kubelet receives the disk management plug-in, it will return the response (return) of obtaining disk information to Kubelet.
[0045] The disk information is sent to the K8S API server in the master component through kubelet, and the K8S API server writes it to etcd.
[0046] This step abstracts the first interface for disk information registration.
[0047] Step 102: Call the disk management plug-in through kubelet to obtain available option information of the disk.
[0048] In this step, kubelet sends a Get Plugin Options message to the disk management plug-in to obtain the available options information for the disk.
[0049] The disk management plugin returns information about available disk options to kubelet.
[0050] These available options are information other than disk information registration, such as using the disk acceleration function, and can be used when creating a pod.
[0051] This step abstracts the second interface for obtaining optional information about the disk.
[0052] Step 103, when it is determined that kubelet has created a pod with storage resources, call the disk management plug-in to initialize the disk corresponding to the pod.
[0053] That is to say, when the storage resource information in the pod is not empty, it indicates that the pod needs storage resources. Then, when creating the pod, kubelet will call the disk management plug-in to initialize the storage resources required by the pod.
[0054] In kubernetes applications, the most basic management unit is the management unit (pod) of the distributed cluster management system, not the container. Pod is a layer of encapsulation of kubernetes on the container, consisting of a group of one or more containers running on the same host. If the container is likened to a process on a traditional machine (it can execute tasks and provide certain functions to the outside world), then the pod can be likened to a traditional host: it contains multiple containers and provides them with some shared resources. Containers in the same Pod will be deployed on the same physical machine and can share resources.
[0055] In this step, kubelet calls the disk management plug-in to initialize the disk through the Allocate storage message;
[0056] The disk management plug-in feeds back the disk initialization results to kubelet through the return storage info message.
[0057] This step abstracts the third interface for disk initialization.
[0058] Step 104, mount the initialized disk directory to the directory corresponding to the pod through kubelet, and run the pod.
[0059] The program running in the pod can be any type of program, such as a web page program, a database program, a background archiving program, etc., which is not limited in the embodiments of the present application.
[0060] Step 105, when the pod ends running, the disk management plug-in is called by kubelet to release the used disk resources.
[0061] In this step, kubelet calls the disk management plug-in through Release storage to release disk resources;
[0062] The disk management plug-in feeds back the release result to kubelet through return.
[0063] This step abstracts the fourth interface for releasing disk resources.
[0064] Based on the four abstracted interfaces above, different types of disks can be managed;
[0065] When a new disk is added, determine whether the disk management plug-in corresponding to the disk type of the disk has been installed. If so, use the corresponding disk management plug-in to manage it; otherwise, install the disk management plug-in corresponding to the disk type of the disk, and use the newly installed disk management plug-in to manage the disk.
[0066] That is to say, if there is a new disk type, you only need to develop a new plug-in based on the disk management interface, without modifying the existing kubernetes code or redeploying the kubernetes cluster. You can deploy the new disk management plug-in to the kubernetes node, that is, the network device, and then you can use the disk corresponding to the new disk type.
[0067] The following is a detailed description of the process of processing a pod request with reference to the accompanying figure.
[0068] See also Figure 2 , Figure 2 This is a flow chart of processing a pod request in an embodiment of the present application. The specific steps are:
[0069] Step 201, when a network device with a master component installed receives a pod request initiated by a user, the network device stores the pod request in etcd.
[0070] In this step, the K8S API server in the master component receives the pod request sent by the user and stores the pod request in etcd.
[0071] In the specific implementation, K8S APIserver will perform conversion processing before storing the pod request in etcd, such as verification, determining the size of the required resources, and the type of disk used.
[0072] Step 202, when the network device monitors the newly stored pod request in etcd, it obtains the disk resource usage of each node, selects a network device for the pod request according to the disk type and space size corresponding to the pod request; and writes the scheduling information into etcd.
[0073] The network device listens to etcd through the scheduler in the master component. When a pod request is received, it selects a network device for the pod request based on the size of the resources required by the pod request and the disk type; and writes the scheduling information into etcd. The scheduling information here includes: the identifier of the selected node and the type of disk used.
[0074] In an embodiment of the present application, when selecting a network device for the pod request based on the size of resources required by the pod request and the disk type, there may be multiple optional network devices, which requires pre-configuration of a rule to select a network device from the multiple optional network devices.
[0075] The rules here may not be restricted, for example, selection may be made according to load balancing principles, such as selection may be made according to the size of the network device serial number, etc.
[0076] Step 203, the network device where the disk is located monitors the scheduling information in etcd through kubelet; when the scheduling information corresponding to the identifier of the network device is monitored, the pod request is obtained, and the pod corresponding to the pod request is run.
[0077] Based on the same inventive concept, the present application also provides a container cluster disk management device, which is applied to a network device. Figure 3 , Figure 3 This is a schematic diagram of the structure of the above device in an embodiment of the present application. The device includes: a disk management plug-in 301 and a kubelet unit 302;
[0078] The disk management plug-in 301 is used to obtain disk information and send the disk information to the kubelet unit; when the kubelet unit 302 calls the available option information of the disk, the available option information of the disk is obtained and fed back to the kubelet unit; when the kubelet unit 302 calls this plug-in to initialize the disk, the disk corresponding to the pod is initialized; when receiving the instruction to release resources sent by the kubelet unit, the used disk resources are released;
[0079] The kubelet unit 302 is used to register the disk information sent by the disk management plug-in 301; call the disk management plug-in for available disk option information; when it is determined that a pod with storage resources is created, call the disk management plug-in to initialize the disk corresponding to the pod; mount the initialized disk directory to the directory corresponding to the pod, and run the pod; when the pod ends, call the disk management plug-in to release the used disk resources.
[0080] Preferably,
[0081] The disk management plug-in 301 is further used to determine whether the disk management plug-in corresponding to the disk type of the disk has been installed when a new disk is added. If so, use the corresponding disk management plug-in to manage it; otherwise, install the disk management plug-in corresponding to the disk type of the disk, and use the newly installed disk management plug-in to manage the disk.
[0082] Preferably,
[0083] When a specific user registers disk information, kubelet unit 302 sends the disk information to the K8S API server in the master component, and causes the K8S API server to write it into etcd.
[0084] Preferably, the device further comprises: a K8S APIserver unit 303 and a scheduler unit 304;
[0085] K8S APIserver unit 303 is used to store the pod request in etcd when receiving the pod request initiated by the user end;
[0086] The scheduler unit 304 is used to obtain the disk resource usage of each node when monitoring the newly stored pod request in etcd, select a network device for the pod request according to the disk type and space size corresponding to the pod request; and write the scheduling information into etcd; wherein the scheduling information includes: the identifier of the selected node and the type of disk used;
[0087] The kubelet unit 302 is used to monitor the scheduling information in etcd; when the scheduling information corresponding to the identifier of the network device is monitored, the pod request is obtained, and the pod corresponding to the pod request is run.
[0088] Preferably,
[0089] The scheduler unit 304 is specifically used to select a network device for the pod request according to the disk type and space size corresponding to the pod request, and if there are multiple network devices that meet the disk type and space size, select one of them as the selected network device according to a preset rule.
[0090] The units in the above-mentioned embodiments may be integrated into one body or deployed separately; they may be combined into one unit or further divided into multiple sub-units.
[0091] In addition, an embodiment of the present application also provides an electronic device, including 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 program, the steps of the container cluster disk management method are implemented.
[0092] In addition, an embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored, characterized in that when the program is executed by a processor, the steps of the container cluster disk management method are implemented.
[0093] In summary, this application abstracts the storage of different disks into a unified disk management interface, registers and manages disk resources, reduces the coupling between applications and disk resources, is easy to expand, and can improve the efficiency of disk management.
[0094] The disk management method provided in the embodiment of the present application is simpler, non-invasive to the service, and does not need to worry about the details of the storage system.
[0095] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A container cluster disk management method, applied to a network device, characterized in that: The network device is installed with a disk management plug-in according to the type of the disk, and the method includes: Call kubelet to register disk information through the disk management plug-in; Call the disk management plug-in through kubelet to obtain the available options information of the disk; When it is determined that kubelet has created a pod with storage resources, call the disk management plug-in to initialize the disk corresponding to the pod; Mount the initialized disk directory to the directory corresponding to the pod through kubelet, and run the pod; When the pod ends, the disk management plug-in is called by kubelet to release the used disk resources.
2. The method according to claim 1, characterized in that The method further comprises: When a new disk is added, determine whether the disk management plug-in corresponding to the disk type of the disk has been installed. If so, use the corresponding disk management plug-in to manage it; otherwise, install the disk management plug-in corresponding to the disk type of the disk, and use the newly installed disk management plug-in to manage the disk.
3. The method according to claim 1, characterized in that: The disk management plug-in is used to call kubelet to register disk information, including: Obtain disk information through the disk management plug-in and send it to kubelet; The disk information is sent to the K8S API server in the master component through kubelet, and the K8S API server writes it to etcd.
4. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: The network device is installed with a master component, and when receiving a pod request initiated by the user end, the master component stores the pod request in etcd; When a new pod request is monitored in etcd, the disk resource usage of each node is obtained, and a network device is selected for the pod request according to the disk type and space size corresponding to the pod request; and the scheduling information is written into etcd; wherein the scheduling information includes: the identifier of the selected node and the type of disk used; The scheduling information in etcd is monitored by kubelet; when the scheduling information corresponding to the identifier of the network device is monitored, the pod request is obtained, and the pod corresponding to the pod request is run.
5. The method according to claim 4, characterized in that When selecting a network device for the pod request according to the disk type and space size corresponding to the pod request, if there are multiple network devices that meet the disk type and space size, one of them is selected as the selected network device according to a preset rule.
6. A container cluster disk management device, applied to a network device, characterized in that: The network device is installed with a disk management plug-in according to the type of disk, and the device includes: a disk management plug-in and a kubelet unit; The disk management plug-in is used to obtain disk information and send the disk information to the kubelet unit; when the kubelet unit calls the available option information of the disk, the available option information of the disk is obtained and fed back to the kubelet unit; when the kubelet unit calls this plug-in to initialize the disk, the disk corresponding to the pod is initialized; when receiving the instruction to release resources sent by the kubelet unit, the used disk resources are released; The kubelet unit is used to register the disk information sent by the disk management plug-in; call the disk management plug-in for available option information of the disk; when it is determined that a pod with storage resources is created, call the disk management plug-in to initialize the disk corresponding to the pod; mount the initialized disk directory to the directory corresponding to the pod, and run the pod; when the pod ends running, call the disk management plug-in to release the used disk resources.
7. The device according to claim 6, characterized in that The disk management plug-in is further used to determine whether the disk management plug-in corresponding to the disk type of the disk has been installed when a new disk is added. If so, use the corresponding disk management plug-in to manage it; otherwise, install the disk management plug-in corresponding to the disk type of the disk, and use the newly installed disk management plug-in to manage the disk.
8. The device according to claim 6, characterized in that The kubelet unit, when a specific user registers disk information, sends the disk information to the K8S APIserver in the master component, and causes the K8S APIserver to write it into etcd.
9. The device according to any one of claims 6 to 8, characterized in that: The device further includes: a K8SAPIserver unit and a scheduler unit; The K8S APIserver unit is used to store the pod request in etcd when receiving the pod request initiated by the user end; The scheduler unit is used to obtain the disk resource usage of each node when monitoring the newly stored pod request in etcd, select a network device for the pod request according to the disk type and space size corresponding to the pod request; and write the scheduling information into etcd; wherein the scheduling information includes: the identifier of the selected node and the disk type used; The kubelet unit is used to monitor the scheduling information in etcd; when the scheduling information corresponding to the identifier of the network device is monitored, the pod request is obtained, and the pod corresponding to the pod request is run.
10. The device according to claim 9, characterized in that The scheduler unit is specifically used to select a network device for the pod request according to the disk type and space size corresponding to the pod request, and if there are multiple network devices that meet the disk type and space size, select one of them as the selected network device according to a preset rule.
11. An electronic 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 program, the method according to any one of claims 1 to 5 is implemented.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method described in any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Method, apparatus, device, and storage medium for scheduling jobs in cluster
CN109117265A