Kalman filter-based k8s scheduling method and device

By introducing Kalman filters in the K8s environment for resource utilization prediction, the problem that native scheduling algorithms cannot dynamically score resource usage is solved, and more efficient resource scheduling and more stable system performance are achieved.

CN119814878APending Publication Date: 2025-04-11E SURFING VISION TECHNOLOGY CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411893283.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-20
Publication Date
2025-04-11

Smart Images

  • Figure CN119814878A_ABST
    Figure CN119814878A_ABST
Patent Text Reader

Abstract

The invention relates to a k8s scheduling method and device based on a Kalman filter. The method comprises the following steps: receiving a creation request; screening the deployable nodes to obtain screened nodes; deploying a Kalman filter, and performing resource utilization prediction on the historical data through the Kalman filter to obtain prediction data; selecting screening nodes based on the prediction data to obtain an optimal node; and deploying the pod to be operated in the creation request to the optimal node to complete scheduling. According to the method, the defect that only static scoring can be carried out on resource use in a scheduling algorithm can be optimized, and scheduling optimization is carried out on services by using dynamic scoring of resource use, so that a future performance trend can be better predicted in system monitoring.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of microservice management, and in particular relates to a K8s scheduling method and device based on a Kalman filter. Background Art

[0002] Thousands of microservices can be run in the K8s environment. The scheduling optimization of microservices is the most efficient way to improve the utilization rate of machine resources. The resource utilization rate of the machine is not constant, but has periodic changes and is predictable. The resource utilization of pods also has periodic changes and is predictable.

[0003] However, using only the native scheduling algorithm does not allow for dynamic scoring of resource usage. The resulting scheduling scores are all static reference values. Because of the static reference values, nodes with periodic changes in resource usage may become overloaded, causing service jitter. Summary of the invention

[0004] In view of the above deficiencies in the prior art, the purpose of the invention is to provide a k8s scheduling method and device based on Kalman filter.

[0005] The first aspect of the present invention provides a k8s scheduling method based on a Kalman filter, comprising:

[0006] S1: Receive a creation request;

[0007] S2: Screen the deployable nodes to obtain the screened nodes;

[0008] S3: deploying a Kalman filter, and using the Kalman filter to predict resource utilization based on historical data to obtain prediction data;

[0009] S4: Selecting a screening node based on the prediction data to obtain an optimal node;

[0010] S5: deploying the pod to be run in the creation request to the optimal node to complete the scheduling.

[0011] According to a Kalman filter-based k8s scheduling method provided by the present invention, the screening of the deployable nodes in step S2 is a multi-stage screening, and the specific screening stages include a pre-screening stage and a priority screening stage.

[0012] According to a K8s scheduling method based on Kalman filter provided by the present invention, the Kalman filter in step S3 is deployed through an admission controller.

[0013] According to a Kalman filter-based k8s scheduling method provided by the present invention, the historical data in step S3 is acquired by prometheus.

[0014] According to a Kalman filter-based k8s scheduling method provided by the present invention, the predicted data in step S3 includes a pod resource usage value after a preset time and a node resource idle value after a preset time.

[0015] According to a K8s scheduling method based on a Kalman filter provided by the present invention, step S4 further includes:

[0016] S41: replacing the basic Least Allocated algorithm in the priority screening phase according to the prediction data to obtain an updated Least Allocated algorithm;

[0017] S42: Score the screening node by using the updated Least Allocated algorithm to obtain a node score;

[0018] S43: According to the node scores, select the node with the highest score among the screened nodes to obtain the optimal node.

[0019] According to a K8s scheduling method based on a Kalman filter provided by the present invention, the expression for updating the Least Allocated algorithm in step S41 is:

[0020]

[0021] Among them, S is the calculated node score, N T is the node resource idle value, P T is the pod resource usage value, and M is the maximum node score defined in the scheduling framework.

[0022] A second aspect of the present invention is a K8s scheduling device based on a Kalman filter, comprising:

[0023] Receiving module: used to receive creation requests;

[0024] Screening module: used to screen deployable nodes and obtain screened nodes;

[0025] Prediction module: used to predict resource utilization based on historical data using the deployed Kalman filter to obtain prediction data;

