Intelligent resource control system and method for Kubernetes

By introducing an intelligent resource control system into the Kubernetes cluster, the inefficiency and interruption problems caused by improper use of Pod resources are solved, and dynamically adjusting resources without restarting the Pod to ensure optimization of resource utilization.

CN114138421BActive Publication Date: 2025-02-07IND BANK CO +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202111495503.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-08
Publication Date
2025-02-07
Estimated Expiration
2041-12-08

AI Technical Summary

Technical Problem

In Kubernetes clusters, it is difficult for the existing technology to effectively manage the resource usage of Pods, resulting in too low resource usage or OOM (out of boundary memory). Regular modification of limits or request values ​​will cause Pod to restart, causing application interruptions and other problems.

Method used

Provide an intelligent resource control system, including resource pre-checking services, resource computing services, resource control services and resource dynamic update services. The system uses resource pre-checking before Pod scheduling, calculates appropriate values ​​using trend CRD settlement results and original Request resource settings; uses resource usage and autopilot workload scaling algorithm to predict resource trends; decides to adjust Pod resources through dispersion or dynamic updates; and Complete CGroup modification through Dbus communication and update Pod resources dynamically.

Benefits of technology

It realizes dynamic modification of CPU and memory resources without restarting the pod to ensure that the container runs at the expected resource utilization rate without affecting the current business.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114138421B_ABST
    Figure CN114138421B_ABST
Patent Text Reader

Abstract

The present invention provides a Kubernetes intelligent resource control system and method, which relates to the field of cloud computing technology, including: resource pre-check service: before application deployment, pre-check resources field, reject illegal large resource requests, and set different initial resource values ​​according to application types; resource calculation service: according to the collected Container resource usage, calculate the resources required for the next time window Container operation; resource control service: according to the calculation result of the calculation service, start the update service to complete the resource setting of the Container; resource update service: acts on the working node, it is started by the resource control service, informs the name of the Container that needs to be updated, and completes the resource setting. The present invention can dynamically modify the resources of the Container in the Pod without restarting the Pod, ensuring that the container can run according to the expected resource usage without affecting the current business.
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 intelligent resource control system and method. Background Art

[0002] With the development of modern Internet technology, the development and application frequency of cloud platform technology is increasing. The application of container technology on cloud platforms has gradually become mainstream. In cloud platforms, Kubernetes is an open source Docker container cluster management system across host clusters. It is used to manage containerized applications on multiple hosts in cloud platforms. It provides a complete set of functions such as resource scheduling, deployment and operation, service discovery, expansion and reduction for containerized applications. The goal of Kubernetes is to make the deployment of containerized applications simple and efficient. It provides a mechanism for application deployment, planning, updating, and maintenance, and is widely used in the industry.

[0003] The invention patent with the publication number CN112751913A discloses a network communication method and system across Kubernetes clusters, which realizes direct connection and interconnection between multiple clusters by opening up VXLAN links and IPsec links, so that multiple Kubernetes clusters can truly form an organic, interconnected, and more isolated whole. The method includes: the submariner-gateway component of the first node of any Kubernetes cluster selects an active IPsec endpoint; the first node includes a node with a gateway label; the active IPsec endpoint of any Kubernetes cluster is used to establish a connection with the active IPsec endpoint of other Kubernetes clusters; the Submariner-route-agent component of the active IPsec endpoint creates a VXLAN VTEP network interface; the Submariner-route-agent component of the second node of any Kubernetes cluster obtains information about the active IPsec endpoint; the second node includes a container set Pod and / or container; the Submariner-route-agent component of the second node of any Kubernetes cluster connects to the VXLAN VTEP network interface; the second node communicates with any node of other Kubernetes clusters through VXLAN links and IPsec links.

[0004] In a kubernetes cluster, resource usage of Pods is controlled by setting resource limits and requests. However, during application operation, the preset values ​​may be too large or too small, resulting in low resource usage or OOM. Conventional modification of limits or request values ​​causes Pod restarts, which can lead to application interruptions and other problems. Summary of the invention

[0005] In view of the defects in the prior art, the present invention provides an intelligent resource control system and method for Kubernetes.

[0006] According to a Kubernetes intelligent resource control system and method provided by the present invention, the scheme is as follows:

[0007] In a first aspect, a Kubernetes intelligent resource control system is provided, the system comprising:

