Kubernetes scheduling method and device

By sending eBPF resource collection programs and multi-objective genetic algorithms for scheduling in Kubernetes clusters, the problems of low scheduling efficiency and inability to customize requirements in the existing technology are solved, and efficient and accurate resource scheduling is achieved.

CN119847707AInactive Publication Date: 2025-04-18SONGSHAN LAB
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411988689.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-04-18
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing Kubernetes scheduling methods have problems such as low scheduling efficiency, poor scheduling results, and inability to schedule according to custom requirements.

Method used

By sending an eBPF resource collection program to each node in the Kubernetes cluster, the real-time resource occupancy of each pod is collected, and scheduled based on a multi-objective genetic algorithm to realize customized resource collection strategies and scheduling strategies.

Benefits of technology

It improves the efficiency of resource data collection and Kubernetes scheduling efficiency, enhances the accuracy of data collection, makes the final scheduling result better, and can monitor and schedule specific resource occupancy according to user needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119847707A_ABST
    Figure CN119847707A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of cloud computing, and provides a Kubernetes scheduling method and device.The method comprises the steps that an eBPF resource collection program is sent to each node in a Kubernetes cluster, the eBPF resource collection program is used for collecting the current real-time resource occupation amount of each Pod in each node of the Kubernetes cluster according to a collection strategy, and the collection strategy comprises data collection precision and target resources to be collected; obtaining the current real-time resource occupation amount of each Pod in each node collected by an eBPF resource collection program; and scheduling the Pod based on the resource demand quantity of each Pod and the current real-time resource occupation quantity of each Pod in each scheduling period. Because the eBPF resource collection program is adopted to collect the current real-time resource occupation amount of each Pod in the kernel mode based on the eBPF mechanism, switching between the kernel mode and the user mode is not needed, and the resource collection efficiency is improved, so that the Kubernetes scheduling efficiency is improved, the data collection precision and target resources can be customized, the data collection precision is improved, and scheduling can be carried out according to user requirements.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of cloud computing technology, and in particular to a Kubernetes scheduling method and device. Background Art

[0002] Kubernetes (K8s for short), as a container orchestration system, is a core component in the field of cloud computing and is used to automate the deployment, expansion, and management of containerized applications. Specifically, Kubernetes runs in a distributed system, which can be understood as having multiple hosts. Usually, a kubernetes consists of a master node (i.e., the main node) and multiple node nodes (i.e., slave nodes). Each master or node occupies a host exclusively. Kubernetes needs to schedule tasks between multiple nodes to achieve load balancing and resource optimization. In a Kubernetes cluster, each container is a process, and the user's application runs in the container. Multiple container instances constitute a Pod. Pod is the smallest resource scheduling unit in Kubernetes. A host can deploy at least one Pod. Kubernetes scheduling is to deploy the Pod to the appropriate host node so that the host node can meet the resources required by the Pod as much as possible.

[0003] During scheduling, it is necessary to collect the real-time resource usage of the Pod. Currently, this is collected through the kube-state-metrics component in the kubernetes cluster. This collection solution has large latency, low accuracy, and cannot customize monitoring requirements, resulting in low scheduling efficiency. The scheduling results cannot achieve better scheduling results (due to the low accuracy of the collected resource data), and scheduling cannot be performed according to customized requirements. Summary of the invention

[0004] The present invention provides a Kubernetes scheduling method and device, which are used to solve the technical problems in the prior art of low scheduling efficiency, poor scheduling results, and inability to perform scheduling according to customized requirements.

[0005] The present invention provides a Kubernetes scheduling method, comprising the following steps.

[0006] Send an eBPF resource collector to each node in the Kubernetes cluster. The eBPF resource collector is used to collect the current real-time resource occupancy of each Pod in each node of the Kubernetes cluster according to a collection strategy, wherein the collection strategy includes data collection accuracy and target resources to be collected, and the real-time resource occupancy is the real-time resource occupancy of the target resource.

[0007] Obtain the current real-time resource usage of each Pod in each node collected by the eBPF resource collector.

