Bandwidth limiting method and device, processing equipment and storage medium

By obtaining container-related information and bandwidth thresholds, adjusting container bandwidth in the K8s cluster, the problems of inflexible configuration and inefficient in the prior art are solved, and the flexibility and efficiency of container bandwidth adjustment are achieved.

CN119276784APending Publication Date: 2025-01-07SINA TECH (CHINA) CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411486881.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-23
Publication Date
2025-01-07

AI Technical Summary

Technical Problem

The bandwidth adjustment configuration in the existing containerized platform K8s cluster is inflexible and inefficient. It is impossible to dynamically adjust the bandwidth limitation of Pod containers, and it is impossible to differentiate configuration based on nodes, Namespace, etc.

Method used

By obtaining the information and bandwidth threshold information associated with the container to be adjusted, adjusting the inlet and exit rates of the container, using token bucket filters and queue rules for bandwidth limitation, supporting multi-level priority based on target nodes, Namespaces, Pod tags, etc. Configuration.

Benefits of technology

It realizes the flexibility and efficiency of container bandwidth adjustment, supports dynamic adjustment and multi-level priority configuration, and improves the flexibility and efficiency of bandwidth management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119276784A_ABST
    Figure CN119276784A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a bandwidth limiting method and device, processing equipment, a computer program product and a storage medium, and the method comprises the steps: obtaining first information which is information associated with a to-be-adjusted container in a K8s cluster; acquiring second information, wherein the second information is information which is configured for the first information and is associated with a bandwidth adjustment threshold value; the bandwidth threshold value is used for limiting the maximum value of the bandwidth when the container is used for transmitting data; and adjusting a bandwidth threshold value associated with the container to be adjusted based on the first information and the second information. According to the embodiment of the invention, the bandwidth threshold can adapt to the information associated with the to-be-adjusted container and the information which is configured for the first information and associated with the adjustment of the bandwidth threshold, the configuration is performed in a targeted manner, the configuration mode is more flexible, and the efficiency of adjusting the bandwidth threshold is higher.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to, but is not limited to, the field of cloud computing technology, and in particular to a method, apparatus, processing device, and storage medium for limiting bandwidth. Background Art

[0002] With the continuous development of cloud computing, more and more projects need to be migrated to containerized platforms. There are more and more container cluster management systems (K8s, Kubernetes) for containerized platforms. In related technologies, it is necessary to adjust the bandwidth of data transmitted by containers in real time, but there are problems such as inflexible configuration and low configuration efficiency. Summary of the invention

[0003] In view of this, the embodiments of the present disclosure disclose a method, apparatus, processing device, and storage medium for limiting bandwidth, so as to be more flexible and efficient at least when adjusting the bandwidth of container data transmission.

[0004] According to a first aspect of an embodiment of the present disclosure, a method for limiting bandwidth is provided, the method comprising:

[0005] Acquire first information, where the first information is information associated with a container to be adjusted in a K8s cluster;

[0006] Acquire second information, where the second information is information configured for the first information and is associated with adjusting a bandwidth threshold; the bandwidth threshold is used to limit a maximum bandwidth when transmitting data using a container;

[0007] Based on the first information and the second information, a bandwidth threshold associated with the to-be-adjusted container is adjusted.

[0008] In some embodiments, the first information includes at least one of the following information:

[0009] The target node name is used to indicate the node name of the K8s node where the Pod to which the container to be adjusted belongs is located;

[0010] The target node label is used to indicate the node label of the K8s node where the Pod to which the container to be adjusted belongs is located;

[0011] The target namespace Namespace name is used to indicate the name of the Namespace associated with the container to be adjusted;

[0012] The target Namespace label is used to indicate the label of the Namespace associated with the container to be adjusted;

[0013] Target Pod label, used to indicate the label of the Pod to which the container to be adjusted belongs;

[0014] Target Pod annotation, used to indicate the annotation of the Pod to which the container to be adjusted belongs.

[0015] In some embodiments, the second information includes level information, wherein the level information includes at least one of the following levels:

[0016] The first level is used to indicate the priority corresponding to adjusting the bandwidth threshold associated with the containers contained in all Pods in the K8s cluster;

[0017] The second level is configured for the target node label in the first information, and is used to indicate the priority corresponding to the bandwidth threshold associated with the container included in the Pod on the K8s node indicated by the target node label;

[0018] The third level is configured for the target node name in the first information, and is used to indicate the priority corresponding to the bandwidth threshold associated with the container included in the Pod on the K8s node indicated by the target node name;

[0019] A fourth level, the fourth level is configured for the target Namespace label in the first information, and is used to indicate a priority corresponding to adjusting a bandwidth threshold associated with a container corresponding to the Namespace indicated by the target Namespace label;

[0020] A fifth level, the fifth level is configured for the target Namespace name in the first information, and is used to indicate the priority corresponding to the bandwidth threshold associated with the container corresponding to the Namespace indicated by the target Namespace name;

[0021] The sixth level is configured for the target Pod label in the first information, and is used to indicate the priority corresponding to the bandwidth threshold associated with the container included in the Pod indicated by the target Pod label.