[0008] Resource pre-check service: before the Pod is scheduled, it calculates an appropriate value based on the corresponding trend CRD settlement result and the original request resource setting, and sets it to the Container in the Pod to complete the Pod's resource setting;

[0009] Resource calculation service: Use the collected resource usage in the container time window and the autopilot workload scaling algorithm to complete the resource trend calculation of the next time window of the container;

[0010] Resource Control Service: The resource control service is the key decision maker for adjusting the container resources in the Pod by dispersing or dynamically updating;

[0011] Resource dynamic update service: a key service that implements dynamic update of Container resources in Pod.

[0012] Preferably, the resource pre-check service includes:

[0013] Mutating Webhook unit: responsible for registering with Kubernetes to observe the creation, update, and deletion of MutatingAdmission configurations of Pods;

[0014] Patch unit: responsible for providing CRD and Pod objects, and completing resource settings for Containers in Pods through Patch;

[0015] Recommendation unit: Calculates an appropriate resource request and limit value based on the configuration in CRD and LimitRange.

[0016] Preferably, the resource computing service includes:

[0017] Collection unit: collects resources consumed by Container in Pod through Prometheus;

[0018] Algorithm unit: calculates the histogram of the resources of the Container in the Pod, which is used to predict the resource consumption of the Container in the Pod in the next time unit;

[0019] Update unit: Updates the configuration in the CRD using the data provided by the algorithm unit.

[0020] Preferably, the resource control service includes:

[0021] Storage unit: responsible for the collection of Pods and CRDs, filtering of abnormal Pods, and structured storage;

[0022] Eviction unit: responsible for handling the evicted Pod;

[0023] Dynamic update unit: responsible for processing dynamically updated Pods;

[0024] Master control unit: responsible for deciding how to update the Pod.

[0025] Preferably, the resource dynamic update service includes:

[0026] DBus unit: responsible for providing commands and interacting with DBus;

[0027] File unit: responsible for providing an interface for interacting with the cgroup file system;

[0028] Search unit: responsible for finding the SystemUnit configuration of the Container of the Pod to be processed;

[0029] Management unit: Based on the acquired resource data, the unit configuration is obtained by searching the unit and passed to the DBus unit to complete the modification of the cgroup.

[0030] On the other hand, a Kubernetes intelligent resource control method is also provided, comprising the following steps:

[0031] Step 1: Use the MutatingWebhook hook to modify the Resources field of a Pod when it is created or updated. The required value comes from the CRD resource.

[0032] Step 2: The collected data comes from Prometheus or Metrics system, and the histogram is obtained according to the algorithm, and the data of the next time window is predicted;

[0033] Step 3: The data of the next time window predicted by the algorithm is propagated through CRD;

[0034] Step 4: Use Dbus communication to modify the CGroup of the Container to which the Pod belongs.

[0035] Compared with the prior art, the present invention has the following beneficial effects:

[0036] The present invention can dynamically modify the CPU and memory resources without restarting the Pod, ensuring that the container can run according to the expected resource utilization rate without affecting the current business. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:

[0038] Figure 1 This is the overall architecture diagram of the present invention;

[0039] Figure 2 Submit CRD process for resource computing services;

[0040] Figure 3 Control the update process for resource control services;

[0041] Figure 4 Dynamically update the process for Pod;

[0042] Figure 5 Pre-check process for resources. DETAILED DESCRIPTION

[0043] The present invention is described in detail below in conjunction with specific embodiments. The following embodiments will help those skilled in the art to further understand the present invention, but are not intended to limit the present invention in any form. It should be noted that, for those of ordinary skill in the art, several changes and improvements can also be made without departing from the concept of the present invention. These all belong to the protection scope of the present invention.

[0044] The embodiment of the present invention provides a Kubernetes intelligent resource control system, referring to Figure 1 and Figure 2 As shown, the system includes:

[0045] Resource pre-check service: before the Pod is scheduled, it calculates an appropriate value based on the corresponding trend CRD settlement result and the original request resource setting, and sets it to the Container in the Pod to complete the Pod's resource setting;

[0046] Resource calculation service: Use the collected resource usage rate in the container time window and the "autopilot; workload scaling" algorithm to complete the resource trend calculation of the next time window of the container;