[0008] Pods are scheduled based on their resource requirements and their current real-time resource usage in each scheduling cycle.

[0009] According to a Kubernetes scheduling method provided by the present invention, obtaining the current real-time resource occupancy of each Pod in each node collected by the eBPF resource collection program includes: Get the current real-time resource occupancy of each Pod in each node returned by the user-state program segment of the eBPF resource collection program, wherein the current real-time resource occupancy of each Pod in each node is obtained by reading the eBPF Maps from the user-state program segment of the eBPF resource collection program by calling the bpftool or libbpf library, and the kernel-state program segment of the eBPF resource collection program is used to store the current real-time resource occupancy of each Pod in each monitored node in the eBPF Maps.

[0010] According to a Kubernetes scheduling method provided by the present invention, before sending the eBPF resource collection program to each node in the Kubernetes cluster, it also includes: configuring the collection strategy in the eBPF resource collection program.

[0011] According to a Kubernetes scheduling method provided by the present invention, the current real-time resource occupancy of any Pod in each scheduling cycle is: the average value of the real-time resource occupancy of each target resource of any Pod collected by the eBPF resource collection program in each scheduling cycle.

[0012] According to a Kubernetes scheduling method provided by the present invention, the Pod is scheduled based on the resource demand of each Pod and the current real-time resource occupancy of each Pod in each scheduling cycle, including: A multi-objective genetic algorithm is used to schedule Pods with the goal of minimizing the sum of the variances between the current real-time resource usage of all Pods and the resource requirements of the corresponding resources.

[0013] According to a Kubernetes scheduling method provided by the present invention, the collection strategy also includes: target resource weight; scheduling the Pod based on the resource demand of each Pod and the current real-time resource occupancy of each Pod in each scheduling cycle, including: A multi-objective genetic algorithm is used to schedule Pods with the goal of minimizing the sum of the variances between the current real-time resource usage of all Pods and the resource requirements of the corresponding resources weighted by the target resource weights.

[0014] The present invention also provides a Kubernetes scheduling device, comprising the following modules.

[0015] A collector loading module is used to send an eBPF resource collector to each node in a Kubernetes cluster. The eBPF resource collector is used to collect the current real-time resource occupancy of each Pod in each node of the Kubernetes cluster according to a collection strategy, wherein the collection strategy includes data collection accuracy and target resources to be collected, and the real-time resource occupancy is the real-time resource occupancy of the target resource.

[0016] The resource occupancy acquisition module is used to obtain the current real-time resource occupancy of each Pod in each node collected by the eBPF resource collection program.

[0017] The Pod scheduling module is used to schedule Pods based on the resource requirements of each Pod and the current real-time resource usage of each Pod in each scheduling cycle.

[0018] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, wherein when the processor executes the program, the Kubernetes scheduling method as described in any one of the above is implemented.

[0019] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the Kubernetes scheduling method as described in any one of the above is implemented.

[0020] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the Kubernetes scheduling method described in any one of the above is implemented.

[0021] The Kubernetes scheduling method and device provided by the present invention, by sending an eBPF resource collection program to each node in the Kubernetes cluster, the eBPF resource collection program is used to collect the current real-time resource occupancy of each Pod in each node of the Kubernetes cluster according to the collection strategy, wherein the collection strategy includes data collection accuracy and target resources to be collected, and the real-time resource occupancy is the real-time resource occupancy of the target resource; obtain the current real-time resource occupancy of each Pod in each node collected by the eBPF resource collection program; schedule the Pod based on the resource demand of each Pod and the current real-time resource occupancy of each Pod in each scheduling cycle. Since the eBPF resource collection program is used to directly collect the current real-time resource occupancy of each Pod in each node in the kernel state based on the eBPF mechanism, there is no need to switch between the kernel state and the user state, which improves the collection efficiency of resource data, thereby improving the Kubernetes scheduling efficiency; users can customize the collection strategy, that is, customize the data collection accuracy, which can improve the data collection accuracy, so that the final scheduling result is better, and can monitor the specific resource occupancy according to user needs, so as to schedule according to the specific resource occupancy to meet user needs. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0023] Figure 1 This is one of the flow charts of the Kubernetes scheduling method provided by the present invention.