[0022] The seventh level is configured for the target Pod annotation in the first information, and is used to indicate the priority corresponding to the bandwidth threshold associated with the container included in the Pod indicated by the target Pod annotation;

[0023] Among them, the priorities of the above levels are sorted from low to high.

[0024] In some embodiments, the obtaining of the first information includes:

[0025] By calling a container bandwidth limit PBL program, a first container identification ID transmitted through a container network interface CNI is obtained; wherein the PBL program is used to implement a function of the container network interface CNI;

[0026] The container associated with the first container ID is used as the container to be adjusted, and first information associated with the container to be adjusted is acquired.

[0027] In some embodiments, taking the container associated with the first container ID as the container to be adjusted and acquiring first information associated with the container to be adjusted includes at least one of the following:

[0028] Based on the first Namespace and the first Pod name, query the corresponding Pod label and / or Pod annotation as the target Pod label and / or the target Pod annotation in the first information;

[0029] Based on the first Namespace, query the corresponding Namespace tag as the target Namespace tag in the first information;

[0030] The first Namespace and / or the first Pod name are obtained based on the first container ID by calling the container running interface CRI.

[0031] In some embodiments, the obtaining of the first information includes at least one of the following:

[0032] In response to the PBL being deployed to the first K8s node, obtaining the node name of the first K8s node based on the system environment variable as the target node name in the first information;

[0033] Based on the first node name transmitted by the application programming interface API, a node label corresponding to the first node name is queried as the target node label in the first information.

[0034] In some embodiments, the method further comprises:

[0035] By calling the PBL program, a first container network interface name IFName transmitted through the CNI is obtained, and based on the first IFName, a node network interface associated with the container to be adjusted is determined; wherein the PBL program is used to implement the function of the CNI;

[0036] Create a token bucket filter TBF;

[0037] Setting the value of the ingress rate ingressRate parameter in the configuration file to the first bandwidth threshold of the TBF; the configuration file is used to limit the ingress rate of the container, and the first bandwidth threshold is the bandwidth threshold adjusted based on the second information;

[0038] The TBF is added to the queue discipline Qdisc and the TBF is bound to the node network interface.

[0039] In some embodiments, the method further comprises:

[0040] By calling the PBL program, a first IFName transmitted through the CNI is acquired, and based on the first IFName, a node network interface associated with the container to be adjusted is determined; wherein the PBL program is used to implement the function of the CNI;

[0041] Obtain the maximum transmission unit (MTU) value of the network interface of the node;

[0042] Creating an intermediate function module IFB based on the MTU value and the container ID;

[0043] adding a filter on the node network interface to mirror traffic to the IFB;

[0044] Create TBF;

[0045] Setting the value of the egress rate parameter egressRate in the configuration file to the second bandwidth threshold of the TBF; the configuration file is used to limit the egress rate of the container, and the second bandwidth threshold is the bandwidth threshold adjusted based on the second information;

[0046] The TBF is added to the queue discipline Qdisc and the TBF is bound to the IFB.

[0047] According to a second aspect of an embodiment of the present disclosure, a bandwidth limiting device is provided, the device comprising:

[0048] An acquisition module is used to: acquire first information, where the first information is information associated with a container to be adjusted in a K8s cluster; acquire second information, where the second information is information associated with an adjustment bandwidth threshold configured for the first information; the bandwidth threshold is used to limit a maximum bandwidth when transmitting data using a container;

[0049] The adjustment module is configured to adjust the bandwidth threshold associated with the container to be adjusted based on the first information and the second information.

[0050] According to a third aspect of an embodiment of the present disclosure, a processing device is provided, the processing device comprising:

[0051] A memory for storing executable programs;

[0052] The processor is used to implement any method described in the embodiments of the present disclosure when executing the executable program stored in the memory.

[0053] According to a fourth aspect of an embodiment of the present disclosure, a computer program product is provided, including a computer program or instructions, which, when executed by a processor, implement the steps of the method described in the present disclosure.

[0054] According to a fifth aspect of the embodiments of the present disclosure, a computer storage medium is provided, wherein the computer storage medium stores an executable program, and when the executable program is executed by a processor, the method described in any one of the embodiments of the present disclosure is implemented.

[0055] In the disclosed embodiment, first information is obtained, where the first information is information associated with the container to be adjusted in the K8s cluster; second information is obtained, where the second information is information associated with adjusting the bandwidth threshold configured for the first information; the bandwidth threshold is used to limit the maximum value of the bandwidth when using the container to transmit data; based on the first information and the second information, the bandwidth threshold associated with the container to be adjusted is adjusted. Since the first information is information associated with the container to be adjusted in the K8s cluster, and the second information is information associated with adjusting the bandwidth threshold configured for the first information, thus, adjusting the bandwidth threshold associated with the container to be adjusted based on the first information and the second information is essentially to make the bandwidth threshold adapt to the information associated with the container to be adjusted and the information associated with adjusting the bandwidth threshold configured for the first information, and to perform targeted configuration, the configuration method will be more flexible, and the efficiency of adjusting the bandwidth threshold will be higher. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] Figure 1 The figure is a schematic diagram of Kubernetes according to an exemplary embodiment.