[0026] Selection module: used to select the screening node based on the prediction data to obtain the optimal node;

[0027] Deployment module: deploys the pod to be run in the creation request to the optimal node to complete the scheduling.

[0028] The third aspect of the present invention provides a K8s scheduling device based on a Kalman filter, comprising:

[0029] A memory and at least one processor, wherein instructions are stored in the memory;

[0030] At least one of the processors calls the instructions in the memory so that the Kalman filter-based k8s scheduling device executes the Kalman filter-based k8s scheduling method as described in any one of the above.

[0031] A fourth aspect of the present invention provides a computer-readable storage medium, characterized in that instructions are stored on the computer-readable storage medium, and when the instructions are executed by the processor, the K8S scheduling method based on the Kalman filter as described in any one of the above items is implemented.

[0032] The present invention provides a K8s scheduling method, device, equipment and storage medium based on Kalman filter. By introducing Kalman filter to predict resource utilization of historical data, it can more accurately predict the use of future resources, so that future resource requirements can be taken into account when selecting the optimal node, avoiding excessive or insufficient allocation of resources, and improving the overall utilization of resources. At the same time, scheduling decisions based on predicted data can find the most suitable node more quickly, thereby improving the efficiency of scheduling. Traditional K8s scheduling methods may rely on simple resource allocation algorithms, such as LeastAllocated algorithms, which often only consider the current allocation of resources. The present invention optimizes the basic scheduling algorithm through the predicted data of Kalman filter. The present invention adopts the multi-stage method of Kalman filter deployment and node screening to make the scheduling system more adaptable to different environments and requirements, and improves the scalability and flexibility of the system. In addition, the present invention obtains historical data through Prometheus and uses Kalman filter to predict resources, realizes data-driven intelligent scheduling, and can make more accurate scheduling decisions based on actual data and prediction results, thereby improving the intelligence level of scheduling. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] The accompanying drawings are only used to illustrate specific embodiments and are not considered to limit the present invention. In the entire drawings, the same reference symbols represent the same components. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings.

[0034] Figure 1 A flow chart of a k8s scheduling method based on a Kalman filter provided in an embodiment of the present invention;

[0035] Figure 2 A schematic diagram of a k8s scheduling device based on a Kalman filter provided in an embodiment of the present invention.

[0036] Reference numerals: 100, receiving module; 200, screening module; 300, prediction module; 400, selection module; 500, deployment module. DETAILED DESCRIPTION

[0037] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. It should be understood that these descriptions are only exemplary and are not intended to limit the scope of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in the field without making creative work should fall within the scope of protection of the present invention.

[0038] Furthermore, in the following description, descriptions of well-known structures and technologies are omitted to avoid unnecessarily obscuring the concepts disclosed in the present invention.

[0039] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the orientation or position relationship indicated by the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inside", "outside", etc. is based on the orientation or position relationship shown in the drawings, which is only for the convenience of describing the present invention and simplifying the description, and does not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation of the present invention. In addition, the terms "first", "second", and "third" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. The terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be a connection between the two elements. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0040] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of methods and systems consistent with some aspects of the present invention as detailed in the appended claims.

[0041] In order to better understand the present invention, the terms appearing in the embodiments of the present invention are first explained below.

[0042] Kalman filter: It is a recursive estimation method suitable for processing time series data with noise. Its core idea is to estimate the hidden state in real time by minimizing the estimation error and combining the state and measurement results of the dynamic system.

[0043] Kubernetes Scheduler (Kube-Scheduler): It is one of the components of the Kubernetes control plane and is responsible for allocating the Pods to be scheduled to the appropriate nodes. The scheduler calculates the score of each node based on a series of rules and policies (such as resource requirements, node availability, affinity and anti-affinity rules, etc.) and selects the best node to run the Pod.

[0044] Kubernetes (k8s for short): is an open source platform for managing containerized applications, which can provide the ability to automatically deploy, expand and manage containerized applications.

[0045] Pod: The smallest deployable unit in Kubernetes, consisting of one or more containers that share networking and storage and run in the same context.