[0024] Figure 2 It is a schematic diagram of a Kubernetes cluster structure in the Kubernetes scheduling method provided by the present invention.

[0025] Figure 3 This is the second flow chart of the Kubernetes scheduling method provided by the present invention.

[0026] Figure 4 It is a structural schematic diagram of the Kubernetes scheduling device provided by the present invention.

[0027] Figure 5 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0028] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0029] In the existing related technologies, in a Kubernetes cluster distributed across regions, services are decomposed into multiple sub-services. Take e-commerce business as an example: sub-services include: user, product, order, authentication, gateway and payment services, which are deployed in Pods on different nodes of the cluster. The server nodes where the Pods are located are connected to the network through switches. In order to ensure the stability, reliability and high-quality operation of the services, these Pods need to have sufficient resource guarantees and good operating status. When it is detected that the Pod's resources are insufficient or the status is abnormal, the Kubernetes scheduler will intervene and migrate these Pods to nodes with sufficient resources and good status to ensure the continuity and performance of the entire e-commerce business service.

[0030] When scheduling Pods in a kubernetes cluster, it is necessary to collect the current real-time resource usage of each Pod. Currently, this is collected through the kube-state-metrics component in the kubernetes cluster. The data collection granularity of the kube-state-metrics component is large, and scheduling cannot be performed according to custom requirements.

[0031] In view of the above problems existing in the existing related technologies, an embodiment of the present invention provides a Kubernetes scheduling method. Figure 1 is a flow chart of a Kubernetes scheduling method provided by an embodiment of the present invention. The method of this embodiment can be deployed on a single host or in a node of a Kubernetes cluster. Figure 1 As shown, the method includes the following steps S110 to S130.

[0032] Step S110: Send the eBPF resource collection program to each node in the Kubernetes cluster. The eBPF resource collection program is used to collect the current real-time resource usage of each Pod in each node of the Kubernetes cluster according to the collection strategy. Resources include: network resources, computing resources and storage resources. Network resources include: bandwidth, latency and packet loss rate, etc.; computing resources include: processor (CPU) and memory, etc.; storage resources include: EmptyDir, PersistentVolume (PV), PersistentVolumeClaim (PVC), etc.

[0033] In the method of this embodiment, the kubernetes scheduling architecture based on eBPF is as follows Figure 2 As shown in the figure, the eBPF resource collector is a user-defined program for collecting the current real-time resource usage of each Pod in each node of the Kubernetes cluster. The resource collection strategy is customized in the program. The Extended Berkeley Packet Filter (eBPF) mechanism is a powerful kernel programming framework that allows users to safely run custom programs in the Linux kernel. eBPF can be used to monitor and limit resource usage. In this step, the user-defined eBPF resource collector is sent to each node in the Kubernetes cluster. After receiving the eBPF resource collector, each node loads the eBPF resource collector, that is, binds the eBPF program to specific kernel events, such as system calls, scheduling events, and network events, to trigger program execution. When the system calls each Pod in the node, the eBPF resource collector will be executed in the kernel through the eBPF mechanism to collect the current real-time resource usage of the Pod.

[0034] Specifically, the eBPF resource collector calls perf_event (perf_event is a performance event subsystem in the Linux kernel) to monitor hardware events such as CPU cycles and instruction retirement to obtain CPU usage data; uses kprobe (Linux kernel probe) to monitor system calls related to memory allocation, such as brk, mmap, and mremap, to track memory allocation events; uses XDP (eXpress Data Path) or TC (Traffic Control) eBPF programs to capture and process data packets at the network layer to monitor network traffic. The resource data collected by the eBPF resource collector is stored in eBPFMaps.

[0035] Among them, the customized collection strategy includes data collection accuracy and target resources to be collected. The data collection accuracy can be MB or even KB to ensure data collection accuracy. The target resource can be at least one of the above-mentioned network service quality indicators, computing resources and storage resources. The real-time resource occupancy is the real-time resource occupancy of the target resource, that is, the current real-time resource occupancy of each Pod in each node of the Kubernetes cluster collected above is the real-time resource occupancy of each target resource specified in the collection strategy. The target resource can be set according to actual conditions. For example: a business system pays more attention to network performance, then the target resource can be set to the network transmission delay.

