Dynamic scheduling method and electronic equipment
Dynamic scheduling method is used to realize the dynamic creation of local persistent volumes in Kubernetes, which solves the problem of inconvenient use of local persistent volumes and improves the user experience and persistent storage capabilities of container data.
Patent Information
- Application Number
- CN202411073567.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-06
- Publication Date
- 2024-11-19
AI Technical Summary
In Kubernetes, local persistent volumes are inconvenient to use and cannot be dynamically created, resulting in poor user experience.
Through dynamic scheduling methods, publish pods to edge nodes, configure persistent volume declaration resource objects, and use extended schedulers and dynamic providers to realize dynamic creation of local persistent volumes, including determining candidate nodes, creating logical volumes, and binding persistent volume declarations, improving Easily use local persistent volumes.
It realizes dynamic creation and pod mapping of local persistent volumes, improves user experience, improves PV usage convenience and persistent storage capabilities of container data.
Smart Images

Figure CN118981365A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computer technology, and in particular to a dynamic scheduling method and electronic equipment. Background Art
[0002] Currently, in Kubernetes, the use of Volume is similar to the disk of a virtual machine. A Pod (which can be compared to a logical virtual machine) needs to be mounted on a disk, and then the process (container) in the Pod can use the mounted disk through VolumeMounts. A Persistent Volume (PV) is a storage space in an external storage system that can be created and maintained by an administrator. Like Volume, PV is persistent and its life cycle is independent of Pod.
[0003] The local storage (Local Volume) provided by Kubernetes does not yet support dynamic creation. When scheduling a Pod, the local persistent volume (Local PersistentVolume) needs to be created manually before the Pod can be successfully scheduled to the node. In this way, it is not convenient for users to use the local persistent volume, and it is impossible to dynamically create the local persistent volume.
[0004] In order to solve the above problems, a dynamic scheduling method and electronic device are proposed in this application. Summary of the invention
[0005] In order to address the deficiencies of the prior art, the present application provides a dynamic scheduling method and electronic device to solve the problems in the prior art that the use of local persistent volumes is not convenient and that dynamic creation of local persistent volumes cannot be achieved.
[0006] The technical effects to be achieved by this application are achieved through the following solutions:
[0007] In a first aspect, the present application provides a dynamic scheduling method, the method comprising:
[0008] Publish the Pod to the edge node and configure the resource object using the persistent volume declaration in the Pod;
[0009] The Kubernetes scheduler determines the first candidate node for the Pod and accesses the extended scheduler;
[0010] The extended scheduler performs secondary filtering on the first candidate node according to the capacity condition to obtain a second candidate node;
[0011] The Kubernetes scheduler determines a target node from the second candidate nodes, and stores the name of the target node in the nodeName of the Pod;
[0012] The dynamic provisioner listens to the Pod, and if the Pod has a nodeName and the storage type declared by the persistent volume mounted by the Pod is local persistent storage, sets the value of the nodeName of the Pod to the annotation mark of the first node, where the first node is the node associated with the persistent volume declaration;
[0013] According to the annotation mark, on the first node, according to the requirements of the persistent volume declaration, a logical volume for logical volume management is created, and then a corresponding local persistent volume is created;
[0014] The binding of the local persistent volume to the persistent volume declaration and the binding of the Pod to the first node are completed, and the scheduling is completed.
[0015] In some embodiments, before publishing the Pod to the edge node and configuring the resource object using the persistent volume declaration in the Pod, the method further includes:
[0016] Determine a local storage provider in the edge node;
[0017] Create a persistent volume claim template, and set the following information in the persistent volume claim template: name, label, annotation, type, access mode, and capacity;
[0018] Publish the persistent volume declaration template to the edge node, and create a resource object of the persistent volume declaration in the Kubernetes cluster of the edge node.
[0019] In some embodiments, determining the local storage provider in the edge node includes: creating a storage type and configuring a delay binding rule.
[0020] In some embodiments, the extended scheduler performs secondary filtering on the first candidate node according to a capacity condition to obtain a second candidate node, including:
[0021] The extended scheduler dynamically obtains the capacity of the first candidate node;
[0022] Each node in the first candidate nodes whose capacity is greater than a threshold is screened out as a second candidate node.
[0023] In some embodiments, the Kubernetes scheduler determines a target node from the second candidate node, including:
[0024] The Kubernetes scheduler determines a target node according to the capacity of the second candidate node and in combination with the status information of the second candidate node.
[0025] In some embodiments, including:
[0026] Defer the binding of dynamically created local storage volumes to persistent volume claims until a Pod is scheduled and actually used.
[0027] In some embodiments, the format of the annotation tag is: volume.kubernetes.io / selected-node:nodeName.
[0028] In some embodiments, the first candidate node includes a plurality of nodes.
[0029] In a second aspect, the present application provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any one of the methods described above when executing the computer program.
[0030] In a third aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement any of the methods described above.
[0031] Through the dynamic scheduling method and electronic device provided by the present application, the method provides the function of dynamically creating a local persistent volume (LocalPersistentVolume, LocalPV), namely, a dynamic local persistent volume (DynamicLocalPersistentVolume), realizes the dynamic creation of LocalPV, and maps it with the Pod, and persistently stores the container data on the local disk and directory, thereby improving the convenience of using PV and improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the embodiments of the present application or the existing technical solutions, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0033] Figure 1 A flowchart of a dynamic scheduling method in an embodiment of the present application;
[0034] Figure 2It is a schematic block diagram of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0035] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0036] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in one or more embodiments of the present application should be understood by people with ordinary skills in the field to which the present application belongs. The "first", "second" and similar words used in one or more embodiments of the present application do not indicate any order, quantity or importance, but are only used to distinguish different components. "Include" or "comprise" and similar words mean that the elements or objects appearing before the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0037] Explanation of technical terms in this application:
[0038] 1. Dynamic Local PV: Dynamic Local PersistentVolume, dynamic local persistent volume.
[0039] 2. StorageClass: storage type.
[0040] 3. PersistentVolumeClaim: Persistent volume claim.
[0041] 4. selectors: selectors.
[0042] 5. affinity: affinity.
[0043] 6. Dynamic Provisoner: Dynamic provider.
[0044] 7.annotation: annotation mark.
[0045] 8. volume.kubernetes.io / selected-node: marks the node where the local storage volume is located.
[0046] The Docker storage management design includes two methods for storing data in containers. One is to store container data through Docker image metadata management, or to provide operations such as initialization of a specific file system, addition, deletion, modification, and difference comparison of image layers through storage drivers. When starting a container, Docker loads all read-only layers of the image and adds a read-write layer to the top layer, so that the container can improve the efficiency of image building, storage, and distribution, saving time and storage space. However, there are also problems such as data being deleted when the container is deleted and data cannot be shared between multiple containers.
[0047] Docker also introduced the volume mechanism. Volume is a specific file or folder that exists in one or more containers. This directory exists in the host machine in a form independent of the union file system and provides a lot of convenience for data sharing and persistence.
[0048] In actual use, the current Kubernetes PV does not support dynamic creation. It needs to be manually created successfully before the Pod can successfully call it, making the use of PV inconvenient.
[0049] Various non-limiting implementations of the present application are described in detail below in conjunction with the accompanying drawings.
[0050] First, refer to Figure 1 , the dynamic scheduling method of the present application is described in detail.
[0051] The present application provides a dynamic scheduling method, the method comprising:
[0052] In a first aspect, the present application provides a dynamic scheduling method, the method comprising:
[0053] S1: Publish the Pod to the edge node and configure the resource object using the persistent volume declaration in the Pod;
[0054] S2: The Kubernetes scheduler determines the first candidate node for the Pod and accesses the extended scheduler;
[0055] S3: the extended scheduler performs secondary filtering on the first candidate nodes according to the capacity condition to obtain a second candidate node;
[0056] S4: the Kubernetes scheduler determines a target node from the second candidate nodes, and stores the name of the target node in the nodeName of the Pod;
[0057] S5: The dynamic provisioner listens to the Pod, and if the Pod has a nodeName and the storage type declared by the persistent volume mounted by the Pod is local persistent storage, the value of the nodeName of the Pod is set to the annotation mark of the first node, where the first node is the node associated with the persistent volume declaration;
[0058] S6: according to the annotation mark, create a logical volume for logical volume management on the first node according to the requirements of the persistent volume declaration, and then create a corresponding local persistent volume;
[0059] S7: The binding of the local persistent volume to the persistent volume declaration and the binding of the Pod to the first node are completed, and the scheduling is completed.
[0060] The above-mentioned embodiments of the present application realize the dynamic creation of LocalPV and mapping with Pod, and store the container data persistently on the local disk and directory, thereby improving the convenience of using PV and improving the user experience.
[0061] In some embodiments, before publishing the Pod to the edge node and configuring the resource object using the persistent volume declaration in the Pod, the method further includes:
[0062] Determine a local storage provider in the edge node;
[0063] Create a persistent volume claim template, and set the following information in the persistent volume claim template: name, label, annotation, type, access mode, and capacity;
[0064] Publish the persistent volume declaration template to the edge node, and create a resource object of the persistent volume declaration in the Kubernetes cluster of the edge node.
[0065] In some embodiments, determining the local storage provider in the edge node includes: creating a storage type and configuring a delay binding rule.
[0066] Specifically, creating a storage type includes:
[0067] Dynamic Local Persistent Volume provides the function of dynamically creating Local Persistent Volume. The underlying layer is implemented by Logical Volume Manager (LVM), which increases the flexibility of storage volume management. Dynamic Local Persistent Volume involves the following functional modules:
[0068] Storage Class: also known as the storage class module, uses a delayed binding mechanism (WaitForFirstConsumer) to postpone the binding of dynamically created local persistent volumes and persistent volume claims (PVC) until a Pod is scheduled and actually used. Therefore, the extended scheduler (including the Local PV extended scheduler) can comprehensively consider and select the appropriate Node node when scheduling, so as not to cause conflicts with Pod resource settings, selectors, affinity and anti-affinity policies, etc.
[0069] If delayed binding is not used, bind the PVC to the LocalPersistentVolume first. Since the LocalPersistentVolume is bound to the node, selectors, affinity, etc. will be invalid. Therefore, select the node according to the scheduling strategy first, and then bind the LocalPersistentVolume.
[0070] In some embodiments, the extended scheduler (also referred to as an extended scheduler module) performs secondary filtering on the first candidate node according to a capacity condition to obtain a second candidate node, including:
[0071] The extended scheduler dynamically obtains the capacity of the first candidate node;
[0072] Each node in the first candidate nodes whose capacity is greater than a threshold is screened out as a second candidate node.
[0073] Specifically, after the Kubernetes scheduler selects the appropriate node for the Pod, it accesses the extended scheduler for secondary screening of the node. The extended scheduler dynamically obtains the capacity of the local storage node from the Kubernetes Node and schedules the Pod using the local storage volume to the correct topology domain.
[0074] In some embodiments, the Kubernetes scheduler determines a target node from the second candidate node, including:
[0075] The Kubernetes scheduler determines a target node according to the capacity of the second candidate node and in combination with the status information of the second candidate node.
[0076] In some embodiments, including:
[0077] Defer the binding of dynamically created local storage volumes to persistent volume claims until a Pod is scheduled and actually used.
[0078] In some embodiments, the format of the annotation tag is: volume.kubernetes.io / selected-node:nodeName.
[0079] In some embodiments, the first candidate node includes a plurality of nodes.
[0080] Specifically, the dynamic provisioner (Dynamic Provisoner): also called the dynamic provisioner module, runs on each Node node in the cluster in the form of a daemon set, is responsible for managing the LVM on each node, reporting the capacity and / or remaining capacity of the node disk, dynamically creating LocalPersistentVolume and other information; in this way, the capacity information can be provided to the extended scheduler and / or kubernetes scheduler to screen out suitable nodes.
[0081] Due to the development of 5G, business demand is growing rapidly. The type container of this application is suitable for edge computing scenarios, and has a significant capacity improvement for scenarios with high requirements such as rapid deployment, large bandwidth and high computing power.
[0082] This application uses the StorageClass module, Scheduler Extender module, and Dynamic Provisoner module to implement dynamic configuration of Local PV.
[0083] In addition, LocalPV is dynamically created and mapped to the Pod. When the pod is restarted, the default-scheduler checks whether the storage and configuration mounted by the pod exist, and then screens all the Node nodes in the kubernetes cluster according to the requested cpu, memory resources and affinity, and selects the Node nodes that meet the requirements. Among them, the scheduler-extender module finds that the pod is mounted with localpv, finds the node name where localpv is located on kubernetes, and updates the node name to the pod's yaml. The kubelet (deployed on each machine of kubernetes) finds that the Node name in the pod's yaml is its own machine, and then the kubelet starts the pod and mounts the file directory specified in pv into the container.
[0084] Through the dynamic scheduling method and electronic device provided in the present application, the method provides the function of dynamically creating a local persistent volume (Local Persistent Volume, Local PV), namely, a dynamic local persistent volume (Dynamic Local Persistent Volume), which realizes the dynamic creation of Local PV, improves the convenience of using PV, and improves the user experience.
[0085] It should be noted that the method of one or more embodiments of the present application can be performed by a single device, such as a computer or server. The method of this embodiment can also be applied to a distributed scenario and completed by multiple devices cooperating with each other. In the case of such a distributed scenario, one of the multiple devices can only perform one or more steps in the method of one or more embodiments of the present application, and the multiple devices will interact with each other to complete the described method.
[0086] It should be noted that the above describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0087] Based on the same inventive concept, corresponding to any of the above-mentioned embodiments and methods, the present application also discloses an electronic device;
[0088] Specifically, Figure 2A schematic diagram of the hardware structure of an electronic device for a dynamic scheduling method provided in this embodiment is shown, and the device may include: a processor 410, a memory 420, an input / output interface 430, a communication interface 440, and a bus 450. The processor 410, the memory 420, the input / output interface 430, and the communication interface 440 are connected to each other in communication within the device through the bus 450.
[0089] The processor 410 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application.
[0090] The memory 420 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 420 may store an operating system and other application programs. When the technical solution provided in the embodiment of the present application is implemented by software or firmware, the relevant program code is stored in the memory 420 and is called and executed by the processor 410.
[0091] The input / output interface 430 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.
[0092] The communication interface 440 is used to connect a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through a wired mode (for example, USB, network cable, etc.) or a wireless mode (for example, mobile network, WIFI, Bluetooth, etc.).
[0093] The bus 450 includes a path that transmits information between the various components of the device (eg, the processor 410 , the memory 420 , the input / output interface 430 , and the communication interface 440 ).
[0094] It should be noted that, although the above device only shows the processor 410, the memory 420, the input / output interface 430, the communication interface 440 and the bus 450, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include the components necessary for implementing the embodiment of the present application, and does not necessarily include all the components shown in the figure.
[0095] The electronic device of the above embodiment is used to implement the corresponding dynamic scheduling method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.
[0096] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, one or more embodiments of the present application also provide a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the dynamic scheduling method described in any of the above embodiments.
[0097] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.
[0098] The computer instructions stored in the storage medium of the above embodiments are used to enable the computer to execute the dynamic scheduling method described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0099] Those skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of the present application (including the claims) is limited to these examples. In line with the concept of the present application, the technical features in the above embodiments or different embodiments may be combined, the steps may be implemented in any order, and there are many other variations of different aspects of one or more embodiments of the present application as described above, which are not provided in detail for the sake of simplicity.
[0100] In addition, to simplify the description and discussion, and in order not to make one or more embodiments of the present application difficult to understand, the known power / ground connections to the integrated circuit (IC) chip and other components may or may not be shown in the provided drawings. In addition, the device can be shown in the form of a block diagram to avoid making one or more embodiments of the present application difficult to understand, and this also takes into account the fact that the details of the implementation of these block diagram devices are highly dependent on the platform on which one or more embodiments of the present application will be implemented (that is, these details should be fully within the scope of understanding of those skilled in the art). In the case of elaborating specific details (e.g., circuits) to describe exemplary embodiments of the present application, it is obvious to those skilled in the art that one or more embodiments of the present application can be implemented without these specific details or when these specific details are changed. Therefore, these descriptions should be considered illustrative rather than restrictive.
[0101] Although the present application has been described in conjunction with specific embodiments of the present application, many replacements, modifications and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may use the embodiments discussed.
[0102] One or more embodiments of the present application are intended to cover all such substitutions, modifications and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present application should be included in the scope of protection of the present application.
Claims
1. A dynamic scheduling method, characterized in that: The method comprises: Publish the Pod to the edge node and configure the resource object using the persistent volume declaration in the Pod; The Kubernetes scheduler determines the first candidate node for the Pod and accesses the extended scheduler; The extended scheduler performs secondary filtering on the first candidate node according to the capacity condition to obtain a second candidate node; The Kubernetes scheduler determines a target node from the second candidate nodes, and stores the name of the target node in the nodeName of the Pod; The dynamic provisioner listens to the Pod, and if the Pod has a nodeName and the storage type declared by the persistent volume mounted by the Pod is local persistent storage, sets the value of the nodeName of the Pod to the annotation mark of the first node, where the first node is the node associated with the persistent volume declaration; According to the annotation mark, on the first node, according to the requirements of the persistent volume declaration, a logical volume for logical volume management is created, and then a corresponding local persistent volume is created; The binding of the local persistent volume to the persistent volume declaration and the binding of the Pod to the first node are completed, and the scheduling is completed.
2. The method for dynamic scheduling according to claim 1, characterized in that: Before publishing the Pod to the edge node and configuring the resource object using the persistent volume declaration in the Pod, the method further includes: Determine a local storage provider in the edge node; Create a persistent volume claim template, and set the following information in the persistent volume claim template: name, label, annotation, type, access mode, and capacity; Publish the persistent volume declaration template to the edge node, and create a resource object of the persistent volume declaration in the Kubernetes cluster of the edge node.
3. The method for dynamic scheduling according to claim 2, characterized in that: Determining the local storage provider in the edge node includes: creating a storage type and configuring a delay binding rule.
4. The method for dynamic scheduling according to claim 3, characterized in that: The extended scheduler performs secondary filtering on the first candidate node according to the capacity condition to obtain a second candidate node, including: The extended scheduler dynamically obtains the capacity of the first candidate node; Each node in the first candidate nodes whose capacity is greater than a threshold is screened out as a second candidate node.
5. The method for dynamic scheduling according to claim 4, characterized in that: The Kubernetes scheduler determines a target node from the second candidate nodes, including: The Kubernetes scheduler determines a target node according to the capacity of the second candidate node and in combination with the status information of the second candidate node.
6. The method for dynamic scheduling according to claim 5, characterized in that: The delayed binding rule includes: Defer the binding of dynamically created local storage volumes to persistent volume claims until a Pod is scheduled and actually used.
7. The method for dynamic scheduling according to claim 1, characterized in that: The format of the annotation tag is: volume.kubernetes.io / selected-node:nodeName.
8. The method for dynamic scheduling according to claim 7, characterized in that: The first candidate node includes multiple nodes.
9. An electronic device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 8 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the method according to any one of claims 1 to 8.