[0046] Prometheus: is an open source monitoring system and time series database, originally developed by SoundCloud, and now part of CNCF (Cloud Native Computing Foundation). Prometheus obtains indicator data from the target through a pull model and provides a powerful query language PromQL for real-time data aggregation and analysis. Prometheus has high performance, reliability and flexibility, so it is widely used for monitoring cloud native environments and distributed systems.

[0047] In order to better understand the present invention, the research background of the present invention is first explained below.

[0048] When deciding which node to schedule a Pod to, the Kubernetes scheduler uses various plug-ins (such as filters, scorers, etc.) to make decisions. The Kube-Scheduler scheduling process goes through the pre-selection Predicates stage and the optimization Priorities stage. The Predicates stage first traverses all nodes and filters out nodes that do not meet the conditions. This is a mandatory rule. All nodes that meet the requirements output by this stage will be recorded and used as input for the second stage. The Priorities stage is to screen the nodes again. If multiple nodes meet the conditions, the system will sort the nodes according to the size of the node priorities (priorites), and finally select the node with the highest priority to deploy the Pod application. The optimization stage depends on the scoring results of multiple plug-ins such as Balanced Allocation, Image Locality, and LeastAllocated, where the weight of each of the above plug-ins is 1.

[0049] The following describes embodiments of the present invention based on the drawings.

[0050] like Figure 1 As shown, the present invention provides a k8s scheduling method based on a Kalman filter, comprising:

[0051] S1: Receive a create request.

[0052] In step S1, the Kubernetes API client first initiates a pod creation request, such as through the kubectlcreate command or directly sending an HTTP request through the Kubernetes API. The request contains the definition of the Pod, including the Pod's name, container, resource requirements, labels and other information. After the Kubernetes API Server receives and processes this request, it is stored in etcd to facilitate the subsequent Kubernetes scheduler to be triggered to schedule this Pod.

[0053] S2: Filter the deployable nodes to obtain the filtered nodes.

[0054] The screening of the deployable nodes in step S2 is a multi-stage screening, and the specific screening stages include a pre-screening stage and a priority screening stage.

[0055] Furthermore, the scheduler's preselection phase traverses all nodes in the cluster and filters out nodes that do not meet the conditions based on a series of conditions. If a node does not meet any of the conditions, it will be removed from the candidate node list.

[0056] The purpose of the pre-selection phase is to exclude nodes that are obviously unsuitable for running Pods as quickly as possible, thereby reducing the complexity of subsequent calculations. The conditions may include whether the node has sufficient resources (CPU, memory, storage, etc.), whether the node meets the affinity and anti-affinity requirements of the Pod, and whether the node has sufficient network bandwidth or I / O performance.

[0057] Furthermore, if multiple nodes meet the scheduling requirements of the Pod in the pre-selection stage, the scheduler will enter the Priorities stage. In this stage, the scheduler will evaluate the priority of each candidate node based on a series of priority functions (or weights), which may include the resource utilization of the node, the geographical location of the node (important for clusters deployed across regions), the number of Pods on the node, whether the node is running a specific system daemon, etc.

[0058] Each priority function scores the candidate nodes, and these scores are aggregated to form a final priority score. The scheduler sorts the candidate nodes from high to low based on the priority score, and then selects the node with the highest score to run the Pod. If multiple nodes have the same score, the scheduler may randomly select a node.

[0059] S3: deploying a Kalman filter, and using the Kalman filter to predict resource utilization based on historical data to obtain prediction data.

[0060] Wherein, the Kalman filter in step S3 is deployed through an admission controller.

[0061] Furthermore, an admission controller is a component in Kubernetes that intercepts and inspects or modifies objects (such as Pods) before they are persisted to the cluster state. The admission controller deploys a Kalman filter or adjusts parts of the scheduler algorithm to ensure that the resource requests and limits of the Pod or node meet specific policies or standards.

[0062] The historical data in step S3 is obtained by prometheus.

[0063] Furthermore, Prometheus is an open source monitoring and alerting toolkit that is very suitable for collecting and processing time series data. In step S3, Prometheus is used to collect historical resource usage data of Pods and nodes. Specifically, Prometheus is used to capture resource usage indicators in the Kubernetes cluster and store these indicators in the Prometheus time series database.