[0036] Step S120: Obtain the current real-time resource occupancy of each Pod in each node collected by the eBPF resource collection program. Specifically, the current real-time resource occupancy of each Pod can be obtained by obtaining data in eBPF Maps.

[0037] Step S130: Schedule the Pods based on the resource requirements of each Pod and the current real-time resource occupancy of each Pod in each scheduling cycle, so as to deploy the Pods to nodes with relatively sufficient resources and capable of meeting the resource requirements of each Pod as much as possible, so as to ensure that the business system can run stably, reliably and with high quality.

[0038] In the Kubernetes scheduling method of this embodiment, an eBPF resource collection program is used to directly collect the current real-time resource occupancy of each Pod in each node in the kernel state based on the eBPF mechanism, without the need to switch between the kernel state and the user state, thereby improving the collection efficiency of resource data and thus improving the Kubernetes scheduling efficiency; users can customize the collection strategy, that is, customize the data collection accuracy, which can improve the data collection accuracy and make the final scheduling result better, and can monitor the specific resource occupancy according to user needs, so as to schedule according to the specific resource occupancy to meet user needs.

[0039] In some embodiments, step S120 specifically includes: obtaining the current real-time resource occupancy of each Pod in each node returned by the user-state program segment of the eBPF resource collection program, wherein the current real-time resource occupancy of each Pod in each node is obtained by the user-state program segment of the eBPF resource collection program calling bpftool (bpftool is a kernel tool for checking eBPF programs and mappings) or the libbpf library reading from eBPF Maps, and the kernel-state program segment of the eBPF resource collection program is used to store the current real-time resource occupancy of each Pod in each monitored node in the eBPF Maps.

[0040] In this embodiment, the user-mode program segment of the eBPF resource collection program directly reads the current real-time resource usage of each Pod in each node from the eBPF Maps, without the need to switch between the user mode and the kernel mode, thus saving data acquisition time and improving resource data collection efficiency.

[0041] In some embodiments, before step S110, it also includes: configuring the collection strategy in the eBPF resource collection program. Specifically, the collection strategy received from the user may be at least one of data collection accuracy and target resources to be collected. After the collection strategy is configured, the eBPF resource collection program is compiled to generate an executable program, and in step S110, the executable program is sent to each node in the Kubernetes cluster.

[0042] In some embodiments, the current real-time resource occupancy of any Pod in each scheduling cycle is: the average value of the real-time resource occupancy of each target resource of any Pod collected by the eBPF resource collection program in each scheduling cycle, that is, taking the average value for each target resource, for example: for CPU resources, in one scheduling cycle, taking the average value of the CPU resources (such as the number of cores) occupied by each Pod collected multiple times. In one scheduling cycle, taking the average value for the real-time resource occupancy of each target resource of any Pod can smooth the random fluctuation data in the real-time resource occupancy, making the collection result of the real-time resource occupancy more stable and reliable, reducing the impact of certain extreme values ​​on the overall scheduling result, and thus making the final scheduling result better.

[0043] In some embodiments, step S130 specifically includes: using a multi-objective genetic algorithm (NSGA-II) to schedule the Pods with the goal of minimizing the sum of the variances between the current real-time resource usage of all Pods and the resource requirements of the corresponding resources. The specific scheduling process of NSGA-II is as follows: Figure 3 As shown, the following steps S310 to S380 are included.

[0044] Step S310: Create a random initial population consisting of N individuals (eg, N is 50-100), each individual is used as a scheduling strategy, and the number of iterations K is initialized to 0. Each scheduling strategy is a scheduling method that deploys all Pods to each node separately.

[0045] Step S320: Assign K=K+1.

[0046] Step S330: For each individual, evaluate its fitness in the objective function space, specifically by calculating the variance between the current real-time resource usage of all Pods and the resource demand of the corresponding resources ETo achieve this. That is, using variance as fitness, the objective function is as follows: .