[0047] Reference Figure 3 and Figure 4 As shown, Resource Control Service: The resource control service is the key decision maker for adjusting the container resources in the Pod by dispersing or dynamically updating;

[0048] Resource dynamic update service: a key service that implements dynamic update of Container resources in Pod.

[0049] Reference Figure 5 As shown, specifically, the resource pre-check service includes:

[0050] Mutating Webhook unit: responsible for registering with Kubernetes to observe the creation, update, and deletion of MutatingAdmission configurations of Pods;

[0051] Patch unit: responsible for providing CRD and Pod objects, and completing resource settings for Containers in Pods through Patch;

[0052] Recommendation unit: Calculates an appropriate resource request and limit value based on the configuration in CRD and LimitRange.

[0053] Resource computing services include:

[0054] Collection unit: collects resources consumed by Container in Pod through Prometheus;

[0055] Algorithm unit: calculates the histogram of the resources of the Container in the Pod, which is used to predict the resource consumption of the Container in the Pod in the next time unit;

[0056] Update unit: Updates the configuration in the CRD using the data provided by the algorithm unit.

[0057] Resource control services include:

[0058] Storage unit: responsible for the collection of Pods and CRDs, filtering of abnormal Pods, and structured storage;

[0059] Eviction unit: responsible for handling the evicted Pod;

[0060] Dynamic update unit: responsible for processing dynamically updated Pods;

[0061] Master control unit: responsible for deciding how to update the Pod.

[0062] Resource dynamic update services include:

[0063] DBus unit: responsible for providing commands and interacting with DBus;

[0064] File unit: responsible for providing an interface for interacting with the cgroup file system;

[0065] Search unit: responsible for finding the SystemUnit configuration of the Container of the Pod to be processed;

[0066] Management unit: Based on the acquired resource data, the unit configuration is obtained by searching the unit and passed to the DBus unit to complete the modification of the cgroup.

[0067] The present invention also provides a Kubernetes intelligent resource control method, comprising the following steps:

[0068] Step 1: Use the MutatingWebhook hook to modify the Resources field of a Pod when it is created or updated. The required value comes from the CRD resource.

[0069] Step 2: The collected data comes from Prometheus or Metrics system, and the histogram is obtained according to the algorithm, and the data of the next time window is predicted;

[0070] Step 3: The data of the next time window predicted by the algorithm is propagated through CRD;

[0071] Step 4: Use Dbus communication to modify the CGroup of the Container to which the Pod belongs.

[0072] Next, the present invention will be described in more detail.

[0073] A Kubernetes intelligent resource control system, refer to Figure 1 As shown in the figure, the system specifically includes resource pre-check service, resource control service, resource update service, and resource calculation service. The services do not communicate directly with each other, but interact through CRD resources to achieve the purpose of dynamically scaling Pod resources.

[0074] Resource pre-check service: The resource pre-check service needs to solve the following problems: First, in kubernetes, a Pod is created. The pre-check service can hook the creation request before creation, and then submit the modified Pod to the system. Secondly, through the description information of the Pod, the pre-check service can quickly match its corresponding CRD information. CRD stores the resource data that should be set for the current round of Pod startup. In order to achieve the first purpose, the pre-check service registers MutatingWebhookConfiguration with kubernetes when it starts. In the configuration, the Create and Update operations of the hook resource Pod are declared. After the above operation, if there is a newly submitted Pod in the system, the hook process of the pre-check service is triggered. When the hook process is triggered, the pre-check service needs to quickly match the Pod information. The pre-check service sets a cache, and stores the following two-tuple {selector, CRD} in the cache. The cache is synchronized in real time to keep the data consistent with kubernetes. By matching the two-tuple, you can quickly find the CRD resource, get the CRD resource, read the resource preset value inside, and set the label of the Pod resource application. The above is the core process of the pre-check service. The core data is the Pod to be created and the CRD that records the resources required for this round of startup.

[0075] Resource Computing Service: The computing service is the producer of CRD resources. This service needs to calculate the trend of Pod's resource consumption and notify other services of the calculation results. First, the computing service obtains the real-time resource consumption of the Pod through the prometheus system, and then stores it in the scaling window algorithm. When the algorithm calculates that the Pod's resource consumption may need to be expanded, the computing service matches the created CRD through the binary, and updates the CRD by submitting an update request to the system. If the binary cannot match the CRD, then submit a request to create the CRD resource and store the calculated value.