[0057] Figure 2 The figure is a flow chart of a method for limiting bandwidth according to an exemplary embodiment.

[0058] Figure 3 The figure is a flow chart of a method for limiting bandwidth according to an exemplary embodiment.

[0059] Figure 4 The figure is a schematic diagram of a device for limiting bandwidth according to an exemplary embodiment. DETAILED DESCRIPTION

[0060] In order to make the purpose, technical solutions and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present invention. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present invention.

[0061] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0062] In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present invention described herein can be implemented in an order other than that illustrated or described herein.

[0063] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which the present invention belongs. The terms used herein are only for the purpose of describing the embodiments of the present invention and are not intended to limit the present invention.

[0064] In order to better understand the embodiments of the present disclosure, the following describes the scenarios in the related art through exemplary embodiments:

[0065] The K8s system is a container-based cluster management platform, including a master node and multiple computing nodes connected to the master node (master). The master node is used to manage and control multiple computing nodes; the computing nodes are deployed on virtual machines, and each computing node includes multiple container groups (pods). Pods are the basic operating units of the K8s system. Each pod encapsulates one or more containers for carrying applications, and containers belonging to the same pod share network resources.

[0066] In some embodiments, network speed limiting technologies include: Kubernetes application programming interface (API), DaemonSet deployment, container network interface (CNI), container runtime interface (CRI), Golang program and Linux memory network speed limiting technology, etc. By using and combining these technologies and implementing container network interface plug-ins, a dynamic and configurable Pod container bandwidth speed limiting method in a Kubernetes cluster is implemented.

[0067] In some embodiments, adjusting the bandwidth of Pod containers in a Kubernetes cluster can only be done by using a plug-in on the CNI, with a one-time configuration through the node local configuration. The bandwidth limit of all Pod container networks created using this CNI plug-in configuration is the same. To modify the bandwidth limit of the Pod container network, you must modify the node local configuration file and restart the Pod.

[0068] In the related technology, the configuration of the CNI plug-in must be stored locally on the node and cannot be managed centrally and uniformly; it can only be used for all Pods on this node, and cannot perform differentiated bandwidth limit configuration based on node name, node label, namespace name, namespace label, pod label, pod annotation, etc.; it cannot dynamically adjust the bandwidth limit of the Pod container; after the configuration is modified, all Pods on this node must be restarted to take effect.

[0069] In the disclosed embodiment, a unified bandwidth speed limit adjustment is performed on the Pod that needs to be adjusted. A CNI plug-in-based approach is adopted, and when the Pod is started, a unified configuration is performed according to a unified configuration file. The user does not need to care about the specific configuration, and the bandwidth speed limit problem is uniformly solved by the Kubernetes underlying CNI interface plug-in. At the same time, it also supports the explicit configuration of annotations in the Pod to perform bandwidth speed limit.

[0070] In some embodiments, see Figure 1 , shows a deployment architecture, including:

[0071] Kubernetes API Figure 1 001): Used to manage and operate Kubernetes clusters.

[0072] Node( Figure 1 002): A node in a Kubernetes cluster.

[0073] Business Pod Figure 1 003 in the present disclosure may also be referred to as Pod, which is not limited here): a business Pod deployed through Deployment, StatefulSet or DaemonSet (each corresponding to a resource model).

[0074] Business Container( Figure 1 004): A container with business programs deployed.

[0075] Bandwidth Limit Pod( Figure 1 005 in): This Pod will be on each Node ( Figure 1The service is deployed on 001 in the cluster, and the newly added Nodes to the cluster are also automatically deployed (using the Kubernetes DaemonSet mode for deployment).

[0076] PBL (Pod Bandwidth Limitation) program Figure 1 006 in ): Using the developed application, the CNI (Container Network Interface) plug-in function is implemented to implement the business Pod ( Figure 1 003) in the container ( Figure 1 004) Bandwidth limitation processing logic.

[0077] Directory / opt / cni / bin / ( Figure 1 007 in): Bandwidth Limit Pod ( Figure 1 005) during the startup process, mount Node( Figure 1 002) in this directory / opt / cni / bin / , which is used to limit the bandwidth of Pod ( Figure 1 005) in pbl( Figure 1 006) program can be used in Node( Figure 1 002) in the above code is chained by CNI.

[0078] unix: / / / run / containerd / containerd.sock( Figure 1 008 in): PBL( Figure 1 When 006) is called by CNI, it communicates with Kubernetes' CRI (Container Runtime Interface) through this Unix Sock to obtain the business container ( Figure 1 004) in the container information.

[0079] IfName (Container Network Interface Name): Business Container ( Figure 1 004 in the example) creates a container network interface through CNI. The pbl program obtains the corresponding node network interface through this interface ( Figure 1 009 in the above example).

[0080] Configuration File( Figure 1 010): The configuration file is stored using the configMap method in Kubernetes and is used for business Pod ( Figure 1 003) Unified configuration file for bandwidth limitation.

[0081] like Figure 2As shown, a method for limiting bandwidth is provided in an embodiment of the present disclosure, and the method is executed by a container cluster management system K8s, and the method includes:

[0082] Step S21, obtaining first information;

[0083] Step S22, obtaining second information;

[0084] Step S23: Adjust the bandwidth threshold associated with the container to be adjusted based on the first information and the second information.

[0085] The method disclosed herein can be applied to a K8s system, which may include nodes, on which Pod and PBL programs, etc. may be deployed.

[0086] In some embodiments, the first information is information associated with the container to be adjusted in the K8s cluster.

[0087] In some embodiments, the first information is information associated with a container to be adjusted contained in a container group Pod in a K8s cluster. The Pod contains at least one of the containers.

[0088] In some embodiments, the second information is information configured for the first information and associated with adjusting a bandwidth threshold; the bandwidth threshold is used to limit a maximum bandwidth when transmitting data using a container.

[0089] It can be understood that adjusting the bandwidth threshold associated with the container to be adjusted can also be understood as adjusting the flow threshold or the rate of transmission flow associated with the container to be adjusted, which is not limited here.

[0090] In some embodiments, first information is obtained, where the first information is information associated with a container to be adjusted in a K8s cluster; second information is obtained, where the second information is information associated with an adjustment bandwidth threshold configured for the first information; the bandwidth threshold is used to limit the maximum value of the bandwidth when using a container to transmit data; based on the first information and the second information, the bandwidth threshold associated with the container to be adjusted is adjusted.

[0091] In some embodiments, the first information includes at least one of the following information: target node name; target node label; target namespace Namesapce name; target Namespace label; Pod label; target Pod annotation.

[0092] In some embodiments, the target node name is used to indicate the node name of the K8s node where the Pod to which the container to be adjusted belongs is located.

[0093] In some embodiments, the target node label is used to indicate the node label of the K8s node where the Pod to which the container to be adjusted belongs is located.

[0094] In some embodiments, the target namespace Namespace name is used to indicate the name of the Namespace associated with the container to be adjusted.

[0095] In some embodiments, the target Namespace tag is used to indicate a tag of a Namespace associated with the container to be adjusted.

[0096] In some embodiments, the target Pod label is used to indicate a label of the Pod to which the to-be-adjusted container belongs.

[0097] In some embodiments, the target Pod annotation is used to indicate an annotation of the Pod to which the to-be-adjusted container belongs.

[0098] In some embodiments, the second information includes level information, and the level information is used to indicate which container is associated with which bandwidth threshold to adjust.

[0099] In some embodiments, the level information includes at least one of the following levels:

[0100] The first level is used to indicate the priority corresponding to adjusting the bandwidth threshold associated with the containers contained in all Pods in the K8s cluster;

[0101] The second level is configured for the target node label in the first information, and is used to indicate the priority corresponding to the bandwidth threshold associated with the container included in the Pod on the K8s node indicated by the target node label;

[0102] The third level is configured for the target node name in the first information, and is used to indicate the priority corresponding to the bandwidth threshold associated with the container included in the Pod on the K8s node indicated by the target node name;

[0103] A fourth level, the fourth level is configured for the target Namespace label in the first information, and is used to indicate a priority corresponding to adjusting a bandwidth threshold associated with a container corresponding to the Namespace indicated by the target Namespace label;

[0104] A fifth level, the fifth level is configured for the target Namespace name in the first information, and is used to indicate the priority corresponding to the bandwidth threshold associated with the container corresponding to the Namespace indicated by the target Namespace name;

[0105] The sixth level is configured for the target Pod label in the first information, and is used to indicate the priority corresponding to the bandwidth threshold associated with the container included in the Pod indicated by the target Pod label.

[0106] The seventh level is configured for the target Pod annotation in the first information, and is used to indicate the priority corresponding to the bandwidth threshold associated with the container included in the Pod indicated by the target Pod annotation.

[0107] In some embodiments, the priorities of the above levels are sorted from low to high.

[0108] In some embodiments, a higher level means a higher priority, that is, a method of adjusting the bandwidth threshold with a higher priority is executed first.

[0109] In some embodiments, where there is configuration overlap between different levels, the higher level configuration overrides the lower level configuration.

[0110] In some embodiments, a container bandwidth limit PBL program is called; wherein the PBL program is used to implement the function of the container network interface CNI; in response to calling the PBL program, the container identification ID and / or the container network interface name IFName transmitted through the container network interface CNI is obtained.

[0111] In some embodiments, a business Pod is created in Kubernetes (such as Figure 1 003 in the example above), the CNI interface is called and the container bandwidth limit PBL program (such as Figure 1 006) is a CNI plug-in that implements the CNI interface. This PBL program is also called when a Pod is created.

[0112] In some embodiments, based on the container ID, the namespace Namespace and / or Pod name of the service Pod is obtained by calling the container running interface CRI.

[0113] In some embodiments, based on the Namespace and the Pod name transmitted by an application programming interface (API), Pod labels and / or Pod annotations are queried.

[0114] In some embodiments, based on the Namespace transmitted by the API, a Namespace tag is queried.

[0115] In some embodiments, in response to the PBL being deployed to the K8s node, the K8s node name of the K8s node is obtained based on the system environment variables.