[0047] in, n Indicates the number of Pods. m Indicates the number of target resources. Indicates i Pod j The resource demand of each target resource, Indicates i Pod j The real-time resource usage of a target resource in a scheduling cycle can be specifically the number of first j The average resource amount of target resources, where j =1,2,…, m .

[0048] Step S340: Apply the fast non-dominated sorting algorithm to stratify the individuals in the population to form multiple Pareto fronts. During this sorting process, the non-dominated level of each individual is determined.

[0049] Step S350: In order to maintain the diversity of the Pareto frontier, for each individual at each Pareto level, calculate its crowding degree in the objective function space, and retain the P individuals with the largest crowding degree to maintain the diversity of the population, where P can be 10-20. The larger the crowding distance between individuals, the wider the interval between them, which helps to maintain the uniform distribution of the Pareto frontier. In this step, in the same Pareto level, the crowding degree of the current individual is the sum of the absolute values ​​of the differences between it and the two adjacent individuals on the objective function (i.e., variance).

[0050] Step S360: Randomly select two individuals from the population for binary competition, giving priority to individuals with higher non-dominated levels, until Q individuals are selected to form a new population, where Q is less than P.

[0051] Step S370: Generate new offspring individuals through crossover and mutation operations, combine parent individuals with offspring individuals, update the population, and delete some individuals to maintain the population size N unchanged, that is, retain N individuals with the smallest variance.

[0052] Step S380: Determine whether K is greater than a preset iteration number threshold, for example, the iteration number threshold is 5-10 times. If so, execute step S390; otherwise, jump to step S320.

[0053] Step S390: Select the optimal solution in the current population as the optimized scheduling result, that is, the scheduling strategy corresponding to the minimum variance is selected as the optimal solution.

[0054] In this embodiment, since Pod scheduling is performed based on multiple target resources, a multi-objective genetic algorithm is adopted, so that the resource demand of each Pod in the Kubernetes cluster is basically met after scheduling, thereby ensuring that the overall performance of the Kubernetes cluster is stable and reliable.

[0055] In some embodiments, the collection strategy also includes: target resource weight; scheduling the Pod based on the resource demand of each Pod and the current real-time resource occupancy of each Pod in each scheduling cycle, including: using a multi-objective genetic algorithm to schedule the Pod with the goal of minimizing the sum of the variances of the current real-time resource occupancy of all Pods and the resource demand of the corresponding resources weighted by the target resource weight. The objective function is as follows: .

[0056] in, Z j Indicates j The weight of the target resource, where j =1,2,…, m , Z 1+ Z 2+…+ Z j +…+ Z m =1.

[0057] For example: n Pods, each Pod needs to be scheduled according to two target resources: network bandwidth and CPU usage (such as the number of cores). The required network bandwidth , the current real-time network bandwidth is , the required CPU usage , current real-time CPU usage Among them, this n If each Pod is more sensitive to network bandwidth, you can set the weight of network bandwidth. Z 1 is greater than the weight of CPU usage Z 2; the obtained variance is E .

[0058] .

[0059] In this embodiment, by configuring the target resource weights in the collection strategy, the weight values ​​of different target resources can be set according to the requirements of different business application scenarios. Therefore, when scheduling, the resource requirements of target resources with larger weights are given priority, so that the final scheduling result meets the requirements of the business application scenario.

[0060] The Kubernetes scheduling device provided by the present invention is described below. The Kubernetes scheduling device described below and the Kubernetes scheduling method described above can be referred to each other.

[0061] The Kubernetes scheduling device of the embodiment of the present invention is as follows: Figure 4 As shown, it includes the following modules.

[0062] The collector loading module 410 is used to send the eBPF resource collector to each node in the Kubernetes cluster, and the eBPF resource collector is used to collect the current real-time resource occupancy of each Pod in each node of the Kubernetes cluster according to the collection strategy, wherein the collection strategy includes data collection accuracy and target resources to be collected, and the real-time resource occupancy is the real-time resource occupancy of the target resource.