[0076] Resource control service: The control service is used to determine whether the Pod is cold started or hot updated. First, the control service regularly traverses all CRD resources and obtains all running Pods at the same time. Through the {selector, Pod} tuple, the matching relationship is quickly resumed, and then the current consumed resources of the Pod are read. The recommended resources are obtained through CRD. Compare whether the recommended resources and the current consumed resources are within a protection range. If they are within the protection range, the Pod is not updated. If they are beyond the protection range, the update process is entered. The purpose of setting the protection range here, that is, the redundancy range, is to avoid frequent updates of the Pod. When entering the update process, the control service first matches the node where the Pod is located, and then calculates whether the node reserved resources can meet the Pod's expansion requirements. If the resources are satisfied, the resource dynamic update service is started, and the Pod and CRD information are passed to the resource dynamic update service; if the resources are not satisfied, it is determined whether the Pod is allowed to be expelled, and the reconstruction of the Pod is triggered by the expulsion operation, thereby triggering the resource pre-check service mentioned above. The above are the main functions of the resource control service. It triggers the dynamic update service or resource pre-check service based on the content of CRD and POD.

[0077] Resource dynamic update service: The resource dynamic update service is responsible for completing the modification of the Systemd unit configuration of the Pod, so as to achieve the purpose of modifying the resource limit of the Pod without stopping the service. First, after the resource dynamic update service is started, the resource control service passes in a CRD and the Pod information to be updated. Through the Pod's dockerID information, the corresponding systemdunit or cgroup location is retrieved. Then the resource presets in the CRD are read out, and the cgroup configuration found above is modified through dbus or the file system. After the modification is completed, the events are reported to the kubernetes api to complete the resource dynamic update process.

[0078] The embodiment of the present invention provides a Kubernetes intelligent resource control system and method, which can dynamically modify Pod resources without restarting the Pod, ensuring that the container can run according to the expected resource utilization rate without affecting the current business.

[0079] Those skilled in the art know that, in addition to realizing the system and its various devices, modules, and units provided by the present invention in a purely computer-readable program code, it is entirely possible to realize the same functions in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, the system and its various devices, modules, and units provided by the present invention can be considered as a hardware component, and the devices, modules, and units included therein for realizing various functions can also be regarded as structures within the hardware component; the devices, modules, and units for realizing various functions can also be regarded as both software modules for realizing the method and structures within the hardware component.

[0080] The above describes the specific embodiments of the present invention. It should be understood that the present invention is not limited to the above specific embodiments, and those skilled in the art can make various changes or modifications within the scope of the claims, which does not affect the essence of the present invention. In the absence of conflict, the embodiments of the present application and the features in the embodiments can be combined with each other arbitrarily.

Claims