[0116] In some embodiments, based on the K8s node name transmitted by the API, the K8s label of the K8s node is queried.

[0117] In some embodiments, a first container identification ID transmitted through a container network interface CNI is obtained by calling a container bandwidth limit PBL program; wherein the PBL program is used to implement a function of the container network interface CNI; a container associated with the first container ID is used as a container to be adjusted, and first information associated with the container to be adjusted is obtained.

[0118] In some embodiments, based on the first Namespace and the first Pod name, the corresponding Pod label and / or Pod annotation are queried as the target Pod label and / or the target Pod annotation in the first information.

[0119] In some embodiments, based on the first Namespace, a corresponding Namespace tag is queried as the target Namespace tag in the first information.

[0120] In some embodiments, the first Namespace and / or the first Pod name is obtained based on the first container ID by calling a container running interface CRI.

[0121] In some embodiments, in response to the PBL being deployed to the first K8s node, the node name of the first K8s node is obtained based on the system environment variables as the target node name in the first information.

[0122] In some embodiments, based on a first node name transmitted by an application programming interface (API), a node label corresponding to the first node name is queried as the target node label in the first information.

[0123] In some embodiments, by calling a PBL program, a first container network interface name IFName transmitted through CNI is obtained, and based on the first IFName, a node network interface associated with the container to be adjusted is determined; wherein the PBL program is used to implement the function of CNI; a token bucket filter TBF is created; the value of an ingress rate ingressRate parameter in a configuration file is set to a first bandwidth threshold of the TBF; the configuration file is used to limit the ingress rate of the container, and the first bandwidth threshold is a bandwidth threshold adjusted based on the second information; the TBF is added to a queue rule Qdisc and the TBF is bound to the node network interface.

[0124] In some embodiments, by calling a PBL program, a first IFName transmitted through the CNI is obtained, and based on the first IFName, a node network interface associated with the container to be adjusted is determined; wherein the PBL program is used to implement the function of the CNI; the maximum transmission unit MTU value of the node network interface is obtained; an intermediate function module IFB is created based on the MTU value and the container ID; a filter is added to the node network interface to mirror the traffic to the IFB; a TBF is created; the value of the egress rate egressRate parameter in the configuration file is set to the second bandwidth threshold of the TBF; the configuration file is used to limit the egress rate of the container, and the second bandwidth threshold is the bandwidth threshold adjusted based on the second information; the TBF is added to the queue rule Qdisc and the TBF is bound to the IFB.

[0125] In some embodiments, a token bucket filter (TBF) is used to implement traffic shaping, ensure that data streams are sent at a constant rate, and allow short burst traffic.

[0126] In some embodiments, queue discipline (Qdisc) is a core concept in the Linux kernel network subsystem, which is responsible for queuing and scheduling data packets entering and leaving the network interface. In Linux, each network interface has one or more queue disciplines (Qdisc), which determine how data packets enter and leave the queue and the order in which they are sent on the network interface. Qdisc provides a variety of different strategies to manage network traffic, and TBF is one of them.

[0127] In some embodiments, IFB is a virtual network interface used to implement traffic shaping in the Linux kernel.

[0128] In some embodiments, first information is obtained, where the first information is information associated with a container to be adjusted in a K8s cluster; second information is obtained, where the second information is information associated with adjusting a bandwidth threshold configured for the first information; the bandwidth threshold is used to limit the maximum bandwidth when using a container to transmit data; based on the first information and the second information, the bandwidth threshold associated with the container to be adjusted is adjusted. By calling a PBL program, the name IFName of the first container network interface transmitted through CNI is obtained, and based on the first IFName, the node network interface associated with the container to be adjusted is determined; wherein the PBL program is used to implement the function of CNI; a token bucket filter TBF is created; the value of the ingress rate ingressRate parameter in the configuration file is set to the first bandwidth threshold of the TBF; the configuration file is used to limit the ingress rate of the container, and the first bandwidth threshold is the bandwidth threshold adjusted based on the second information; the TBF is added to the queue rule Qdisc and the TBF is bound to the node network interface.

[0129] In some embodiments, first information is obtained, the first information being information associated with a container to be adjusted in a K8s cluster; second information is obtained, the second information being information associated with adjusting a bandwidth threshold configured for the first information; the bandwidth threshold is used to limit the maximum bandwidth when using a container to transmit data; based on the first information and the second information, the bandwidth threshold associated with the container to be adjusted is adjusted. By calling a PBL program, a first IFName transmitted through a CNI is obtained, and based on the first IFName, a node network interface associated with the container to be adjusted is determined; wherein the PBL program is used to implement the function of the CNI; a maximum transmission unit MTU value of the node network interface is obtained; an intermediate function module IFB is created based on the MTU value and the container ID; a filter is added to the node network interface to mirror traffic to the IFB; a TBF is created; the value of the egress rate egressRate parameter in the configuration file is set to the second bandwidth threshold of the TBF; the configuration file is used to limit the egress rate of the container, and the second bandwidth threshold is the bandwidth threshold adjusted based on the second information; the TBF is added to the queue discipline Qdisc and the TBF is bound to the IFB. In the disclosed embodiment, first information is obtained, the first information being information associated with a container to be adjusted in a K8s cluster; second information is obtained, the second information being information associated with adjusting a bandwidth threshold configured for the first information; the bandwidth threshold is used to limit the maximum value of the bandwidth when using a container to transmit data; based on the first information and the second information, the bandwidth threshold associated with the container to be adjusted is adjusted. Since the first information is information associated with the container to be adjusted in a K8s cluster, and the second information is information associated with adjusting a bandwidth threshold configured for the first information, the bandwidth threshold associated with the container to be adjusted adjusted based on the first information and the second information is essentially to make the bandwidth threshold adapt to the information associated with the container to be adjusted and the information associated with adjusting the bandwidth threshold configured for the first information, and to perform targeted configuration, the configuration method will be more flexible, and the efficiency of adjusting the bandwidth threshold will be higher.