[0063] The resource occupancy acquisition module 420 is used to obtain the current real-time resource occupancy of each Pod in each node collected by the eBPF resource collection program.

[0064] The Pod scheduling module 430 is used to schedule the Pods based on the resource demand of each Pod and the current real-time resource occupancy of each Pod in each scheduling cycle.

[0065] In the Kubernetes scheduling device of this embodiment, an eBPF resource collection program is used to directly collect the current real-time resource occupancy of each Pod in each node in the kernel state based on the eBPF mechanism, without the need to switch between the kernel state and the user state, thereby improving the collection efficiency of resource data and thus improving the Kubernetes scheduling efficiency; users can customize the collection strategy, that is, customize the data collection accuracy, which can improve the data collection accuracy and make the final scheduling result better, and can monitor the specific resource occupancy according to user needs, so as to schedule according to the specific resource occupancy to meet user needs.

[0066] In some embodiments, the resource occupancy acquisition module 420 is specifically used to obtain the current real-time resource occupancy of each Pod in each node returned by the user-state program segment of the eBPF resource collection program, wherein the current real-time resource occupancy of each Pod in each node is obtained by the user-state program segment of the eBPF resource collection program calling the bpftool or libbpf library to read from the eBPFMaps, and the kernel-state program segment of the eBPF resource collection program is used to store the current real-time resource occupancy of each Pod in each monitored node in the eBPF Maps.

[0067] In some embodiments, the Kubernetes scheduling device also includes: a collection strategy configuration module, which is used to configure the collection strategy in the eBPF resource collection program before sending the eBPF resource collection program to each node in the Kubernetes cluster.

[0068] In some embodiments, the current real-time resource occupancy of any Pod in each scheduling cycle is: the average value of the real-time resource occupancy of each target resource of any Pod collected by the eBPF resource collection program in each scheduling cycle.

[0069] In some embodiments, the Pod scheduling module 430 is specifically used to schedule the Pods by adopting a multi-objective genetic algorithm with the goal of minimizing the sum of the variances between the current real-time resource occupancy of all Pods and the resource demand of the corresponding resources.

[0070] In some embodiments, the collection strategy also includes: target resource weight; the Pod scheduling module 430 is specifically used to adopt a multi-objective genetic algorithm to schedule the Pod with the goal of minimizing the sum of the variances of the current real-time resource occupancy of all Pods and the resource demand of the corresponding resources weighted by the target resource weight.

[0071] Figure 5 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 5 As shown, the electronic device may include: a processor 510, a communications interface 520, a memory 530, and a communication bus 540, wherein the processor 510, the communications interface 520, and the memory 530 communicate with each other through the communication bus 540. The processor 510 may call the logic instructions in the memory 530 to execute the Kubernetes scheduling method, which includes the following steps.

[0072] Send an eBPF resource collector to each node in the Kubernetes cluster. The eBPF resource collector is used to collect the current real-time resource occupancy of each Pod in each node of the Kubernetes cluster according to a collection strategy, wherein the collection strategy includes data collection accuracy and target resources to be collected, and the real-time resource occupancy is the real-time resource occupancy of the target resource.

[0073] Obtain the current real-time resource usage of each Pod in each node collected by the eBPF resource collector.

[0074] Pods are scheduled based on their resource requirements and their current real-time resource usage in each scheduling cycle.

[0075] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0076] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the Kubernetes scheduling method provided by the above methods, and the method includes the following steps.

[0077] Send an eBPF resource collector to each node in the Kubernetes cluster. The eBPF resource collector is used to collect the current real-time resource occupancy of each Pod in each node of the Kubernetes cluster according to a collection strategy, wherein the collection strategy includes data collection accuracy and target resources to be collected, and the real-time resource occupancy is the real-time resource occupancy of the target resource.

[0078] Obtain the current real-time resource usage of each Pod in each node collected by the eBPF resource collector.

[0079] Pods are scheduled based on their resource requirements and their current real-time resource usage in each scheduling cycle.

[0080] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the Kubernetes scheduling method provided by the above methods is implemented, and the method includes the following steps.

