A kubernetes-based cluster resource scheduling method, system, device and storage medium
Patent Information
- Application Number
- CN202210944014.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-08
- Publication Date
- 2026-09-22
- Estimated Expiration
- 2042-08-08
AI Technical Summary
[0004]本发明的目的在于提供一种基于kubernetes的集群资源调度方法、系统、设备和存储介质,解决k8s无法做到有效地调度和管理集群资源,从而使集群资源不能得到有效利用的问题
本实施例基于k8s平台,以标签和污点将集群节点Node分为不同的资源池,创建租户分配租户资源,创建项目分配项目资源,创建Namespace分配Namespace资源,同时创建ResourceQuota设置Namespace资源配额,在Namespace下创建工作负载,利用k8s资源Deployment部署动态准入Webhook,所述Webhook监控Pod的创建或更新,为Pod设置标签选择和污点容忍,Pod根据标签选择和污点容忍调度到特定集群节点Node上,实现对集群资源进行整体调度和管理,可有效提高集群资源的利用率。
Smart Images

Figure CN115185697B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of cloud computing technology, and in particular to a cluster resource scheduling method, system, device, and storage medium based on Kubernetes. Background Technology
[0002] Kubernetes, short for Kubernetes, is an open-source container orchestration engine that supports automated deployment, large-scale scalability, and application containerization management. It also provides numerous mechanisms for scalable operations on Kubernetes resources, including access control plugins, admission control, scalable resources, autoscaling, and resource quota management.
[0003] Kubernetes provides cluster resource management, which involves allocating and managing cluster resources through Kubernetes resource namespaces. However, it cannot perform overall scheduling of cluster resources, resulting in low cluster resource utilization. How to perform overall management and scheduling of cluster resources and improve the utilization of cluster resources is a problem that needs to be solved by those skilled in the art. Summary of the Invention
[0004] The purpose of this invention is to provide a cluster resource scheduling method, system, device, and storage medium based on Kubernetes, to solve the problem that Kubernetes cannot effectively schedule and manage cluster resources, thus preventing the effective utilization of cluster resources.
[0005] To address the aforementioned technical problems, this invention provides a cluster resource scheduling method based on Kubernetes, comprising the following steps: Create a resource pool, set the resource pool's tags and taints, and pull some cluster nodes from the cluster into the resource pool; Create a tenant by allocating some cluster resources from the resource pool to the tenant, which then becomes the tenant's resources. Create a project under a tenant and allocate some tenant resources to the project, which then become project resources; Create a namespace under the project and allocate some project resources to the namespace; Create a workload under the namespace, set the amount of cluster resources requested by the workload, and create a group of Pods for the workload; By leveraging dynamic admission control in Kubernetes, we can monitor the creation or update of Pods and set Pod label selection and taint tolerance based on the Namespace to which the Pod belongs. Pods are scheduled to cluster nodes in the resource pool that have the corresponding labels and taints set, based on label selection and taint tolerance, and use the cluster resources on the cluster nodes.
[0006] Preferably, a resource pool is created, its tags and taints are set, and some cluster nodes are pulled into the resource pool. This process includes the following steps: Create a resource pool and set its tags and taints. Pull some cluster nodes from the cluster into the resource pool; Add the resource pool's tag and taint to all cluster nodes pulled into this resource pool.
[0007] Preferably, a namespace is created under the project, and some project resources are allocated to the namespace, specifically including the following steps: Create a namespace under the project; Create a ResourceQuota under the Namespace and set the cluster resource quota allocated to the Namespace; Set the label and taint of the resource pool to which the cluster resource quota belongs on the namespace annotation.
[0008] Preferably, dynamic admission control in the cluster is used to monitor the creation or update of Pods, and the label selection and taint tolerance of Pods are set according to the namespace to which the Pod belongs. Specifically, this includes the following steps: Create a MutatingWebhookConfiguration and configure the Webhook address for dynamic admission control; Dynamic admission control listens for Pod creation or updates via the Application Programming Interface (API) and sets the Pod's label selection and taint tolerance based on the labels and taints in the Namespace annotations of the Pod's parent namespace.
[0009] Preferably, configuring the Webhook address for dynamic admission control specifically includes setting the path of the Webhook API interface called when creating or updating a Pod.
[0010] Preferably, dynamic admission control listens for Pod creation or updates via an application programming interface (API), and sets Pod label selection and taint tolerance based on the labels and taints in the Namespace annotations to which the Pod belongs. Specifically, this includes the following steps: Dynamic admission control listens for the creation or update of Pods through the application programming interface (API). When the creation or update of the Pod resources is detected, the labels and taints of the bound resource pool are obtained through annotations on the namespace. The label selection and taint tolerance are set for the Pod as the label selection and taint tolerance of the Pod.
[0011] The present invention also provides a system for implementing the above-described Kubernetes-based cluster resource scheduling method, comprising: The user management module is used to authenticate user roles and permissions, and to manage tenants and projects in the system, as well as the tenants and projects to which users belong. The resource management module is used to manage cluster resource quotas and resource pools for tenants, projects, and namespaces. The Webhook module is used to listen for the creation or update of the Pod, obtain the tags and taints of the bound resource pool through annotations on the Namespace, and set tag selection and taint tolerance for the Pod.
[0012] The present invention also provides a computer device, comprising: At least one processor; The processor executes the computer program to implement the steps of the Kubernetes-based cluster resource scheduling method described above.
[0013] The present invention also provides a computer-readable storage medium storing a computer program, characterized in that the computer program, when executed by a processor, implements the steps of the above-described Kubernetes-based cluster resource scheduling method.
[0014] Compared with the prior art, the beneficial effects of the present invention are as follows: This embodiment is based on the Kubernetes platform. Cluster nodes are divided into different resource pools using tags and taints. Tenants are created and tenant resources are allocated, projects are created and project resources are allocated, and namespaces are created and namespace resources are allocated. At the same time, ResourceQuota is created to set namespace resource quotas. Workloads are created under the namespace, and dynamic admission webhooks are deployed using Kubernetes resource Deployments. The webhooks monitor the creation or update of Pods, set tag selection and taint tolerance for Pods, and schedule Pods to specific cluster nodes according to tag selection and taint tolerance. This realizes the overall scheduling and management of cluster resources, which can effectively improve the utilization of cluster resources. Attached Figure Description
[0015] The specific embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.
[0016] Figure 1 A schematic diagram illustrating the process of a Kubernetes-based cluster resource scheduling method provided in an embodiment of the present invention; Figure 2 This is a schematic diagram illustrating the process of creating a resource pool, setting tags and taints for the resource pool, and pulling some cluster nodes into the resource pool, as provided in this embodiment of the invention. Figure 3 This is a schematic diagram illustrating the process of creating a tenant, allocating some resources from the resource pool to the tenant to become tenant resources, creating a project under the tenant, and allocating some of the tenant's resources to the project to become project resources, as provided in the embodiments of the present invention. Figure 4 This is a schematic diagram illustrating the process of creating a k8s resource namespace under a project and allocating some project resources to the namespace, as provided in an embodiment of the present invention. Figure 5 This is a schematic diagram illustrating the process of using dynamic admission control Webhook in Kubernetes to monitor the creation or update of Pods and set the Pod's label selection and taint tolerance according to the Namespace to which the Pod belongs, as provided in this embodiment of the invention. Figure 6 A schematic diagram of a Kubernetes-based cluster resource scheduling system provided in an embodiment of the present invention; Figure 7 A schematic diagram of the hardware structure of a computer device for cluster resource scheduling based on Kubernetes, provided for an embodiment of the present invention; Figure 8 This invention provides a schematic diagram of a computer storage medium for cluster resource scheduling based on Kubernetes.
[0017] In the diagram: 701 - Processor; 702 - Storage; 703 - Computer instructions; 801 - Computer-readable storage medium; 802 - Computer program. Detailed Implementation
[0018] Numerous specific details are set forth in the following description to provide a full understanding of the invention. However, the invention can be practiced in many other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of the invention. Therefore, the invention is not limited to the specific embodiments disclosed below.
[0019] The terminology used in one or more embodiments of this specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of this specification. The singular forms “a,” “described,” and “the” as used in one or more embodiments of this specification and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.
[0020] It should be understood that although the terms first, second, etc., may be used to describe various information in one or more embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first may also be referred to as second without departing from the scope of one or more embodiments of this specification, and similarly, second may also be referred to as first. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."
[0021] The relevant terms used in this embodiment are explained as follows: Cluster resources: All resources that can be allocated to Pods, including: CPU, memory, number of GPU cores, GPU memory, cluster storage, etc. Pod: A Pod is the smallest deployable unit of computing that can be created and managed in Kubernetes. A Pod can include one or a group of containers. Namespace: Namespace is a crucial resource in a Kubernetes (k8s) system. Its primary function is to isolate resources across multiple environments or across multiple tenants. By default, all Pods in a k8s cluster can access each other. However, in practice, it may be necessary to prevent two Pods from accessing each other. In such cases, the two Pods can be placed in different Namespaces. By allocating resources within the cluster to different Namespaces, k8s creates logical "groups," facilitating the isolated use and management of resources within different groups. Labels: Labels are key-value pairs attached to Kubernetes objects (such as Pods). By labeling cluster nodes and then selecting these labels for Pods, Pods can be scheduled to those tagged cluster nodes and use the resources on those nodes. Taints: A taint is an attribute on a cluster node. Only Pods that tolerate the taint can be scheduled to use on that cluster node. Taints and tolerance work together to prevent Pods from being assigned to inappropriate cluster nodes. Each cluster node can contain one or more taints, meaning that Pods that cannot tolerate these taints will not be scheduled to that cluster node. A taint mainly consists of three attributes: key, value, and effect. Workloads: Workloads are applications running on Kubernetes. Workloads are a further abstraction for better Pod management. In Kubernetes, workload resources can be used to manage a group of Pods instead of a single Pod. Typically, a workload creates a group of Pods. Kubernetes provides the following built-in workload resources: Deployment, ReplicaSet, StatefulSet, DaemonSet, Job, and CronJob. Dynamic admission control: Dynamic admission control is an HTTP or HTTPS callback mechanism used to receive and process admission requests. There are two types of dynamic admission control: validation-based admission control (ValidatingAdmissionWebhook) and modification-based admission control (MutatingAdmissionWebhook). This invention uses the second type of admission control. Modification-based admission control is invoked first, allowing changes to Kubernetes resource objects to perform custom modifications, accompanied by MutatingAdmissionWebhook. ResourceQuota: A Kubernetes resource that limits the total amount of resources consumed by each namespace. It can limit the maximum number of objects of a certain type within a namespace, or the maximum amount of computing resources a Pod in a namespace can use. Using ResourceQuota, you can limit the amount of cluster resources used by a Pod within a namespace, thus enabling resource scheduling. MutatingWebhookConfiguration: A Kubernetes resource that configures the MutatingAdmissionWebhook for dynamic admission control, dynamically configuring which Kubernetes resources should be processed by which admission Webhooks.
[0022] The main technical problems to be solved by the embodiments of the present invention are as follows: While Kubernetes provides namespace-level scheduling and management of cluster resources, it cannot effectively schedule and manage the entire cluster resources, resulting in inefficient utilization of these resources.
[0023] To address the aforementioned problems, embodiments of the present invention provide a cluster resource scheduling method based on Kubernetes, such as... Figure 1 As shown, it includes the following steps: S110: Create a resource pool, set the tags and taints of the resource pool, and pull some cluster nodes in the cluster into the resource pool; S120: Create a tenant, which allocates some cluster resources from the resource pool to the tenant, making them tenant resources; Cluster resources include CPU, memory, number of GPU cores, GPU memory, and cluster storage in the cluster nodes.
[0024] S130: Create a project under a tenant and allocate some tenant resources to the project, which then become project resources; S140: Create a Kubernetes resource namespace under the project and allocate some project resources to the namespace; S150: Create a workload under the Namespace and set the amount of cluster resources requested by the workload; The purpose of creating the workload is that the workload will create a Pod, and the Pod will be scheduled to a cluster node in the resource pool according to its resource pool, so as to use the cluster resources of the corresponding resource pool and achieve the purpose of scheduling the cluster resources. The amount of cluster resources requested by a workload should be less than or equal to the available cluster resource quota of the Namespace; when there is no available cluster resource quota, the Namespace can no longer create workloads; project quotas can be reallocated to the Namespace to increase the Namespace's available cluster resource quota; S160: Utilizes dynamic admission control in Kubernetes to monitor the creation or update of Pods, and sets the label selection and taint tolerance of Pods based on the Namespace to which the Pod belongs; S170: Pods are scheduled to cluster nodes with corresponding labels and taints based on label selection and taint tolerance, and use the cluster resources on those nodes.
[0025] This embodiment can perform overall scheduling and management of cluster resources, which can effectively improve the utilization rate of cluster resources.
[0026] As a preferred embodiment, a resource pool is created, tags and taints are set for the resource pool, and some cluster nodes in the cluster are pulled into the resource pool, such as... Figure 2As shown, the following methods can be used: S111: Create a resource pool and set its tags and taints. The labels and taints of the resource pool are set manually. Preferably, the labels and taints of the resource pool should not be labels and taints contained in the cluster nodes. This is because if no cluster node added to the resource pool contains the labels and taints of this resource pool, a Pod may be scheduled to that cluster node, causing chaos in cluster resource management. S112: Pull some cluster nodes from the cluster to this resource pool; The cluster nodes in the cluster are cluster nodes that do not belong to any resource pool and do not contain any taints. This is because if the cluster nodes that pull the resource pool contain other taints, the Pod will only tolerate the taints set by the resource pool when scheduling, and will not tolerate the original taints of the cluster nodes. This will cause the Pod to be unable to be scheduled to the cluster nodes with the original taints, and the resources on the cluster nodes will be unusable, resulting in resource waste. S113: Add the resource pool's tag and taint to all cluster nodes pulled into this resource pool.
[0027] In one preferred embodiment, creating a tenant involves allocating a portion of the cluster resources from the resource pool to the tenant, which then becomes tenant resources; creating a project under the tenant and allocating a portion of the tenant's resources to the project, which then becomes project resources; as follows: Figure 3 As shown, it specifically includes: Tenants are created on the cluster management system, and a portion of the cluster resources in the resource pool are allocated to the tenants, becoming tenant resources. Create a project under this tenant, and allocate some of the tenant's resources to the project, making them project resources; The tenant information and the tenant's resource quota are stored in the system database. The resources allocated to the tenant come from the resource pool. Therefore, the amount of resources allocated to the resource pool by the tenant cannot exceed the amount of resources that can be allocated in the resource pool. The project information and the project resource quota are stored in the system database. The resources allocated to the project come from the tenant. Therefore, the amount of resources allocated to the tenant for the project cannot exceed the amount of resources that the tenant can allocate.
[0028] As a preferred embodiment, the step involves creating a Kubernetes resource namespace under the project and allocating some project resources to the namespace; for example... Figure 4 As shown, the process includes: Create a Kubernetes resource namespace under the project; Create a k8s resource ResourceQuota under the Namespace and set the cluster resource quota allocated to the Namespace; Set the label and taint of the resource pool to which the cluster resource quota belongs on the namespace annotation; In the technical solution provided by this invention, the tags and taints of the resource pool to which the cluster resource quota belongs are set on the annotation of the namespace. Optionally, the information of the tags and taints and the namespace is stored in the system database. Dynamic admission control obtains the tags and taints from the system database and sets the tag selection and taint tolerance of the Pod. As a preferred embodiment, the method utilizes dynamic admission control in Kubernetes to monitor the creation or update of Pods, and sets the Pod's label selection and taint tolerance based on the Namespace to which the Pod belongs; for example... Figure 5 The process includes: Create a Kubernetes resource MutatingWebhookConfiguration and configure the Webhook address for dynamic admission control. Specifically, the Webhook address for dynamic admission control is configured by setting the path of the Webhook API interface called when creating or updating a Pod. Dynamic admission control monitors the creation or update of Pods through the application programming interface (API). It sets the label selection and taint tolerance of Pods based on the labels and taints in the annotations of the Namespace to which the Pod belongs. Specifically, when the creation or update of the Pod resource is detected, the labels and taints of the bound resource pool are obtained through the annotations on the Namespace. The label selection and taint tolerance of the Pod are set as the label selection and taint tolerance of the Pod. Optionally, the Webhook address configured for dynamic access control can be either HTTP or HTTPS. For HTTPS, one-way or two-way authentication can be used.
[0029] To implement the above method, a second aspect of this invention proposes a cluster resource scheduling system based on Kubernetes. For example... Figure 6 As shown, the system includes the following modules: The user management module authenticates user roles and permissions, and manages tenants and projects in the system, as well as the tenants and projects to which users belong. The resource management module is used to manage cluster resource quotas and resource pools for tenants, projects, and namespaces. The Webhook module is used to listen for the creation or update of the Kubernetes resource Pod, obtain the tags and taints of the bound resource pool through annotations on the Namespace, and set tag selection and taint tolerance for the Pod. The user management module is configured to authenticate user roles and permissions based on RBAC (role-based access control), use JWTToken for authentication, and manage the tenants, projects, namespaces, cluster resources, etc. that users can operate. The resource management module is configured to manage the creation and scheduling of cluster resources, including: creating resource pools, allocating tenant resources, allocating project resources, and creating namespace resources, etc. The Webhook module is configured to listen for Pod creation and set tag selection and taint tolerance for Pods based on their namespace. The Webhook module is deployed using Kubernetes Deployment and exposed within the cluster as a Service. This embodiment is based on the Kubernetes platform. Nodes are divided into different resource pools using tags and taints. Tenants are created and tenant resources are allocated, projects are created and project resources are allocated, and namespaces are created and namespace resources are allocated. Simultaneously, a ResourceQuota is created to set namespace resource quotas. Workloads are created under the namespace, and dynamic admission webhooks are deployed using Kubernetes resource Deployments. These webhooks monitor Pod creation, set tag selection and taint tolerance for Pods, and schedule Pods to specific cluster nodes based on tag selection and taint tolerance. This achieves overall scheduling and management of cluster resources, effectively improving the utilization rate of cluster resources.
[0030] To achieve the aforementioned objectives, a third aspect of this invention provides a computer device comprising a memory and a processor. The memory stores a computer program, and the processor, when executing the computer program, implements the steps of the aforementioned Kubernetes-based cluster resource scheduling method. The computer program may be in the form of source code, object code, an executable file, or some intermediate form.
[0031] like Figure 7 The diagram shown is a hardware structure schematic of an embodiment of the Kubernetes-based cluster resource scheduling device provided by the present invention.
[0032] like Figure 7 The device shown is an example, which includes a processor 701 and a memory 702.
[0033] Processor 701 and memory 702 can be connected via bus and other means. Figure 7 Taking the example of a connection between China and Israel via a bus.
[0034] The memory 702, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. These non-volatile software programs, non-volatile computer-executable programs, and modules serve as computer instructions 703, such as the program instructions / modules corresponding to a Kubernetes-based cluster resource scheduling method in this embodiment of the invention. The processor 701 executes various server functions and data processing by running the computer instructions 703 stored in the memory 702, thereby implementing a Kubernetes-based cluster resource scheduling method as described in the above embodiment.
[0035] The memory 702 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created according to a Kubernetes-based cluster resource scheduling method. Furthermore, the memory 702 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 702 may optionally include memory remotely located relative to the processor 701, and these remote memories may be connected to the local module via a network. Embodiments of the aforementioned network include, but are not limited to, the Internet, enterprise intranets, local area networks, mobile communication networks, and combinations thereof.
[0036] The present invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, performs the above-described Kubernetes-based cluster resource scheduling method.
[0037] like Figure 8 The diagram shown is a schematic representation of an embodiment of the Kubernetes-based cluster resource scheduling storage medium provided by the present invention. Figure 8 Taking the computer storage medium shown as an example, the computer-readable storage medium 801 stores a computer program 802 that, when executed by a processor, performs the above method.
[0038] Finally, it should be noted that those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. A program for a Kubernetes-based cluster resource scheduling method can be stored in a computer-readable storage medium. When executed, this program can implement the processes of the embodiments of the above methods. The storage medium for the program can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc. The above computer program embodiments can achieve the same or similar effects as any of the corresponding foregoing method embodiments.
[0039] A computer-readable storage medium storing a computer program, which, when executed by a processor, performs any of the methods described above.
[0040] More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wire segments, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0041] In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless segments, wire segments, optical cables, RF, etc., or any suitable combination thereof.
[0042] In the several embodiments provided by this invention, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of modules, units, or units is merely a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units, modules, or components may be combined or integrated into another device, or some features may be ignored or not executed.
[0043] The units may or may not be physically separate. The components shown as units can be one or more physical units, meaning they can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0044] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0045] In particular, according to embodiments disclosed in this invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication component, and / or installed from a removable medium. When the computer program is executed by a central processing unit (CPU), it performs the functions defined in the methods of this invention. It should be noted that the computer-readable medium described above in this invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof.
[0046] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0047] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions within the technical scope disclosed in the present invention should be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A cluster resource scheduling method based on Kubernetes, characterized in that, Includes the following steps: Create a resource pool, set the resource pool's tags and taints, and pull some cluster nodes from the cluster into the resource pool; Create a tenant by allocating some cluster resources from the resource pool to the tenant, which then becomes the tenant's resources. Create a project under a tenant and allocate some tenant resources to the project, which then become project resources; Create a namespace under the project; Create a ResourceQuota under the Namespace and set the cluster resource quota allocated to the Namespace; Set the label and taint of the resource pool to which the cluster resource quota belongs on the namespace annotation; Create a workload under the namespace, set the amount of cluster resources requested by the workload, and create a group of Pods for the workload; By leveraging dynamic admission control in Kubernetes, we can monitor the creation or update of Pods and set Pod label selection and taint tolerance based on the Namespace to which the Pod belongs. Pods are scheduled to cluster nodes in the resource pool that have the corresponding labels and taints set, based on label selection and taint tolerance, and use the cluster resources on the cluster nodes.
2. The cluster resource scheduling method based on Kubernetes according to claim 1, characterized in that, Creating a resource pool, setting its tags and taints, and pulling some cluster nodes into the resource pool involves the following steps: Create a resource pool and set its tags and taints. Pull some cluster nodes from the cluster into the resource pool; Add the resource pool's tag and taint to all cluster nodes pulled into this resource pool.
3. The cluster resource scheduling method based on Kubernetes according to claim 1, characterized in that, By leveraging dynamic admission control within the cluster, the creation or update of Pods can be monitored. Based on the namespace to which the Pod belongs, Pod label selection and taint tolerance can be configured. Specifically, the steps include: Create a MutatingWebhookConfiguration and configure the Webhook address for dynamic admission control; Dynamic admission control listens for Pod creation or updates via the Application Programming Interface (API) and sets the Pod's label selection and taint tolerance based on the labels and taints in the Namespace annotations of the Pod's parent namespace.
4. The cluster resource scheduling method based on Kubernetes according to claim 3, characterized in that: Configuring the Webhook address for dynamic admission control specifically includes setting the path to the Webhook API interface called when creating or updating a Pod.
5. A cluster resource scheduling method based on Kubernetes according to claim 4, characterized in that, Dynamic admission control listens for Pod creation or updates via the Application Programming Interface (API), and sets Pod label selection and taint tolerance based on the labels and taints in the Namespace annotations to which the Pod belongs. Specifically, it includes the following steps: Dynamic admission control listens for the creation or update of Pods through the application programming interface (API). When the creation or update of the Pod resources is detected, the labels and taints of the bound resource pool are obtained through annotations on the namespace. The label selection and taint tolerance are set for the Pod as the label selection and taint tolerance of the Pod.
6. A cluster resource scheduling method based on Kubernetes according to claim 3, characterized in that: Configure the Webhook address for dynamic admission control to use either the HTTP or HTTPS protocol; The HTTPS protocol can be either one-way or two-way authentication.
7. A system for implementing the Kubernetes-based cluster resource scheduling method according to any one of claims 3-6, characterized in that, include: The user management module is used to authenticate user roles and permissions, and to manage tenants and projects in the system, as well as the tenants and projects to which users belong. The resource management module is used to manage cluster resource quotas and resource pools for tenants, projects, and namespaces. The Webhook module is used to listen for the creation or update of the Pod, obtain the tags and taints of the bound resource pool through annotations on the Namespace, and set tag selection and taint tolerance for the Pod.
8. A computer device, characterized in that, include: At least one processor; And a memory storing a computer program, characterized in that the processor executes the computer program to implement the steps of the method according to any one of claims 1-6.
9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1-6.
Citation Information
Patent Citations
container Cloud-platform multi-cluster building method, media and device based on Kubernetes and OpenStack
CN109067828A
Resource scheduling method, device and system
CN113535411A