[0130] It should be noted that those skilled in the art can understand that the method provided in the embodiments of the present disclosure can be executed alone or together with some methods in the embodiments of the present disclosure or some methods in related technologies.

[0131] In order to better understand the embodiments of the present disclosure, the technical solution of the present disclosure is further described below through an exemplary embodiment:

[0132] like Figure 3 As shown, a method for limiting bandwidth is provided in an embodiment of the present disclosure, and the method includes:

[0133] Step S31: Call the PBL program. Create a business Pod in Kubernetes (such as Figure 1 003 in the business Pod, which can also be called Pod), will call the CNI interface and the container bandwidth limit PBL program (such as Figure 1 006) is a CNI plug-in that implements the CNI interface. This PBL program is also called when a Pod is created.

[0134] Step S32: Get the container identifier and the container network interface name. When calling the PBL program, CNI will pass several parameters. This PBL needs to obtain the corresponding container in the Pod (such as Figure 1 004)ID (containerID) and container network interface name (IfName) in.

[0135] Step S33, obtain the Namespace and Pod name of the business Pod. Call the Container Runtimes Interface (CRI) through the containerID (this sock exists on the node, the corresponding path is: unix: / / / run / containerd / containerd.sock, please refer to Figure 1 008 in), obtain the business Pod (see Figure 1 003) in the Namespace and Pod name.

[0136] Step S34: Query the labels and annotations of the business Pod. By calling the Kubernetes API (see Figure 1 001) interface in the Pod (see Figure 1 003) Namespace and business Pod (see Figure 1 003) name in the query to find out the labels and annotations of the business Pod.

[0137] Step S35: Query the namespace label. By calling the Kubernetes API (see Figure 1 001) interface in the Pod (see Figure 1 003)Namespace in the query to find out the label of Namespace.

[0138] Step S36: Query the node label. When the pbl program is deployed to the corresponding node, the Node can be obtained through the system environment variables (see Figure 1002) name in ; by calling the Kubernetes API (see Figure 1 001) interface in the Node, pass the Node name, and you can query the node label.

[0139] Step S37, obtain the Node name, Node label, Namespace name, Namespace label, Pod name, Pod label and Pod annotation (corresponding to the information contained in the first information in this disclosure). At this point, the Node name, Node label, Namespace name, Namespace label, Pod name, Pod label and Pod annotation can be obtained.

[0140] Step S38: Get the configuration file (corresponding to the second information in this disclosure). Figure 1 001) interface, read the configuration file (see Figure 1 010) (This configuration file has been deployed in the Kubernetes cluster when the pbl service was deployed). The content of the configuration file is as follows:

[0141]

[0142]

[0143]

[0144]

[0145] Step S39: Perform hierarchical processing. Pass the Node name, Node label, Namespace name, Namespace label, Pod label, Pod annotation, and configuration file (see Figure 1 The configurations in 010) are processed hierarchically. If there is configuration overlap, the lower-level configuration can be overwritten by the higher-level configuration.

[0146] The global level is 0 (corresponding to the first level), and global represents all business Pods (see Figure 1 The bandwidth limit of the container 003) in will be adjusted.

[0147] The node tag level is 1 (corresponding to the second level), and the node tag represents if the Node (see Figure 1 002 in , which can also be called node01) contains a node label, then this Node (see Figure 1 002) on the business Pod (see Figure 1003) in the container bandwidth limit.

[0148] The node name level is 2 (corresponding to the third level), and the node name represents if the Node (see Figure 1 002) name is equal to the node name, then for this Node (see Figure 1 002) on the business Pod (see Figure 1 003) in the container bandwidth limit.