[0081] Send an eBPF resource collector to each node in the Kubernetes cluster. The eBPF resource collector is used to collect the current real-time resource occupancy of each Pod in each node of the Kubernetes cluster according to a collection strategy, wherein the collection strategy includes data collection accuracy and target resources to be collected, and the real-time resource occupancy is the real-time resource occupancy of the target resource.

[0082] Obtain the current real-time resource usage of each Pod in each node collected by the eBPF resource collector.

[0083] Pods are scheduled based on their resource requirements and their current real-time resource usage in each scheduling cycle.

[0084] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0085] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0086] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A Kubernetes scheduling method, characterized in that: include: Send an eBPF resource collector to each node in the Kubernetes cluster, where the eBPF resource collector is used to collect the current real-time resource occupancy of each Pod in each node of the Kubernetes cluster according to a collection strategy, where the collection strategy includes data collection accuracy and target resources to be collected, and the real-time resource occupancy is the real-time resource occupancy of the target resource; Obtain the current real-time resource usage of each Pod in each node collected by the eBPF resource collection program; Pods are scheduled based on their resource requirements and their current real-time resource usage in each scheduling cycle.

2. The Kubernetes scheduling method according to claim 1, characterized in that: Obtain the current real-time resource usage of each Pod in each node collected by the eBPF resource collection program, including: Get the current real-time resource occupancy of each Pod in each node returned by the user-state program segment of the eBPF resource collection program, wherein the current real-time resource occupancy of each Pod in each node is obtained by reading the eBPF Maps from the user-state program segment of the eBPF resource collection program by calling the bpftool or libbpf library, and the kernel-state program segment of the eBPF resource collection program is used to store the current real-time resource occupancy of each Pod in each monitored node in the eBPF Maps.

3. The Kubernetes scheduling method according to claim 1, characterized in that: Before sending the eBPF resource collection program to each node in the Kubernetes cluster, it also includes: configuring the collection strategy in the eBPF resource collection program.

4. The Kubernetes scheduling method according to claim 1, characterized in that: The current real-time resource occupancy of any Pod in each scheduling cycle is: the average value of the real-time resource occupancy of each target resource of any Pod collected by the eBPF resource collector in each scheduling cycle.

5. The Kubernetes scheduling method according to any one of claims 1 to 4, characterized in that: Pods are scheduled based on their resource requirements and their current real-time resource usage in each scheduling cycle, including: A multi-objective genetic algorithm is used to schedule Pods with the goal of minimizing the sum of the variances between the current real-time resource usage of all Pods and the resource requirements of the corresponding resources.

6. The Kubernetes scheduling method according to claim 5, characterized in that: The collection strategy also includes: target resource weight; scheduling the Pod based on the resource demand of each Pod and the current real-time resource occupancy of each Pod in each scheduling cycle, including: A multi-objective genetic algorithm is used to schedule Pods with the goal of minimizing the sum of the variances between the current real-time resource usage of all Pods and the resource requirements of the corresponding resources weighted by the target resource weights.

7. A Kubernetes scheduling device, characterized in that: include: A collector loading module, used to send an eBPF resource collector to each node in the Kubernetes cluster, wherein the eBPF resource collector is used to collect the current real-time resource occupancy of each Pod in each node of the Kubernetes cluster according to a collection strategy, wherein the collection strategy includes data collection accuracy and target resources to be collected, and the real-time resource occupancy is the real-time resource occupancy of the target resource; A resource occupancy acquisition module is used to obtain the current real-time resource occupancy of each Pod in each node collected by the eBPF resource collection program; The Pod scheduling module is used to schedule Pods based on the resource requirements of each Pod and the current real-time resource usage of each Pod in each scheduling cycle.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the Kubernetes scheduling method according to any one of claims 1 to 6 is implemented.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the Kubernetes scheduling method according to any one of claims 1 to 6 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the Kubernetes scheduling method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Dynamic load balancing resource scheduling method based on Kubernetes

    CN110780998A

  • Kubernetes cluster adaptive traffic scheduling device based on eBPF

    CN118474104A

  • KR20240062632A