Container service network configuration method and related products
By configuring virtual network cards and registering load balancing hook functions in the container network stack, the problem of long data transmission links and large network delays in the container service network is solved, and high-performance data transmission and load balancing are achieved, which is suitable for large-scale applications. service scene.
Patent Information
- Application Number
- CN202111643239.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-29
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2041-12-29
AI Technical Summary
When the container service network transmits data, there are problems such as long data transmission links and large network delays, which leads to performance loss of the container cluster.
By configuring a virtual network card in the container network stack and registering a hook function for load balancing the container's service access traffic, the data packets are directly transmitted to the host's physical network card through the L2 layer, avoiding namespace crossing and shortening data transmission. path to reduce network latency.
It achieves efficient data transmission and load balancing, is suitable for large-scale service scenarios, and significantly reduces the transmission and processing delays of the container service network.
Smart Images

Figure CN114363170B
Abstract
Description
Technical Field
[0001] The present application belongs to the field of cloud computing technology, and specifically relates to a container service network configuration method, a container service network configuration device, a computer-readable medium, an electronic device, and a computer program product. Background Art
[0002] The container service network is one of the three core network capabilities of the container cluster (Kubernetes cluster). It provides forwarding and load balancing capabilities from container to container service based on the container network connectivity. When the container communicates data with the host, it needs to cross multiple network layers. Therefore, there are common technical problems such as long data transmission links and large network latency, which further leads to obvious performance loss in the container cluster. Summary of the invention
[0003] The purpose of the present application is to provide a container service network configuration method, a container service network configuration device, a computer-readable medium, an electronic device, and a computer program product, which at least to a certain extent overcome the technical problems existing in the related technology such as long data transmission links and large network delays.
[0004] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by the practice of the present application.
[0005] According to one aspect of an embodiment of the present application, a container service network configuration method is provided, the method comprising:
[0006] When a new container is detected to be created on the host, a container network stack is configured for the container;
[0007] Configuring a virtual network card corresponding to the physical network card of the host, wherein the virtual network card is a network interface with an independent physical address;
[0008] Recording the physical address of the virtual network card in the physical network card of the host;
[0009] A hook function for load balancing service access traffic of the container is registered according to the physical address of the virtual network card.
[0010] According to one aspect of an embodiment of the present application, a container service network configuration device is provided, the device comprising:
[0011] A network stack configuration module is configured to configure a container network stack for the container when a new container is detected to be created on the host;
[0012] A virtual network card configuration module, configured to configure a virtual network card corresponding to the physical network card of the host, wherein the virtual network card is a network interface with an independent physical address;
[0013] An address recording module, configured to record the physical address of the virtual network card in the physical network card of the host;
[0014] The function registration module is configured to register a hook function for load balancing the service access traffic of the container according to the physical address of the virtual network card.
[0015] In one embodiment of the present application, based on the above technical solution, the function registration module may further include:
[0016] An information acquisition module, configured to acquire service configuration information of the container network stack according to the physical address of the virtual network card;
[0017] The function conversion module is configured to convert the service configuration information into a hook function for load balancing the service access traffic of the container through a traffic controller installed in the host.
[0018] In one embodiment of the present application, based on the above technical solution, the function conversion module may further include:
[0019] A code writing module, configured to write the service configuration information into a programming language code through a traffic controller installed in the host;
[0020] The code conversion module is configured to convert the programming language code into a hook function for performing load balancing processing on the service access traffic of the container.
[0021] In one embodiment of the present application, based on the above technical solution, the code conversion module may further include:
[0022] A code compiling module, configured to call an underlying virtual machine configured in the host to compile the programming language code into Berkeley packet filter instructions;
[0023] a bytecode compilation module configured to compile the Berkeley packet filter instructions into bytecodes through an extended Berkeley packet filter installed in the host;
[0024] The bytecode registration module is configured to register the bytecode as a hook function for load balancing the service access traffic of the container.
[0025] In one embodiment of the present application, based on the above technical solution, the bytecode compilation module can be further configured to: call the kernel just-in-time compiler through the extended Berkeley packet filter configured in the host, so as to compile the Berkeley packet filter instructions into bytecodes through the kernel just-in-time compiler.
[0026] In one embodiment of the present application, based on the above technical solution, the network stack configuration module can be further configured to: call the container network interface plug-in through the agent node of the container orchestration engine installed on the host, so as to configure the container network stack for the container through the container network interface plug-in.
[0027] In one embodiment of the present application, based on the above technical solution, the container network interface plug-in interacts with the proxy node of the container orchestration engine based on the container network interface standard to implement adding network functions and removing network functions in the container network interface standard.
[0028] According to one aspect of an embodiment of the present application, a computer-readable medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the container service network configuration method in the above technical solution is implemented.
[0029] According to one aspect of an embodiment of the present application, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the container service network configuration method in the above technical solution by executing the executable instructions.
[0030] According to one aspect of an embodiment of the present application, a computer program product or a computer program is provided, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the container service network configuration method in the above technical solution.
[0031] In the technical solution provided in the embodiment of the present application, by configuring a virtual network card in the container network stack and registering a hook function for load balancing the service access traffic of the container, the data packet can be transmitted directly to the physical network card of the host through the L2 layer without crossing the namespace. Therefore, the data transmission path can be shortened, cross-layer transmission can be reduced, and the network delay of data transmission can be reduced. It can also solve the problem of load balancing at the L2 data link layer, which is more suitable for large-scale service scenarios.
[0032] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present application, and together with the specification are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0034] Figure 1 A network architecture diagram for implementing a container service network in the related technology of this application is shown.
[0035] Figure 2 A flowchart of the steps of a container service network configuration method in one embodiment of the present application is shown.
[0036] Figure 3 A module block diagram of an embodiment of the present application for performing container service network configuration on Kubernetes is shown.
[0037] Figure 4 A module block diagram of a data forwarding path based on macvlan in one embodiment of the present application is shown.
[0038] Figure 5 A module block diagram for implementing data packet load balancing in one embodiment of the present application is shown.
[0039] Figure 6 The structure block diagram of the container service network configuration device provided in an embodiment of the present application is schematically shown.
[0040] Figure 7 The structure block diagram of a computer system suitable for implementing an electronic device of an embodiment of the present application is schematically shown. DETAILED DESCRIPTION
[0041] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this application will be more comprehensive and complete and fully convey the concept of the example embodiments to those skilled in the art.
[0042] In addition, described feature, structure or characteristic can be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present application. However, those skilled in the art will appreciate that the technical scheme of the present application can be put into practice without one or more of the specific details, or other methods, components, devices, steps, etc. can be adopted. In other cases, known methods, devices, realizations or operations are not shown or described in detail to avoid blurring the various aspects of the application.
[0043] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0044] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0045] The embodiments of the present application relate to a technical solution for building a high-performance container service network based on cloud technology.
[0046] Cloud technology refers to a hosting technology that unifies hardware, software, network and other resources in a wide area network or local area network to achieve data computing, storage, processing and sharing. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool, which is used on demand and flexible and convenient. Cloud computing technology will become an important support. The background services of the technical network system require a large amount of computing and storage resources, such as video websites, picture websites and more portal websites. With the high development and application of the Internet industry, each item may have its own identification mark in the future, and all need to be transmitted to the background system for logical processing. Data of different levels will be processed separately. All kinds of industry data require strong system backing support, which can only be achieved through cloud computing.
[0047] Cloud computing is a computing model that distributes computing tasks on a resource pool composed of a large number of computers, so that various application systems can obtain computing power, storage space and information services as needed. The network that provides resources is called a "cloud". From the user's point of view, the resources in the "cloud" can be infinitely expanded, and can be obtained at any time, used on demand, expanded at any time, and paid for by use. As a basic capability provider for cloud computing, a cloud computing resource pool (referred to as a cloud platform, generally referred to as an IaaS (Infrastructure as a Service) platform) will be established, and various types of virtual resources will be deployed in the resource pool for external customers to choose to use. The cloud computing resource pool mainly includes: computing devices (virtualized machines, including operating systems), storage devices, and network devices.
[0048] Kubernetes, or K8s for short, is an abbreviation that replaces the eight characters in the middle of the name "ubernete". Kubernetes is an open source platform for managing containerized applications on multiple hosts in a cloud platform. The goal of Kubernetes is to make the deployment of containerized applications simple and efficient. Kubernetes provides mechanisms for application deployment, planning, updating, and maintenance.
[0049] The traditional way of deploying applications is to install them through plug-ins or scripts. The disadvantage of this is that the operation, configuration, management, and entire life cycle of the application will be bound to the current operating system, which is not conducive to application upgrades / rollbacks. Of course, some functions can be implemented by creating virtual machines, but virtual machines are very heavy and not conducive to portability.
[0050] Kubernetes implements application deployment on the cloud platform by creating containers. Each container is isolated from each other and has its own file system. The processes between containers will not affect each other and can distinguish computing resources. Compared with virtual machines, containers can be deployed quickly. Since containers are decoupled from the underlying facilities and machine file systems, they can be migrated between different clouds and different versions of operating systems.
[0051] Containers take up less resources and are quick to deploy. Each application can be packaged into a container image. The one-to-one relationship between each application and the container also gives containers greater advantages. Using containers, you can create container images for applications during the build or release phase, because each application does not need to be combined with the rest of the application stack, nor does it rely on the production environment infrastructure, which enables a consistent environment from R&D to testing and production. Similarly, containers are lighter and more "transparent" than virtual machines, which makes them easier to monitor and manage.
[0052] Kubernetes supports automated deployment, large-scale scalability, and containerized application management. When deploying an application in a production environment, you usually need to deploy multiple instances of the application to load balance application requests. In Kubernetes, you can create multiple containers, each of which runs an application instance, and then use the built-in load balancing strategy to manage, discover, and access this group of application instances, without requiring operations and maintenance personnel to perform complex manual configuration and processing.
[0053] Container service network is one of the three core network capabilities of the Kubernetes container cluster. It provides forwarding and load balancing capabilities from container to container service based on container network connectivity.
[0054] Figure 1A network architecture diagram for implementing a container service network in the related technology of this application is shown.
[0055] like Figure 1 As shown in the figure, the key datapath of the container service network is that the data packet is first sent from the container's network stack to the host network stack via the veth pair (across the namespace namespace), and then load-balanced forwarding to the container service instance is implemented based on the host's iptables / ipvs rules (out of the host network card).
[0056] The implementation of the key datapath of the container service network has obvious performance loss and cannot meet the requirements of high-performance service access (such as ultra-low latency).
[0057] The main problems of this solution are as follows:
[0058] 1) Data packets from the container to the host are sent and received via the veth pair, which is a virtual network interface. Its data packet sending and receiving is similar to that of a real network device, with obvious processing delays caused by (soft) interrupts;
[0059] 2) From the veth interface on the host side to the physical network card, it needs to go through the L3 protocol stack, which has a long link and high latency;
[0060] 3) Load balancing modules such as ipvs / iptables are implemented based on the packet filtering mechanism of Netfilter, and have obvious performance problems in high-concurrency scenarios.
[0061] In response to the above-mentioned problems existing in the related technologies, the embodiments of the present application propose a method and system for building a high-performance container service network based on macvlan and eBPF. Specifically, the embodiments of the present application design a new mechanism for implementing a container service network, which uses the L2 link layer solution macvlan to replace the veth pair and the host L3 solution to achieve an efficient data forwarding path, and focuses on designing the "tc-ebpf" solution to solve the problem that macvlan at the L2 layer cannot adapt to the iptables / ipvs at the L3 layer, and achieves efficient load balancing capabilities; based on the above mechanism, a system implementation process in a kubernetes environment is designed. Through the above method and system embodiments, the present application can greatly reduce the transmission and processing delays of the container service network and achieve a high-performance container service network.
[0062] The following is a detailed description of the technical solutions such as the container service network configuration method, container service network configuration device, computer-readable medium, electronic device, and computer program product provided in this application in combination with specific implementation methods.
[0063] Figure 2A flowchart of the steps of the container service network configuration method in one embodiment of the present application is shown. Figure 2 As shown, the container service network configuration method may mainly include the following steps S210 to S240.
[0064] Step S210: When a new container is detected to be created on the host, a container network stack is configured for the container;
[0065] Step S220: configuring a virtual network card corresponding to the physical network card of the host in the container network stack, where the virtual network card is a network interface with an independent physical address;
[0066] Step S230: Record the physical address of the virtual network card in the physical network card of the host;
[0067] Step S240: registering a hook function for load balancing the service access traffic of the container in the container network stack according to the physical address of the virtual network card.
[0068] In the container service network configuration method provided in the embodiment of the present application, by configuring a virtual network card in the container network stack and registering a hook function for load balancing the service access traffic of the container, the data packet can be transmitted directly to the physical network card of the host through the L2 layer without crossing the namespace. Therefore, the data transmission path can be shortened, cross-layer transmission can be reduced, and the network delay of data transmission can be reduced. It can also solve the problem of load balancing at the L2 data link layer, which is more suitable for large-scale service scenarios.
[0069] The following is a detailed description of each method step of the container service network configuration method in this application.
[0070] In step S210, when it is detected that a new container is created on the host, a container network stack is configured for the container.
[0071] The network stack includes multiple elements such as network cards, loopback devices, routing tables, Iptables rules, etc. For a process, these elements constitute the basic environment for initiating and responding to network requests. For containers, the host's network stack can be used directly, that is, the network namespace Network Namespace is not enabled, but this will inevitably introduce problems with shared network resources, such as port conflicts. Therefore, the embodiment of the present application configures its own container network stack for the container in the Network Namespace, so that the container has its own IP address and port.
[0072] Figure 3 The following is a block diagram showing a module for configuring a container service network on Kubernetes according to an embodiment of the present application. Figure 3As shown, the implementation scheme of the embodiment of the present application mainly includes two parts. On the one hand, the network stack is configured for the container based on the macvlan mechanism, including IP and MAC addresses; specifically, it includes the implementation of the network plug-in cni_macvlan, which is responsible for integrating with kubernetes and configuring the container network stack; on the other hand, the load balancing strategy is configured based on the eBPF mechanism; specifically, it includes writing the tc_controller plug-in, which is responsible for monitoring the creation of container services and converting container services into hook functions for load balancing.
[0073] In one embodiment of the present application, the container network interface plug-in cni_macvlan can be called by the agent node kubelet of the container orchestration engine Kubernetes installed on the host to configure the container network stack for the container through the container network interface plug-in cni_macvlan.
[0074] In one embodiment of the present application, the container network interface plug-in interacts with the proxy node of the container orchestration engine based on the container network interface standard to implement the add network function addNetwork and remove network function delNetwork in the container network interface standard.
[0075] In step S220, a virtual network card corresponding to the physical network card of the host is configured in the container network stack, and the virtual network card is a network interface with an independent physical address.
[0076] Figure 4 FIG. 1 shows a block diagram of a module for implementing a data forwarding path based on macvlan in one embodiment of the present application. Figure 4 As shown in the figure, the physical network card on the host is eth_0. Based on the macvlan mechanism, corresponding virtual network cards eth_1 and eth_2 can be configured for the two containers respectively.
[0077] macvlan is a network card virtualization technology that can virtualize a physical network card into multiple network interfaces with independent MAC addresses and IP addresses, and these network interfaces can be directly configured in the network stack of the container namespace.
[0078] The data packet reaches the physical network card directly at the link layer through the virtual network interface of macvlan (such as eth_1) without passing through the Netfilter module of the kernel. Therefore, the data does not pass through the L3 protocol stack, avoiding cross-layer transmission of the data packet.
[0079] In step S230, the physical address of the virtual network card is recorded in the physical network card of the host.
[0080] By recording the physical address of the virtual network card in the physical network card of the host, the physical network card of the host can perform data packet forwarding processing.
[0081] Macvlan can configure multiple virtual network interfaces on a network interface of the host. These network interfaces have their own independent MAC addresses and can also be configured with IP addresses for communication. The virtual machine or container network under Macvlan is in the same network segment as the host and shares the same broadcast domain. Macvlan is similar to Bridge, but because it omits the existence of Bridge, it is simpler to configure and debug, and the efficiency is relatively high. In addition, Macvlan itself also perfectly supports VLAN.
[0082] Data transmission between the same VLANs is achieved through Layer 2 mutual access, that is, MAC address, and does not require routing. By default, users in different VLANs cannot communicate directly by unicast. If they want to communicate, they need Layer 3 devices for routing, and the same is true for Macvlan. The virtual network card virtualized by Macvlan technology is logically equivalent to the physical network card. The physical network card is equivalent to a switch, which records the corresponding virtual network card and MAC address. When the physical network card receives a data packet, it will determine which virtual network card the packet belongs to based on the destination MAC address. This means that as long as the data packet is sent from the Macvlan sub-interface (or the data packet is sent to the Macvlan sub-interface), the physical network card only receives the data packet and does not process the data packet.
[0083] In simple terms, the Macvlan virtual network card device is parasitic on the physical network card device. When sending a packet, it calls its own packet sending function, finds the parasitic physical device, and then sends the packet through the physical device. When receiving a packet, it processes the data packet by registering the rx_handler callback function of the parasitic physical device.
[0084] In step S240, a hook function for load balancing service access traffic of the container is registered in the container network stack according to the physical address of the virtual network card.
[0085] In one embodiment of the present application, a method for registering a hook function for load balancing service access traffic of a container in a container network stack according to the physical address of a virtual network card may include: obtaining service configuration information of the container network stack according to the physical address of the virtual network card; converting the service configuration information into a hook function for load balancing service access traffic of the container through a traffic controller installed in the host.
[0086] Hook technology is also called hook function. Before the system calls the function, the hook program captures the message first, and the hook function gets control first. At this time, the hook function can process (change) the execution behavior of the function and force the end of the message transmission.
[0087] Figure 5 FIG. 1 shows a block diagram of a module for implementing data packet load balancing in one embodiment of the present application. Figure 5 As shown, the TC module directly hooks into the network card device to take over the inbound and outbound traffic. The kernel's traffic controller tc_controller module can work directly at the link layer to take over the inbound and outbound traffic of the container, and provide a hook interface for the eBPF framework. Load balancing function can be achieved by writing eBPF hook functions: eBPF is a set of kernel frameworks that can add custom execution logic through hooks at each key processing node in the kernel. The embodiment of the present application implements load balancing processing by writing eBPFhook code in the egress node of the tc module.
[0088] In one embodiment of the present application, service configuration information is converted into a hook function for load balancing service access traffic of a container through a traffic controller installed in a host, including: writing the service configuration information into a programming language code through a traffic controller installed in the host; converting the programming language code into a hook function for load balancing service access traffic of a container.
[0089] Traffic Control (TC) in the Linux operating system is used for flow control in the Linux kernel. It uses queue rules to establish queues for processing data packets and defines how the data packets in the queues are sent, thereby achieving flow control. The queue rules used by the TC module to implement flow control functions are divided into two categories: classless queue rules and classified queue rules. Classless queue rules are relatively simple, while classified queue rules introduce concepts such as classification and filters, which enhances its flow control function.
[0090] Classless queue rules are queue rules that treat data flows entering a network device (network card) uniformly without distinction. Queues formed using classless queue rules can receive data packets and re-arrange, delay, or discard data packets. Queues formed by this type of queue rule can shape the traffic of the entire network device (network card), but cannot be subdivided into various situations. Commonly used classless queue rules include pfifo_fast (first in, first out), TBF (token bucket filter), SFQ (random fair queue), ID (forward random packet loss), etc. The traffic shaping methods used by this type of queue rule are mainly sorting, rate limiting, and packet loss.
[0091] Classified queue rules are queue rules that treat packets entering a network device in a classified manner according to different requirements. After a packet enters a classified queue, it needs to be sent to a certain class, that is, the packet needs to be classified. The tool for classifying packets is the filter, which returns a decision, and the queue rule sends the packet to the corresponding class for queueing based on this decision. Each subclass can use its filters again for further classification. Until further classification is no longer needed, the packet will enter the queue contained in the class. In addition to being able to contain other queue rules, most classified queue rules can also shape traffic. This is very useful for situations where scheduling (such as using SFQ) and flow control are required at the same time.
[0092] In one embodiment of the present application, a method for converting a programming language code into a hook function for load balancing service access traffic of a container may include: calling an underlying virtual machine configured in a host to compile the programming language code into Berkeley packet filter instructions; compiling the Berkeley packet filter instructions into bytecodes through an extended Berkeley packet filter installed in the host; and registering the bytecodes as a hook function for load balancing service access traffic of a container.
[0093] In one embodiment of the present application, tc_controller first writes the configuration information of the container service into C language program code, and then calls the underlying virtual machine LLVM to compile the C language program code into BPF instructions.
[0094] Berkeley Packet Filter (BPF) is a primitive interface to the data link layer on Unix-like systems, providing the sending and receiving of raw link layer packets. In addition, if the network card driver supports flooding mode, it can put the network card in this mode, so that all packets on the network can be received, regardless of whether their destination is the host. BPF supports "filtering" packets, so that BPF will only pass "interesting" packets to the upper layer software, which can avoid copying other packets from the operating system kernel to the user state, reduce the burden of the CPU for packet capture and the required buffer space, thereby reducing the packet loss rate. BPF's filtering function is implemented in the form of an interpreter for the BPF virtual machine machine language. Programs in this language can capture packet data, perform arithmetic operations on the data in the packet, and compare the result with a constant or a test bit in the data or result in the packet, and decide whether to accept or reject the packet based on the comparison result. On some platforms, including FreeBSD and WinPcap, just-in-time compilation technology is used to convert virtual machine instructions into source code to further reduce overhead.
[0095] The extended Berkeley Packet Filter (eBPF) is a general-purpose execution engine that provides a general capability to efficiently and securely execute specific code based on system or program events. The users of this general capability are no longer limited to kernel developers. eBPF can be composed of bytecode execution instructions, storage objects, and Helper functions. The bytecode instructions must be verified by the BPF verifier before being executed in the kernel. At the same time, in a kernel with BPF JIT mode enabled, the bytecode instructions will be directly converted into kernel executable local instructions for execution.
[0096] In one embodiment of the present application, a method for compiling Berkeley packet filter instructions into bytecodes through an extended Berkeley packet filter configured in a host may include: calling a kernel just-in-time compiler through the extended Berkeley packet filter configured in the host to compile Berkeley packet filter instructions into bytecodes through the kernel just-in-time compiler.
[0097] In the Java programming language and environment, a just-in-time compiler (JIT compiler) is a program that converts Java bytecode (a program that includes instructions that need to be interpreted) into instructions that can be sent directly to the processor. When a Java program is written, the statements of the source language will be compiled into bytecode by the Java front-end compiler (javac or the incremental compiler in Eclipse JDT), rather than compiled into native instruction code corresponding to a specific processor hardware platform (for example, Intel's Pentium microprocessor or IBM's System / 390 processor). Bytecode is a platform-independent code that can be sent to any platform and can run on that platform. The just-in-time compiler (JIT compiler) is provided with the virtual machine and is optional. It compiles bytecode into executable code for the specified platform that can be executed immediately.
[0098] In one embodiment of the present application, tc_controller first writes the configuration information of the container service into C language code, and then calls LLVM to compile the C program into BPF instructions; the eBPF module calls the kernel just-in-time compiler JIT to compile the BPF instructions into opcode bytecode; the eBPF module registers the bytecode as a hook function of the TC module Egress traffic, which is responsible for load balancing the container's service access.
[0099] It should be noted that although the steps of the method in the present application are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0100] The following introduces an apparatus embodiment of the present application, which can be used to execute the container service network configuration method in the above embodiment of the present application. Figure 6 The structure block diagram of the container service network configuration device provided by the embodiment of the present application is schematically shown. Figure 6 As shown, the container service network configuration device 600 may include:
[0101] The network stack configuration module 610 is configured to configure a container network stack for a container when a new container is detected to be created on the host;
[0102] A virtual network card configuration module 620 is configured to configure a virtual network card corresponding to a physical network card of the host, wherein the virtual network card is a network interface with an independent physical address;
[0103] An address recording module 630 is configured to record the physical address of the virtual network card in the physical network card of the host;
[0104] The function registration module 640 is configured to register a hook function for load balancing the service access traffic of the container according to the physical address of the virtual network card.
[0105] In one embodiment of the present application, based on the above embodiment, the function registration module 640 may further include:
[0106] An information acquisition module, configured to acquire service configuration information of the container network stack according to the physical address of the virtual network card;
[0107] The function conversion module is configured to convert the service configuration information into a hook function for load balancing the service access traffic of the container through a traffic controller installed in the host.
[0108] In one embodiment of the present application, based on the above embodiment, the function conversion module may further include:
[0109] A code writing module, configured to write the service configuration information into a programming language code through a traffic controller installed in the host;
[0110] The code conversion module is configured to convert the programming language code into a hook function for performing load balancing processing on the service access traffic of the container.
[0111] In one embodiment of the present application, based on the above embodiment, the code conversion module may further include:
[0112] A code compiling module, configured to call an underlying virtual machine configured in the host to compile the programming language code into Berkeley packet filter instructions;
[0113] a bytecode compilation module configured to compile the Berkeley packet filter instructions into bytecodes through an extended Berkeley packet filter installed in the host;
[0114] The bytecode registration module is configured to register the bytecode as a hook function for load balancing the service access traffic of the container.
[0115] In one embodiment of the present application, based on the above embodiments, the bytecode compilation module can be further configured to: call the kernel just-in-time compiler through the extended Berkeley packet filter configured in the host, so as to compile the Berkeley packet filter instructions into bytecodes through the kernel just-in-time compiler.
[0116] In one embodiment of the present application, based on the above embodiments, the network stack configuration module 610 can be further configured to: call the container network interface plug-in through the agent node of the container orchestration engine installed on the host, so as to configure the container network stack for the container through the container network interface plug-in.
[0117] In one embodiment of the present application, based on the above embodiments, the container network interface plug-in interacts with the proxy node of the container orchestration engine based on the container network interface standard to implement adding network functions and removing network functions in the container network interface standard.
[0118] The specific details of the container service network configuration device provided in each embodiment of the present application have been described in detail in the corresponding method embodiment and will not be repeated here.
[0119] Figure 7 The structure block diagram of a computer system for implementing an electronic device according to an embodiment of the present application is schematically shown.
[0120] It should be noted that Figure 7 The computer system 700 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0121] like Figure 7As shown, the computer system 700 includes a central processing unit 701 (CPU), which can perform various appropriate actions and processes according to the program stored in the read-only memory 702 (ROM) or the program loaded from the storage part 708 to the random access memory 703 (RAM). Various programs and data required for system operation are also stored in the random access memory 703. The central processing unit 701, the read-only memory 702 and the random access memory 703 are connected to each other through a bus 704. An input / output interface 705 (Input / Output interface, i.e., I / O interface) is also connected to the bus 704.
[0122] The following components are connected to the input / output interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the input / output interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed so that a computer program read therefrom is installed into the storage section 708 as needed.
[0123] In particular, according to an embodiment of the present application, the process described in each method flow chart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer readable medium, and the computer program contains a program code for executing the method shown in the flow chart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the central processor 701, various functions defined in the system of the present application are executed.
[0124] It should be noted that the computer-readable medium shown in the embodiment of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by an instruction execution system, device or device or used in combination with it. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer readable signal media may also be any computer readable medium other than computer readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0125] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the above-mentioned module, program segment or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0126] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.
[0127] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the implementation methods of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the implementation methods of the present application.
[0128] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary technical means in the art that are not disclosed in the present application.
[0129] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A container service network configuration method, characterized in that: include: When a new container is detected to be created on the host, a container network stack is configured for the container; Configuring a virtual network card corresponding to the physical network card of the host, wherein the virtual network card is a network interface with an independent physical address; Recording the physical address of the virtual network card in the physical network card of the host; Registering a hook function for load balancing service access traffic of the container according to the physical address of the virtual network card; Wherein, registering a hook function for load balancing the service access traffic of the container according to the physical address of the virtual network card includes: Acquire service configuration information of the container network stack according to the physical address of the virtual network card; The service configuration information is converted into a hook function for load balancing the service access traffic of the container through a traffic controller installed in the host.
2. The container service network configuration method according to claim 1, characterized in that: The service configuration information is converted into a hook function for load balancing the service access traffic of the container through a traffic controller installed in the host, including: Writing the service configuration information into a programming language code through a traffic controller installed in the host; The programming language code is converted into a hook function for performing load balancing processing on the service access traffic of the container.
3. The container service network configuration method according to claim 2, characterized in that: Converting the programming language code into a hook function for load balancing the service access traffic of the container includes: Invoking an underlying virtual machine configured in the host to compile the programming language code into Berkeley packet filter instructions; Compiling the Berkeley Packet Filter instructions into bytecodes via an extended Berkeley Packet Filter installed in the host; The bytecode is registered as a hook function for performing load balancing processing on the service access traffic of the container.
4. The container service network configuration method according to claim 3, characterized in that: Compiling the Berkeley packet filter instructions into bytecodes via an extended Berkeley packet filter configured in the host includes: The kernel just-in-time compiler is called through the extended Berkeley packet filter configured in the host, so as to compile the Berkeley packet filter instructions into bytecodes through the kernel just-in-time compiler.
5. The container service network configuration method according to claim 1, characterized in that: Configuring a container network stack for the container includes: A container network interface plug-in is called through an agent node of the container orchestration engine installed on the host, so as to configure a container network stack for the container through the container network interface plug-in.
6. The container service network configuration method according to claim 5, characterized in that: The container network interface plug-in performs data interaction with the proxy node of the container orchestration engine based on the container network interface standard to implement adding network functions and removing network functions in the container network interface standard.
7. A container service network configuration device, characterized in that: include: A network stack configuration module is configured to configure a container network stack for the container when a new container is detected to be created on the host; A virtual network card configuration module, configured to configure a virtual network card corresponding to the physical network card of the host, wherein the virtual network card is a network interface with an independent physical address; An address recording module, configured to record the physical address of the virtual network card in the physical network card of the host; A function registration module, configured to register a hook function for load balancing service access traffic of the container according to the physical address of the virtual network card; Wherein, registering a hook function for load balancing the service access traffic of the container according to the physical address of the virtual network card includes: Acquire service configuration information of the container network stack according to the physical address of the virtual network card; The service configuration information is converted into a hook function for load balancing the service access traffic of the container through a traffic controller installed in the host.
8. A computer-readable medium, characterized in that The computer-readable medium stores a computer program, and when the computer program is executed by a processor, the container service network configuration method according to any one of claims 1 to 6 is implemented.
9. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to enable the electronic device to execute the container service network configuration method according to any one of claims 1 to 6 by executing the executable instructions.
Citation Information
Patent Citations
Flat network configuration method, computer equipment and storage medium
CN111404753A
Container communication method and device, network equipment and storage medium
CN111885075A
Cloud computing container online and offline method and device
CN112911008A
Multi-RDMA network card virtualization method and equipment for realizing load balancing
CN113535370A
Configuring service load balancers with specified backend virtual networks
US20200314015A1