[0149] The Namespace tag level is 3 (corresponding to the fourth level). The Namespace tag represents the business Pod (see Figure 1 003 in the Namespace contains the Namespace label, then this business Pod (see Figure 1 003) in the container to adjust the bandwidth limit.

[0150] The namespace name level is 4 (corresponding to the fifth level). The namespace name represents the business Pod (see Figure 1 003 in ) is equal to the Namespace name, then this business Pod (see Figure 1 003) in the container to adjust the bandwidth limit.

[0151] The pod label level is 5 (corresponding to the sixth level). The pod label represents the business pod (see Figure 1 003) label in contains the pod label, then this business Pod (see Figure 1 003) in the container to adjust the bandwidth limit.

[0152] The pod annotation level is 6 (corresponding to the seventh level), and the pod annotation represents the business pod (see Figure 1 003) in the container bandwidth limit adjustment, the bandwidth limit parameters to be adjusted are obtained from the pod annotation.

[0153] Step S40: Generate a dictionary containing only the bandwidth limits that need to be adjusted. Finally, a dictionary containing only the bandwidth limits that need to be adjusted is generated. If the dictionary is empty, it means that this business Pod (see Figure 1 003) in the container does not need to limit the container bandwidth.

[0154] Step S41, container inlet flow restriction configuration:

[0155] In some embodiments, the node network interface corresponding to the container is obtained through the container network interface name (IfName) passed by CNI (see Figure 1 009 in ); create a token bucket filter (TBF, Token Bucket Filter), the ingressRate and ingressBurst in the configuration file are the limit and buffer of TBF respectively; add TBF to the queue discipline (Qdisc, Queue Discipline) and bind it to the node network interface corresponding to the container (see Figure 1 009 in the figure). This way, the flow rate at the container entrance can be limited.

[0156] Step S42: Container outflow flow restriction configuration:

[0157] Get the node network interface corresponding to the container by using the container network interface name (IfName) passed by CNI (see Figure 1 009 in ); Get the maximum transmission unit (MTU) value of the node network interface; Use this MTU value and the container (see Figure 1 004)ID (containerID) creates an IFB (Intermediate Functional Block virtual network interface); on the node network interface (see Figure 1 009 in the configuration file) to mirror the traffic to the IFB (virtual network interface) network interface; create a token bucket filter (TBF), and the egressRate and egressBurst in the configuration file are the limit and buffer of TBF respectively; add TBF to Qdisc (Queue Discipline) and bind it to the IFB network interface. In this way, the container egress traffic can be restricted.

[0158] Step S43: When the PBL program is executed, the business Pod (see Figure 1 The node network interface used when the container is started in 003) has already added the corresponding inflow and outflow rate limits.

[0159] It should be noted that those skilled in the art can understand that the method provided in the embodiments of the present disclosure can be executed alone or together with some methods in the embodiments of the present disclosure or some methods in related technologies.

[0160] like Figure 4 As shown, in an embodiment of the present disclosure, a bandwidth limiting device is provided, the device comprising:

[0161] An acquisition module 41 is used to: acquire first information, where the first information is information associated with a container to be adjusted in a K8s cluster; acquire second information, where the second information is information associated with an adjustment bandwidth threshold configured for the first information; the bandwidth threshold is used to limit a maximum bandwidth when transmitting data using a container;

[0162] The adjustment module 42 is configured to adjust the bandwidth threshold associated with the at least one container to be adjusted based on the first information and the second information.

[0163] It should be noted that those skilled in the art can understand that the method provided in the embodiments of the present disclosure can be executed alone or together with some methods in the embodiments of the present disclosure or some methods in related technologies.

[0164] The present disclosure provides a processing device, the processing device comprising:

[0165] A memory for storing executable programs;

[0166] The processor is used to implement any method described in the embodiments of the present disclosure when executing the executable program stored in the memory.

[0167] It can be understood that the memory can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM, SyncLink Dynamic Random Access Memory), and direct RAM bus random access memory (DRRAM, Direct Rambus Random Access Memory).The memories described in the embodiments of the present application are intended to include, but are not limited to, these and any other suitable types of memories.

[0168] Among them, the method disclosed in the present invention can be applied to the processor or implemented by the processor. The processor can be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the voice conversion method can be completed by the hardware integrated logic circuit or software instructions in the processor. The above-mentioned processor can be a general-purpose processor, a digital signal processor (DSP, Digital Signal Processor), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor can implement or execute the methods, steps and logic block diagrams disclosed in the present invention. The general-purpose processor can be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the present invention, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in a memory, and the processor reads the information in the memory, and completes the steps of the voice conversion method provided in the embodiment of the present application in combination with its hardware.

[0169] The present invention also provides a computer storage medium, wherein the computer storage medium stores an executable program, and when the executable program is executed by a processor, the method described in any one of the embodiments of the present disclosure is implemented. Specifically, it can be a computer-readable storage medium, for example, a memory including a computer program, and the computer program can be executed by a processor of a processing device to complete the steps described in the method of the embodiment of the present application. The computer-readable storage medium can be a memory such as a ROM, a PROM, an EPROM, an EEPROM, a Flash Memory, a magnetic surface memory, an optical disk, or a CD-ROM.

[0170] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A method for limiting bandwidth, characterized in that: The method comprises: Acquire first information, where the first information is information associated with a container to be adjusted in a K8s cluster; Acquire second information, where the second information is information configured for the first information and is associated with adjusting a bandwidth threshold; the bandwidth threshold is used to limit a maximum bandwidth when transmitting data using a container; Based on the first information and the second information, a bandwidth threshold associated with the to-be-adjusted container is adjusted.