1. A Kubernetes intelligent resource control system, characterized in that: include: Resource pre-check service: before the Pod is scheduled, it calculates an appropriate value based on the corresponding trend CRD settlement result and the original request resource setting, and sets it to the Container in the Pod to complete the Pod's resource setting; Resource calculation service: Use the collected resource usage in the container time window and the autopilot workload scaling algorithm to complete the resource trend calculation of the next time window of the container; Resource Control Service: The resource control service is the key decision maker for adjusting the container resources in the Pod by dispersing or dynamically updating; Resource dynamic update service: a key service that implements dynamic update of Container resources in Pod; The resource pre-check service includes: in kubernetes, a Pod is created, the pre-check service can hook the creation request before creation, and then submit the modified Pod to the system, and then through the description information of the Pod, the pre-check service can quickly match its corresponding CRD information, and the CRD stores the resource data that should be set for the current round of Pod startup; When the pre-check service is started, it registers MutatingWebhookConfiguration with kubernetes. In the configuration, the Create and Update operations of the hook resource Pod are declared. After the above operations, if there is a newly submitted Pod in the system, the hook process of the pre-check service is triggered; when the hook process is triggered, the pre-check service needs to quickly match the Pod information. The pre-check service sets up a cache and stores the following two-tuple {selector, CRD} in the cache. The cache is synchronized in real time to keep the data consistent with that in kubernetes; by matching the two-tuple, the CRD resource is quickly found, and the CRD resource is obtained. After reading the resource preset value in it, the label of the Pod resource application is set; The resource calculation service includes: realizing the trend calculation of the resource consumption of the Pod and notifying the calculation results to other services; first, the calculation service obtains the real-time resource consumption of the Pod through the prometheus system, and then stores it in the scaling window algorithm. When the algorithm calculates that the Pod consumption resources need to be expanded, the calculation service matches the created CRD through the binary, and submits an update request to the system to update the CRD; if the binary cannot match the CRD, then submit a request to create a CRD resource and store the calculated value; The resource control service includes: the control service is used to determine whether the Pod is cold started or hot updated; first, the control service regularly traverses all CRD resources and obtains all running Pods; quickly matches the relationship through the {selector, Pod} tuple, and then reads the current consumption resources of the Pod; Get recommended resources through CRD, compare the recommended resources and currently consumed resources to see if they are within a protection range. If they are within the protection range, do not update the Pod. If they are beyond the protection range, enter the update process. After entering the update process, the control service first matches the node where the Pod is located, and then calculates whether the node's reserved resources can meet the Pod's expansion requirements. If the resources meet the requirements, start the resource dynamic update service and pass the Pod and CRD information to the resource dynamic update service. If the resources do not meet the requirements, determine whether the Pod is allowed to be evicted, and trigger the reconstruction of the Pod through the eviction operation, thereby triggering the resource pre-check service mentioned above. The resource dynamic update service includes: the resource dynamic update service is responsible for completing the modification of the Systemd unit configuration of the Pod, and modifying the resource limit of the Pod without stopping the server; first, after the resource dynamic update service is started, the resource control service passes in a CRD and the Pod information to be updated; through the Pod's dockerID information, the corresponding systemd unit or cgroup location is retrieved, and then the resource preset in the CRD is read out, and the cgroup configuration found above is modified through dbus or the file system. After the modification is completed, the events are reported to the kubernetes api to complete the resource dynamic update process.

2. The intelligent resource control system of Kubernetes according to claim 1, characterized in that: The resource pre-check service includes: MutatingWebhook unit: responsible for registering with kubernetes to observe the creation, update, and deletion of MutatingAdmission configurations of Pods; Patch unit: responsible for providing CRD and Pod objects, and completing resource settings for Containers in Pods through Patch; Recommendation unit: Calculate a resource request value and limit value based on the configuration in CRD and LimitRange.

3. The intelligent resource control system of Kubernetes according to claim 1, characterized in that: The resource computing service includes: Collection unit: collects resources consumed by Container in Pod through Prometheus; Algorithm unit: calculates the histogram of the resources of the Container in the Pod, which is used to predict the resource consumption of the Container in the Pod in the next time unit; Update unit: Updates the configuration in the CRD using the data provided by the algorithm unit.

4. The intelligent resource control system of Kubernetes according to claim 1, characterized in that: The resource control service includes: Storage unit: responsible for the collection of Pods and CRDs, filtering of abnormal Pods, and structured storage; Eviction unit: responsible for handling the evicted Pod; Dynamic update unit: responsible for processing dynamically updated Pods; Master control unit: responsible for deciding how to update the Pod.

5. The intelligent resource control system of Kubernetes according to claim 1, characterized in that: The resource dynamic update service includes: DBus unit: responsible for providing commands and interacting with DBus; File unit: responsible for providing an interface for interacting with the cgroup file system; Search unit: responsible for finding the SystemUnit configuration of the Container of the Pod to be processed; Management unit: Based on the acquired resource data, the unit configuration is obtained by searching the unit and passed to the DBus unit to complete the modification of the cgroup.

6. A Kubernetes intelligent resource control method, based on the Kubernetes intelligent resource control system according to any one of claims 1 to 5, characterized in that: The following steps are involved: Step 1: Use the MutatingWebhook hook to modify the Resources field of a Pod when it is created or updated. The required value comes from the CRD resource. Step 2: The collected data comes from Prometheus or Metrics system, and the histogram is obtained according to the algorithm, and the data of the next time window is predicted; Step 3: The data of the next time window predicted by the algorithm is propagated through CRD; Step 4: Use Dbus communication to modify the CGroup of the Container to which the Pod belongs.

Citation Information

Patent Citations

  • Cross-Kubernetes cluster network communication method and system

    CN112751913A

  • A parallel deep learning scheduling training method and system based on a container

    CN109885389A

  • Kubernetes-based container resource dynamic adjustment method

    CN110287029A