[0064] The predicted data in step S3 includes a pod resource usage value after a preset time and a node resource idle value after a preset time.

[0065] Specifically, in step S3, the historical data obtained from Prometheus is processed using a Kalman filter to generate future resource usage forecasts, which are then combined with the scheduler's priority function to take into account future resource requirements, ultimately obtaining the above-mentioned forecast values.

[0066] S4: Selecting screening nodes based on the prediction data to obtain the optimal node.

[0067] Wherein, step S4 further comprises:

[0068] S41: According to the prediction data, the basic Least Allocated algorithm in the priority screening stage is replaced to obtain an updated Least Allocated algorithm.

[0069] The expression for updating the Least Allocated algorithm in step S41 is:

[0070]

[0071] Among them, S is the calculated node score, N T is the node resource idle value, P T is the pod resource usage value, and M is the maximum node score defined in the scheduling framework.

[0072] Specifically, in step S41, the Least Allocated score in the priorites scoring stage needs to be replaced with ((24node-24pod)*int64(framework.MaxNodeScore)) / 24node}, that is, the above expression. The purpose of step S41 is to consider future resource usage. Here, an updated Least Allocated algorithm is proposed. This new algorithm will use predicted data, node resource idle value and Pod resource usage value to calculate the node score.

[0073] S42: Score the screening node by using the updated Least Allocated algorithm to obtain a node score.

[0074] In step S42, the updated Least Allocated algorithm is used to score the nodes selected in the pre-selection phase. The scoring is based on the future resource availability of the nodes and other possible factors to reserve sufficient node resources for the resource requirements of the Pods to be deployed.

[0075] S43: According to the node scores, select the node with the highest score among the screened nodes to obtain the optimal node.

[0076] In step S43, the node with the highest score is selected as the optimal node to deploy the new Pod. The optimal node is selected based on the prediction of future resource usage, so it can better balance the resource usage of the cluster and avoid resource overload or waste.

[0077] S5: deploying the pod to be run in the creation request to the optimal node to complete the scheduling.

[0078] The overall process of steps S1 to S5 is as follows: the client initiates a request to create a pod; the pod enters the pre-selection Predicates stage, in which all nodes are first traversed to filter out nodes that do not meet the conditions; the pod enters the Priorities stage, which is to screen the nodes again. If multiple nodes meet the conditions, the system will sort the nodes according to the size of their priorities (priorites).

[0079] Use the admission controller to deploy the Kalman filter and adjust the LeastAllocated algorithm in the Priorities stage. Obtain all historical data from prometheus to obtain the 24pod resource usage value and 24node resource idle value after 24 hours. Replace the LeastAllocated score in the Priorities scoring stage with the scoring method written based on the predicted value. Finally, select the node with the highest score based on the final score for pod deployment.

[0080] like Figure 2 As shown, the present invention also provides a K8s scheduling device based on a Kalman filter, comprising:

[0081] Receiving module 100: used to receive a creation request;

[0082] Screening module 200: used to screen deployable nodes and obtain screened nodes;

[0083] Prediction module 300: used to predict resource utilization based on historical data using a deployed Kalman filter to obtain prediction data;

[0084] Selection module 400: used to select screening nodes based on the prediction data to obtain the optimal node;

[0085] Deployment module 500: deploys the pod to be run in the creation request to the optimal node to complete scheduling.

[0086] The present invention also provides a K8s scheduling device based on a Kalman filter, comprising:

[0087] A memory and at least one processor, wherein instructions are stored in the memory;

[0088] At least one of the processors calls the instructions in the memory so that the Kalman filter-based k8s scheduling device executes the Kalman filter-based k8s scheduling method as described in any one of the above.

[0089] The present invention also provides a computer-readable storage medium, characterized in that instructions are stored on the computer-readable storage medium, and when the instructions are executed by a processor, the K8S scheduling method based on the Kalman filter as described in any of the above items is implemented.

[0090] Furthermore, a K8s scheduling device based on a Kalman filter provided by the present invention may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU), for example, one or more processors and memories, one or more storage media for storing applications or data, such as one or more massive storage devices, wherein the memories and storage media may be short-term storage or persistent storage, and the program stored in the storage medium may include one or more modules, each module may include a series of instruction operations in the K8s scheduling device based on the Kalman filter, and further, the processor may be configured to communicate with the storage medium to execute a series of instruction operations in the storage medium on the K8s scheduling device based on the Kalman filter.