2. The method according to claim 1, characterized in that The first information includes at least one of the following information: The target node name is used to indicate the node name of the K8s node where the Pod to which the container to be adjusted belongs is located; The target node label is used to indicate the node label of the K8s node where the Pod to which the container to be adjusted belongs is located; The target namespace Namespace name is used to indicate the name of the Namespace associated with the container to be adjusted; The target Namespace label is used to indicate the label of the Namespace associated with the container to be adjusted; Target Pod label, used to indicate the label of the Pod to which the container to be adjusted belongs; Target Pod annotation, used to indicate the annotation of the Pod to which the container to be adjusted belongs.

3. The method according to claim 1 or 2, characterized in that: The second information includes level information, wherein the level information includes at least one of the following levels: The first level is used to indicate the priority corresponding to adjusting the bandwidth threshold associated with the containers contained in all Pods in the K8s cluster; The second level is configured for the target node label in the first information, and is used to indicate the priority corresponding to the bandwidth threshold associated with the container included in the Pod on the K8s node indicated by the target node label; The third level is configured for the target node name in the first information, and is used to indicate the priority corresponding to the bandwidth threshold associated with the container included in the Pod on the K8s node indicated by the target node name; A fourth level, the fourth level is configured for the target Namespace label in the first information, and is used to indicate a priority corresponding to adjusting a bandwidth threshold associated with a container corresponding to the Namespace indicated by the target Namespace label; A fifth level, the fifth level is configured for the target Namespace name in the first information, and is used to indicate the priority corresponding to the bandwidth threshold associated with the container corresponding to the Namespace indicated by the target Namespace name; The sixth level is configured for the target Pod label in the first information, and is used to indicate the priority corresponding to the bandwidth threshold associated with the container included in the Pod indicated by the target Pod label. The seventh level is configured for the target Pod annotation in the first information, and is used to indicate the priority corresponding to the bandwidth threshold associated with the container included in the Pod indicated by the target Pod annotation; Among them, the priorities of the above levels are sorted from low to high.

4. The method according to claim 2, characterized in that: The obtaining of the first information includes: By calling a container bandwidth limit PBL program, a first container identification ID transmitted through a container network interface CNI is obtained; wherein the PBL program is used to implement a function of the container network interface CNI; The container associated with the first container ID is used as the container to be adjusted, and first information associated with the container to be adjusted is acquired.

5. The method according to claim 4, characterized in that The step of taking the container associated with the first container ID as the container to be adjusted and acquiring first information associated with the container to be adjusted includes at least one of the following: Based on the first Namespace and the first Pod name, query the corresponding Pod label and / or Pod annotation as the target Pod label and / or the target Pod annotation in the first information; Based on the first Namespace, query the corresponding Namespace tag as the target Namespace tag in the first information; The first Namespace and / or the first Pod name are obtained based on the first container ID by calling the container running interface CRI.

6. The method according to claim 2, characterized in that The obtaining of the first information includes at least one of the following: In response to the PBL being deployed to the first K8s node, obtaining the node name of the first K8s node based on the system environment variable as the target node name in the first information; Based on the first node name transmitted by the application programming interface API, a node label corresponding to the first node name is queried as the target node label in the first information.

7. The method according to claim 1, characterized in that The method further comprises: By calling the PBL program, a first container network interface name IFName transmitted through the CNI is obtained, and based on the first IFName, a node network interface associated with the container to be adjusted is determined; wherein the PBL program is used to implement the function of the CNI; Create a token bucket filter TBF; Setting the value of the ingress rate ingressRate parameter in the configuration file to the first bandwidth threshold of the TBF; the configuration file is used to limit the ingress rate of the container, and the first bandwidth threshold is the bandwidth threshold adjusted based on the second information; The TBF is added to the queue discipline Qdisc and the TBF is bound to the node network interface.

8. The method according to any one of claims 1 to 6, characterized in that The method further comprises: By calling the PBL program, a first IFName transmitted through the CNI is acquired, and based on the first IFName, a node network interface associated with the container to be adjusted is determined; wherein the PBL program is used to implement the function of the CNI; Obtain the maximum transmission unit (MTU) value of the network interface of the node; Creating an intermediate function module IFB based on the MTU value and the container ID; adding a filter on the node network interface to mirror traffic to the IFB; Create TBF; Setting the value of the egress rate parameter egressRate in the configuration file to the second bandwidth threshold of the TBF; the configuration file is used to limit the egress rate of the container, and the second bandwidth threshold is the bandwidth threshold adjusted based on the second information; The TBF is added to the queue discipline Qdisc and the TBF is bound to the IFB.

9. A bandwidth limiting device, characterized in that: The device comprises: An acquisition module is used to: acquire first information, where the first information is information associated with a container to be adjusted in a K8s cluster; acquire second information, where the second information is information associated with an adjustment bandwidth threshold configured for the first information; the bandwidth threshold is used to limit a maximum bandwidth when transmitting data using a container; The adjustment module is configured to adjust the bandwidth threshold associated with the container to be adjusted based on the first information and the second information.

10. A processing device, characterized in that: The processing equipment comprises: A memory for storing executable programs; A processor, configured to implement the method according to any one of claims 1 to 8 when executing the executable program stored in the memory.

Citation Information

Cited By

  • Bandwidth setting method and device, electronic equipment and storage medium

    CN121151225A