[0091] It may also include one or more power supplies, one or more wired or wireless network interfaces, one or more input and output interfaces, and one or more operating systems, such as WindowsServe, MacOSX, Unix, Linux, FreeBSD, etc. Those skilled in the art will appreciate that the K8s scheduling device structure based on the Kalman filter provided by the present invention does not constitute a limitation on the device.

[0092] The present invention provides a K8s scheduling method, device, equipment and storage medium based on Kalman filter, which uses an admission controller to dynamically adjust the scoring weight of the kube-scheduler scheduling plug-in, predicts the usage value of pod and node resources through the Kalman filter algorithm, and replaces the native static resource scoring with dynamic resource scoring, so that the scoring has more reference value, resource scheduling is more stable, and resources are more fully used. In addition, the scheduling adjustment method of the present invention has strong scalability and can be used to expand more application scenarios, including CPU priority, memory priority, GPU priority, etc.

[0093] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the embodiments of the present invention, rather than to limit them. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions recorded in the above embodiments, or replace some of the technical features therein by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention. Any changes or replacements that can be easily thought of by those skilled in the art within the technical scope disclosed in the present invention should be covered within the protection scope of the present invention.

Claims

1. A k8s scheduling method based on Kalman filter, characterized in that: include: S1: Receive a creation request; S2: Screen the deployable nodes to obtain the screened nodes; S3: deploying a Kalman filter, and using the Kalman filter to predict resource utilization based on historical data to obtain prediction data; S4: Selecting a screening node based on the prediction data to obtain an optimal node; S5: deploying the pod to be run in the creation request to the optimal node to complete the scheduling.

2. According to a Kalman filter-based k8s scheduling method according to claim 1, it is characterized in that: The screening of the deployable nodes in step S2 is a multi-stage screening, and the specific screening stages include a pre-screening stage and a priority screening stage.

3. According to a Kalman filter-based k8s scheduling method according to claim 1, it is characterized in that: The Kalman filter in step S3 is deployed via an admission controller.

4. According to a Kalman filter-based k8s scheduling method according to claim 1, it is characterized in that: The historical data in step S3 is obtained by prometheus.

5. According to a Kalman filter-based k8s scheduling method according to claim 1, it is characterized in that: The predicted data in step S3 includes a pod resource usage value after a preset time and a node resource idle value after a preset time.

6. According to a Kalman filter-based k8s scheduling method according to claim 1, it is characterized in that: Step S4 further comprises: S41: According to the prediction data, the basic Least Allocated algorithm in the priority screening stage is replaced to obtain an updated Least Allocated algorithm; S42: Score the screening node by using the updated Least Allocated algorithm to obtain a node score; S43: According to the node scores, select the node with the highest score among the screened nodes to obtain the optimal node.

7. According to claim 6, a K8s scheduling method based on Kalman filter is characterized in that: The expression for updating the Least Allocated algorithm in step S41 is: Among them, S is the calculated node score, N T is the node resource idle value, P T is the pod resource usage value, and M is the maximum node score defined in the scheduling framework.

8. A k8s scheduling device based on Kalman filter, characterized in that: include: Receiving module: used to receive creation requests; Screening module: used to screen deployable nodes and obtain screened nodes; Prediction module: used to predict resource utilization based on historical data using the deployed Kalman filter to obtain prediction data; Selection module: used to select the screening node based on the prediction data to obtain the optimal node; Deployment module: deploys the pod to be run in the creation request to the optimal node to complete the scheduling.

9. A K8s scheduling device based on Kalman filter, characterized in that: include: A memory and at least one processor, wherein instructions are stored in the memory; At least one of the processors calls the instructions in the memory so that the Kalman filter-based k8s scheduling device executes the Kalman filter-based k8s scheduling method as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed by the processor, the K8s scheduling method based on the Kalman filter as described in any one of claims 1-7 is implemented.

Citation Information

Cited By

  • Kubernetes cluster one-key deployment and life cycle management method and system

    CN120029637A