WO2023098645A1 - 容器网络配置方法、装置、计算节点、主节点及存储介质 - Google Patents

容器网络配置方法、装置、计算节点、主节点及存储介质 Download PDF

Info

Publication number
WO2023098645A1
WO2023098645A1 PCT/CN2022/134903 CN2022134903W WO2023098645A1 WO 2023098645 A1 WO2023098645 A1 WO 2023098645A1 CN 2022134903 W CN2022134903 W CN 2022134903W WO 2023098645 A1 WO2023098645 A1 WO 2023098645A1
Authority
WO
WIPO (PCT)
Prior art keywords
network
target
container
network address
information
Prior art date
Application number
PCT/CN2022/134903
Other languages
English (en)
French (fr)
Inventor
陈飞
Original Assignee
百果园技术(新加坡)有限公司
陈飞
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 百果园技术(新加坡)有限公司, 陈飞 filed Critical 百果园技术(新加坡)有限公司
Publication of WO2023098645A1 publication Critical patent/WO2023098645A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0803Configuration setting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/04Network management architectures or arrangements
    • H04L41/046Network management architectures or arrangements comprising network management agents or mobile agents therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45595Network integration; Enabling network access in virtual machine instances

Definitions

  • the present disclosure relates to the technical field of cloud computing, for example, to a container network configuration method, device, computing node, master node, and computer-readable storage medium.
  • Kubernetes is a container-based cluster management platform.
  • a Kubernetes cluster generally includes a master node (Master) and multiple computing nodes (Nodes) that communicate with the master node.
  • the master node is generally used for management and Control multiple computing nodes, computing nodes as workload nodes, which contain the original application directly deployed in the node and multiple Pods, each Pod is encapsulated with at least one container (Container) for carrying the application, the at least A container shares the network address of its Pod, that is, the Internet Protocol (IP) address and port range.
  • IP Internet Protocol
  • Kubernetes integrates the container network interface (Container Network Interface, CNI) specification, and implements network configuration for containers based on external CNI network plug-ins, such as Calico, Flannel, MacVLAN and other network plug-ins.
  • CNI Container Network Interface
  • the method of implementing container network configuration based on external CNI network plug-ins in related technologies either has the problem of additional network transmission performance loss, or cannot flexibly implement network communication between containers and between containers and physical machines across computer rooms. question.
  • Embodiments of the present disclosure provide a container network configuration method, device, computing node, and storage medium, which can flexibly implement container network configuration without additional loss of performance.
  • a first aspect of the present disclosure provides a method for configuring a container network, which is applied to an agent of any computing node in a Kubernetes cluster, and the method includes:
  • Target container is any container scheduled to run by the master node of the Kubernetes cluster to the computing node;
  • network configuration is performed on the target container based on a preset virtual network device.
  • the second aspect of the present disclosure provides another container network configuration method, which is applied to the master node of the Kubernetes cluster, and the method includes:
  • the target network address is obtained based on preset mapping data, wherein the preset mapping data reflects the correspondence between the computer room and the network segment of the computer room;
  • the target container performs network configuration.
  • a third aspect of the present disclosure provides a container network configuration device, which is applied to an agent of any computing node in a Kubernetes cluster, and the device includes:
  • the request receiving module is configured to receive a network configuration request for a target container, wherein the target container is any container dispatched to the computing node by the master node of the Kubernetes cluster;
  • a request response module configured to generate a network address allocation request, and send the network address allocation request to the master node
  • a network information obtaining module configured to receive a first response message corresponding to the network address allocation request returned by the master node, and obtain target network information corresponding to the target container according to the first response message;
  • the network configuration module is configured to perform network configuration on the target container based on the preset virtual network device according to the target network information.
  • a computing node in a Kubernetes cluster including:
  • a memory configured to store executable instructions
  • a processor configured to execute the computing node to execute the container network configuration method described in the first aspect of the present disclosure under the control of the instruction.
  • a fifth aspect of the present disclosure also provides a master node in a Kubernetes cluster, including:
  • a memory configured to store executable instructions
  • a processor configured to execute the computing node to execute the container network configuration method described in the second aspect of the present disclosure under the control of the instruction.
  • a sixth aspect of the present disclosure further provides a computer-readable storage medium, the computer-readable storage medium stores a computer program that can be read and executed by a computer, and the computer program is set to During operation, the method according to the first aspect or the second aspect of the present disclosure is executed.
  • Fig. 1 is a schematic flowchart of a container network configuration method provided by an embodiment of the present disclosure.
  • FIG. 2 is a schematic diagram of the architecture of a Kubernetes cluster provided by an embodiment of the present disclosure.
  • Fig. 3 is a schematic diagram of network address management based on a bitmap data structure provided by an embodiment of the present disclosure.
  • FIG. 4 is a schematic diagram of a network architecture of containers in computing nodes provided by an embodiment of the present disclosure.
  • Fig. 5 is a schematic flowchart of another container network configuration method provided by an embodiment of the present disclosure.
  • Fig. 6 is a functional block diagram of an apparatus for configuring a container network provided by an embodiment of the present disclosure.
  • FIG. 7 is a schematic diagram of a hardware structure of a computing node in a Kubernetes cluster provided by an embodiment of the present disclosure.
  • FIG. 8 is a schematic diagram of a hardware structure of a master node in a Kubernetes cluster provided by an embodiment of the present disclosure.
  • any set values should be construed as merely exemplary. Therefore, other instances of the exemplary embodiment may have different values.
  • Vxlan Virtual Extended Local Area Network
  • Underlay network refers to the traditional IT infrastructure network, which is composed of network devices such as switches and routers, driven by Ethernet protocols, routing protocols, and virtual local area network (Virtual Local Area Network, VLAN) protocols;
  • Overlay networks is a software-defined network that uses software to create a network abstraction layer, based on the Underlay network.
  • FIG. 1 is a schematic flow chart of a container network configuration method provided by an embodiment of the present disclosure.
  • This method can be applied to a Kubernetes cluster, for example, it can be applied to the agent of any computing node in the Kubernetes cluster, and the agent is responsible for performing network configuration on the target container according to the received network configuration request for the target container, so as to This enables the target container to flexibly communicate with other containers or physical machines.
  • the method of this embodiment may include the following steps S1100-S1400.
  • Step S1100 the agent in the computing node receives a network configuration request for the target container, wherein the computing node is any computing node in the Kubernetes cluster, and the target container is scheduled by the master node of the Kubernetes cluster to any container running on the compute node.
  • the network configuration request is a data request sent by the master node to the agent of the computing node after the target container is dispatched to the computing node.
  • the data request is used to request the agent to configure the network of the target container.
  • the definition of the network can be similar to (IDC, NetworkName, VLANID, GateWay , Subnet) form, wherein, IDC is the computer room identification, NetworkName is the network name, VLANID is the VLAN identification, GateWay refers to the gateway, for example can be 10.10.4.1, Subnet refers to the network segment, for example can be 10.10.4.1/28.
  • FIG. 2 is a schematic structural diagram of a Kubernetes cluster provided by an embodiment of the present disclosure.
  • the Kubernetes cluster provided by the embodiment of the present disclosure includes: a master node (Master) based on a master-slave architecture setting and a plurality of slave nodes (Slave) corresponding to the master node, a plurality of computing nodes (Node) and a cluster A configuration database (Etcd), wherein each computing node includes an agent for network configuration of the container in the node, that is, Agent, and a CNI plug-in for implementing the CNI specification interface, that is, CNI Plugin.
  • Master master node
  • Slave slave nodes
  • Node plurality of computing nodes
  • Etcd configuration database
  • Etcd is a highly available distributed key-value (key-value) database, which is used to save all network configurations and object cluster configuration data of the Kubernetes cluster.
  • the Pod configures the network so that the target container can communicate with other containers and physical machines across network segments and computer rooms.
  • the master node sends the network configuration request for the target container to the corresponding computing node by communicating with the CNI plug-in in the computing node; after receiving the network configuration request, the CNI plug-in in the computing node forwards the network configuration request to The agent of the computing node, which is used to configure the network of the target container.
  • a Pod in a Kubernetes cluster, can usually include multiple containers, but for the convenience of management, usually only one container is configured in a Pod, therefore, in the embodiment of the present disclosure, a Pod A container is included for illustration.
  • the network configuration request sent by the master node to the computing node may include the command type, the container ID used to identify the target container, the target network port name of the network port allocated to the target container, and the name of the target network namespace where the target container is located.
  • Information such as target network namespace information, wherein, a network port is also called a network interface device, and the name of the network port may be, for example, eth0, eth1 and the like.
  • Step S1200 generating a network address allocation request in response to the network configuration request, and sending the network address allocation request to the master node.
  • the agent in the computing node parses the relevant parameters in the network configuration request, for example, can determine the required Configure the network configuration of the target container.
  • the network addresses in multiple computer rooms can be centrally managed by the master node of the Kubernetes cluster, so that the Kubernetes cluster can perform network management down to the IP dimension. Therefore, after step S1100, the agent in the computing node receives the network configuration request sent by the master node, in response to the network configuration request, it can first send a network address acquisition request to the master node to request the master node to allocate a network address for the target container. Address, namely the IP address, and the network information of the network to which the network address belongs.
  • IDC Internet Data Center
  • the generating the network address allocation request includes: obtaining the target container identifier of the target container from the network configuration request; obtaining the computing node ID from the service configuration information stored in the computing node The computer room identifier of the computer room where the node is located; generating the network address assignment request according to the target container identifier and the computer room identifier.
  • the network address allocation request sent by the agent to the master node may include the computer room identifier of the computer room where the computing node is located, and the target container identifier of the target container, that is, may be in the form of (IDC, ContainerID), where the computer room
  • the computer room ID can be obtained through configuration information preset in the computing nodes.
  • the following describes how the master node responds to the network address allocation request after receiving the network address allocation request sent by the agent.
  • the master node of the Kubernetes cluster receives the network address allocation request for the target container sent by the agent in the computing node; and responds to the network address allocation request , based on the preset mapping data, the target network address is obtained, wherein the preset mapping data reflects the corresponding relationship between the computer room and the network segment of the computer room; according to the target network address, a first response message is generated, and the first response message is sent to the agent , so that the agent performs network configuration on the target container based on the preset virtual network device according to the first response message.
  • the obtaining the target network address based on the preset mapping data includes: according to the computer room identifier , obtain the network segment information set corresponding to the computer room, wherein the network segment information set includes the network segment information of all network segments corresponding to the computer room; from the network segment information set, obtain an idle network address in the target network segment as the target network address, wherein, the idle network address is an unallocated network address in the target network segment, and the target network segment is any network segment in the above network segment information set.
  • the master node uses the computer room identification as a key value to centrally manage the network address allocation under different computer rooms, therefore, when receiving the network address allocation request sent by the agent in the computing node, it can be assigned according to the network address The server room ID in the request, and obtain an unallocated free network address under a network segment as the target network address.
  • the relevant information about the network addresses of different network segments in different computer rooms can be pre-configured in Etcd of the Kubernetes cluster by adding the network command.
  • the master node in order to save storage space, when the master node manages network addresses in different computer rooms, it can manage network addresses under a network segment based on a bitmap (bitSet) data structure.
  • bitmap bitmap
  • a 2-byte bitmap may be used to map and represent the network address range.
  • the allocation state of the corresponding network address can be identified according to the bit information in the 16 bits of the 2 bytes.
  • the bit information in the corresponding bit is set to 1, and each time a network address under the network segment is successfully recovered, the bit information in the corresponding bit is set to 0, so as to achieve the effect of convenient management of network addresses.
  • the start IP, index is the index identifier corresponding to each bit, for example, the Start_IP corresponding to the bitmap structure shown in FIG. 3 may be "10.10.4.1", and the index identifier may be in the form of 1, 2, 3....
  • the acquisition of an idle network address in the target network segment includes: Among the multiple bits of the target bitmap corresponding to the target network segment, the corresponding bit information is obtained to indicate that there is an index mark of the target bit of the idle network address; according to the index mark, the above-mentioned idle network address is obtained, and the target bit is The bit information of is set to indicate that the corresponding network address has been allocated.
  • the distribution information of the target network address can be written to Etcd in the form of (ContainerID, NetworkName, IP) with the target container ID as the key value, because the container ID is idempotent Therefore, the allocation information of the network address is saved by using the container ID as the key value, which can prevent the same container from being assigned a second IP.
  • the master node After the master node obtains the target network address, it can generate a first response message corresponding to the above URL assignment request according to the target container ID, computer room ID, the target network address, and the network segment name of the target network segment, and send the The first response message is returned to the agent in the computing node, so that the agent performs network configuration on the target container according to the first response information obtained by the agent and the target network address assigned to the target container in the first response information.
  • step S1300 receive the first response message corresponding to the network address allocation request returned by the master node, and obtain the target network information corresponding to the target container according to the first response message and performing step S1400, performing network configuration on the target container based on the preset virtual network device according to the target network information.
  • the agent by setting the agent in the computing node of the Kubernetes cluster, and based on the agent receiving the network configuration request for the target container scheduled to run in the computing node; after the agent receives the network configuration request, Different from the method of completing the network configuration of the container based on the open source CNI network plug-in in the related technology, in the embodiment of the present disclosure, the agent sends a network address allocation request to the master node, so that the master node that uniformly manages the network addresses of different network segments in all computer rooms Nodes centrally allocate network addresses for target containers; after the agent receives the first response message returned by the master node, it obtains the target network information in the first response message, according to the target network information, based on the preset virtual
  • the network device can flexibly configure the network of the target container in the form of configuration routing, so that the target container can realize network communication across computer rooms, network segments, containers, and physical machines.
  • the performing network configuration on the target container based on the preset virtual network device according to the target network information includes: creating a virtual device interface pair based on the preset virtual network device, wherein the virtual The device interface pair includes a first virtual device interface and a second virtual device interface; according to the target network segment information, configure the network segment to which the first virtual device interface belongs, and connect the configured first virtual device interface to a preset network bridge , where the preset network bridge is created based on the preset virtual multi-layer network switch in the computing node, and the physical network card of the computing node is used as the cascading port; the target physical address corresponding to the target network address is generated, and according to the target physical address, the configuration The physical address information of the second virtual device interface, and according to the target network namespace information, move the configured second virtual device interface to the target network namespace; according to the target network port name, set the network port of the second virtual device interface name, and configure the network address of the second virtual device interface as the target network address and activate the second virtual device interface
  • the network card of each computing node needs to be configured first to support multi-VLAN mode.
  • the network card of the computing node does not directly assign a network address, but uses the VLAN sub-interface to configure the network address of the computing node;
  • the cascading port bond0 realizes external communication, wherein, the network bridge can be created based on a preset virtual multilayer network switch, for example, OVS (Open vSwitch). It should be noted that OVS is a multilayer virtual switch developed in C language.
  • the trunk port can allow multiple VLANs to pass through, can receive and send multiple VLAN messages
  • the trunk port is a communication port between switches or between a switch and an upper-layer device, and is used for a trunk link (trunk link).
  • the preset virtual network device may be a paired virtual network device (Veth-Pair), wherein the Veth-Pair creates two paired virtual device interfaces, and One end is connected to the network protocol stack, and the other end is connected to each other to act as a bridge for network transmission.
  • Veth-Pair paired virtual network device
  • the agent can first create a virtual device interface based on the virtual network device Veth-Pair (the first virtual device interface vport , the second virtual device interface vvport); Afterwards, by activating the first virtual device interface vport and according to the target network port name in the network configuration request, the tag attribute value of the first virtual device interface is set to the target network port name, and The VLAN mode is selected as access to join the bridge created based on the preset virtual multilayer network switch; after that, the maximum transmission unit (Maximum Transmission Unit, MTU) size of the second virtual device interface vvport can be set, And according to the target network address allocated for the target container in the target network information, generate a physical address, that is, a Media Access Control (Media Access Control, mac) address, to configure the physical address of the second virtual device interface, after that, the above-mentioned The configured second virtual device interface is moved to the target network namespace
  • FIG. 4 is a schematic diagram of a network architecture of containers in computing nodes provided by an embodiment of the present disclosure.
  • computing node 1 that is, container 1 and container 2 in Node1, that is, Pod1 and Pod2
  • OVS OVS in Node1
  • the switch includes two different switch ports vlan10 and vlan20; after completing the above pre-configuration, for Pod1 and Pod2 to be network configured, you can create a virtual device interface pair vport11 through Veth-Pair -vport12, and vport21-vport22, through the network addresses assigned to Pod1 and Pod2, for example, 10.15.4.30 and 10.15.8.20, configure vport11 and vport21 and connect them to the OVS bridge, while for vport12 and vport22, You can set its MTU size, set its physical address accordingly, and name it according to the specified network port name, for example, name it eth0, and set its network address to 10.15.4.30 and 10.15.8.20 accordingly, then activate Start the two ports and configure their routing information in the network
  • the method further includes: according to the target container identifier of the target container, the network address of the computing node, the interface information of the first virtual device interface, and the target network address , generating target bridge network port information, and storing the target bridge network port information in the cluster configuration database.
  • the target bridge port information allocated to the target container may be stored in the form of (target container identifier, network address of the computing node, interface information of the first virtual device interface, target network address)
  • the abnormal recovery can be performed in time according to the information of the target bridge network port.
  • the processing completion result can also be returned to the corresponding CNI plug-in, so that the CNI plug-in can output the result to the standard output.
  • the Kubernetes cluster receives the execution result of the network configuration completion of the target container, it can follow the Execute the result and continue to create the container.
  • embodiments of the present disclosure can reclaim the network of the target container through the following steps: when receiving the network configuration deletion request for the target container, generate A network address recovery request, and sending the network address recovery request to the master node; receiving a second response message returned by the master node and corresponding to the network address recovery request; when the second response message indicates that the target network address is successfully recovered , delete the first virtual device interface on the preset network bridge, delete the virtual device interface pair, and delete the aforementioned target bridge network port information in the cluster configuration database.
  • the agent in the computing node when it receives the network configuration deletion request for the target container, it can first send a network address recovery request to the master node with the computer room ID and the target container ID as parameters; the master node After receiving the network address recycling request, the target network address assigned to the container can be found through the target container identifier, and the target network address is mapped back to the corresponding bit of the bitmap data structure storing the network address, and in Set the bit information in the corresponding bit to the unallocated information of the target network address. For example, after setting it to 0, it means that the target network address is successfully reclaimed. After that, the container network information stored in Etcd allocated for the target container can be deleted.
  • the agent when the agent receives the second response message indicating that the target network address has been successfully reclaimed, it can first connect to the preset bridge, such as the OVS bridge, and delete the connection to the bridge. Afterwards, delete the virtual device interface pair created for the target container, and delete the information such as the target bridge network port information corresponding to the target container stored in Etcd, that is, the network for the target container is successfully cleaned up.
  • the preset bridge such as the OVS bridge
  • the agent can return the execution result to the CNI plug-in, so that the CNI plug-in can output to the standard output according to the specification result; after the master node obtains the standard output, it can according to the Execute the status of success or failure to decide whether to proceed to the next step of cleaning up the container or to clean up the network configuration again according to the preset failure retry mechanism.
  • the container network configuration method sends a network address allocation request to the master node by the agent set in the computing node, so that the master node that manages the network addresses of different network segments in all computer rooms in a unified manner Centrally allocate the network address for the target container; after the agent receives the first response message returned by the master node, by obtaining the target network information in the first response message, according to the target network information, based on the preset virtual network device
  • the network configuration of the target container can be flexibly configured in the form of routing, so that the target container can realize network communication across computer rooms, network segments, containers, and physical machines.
  • This method uses the master node in the Kubernetes cluster as the center to manage the network.
  • this method can reduce the coupling of the system and facilitate the iterative upgrade of the system by implementing the Kubernetes CNI specification based on a separate CNI plug-in in all computing nodes.
  • FIG. 5 is a schematic flowchart of another method for configuring a container network provided by an embodiment of the present disclosure.
  • the method can be applied to the master node of the Kubernetes cluster. As shown in FIG. 5 , the method in this embodiment can include the following steps S5100-S5300.
  • Step S5100 the master node of the Kubernetes cluster receives a network address allocation request for the target container sent by the agent in the computing node, wherein the computing node is any computing node in the Kubernetes cluster.
  • Step S5200 in response to the network address assignment request, obtain a target network address based on preset mapping data, wherein the preset mapping data reflects the correspondence between the computer room and the network segment of the computer room.
  • Step S5300 generate a first response message according to the target network address, and send the first response message to the agent, so that the agent can use the first response message based on the preset virtual
  • the network device performs network configuration on the target container.
  • the network address allocation request includes the computer room identifier of the computer room where the computing node is located and the target container identifier of the target container to be configured for the network;
  • the obtaining the target network address based on the preset mapping data includes : According to the computer room identifier, obtain the network segment information set corresponding to the computer room, wherein the network segment information set includes the network segment information of all network segments corresponding to the computer room; from the network segment information set, obtain An idle network address in the target network segment is used as the target network address, wherein the idle network address is an unassigned network address in the target network segment, and the target network segment is an address in the network segment information set. any segment of the network.
  • the master node manages the network addresses under each network segment through a bitmap data structure; the acquisition of an idle network address in the target network segment includes: from the target bit corresponding to the target network segment Among the multiple bits in the figure, obtaining the corresponding bit information indicates that there is an index identification of the target bit of the idle network address; according to the index identification, the idle network address is obtained, and the bit in the target bit is The information is set as information indicating that the corresponding network address has been allocated.
  • the generating the first response message according to the target network address includes: according to the target container identifier, the computer room identifier, the target network address, and the network segment name of the target network segment , generating the response message.
  • a device for configuring a container network is also provided, which can be applied to an agent of any computing node in a Kubernetes cluster.
  • the apparatus 600 may include a request receiving module 610 , a request responding module 620 , a network information obtaining module 630 and a network configuration module 640 .
  • the request receiving module 610 is configured to receive a network configuration request for a target container, wherein the target container is any container scheduled by the master node of the Kubernetes cluster to run on the computing node; the request response module 620, It is configured to generate a network address allocation request, and send the network address allocation request to the master node; the network information obtaining module 630 is configured to receive the first information corresponding to the network address allocation request returned by the master node A response message, and according to the first response message, obtain the target network information corresponding to the target container; the network configuration module 640 is configured to configure the target network based on the preset virtual network device according to the target network information The container configures the network.
  • a computing node in a Kubernetes cluster is also provided.
  • the computing node 700 may also include a processor 720 and a memory 710, and the memory 710 is configured to store executable instructions; the processing The processor 720 is configured to run the computing node according to the control of the instruction to execute the method according to Embodiment 1 of the present disclosure.
  • a master node in a Kubernetes cluster is also provided.
  • the master node 800 may also include a processor 820 and a memory 810, and the memory 810 is configured to store executable instructions; the processing The controller 820 is configured to run the master node according to the control of the instruction to execute the method according to the second embodiment of the present disclosure.
  • a computer-readable storage medium stores a computer program that can be read and run by a computer, and the computer program is set to be When the computer reads and runs, it executes the method described in any of the above embodiments of the present disclosure.
  • each block in a flowchart or block diagram may represent a module, a program segment, or a portion of an instruction that includes at least one executable program for implementing specified logical functions. instruction.
  • the functions noted in the block may occur out of the order noted in the figures. For example, two blocks in succession may, in fact, be executed substantially concurrently, or they may sometimes be executed in the reverse order, depending upon the functionality involved.
  • each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations can be implemented by a dedicated hardware-based system that performs the specified function or action , or may be implemented by a combination of dedicated hardware and computer instructions. It is well known to those skilled in the art that implementation by means of hardware, implementation by means of software, and implementation by a combination of software and hardware are all equivalent.

Abstract

本申请实施例提供了一种容器网络配置方法、装置、计算节点及存储介质,该方法应用于Kubernetes集群的任意一个计算节点的代理端中,包括:接收针对目标容器的网络配置请求;响应于所述网络配置请求,生成网络地址分配请求,并将所述网络地址分配请求发送至主节点;接收所述主节点返回的、与所述网络地址分配请求对应的第一响应消息,并根据所述第一响应消息,获得所述目标容器对应的目标网络信息;根据所述目标网络信息,基于预设的虚拟网络设备对所述目标容器进行网络配置。

Description

容器网络配置方法、装置、计算节点、主节点及存储介质
本公开要求在2021年12月1日提交中国专利局、申请号为202111454884.4的中国专利申请的优先权,以上申请的全部内容通过引用结合在本申请中。
技术领域
本公开涉及云计算技术领域,例如涉及一种容器网络配置方法、装置、计算节点、主节点及计算机可读存储介质。
背景技术
随着云计算的发展,Kubernetes逐渐发展成为用来进行容器编排管理的主力工具。Kubernetes,简称K8S,是一种基于容器的集群管理平台,Kubernetes集群一般包括主节点(Master),以及分别与主节点通信连接的多个计算节点(Node),其中,主节点一般用于管理和控制多个计算节点,计算节点作为工作负载节点,其包含直接部署在节点中的原应用程序和多个Pod,每个Pod中封装有至少一个用于承载应用程序的容器(Container),该至少一个容器共享其所属Pod的网络地址,即网际互连协议(Internet Protocol,IP)地址和端口范围,Pod是Kubernetes的基本操作单元,是最小的可创建、调试和管理的部署单元。
通常,Kubernetes集成容器网络接口(Container Network Interface,CNI)规范,并基于外部CNI网络插件,例如,Calico、Flannel、MacVLAN等网络插件实现针对容器的网络配置。然而,相关技术基于外部CNI网络插件实现容器网络配置的方法或是存在额外网络传输性能损耗的问题,或是存在不能灵活实现容器与容器之间、容器与物理机之间跨机房进行网络通信的问题。
发明内容
本公开实施例提供了一种容器网络配置方法、装置、计算节点及存储介质,可以在不额外损耗性能的情况下灵活的实现容器的网络配置。
本公开的第一方面,提供了一种容器网络配置方法,应用于Kubernetes集群的任意一个计算节点的代理端中,所述方法包括:
接收针对目标容器的网络配置请求,其中,所述目标容器为由所述 Kubernetes集群的主节点调度至所述计算节点运行的任意一容器;
响应于所述网络配置请求,生成网络地址分配请求,并将所述网络地址分配请求发送至所述主节点;
接收所述主节点返回的、与所述网络地址分配请求对应的第一响应消息,并根据所述第一响应消息,获得所述目标容器对应的目标网络信息;
根据所述目标网络信息,基于预设的虚拟网络设备对所述目标容器进行网络配置。
本公开的第二方面,提供了另一种容器网络配置方法,应用于Kubernetes集群的主节点中,所述方法包括:
接收计算节点中的代理端发送的、针对目标容器的网络地址分配请求,其中,所述计算节点为所述Kubernetes集群中的任意一计算节点;
响应于所述网络地址分配请求,基于预设映射数据,获得目标网络地址,其中,所述预设映射数据反映机房与机房网段的对应关系;
根据所述目标网络地址,生成第一响应消息,并将所述第一响应消息发送至所述代理端,以由所述代理端根据所述第一响应消息,基于预设的虚拟网络设备对所述目标容器进行网络配置。
本公开的第三方面,提供了一种容器网络配置装置,应用于Kubernetes集群的任意一个计算节点的代理端中,所述装置包括:
请求接收模块,设置为接收针对目标容器的网络配置请求,其中,所述目标容器为由所述Kubernetes集群的主节点调度至所述计算节点运行的任意一容器;
请求响应模块,设置为生成网络地址分配请求,并将所述网络地址分配请求发送至所述主节点;
网络信息获得模块,设置为接收所述主节点返回的、与所述网络地址分配请求对应的第一响应消息,并根据所述第一响应消息,获得所述目标容器对应的目标网络信息;
网络配置模块,设置为根据所述目标网络信息,基于预设的虚拟网络设备对所述目标容器进行网络配置。
本公开的第四方面,还提供了一种Kubernetes集群中的计算节点,包括:
存储器,设置为存储可执行的指令;
处理器,设置为根据所述指令的控制运行所述计算节点执行本公开的第一方面所述的容器网络配置方法。
本公开的第五方面,还提供了一种Kubernetes集群中的主节点,包括:
存储器,设置为存储可执行的指令;
处理器,设置为根据所述指令的控制运行所述计算节点执行本公开的第二方面所述的容器网络配置方法。
本公开的第六方面,还提供了一种计算机可读存储介质,所述计算机可读存储介质存储有可被计算机读取执行的计算机程序,所述计算机程序设置为在被所述计算机读取运行时,执行根据本公开的第一方面或第二方面所述的方法。
附图说明
图1是本公开实施例提供的一种容器网络配置方法的流程示意图。
图2是本公开实施例提供的Kubernetes集群的架构示意图。
图3是本公开实施例提供的基于位图数据结构管理网络地址的示意图。
图4是本公开实施例提供的计算节点中容器的网络架构示意图。
图5是本公开实施例提供的另一种容器网络配置方法的流程示意图。
图6是本公开实施例提供的一种容器网络配置装置的原理框图。
图7是本公开实施例提供的一种Kubernetes集群中的计算节点的硬件结构示意图。
图8是本公开实施例提供的一种Kubernetes集群中的主节点的硬件结构示意图。
具体实施方式
现在将参照附图来描述本公开的各种示例性实施例。应注意到:除非另外说明,否则在这些实施例中阐述的部件和步骤的相对布置、数字表达式和数值不限制本公开的范围。
以下对至少一个示例性实施例的描述实际上仅仅是说明性的。
对于相关领域普通技术人员已知的技术、方法和设备可能不作讨论,但在 适当情况下,所述技术、方法和设备应当被视为说明书的一部分。
在这里示出和讨论的所有例子中,任何设定值应被解释为仅仅是示例性的。因此,示例性实施例的其他例子可以具有不同的值。
本公开的说明书和权利要求书中的术语“第一”、“第二”等是用于区别类似的对象,而不用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便本公开的实施例能够以除了在这里图示或描述的那些以外的顺序实施。
应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦一项在一个附图中被定义,则在随后的附图中不需要对其进行讨论。
<方法实施例一>
在实际中,企业根据业务和灾备的需要通常会在多个地方规划建设网络,企业的一个业务应用往往需要部署在多个机房,同时由于业务应用对网络延迟较为敏感,所以往往还对网络传输性能的要求较高;另一方面由于业务的服务可能部分部署在物理机中,部分部署在Kubernetes集群的容器中,这就要求容器中部署的服务可以与部署在物理机上的服务直接进行通信。
在相关技术中,为了实现容器与容器之间、容器与物理机之间的跨网段、跨机房通信,一般是基于开源CNI网络插件,例如Calico插件和Flannel插件中的虚拟扩展本地局域网(Visual eXtensible Local Area Network,Vxlan)方式来实现,该种方式基于Overlay网络实现,但是该种方式在传输网络包时,需要在发送端先对网络包进行封包,再在接收端进行解包处理,这存在网络传输性能的损耗;而Calico插件和Flannel插件中基于路由实现网络传输的方式,虽然基于Underlay网络实现,但是存在不能跨网段,进而也不能跨机房进行网络通信的问题;另外,开源MacVLAN插件虽然是基于Underlay网络的实现,但是其基于虚拟网卡实现,存在不灵活且不能针对多机房场景进行网络管理的问题。需要说明的是,Underlay网络,是指传统IT基础设施网络,其由交换机和路由器等网络设备组成,借助以太网协议、路由协议和虚拟局域网(Virtual Local Area Network,VLAN)协议等驱动;Overlay网络,是一种软件定义网络,使用软件创建网络抽象层的方法,基于Underlay网络。
为了使得容器可以跨网段、跨机房灵活的进行网络通信,本公开的实施例提供了一种容器网络配置方法,请参看图1,其是本公开实施例提供的容器网络配置方法流程示意图,该方法可以应用于Kubernetes集群中,例如可以应用于Kubernetes集群的任意一个计算节点的代理端中,该代理端负责根据接收到的、针对目标容器的网络配置请求,对目标容器进行网络配置,以使得该目标容器可以灵活的与其他容器或物理机进行通信。
如图1所述,本实施例的方法可以包括如下步骤S1100-S1400。
步骤S1100,计算节点中的代理端接收针对目标容器的网络配置请求,其中,所述计算节点为所述Kubernetes集群中的任意一计算节点,所述目标容器为由所述Kubernetes集群的主节点调度至所述计算节点运行的任意一容器。
网络配置请求,是在目标容器被调度到计算节点之后,由主节点发送至该计算节点的代理端的数据请求,该数据请求用于请求代理端对目标容器进行网络配置。
另外,由于该方法是针对可能处于不同机房内的容器进行网络配置,因此,为了唯一性的标识一个网络,在本公开的实施例中,网络的定义可以为类似(IDC,NetworkName,VLANID,GateWay,Subnet)的形式,其中,IDC为机房标识,NetworkName为网络名称,VLANID为VLAN标识,GateWay是指网关,例如可以为10.10.4.1,Subnet是指网段,例如可以为10.10.4.1/28。
为便于理解,请参看图2,其是本公开实施例提供的Kubernetes集群的架构示意图。如图2所示,本公开实施例提供的Kubernetes集群包括:基于主从架构设置的主节点(Master)和与主节点对应的多个从节点(Slave),多个计算节点(Node)以及集群配置数据库(Etcd),其中,每一计算节点中包括用于对该节点中的容器进行网络配置的代理端,即Agent,以及用于实现CNI规范接口的CNI插件,即CNI Plugin。
需要说明的是,Etcd,是一个高可用的分布式键值(key-value)数据库,用于保存Kubernetes集群所有的网络配置和对象的集群配置数据。
另外,以计算节点运行与Unix操作系统为例,在为每一个计算节点配置如图2所示的CNI插件时,可以通过在/etc/CNI/net.d目录下创建CNI配置文件,并把CNI插件的可执行文件放在/opt/CNI/bin/目录下完成对该CNI插件的配置。
在一个实施例中,在Kubernets创建目标容器并将目标容器调度到一计算节点之后,由于目标容器共享其所属Pod的网络地址,因此,在本公开的实施例中,可以通过对目标容器所属的Pod进行网络配置,使得目标容器可以跨网段、跨机房与其他容器、物理机进行通信。
即,主节点通过与计算节点中的CNI插件通信,将针对目标容器的网络配置请求发送至对应计算节点;计算节点中的CNI插件在接收到该网络配置请求之后,将该网络配置请求转发至计算节点的代理端,以由该代理端对目标容器进行网络配置。
需要说明的是,在Kubernetes集群中,一个Pod中通常可以包括多个容器,但是,为方便管理,通常仅在一个Pod中配置一个容器,因此,在本公开的实施例中,以一个Pod中包含一个容器进行举例说明。
另外,主节点发送至计算节点的网络配置请求可以包含命令类型、用于标识目标容器的容器标识、为目标容器分配的网口的目标网口名称,以及目标容器所处的目标网络命名空间的目标网络命名空间信息等信息,其中,网口,又 称网络接口设备,网口名称例如可以为eth0、eth1等名称。
步骤S1200,响应于所述网络配置请求,生成网络地址分配请求,并将所述网络地址分配请求发送至所述主节点。
可选地,计算节点中的代理端在接收到CNI插件转发的网络配置请求之后,通过解析该网络配置请求中的相关参数,例如,可以根据网络配置请求中的命令类型以及容器标识,确定需要对目标容器进行网络配置。
区别于相关技术的每个互联网数据中心(Internet Data Center,IDC),也即机房通过网络设备单独管理其多个网段,即多个VLANID下的网络地址的方式,在本公开的实施例中,可以由Kubernetes集群的主节点集中管理多个机房中的网络地址,以使得Kubernetes集群可以精细到IP维度进行网络管理。因此,在经过步骤S1100计算节点中的代理端接收到主节点发送的网络配置请求之后,响应于该网络配置请求,可以先向主节点发送网络地址获取请求,以请求主节点为目标容器分配网络地址,即IP地址,以及该网络地址所属的网络的网络信息。
在一个实施例中,所述生成网络地址分配请求,包括:从所述网络配置请求中,获得所述目标容器的目标容器标识;从所述计算节点存储的服务配置信息中,获取所述计算节点所处机房的机房标识;根据所述目标容器标识和所述机房标识,生成所述网络地址分配请求。
即,代理端发送至主节点的网络地址分配请求可以包括该计算节点所处机房的机房标识,以及该目标容器的目标容器标识,即,可以为(IDC,ContainerID)的形式,其中,机房的机房标识可以通过预先设置在计算节点中的配置信息获得。
以下对主节点在接收到代理端发送的网络地址分配请求之后,如何响应该网络地址分配请求进行说明。
在一个实施例中,在代理端向主节点发送网络地址分配请求之后,Kubernetes集群的主节点接收计算节点中的代理端发送的、针对目标容器的网络地址分配请求;响应于该网络地址分配请求,基于预设映射数据,获得目标网络地址,其中,该预设映射数据反映机房与机房网段的对应关系;根据目标网络地址,生成第一响应消息,并将第一响应消息发送至代理端,以由该代理端根据该第一响应消息,基于预设的虚拟网络设备对该目标容器进行网络配置。
在一个实施例中,在该网络地址分配请求包括计算节点所处机房的机房标识和目标容器的目标容器标识的情况下,所述基于预设映射数据,获得目标网络地址,包括:根据机房标识,获得机房对应的网段信息集合,其中,网段信息集合包括机房对应的全部网段的网段信息;从网段信息集合中,获取目标网段中的一个空闲网络地址作为目标网络地址,其中,该空闲网络地址为目标网段中未被分配的网络地址,目标网段为上述网段信息集合中的任意一网段。
即,由于主节点通过机房标识为键值,集中管理不同机房下的网络地址分 配情况,因此,在接收到计算节点中的代理端发送的网络地址分配请求的情况下,可以根据该网络地址分配请求中的机房标识,获取一网段下未分配的空闲网络地址作为目标网络地址。需要说明的是,不同机房下不同网段的网络地址的相关信息可以通过添加网络命令预先配置在Kubernetes集群的Etcd中。
另外,在本公开的实施例中,为了节省存储空间,主节点在管理不同机房中的网络地址时,可以基于位图(bitSet)数据结构管理一网段下的网络地址。
例如,针对网段10.10.4.1/28,其表示的网络地址范围为10.10.4.1-10.10.4.16,则可以使用一2字节的位图来映射表示该网络地址范围。如图3所示,可以根据该2字节的16个比特位中的比特信息来标识对应网络地址的分配状态。
例如,可以在图3中索引标识为1的比特中的数值为1的情况下,表示该比特位对应的网络地址已分配;这样,通过每次将该网段下的网络地址分配出去一个,即将对应比特位中的比特信息置为1,每次将该网段下的网络地址成功回收一个,即将对应比特位中的比特信息置为0的方式,实现便捷管理网络地址的效果。需要说明的是,在基于该位图数据结构管理网络地址时,比特位映射IP的公式可以为:Dec_IP=Start_IP+index-1,Dec_IP指待映射获取的IP,Start_IP为对应位图结构所表示的起始IP,index为每一比特位对应的索引标识,例如,图3所示的位图结构对应的Start_IP可以为“10.10.4.1”,索引标识可以为1、2、3…的形式。
根据以上说明可知,在本公开的实施例中,主节点在通过位图数据结构管理每一网段下的网络地址的情况下,所述获取目标网段中的一个空闲网络地址,包括:从目标网段对应的目标位图的多个比特位中,获取对应比特信息表示存在空闲网络地址的目标比特位的索引标识;根据该索引标识,获得上述空闲网络地址,并将该目标比特位中的比特信息设置为表示对应网络地址已被分配的信息。
另外,在主节点获得目标网络地址之后,可以以目标容器标识为键值,将该目标网络地址的分配信息以(ContainerID,NetworkName,IP)的形式写入至Etcd,由于容器的标识作为幂等性设计,因此以容器标识作为键值保存该网络地址的分配信息,可以防止同样的容器被分配二次IP的情况出现。
主节点在获得目标网络地址之后,可以根据该目标容器标识、机房标识、该目标网络地址和该目标网段的网段名称等信息,生成对应上述网址分配请求的第一响应消息,并将该第一响应消息返回至计算节点中的代理端,以由代理端根据通过获取该第一响应信息,并根据该第一响应信息中为目标容器分配的目标网络地址,对目标容器进行网络配置。
在步骤S1200之后,执行步骤S1300,接收所述主节点返回的、与所述网络地址分配请求对应的第一响应消息,并根据所述第一响应消息,获得所述目标容器对应的目标网络信息;以及执行步骤S1400,根据所述目标网络信息,基于预设的虚拟网络设备对所述目标容器进行网络配置。
在一实施例中,通过在Kubernetes集群的计算节点中设置代理端,并基于代理端接收针对调度至该计算节点中运行的目标容器的网络配置请求;在代理端接收到该网络配置请求之后,区别于相关技术基于开源CNI网络插件完成容器的网络配置的方法,本公开的实施例由该代理端向主节点发送网络地址分配请求,以由统一管理所有机房中不同网段的网络地址的主节点集中的为目标容器分配网络地址;在该代理端接收到主节点返回的第一响应消息之后,通过获取该第一响应消息中的目标网络信息,根据该目标网络信息,基于预设的虚拟网络设备可以以配置路由的形式灵活的对目标容器进行网络配置,以使得目标容器可以实现跨机房、跨网段、跨容器以及跨物理机的进行网络通信。
在一个实施例中,所述根据所述目标网络信息,基于预设的虚拟网络设备对所述目标容器进行网络配置,包括:基于预设的虚拟网络设备,创建虚拟设备接口对,其中,虚拟设备接口对包括第一虚拟设备接口和第二虚拟设备接口;根据目标网段信息,配置第一虚拟设备接口所属的网段,并将完成配置的第一虚拟设备接口连接至预设的网桥,其中,预设的网桥基于计算节点中预设的虚拟多层网络交换机创建,且以计算节点的物理网卡作为级联端口;生成目标网络地址对应的目标物理地址,根据目标物理地址,配置第二虚拟设备接口的物理地址信息,并根据目标网络命名空间信息,将完成配置的第二虚拟设备接口移动至目标网络命名空间中;根据目标网口名称,设置第二虚拟设备接口的网口名,以及,配置第二虚拟设备接口的网络地址为目标网络地址并激活第二虚拟设备接口;通过在目标网络命名空间中配置目标容器的默认路由网关为该网段对应的网关,完成针对目标容器的网络配置。
需要说明的是,在执行上述处理之前,需要先对物理硬件进行一些预先设置。例如,需要先对每一计算节点的网卡进行配置,以将其配置为支持多VLAN模式,计算节点的网卡不直接分配网络地址,而是使用VLAN子接口的方式配置该计算节点的网络地址;另外,如果计算节点中存在多个网卡,则需要将该多个网卡设置为绑定(bond)模式,例如,假设计算节点中存在eth0和eth1两个物理网卡,则可以创建虚拟网卡bond0绑定eth0和eth1,同时,不为bond0分配网络地址,而是通过创建bond0.xxxVLAN子接口的方式用作该计算节点通信的网络地址,而将bond0配置为该计算节点的网桥的上联端口,也即级联端口,使得在对容器进行网络配置时,可以通过创建虚拟网络接口对,并将虚拟网络接口对中的其中一个虚拟网络接口连接至该网桥的方式,以基于该网桥的级联端口bond0实现对外通信,其中,该网桥可以基于预设的的虚拟多层网络交换机,例如,OVS(Open vSwitch)创建。需要说明的是,OVS是一个用C语言开发的多层虚拟交换机。
另外,还需要预先对每一机房的网络网段预先做好VLAN划分和配置,例如,针对一个待分配网段,配置好对应VLANID和网关出口,并且,物理机使用trunk端口连接交换机。其中,trunk端口,可以允许多个VLAN通过,可以接收和发送多个VLAN报文,trunk端口是交换机之间或者交换机和上层设备之间的通信端口, 用于干道链路(trunk link)。
在本公开的实施例中,该预设的虚拟网络设备可以为一种成对出现的虚拟网络设备(Veth-Pair),其中,Veth-Pair通过创建两个成对的虚拟设备接口,并将一端与网络协议栈连接,另一端彼此相连的方式,以充当网络传输的桥梁。
在一个实施例中,代理端在根据主节点返回的第一响应消息,获得包含目标网络地址的目标网络信息之后,可以先基于虚拟网络设备Veth-Pair创建虚拟设备接口(第一虚拟设备接口vport,第二虚拟设备接口vvport);之后,通过激活第一虚拟设备接口vport并根据网络配置请求中的目标网口名称,设置第一虚拟设备接口的tag属性值为该目标网口名称,并将VLAN模式选择为访问(access)以加入到基于预设的虚拟多层网络交换机创建的网桥上;之后,可以设置第二虚拟设备接口vvport的最大传输单元(Maximum Transmission Unit,MTU)的大小,并根据目标网络信息中为该目标容器分配的目标网络地址,生成一物理地址,即媒体访问控制(Media Access Control,mac)地址,以配置第二虚拟设备接口的物理地址,之后,将完成上述配置的第二虚拟设备接口移动至目标容器所在的目标网络命名空间,并设置第二虚拟设备接口的接口名为网络配置请求中指定的目标网口名称,再设置该第二虚拟设备接口的网络地址为目标网络地址并激活启动该第二虚拟设备接口;之后,通过到目标容器所处的网络命名空间中配置容器路由,并设置默认网关为目标网段信息所表示的网段对应的网关即可完成对目标容器的网络配置。
为便于理解上述配置,请参看图4,其是本公开实施例提供的计算节点中容器的网络架构示意图。如图4所示,针对计算节点1,即Node1中的容器1和容器2,即Pod1和Pod2,在对其进行网络配置之前,可以先在Node1中基于OVS创建虚拟交换机,也即网桥,以及,通过对Node1中的多个网卡进行绑定,并将绑定得到的虚拟网卡bond0作为该网桥的级联端口,即uplink port;同时,预先对Node1所处的机房中的网段进行划分和配置,并连接物理交换机,交换机包括vlan10和vlan20两个不同的交换机端口;在完成上述预先配置之后,针对待进行网络配置的Pod1和Pod2,可以通过Veth-Pair分别创建虚拟设备接口对vport11-vport12,以及vport21-vport22,通过分别为Pod1和Pod2分配的网络地址例如,10.15.4.30和10.15.8.20,对vport11和vport21进行配置并将其连接至OVS网桥上,而针对vport12和vport22,可以通过分别设置其MTU大小,以及对应设置其物理地址、根据指定的网口名称分别对其命名,例如,均命名为eth0,并对应设置其网络地址为10.15.4.30和10.15.8.20之后,激活启动该两个端口,并对应配置其在网络命名空间中的路由信息,即可完成对Pod1和Pod2的网络配置,使得Pod1和Pod2之间不仅可以跨网段进行通信,还可以跨机房与其他容器或物理机进行通信。
另外,在代理端完成上述网络配置之后,该方法还包括:根据所述目标容器的目标容器标识、所述计算节点的网络地址、所述第一虚拟设备接口的接口信息和所述目标网络地址,生成目标网桥网口信息,并将所述目标网桥网口信息存储至集群配置数据库中。
在本公开的实施例中,可以将为目标容器分配的目标网桥网口信息以(目标容器标识,计算节点的网络地址,第一虚拟设备接口的接口信息,目标网络地址)的形式保存在Etcd中,以便于在目标容器出现异常或者网络出现异常的情况下,可以根据该目标网桥网口信息及时进行异常恢复。此外,在完成上述网络配置之后,还可以将处理完成结果返回对应CNI插件,以由CNI插件将结果输出至标准输出,Kubernetes集群在接收到目标容器的网络配置完成的执行结果之后,可以根据该执行结果,继续执行容器的创建工作。
在完成针对目标容器的网络配置之后,在需要删除容器时,本公开的实施例可以通过以下步骤对该目标容器的网络进行回收:在接收到针对目标容器的网络配置删除请求的情况下,生成网络地址回收请求,并将所述网络地址回收请求发送至主节点;接收主节点返回的、与网络地址回收请求对应的第二响应消息;在第二响应消息表示成功回收目标网络地址的情况下,删除预设的网桥上的第一虚拟设备接口,删除虚拟设备接口对,以及,删除集群配置数据库中的上述目标网桥网口信息。
在一个实施例中,计算节点中的代理端在接收到针对目标容器的网络配置删除请求的情况下,可以先以机房标识、目标容器标识作为参数,向主节点发送网络地址回收请求;主节点在接收到该网络地址回收请求之后,可以通过目标容器标识,查找为该容器分配的目标网络地址,通过将该目标网络地址映射回存储该网络地址的位图数据结构的对应比特位,并在将该对应比特位中的比特信息设置为目标网络地址未分配的信息,例如设置为0之后,表示成功回收该目标网络地址,之后,可以删除Etcd中存储的为目标容器分配的容器网络信息,并将网段信息以类似(IDC,NetworkName,VLANID,Gateway,Subnet)的形式回写至Etcd;再之后,将表示成功回收网络地址的第二响应消息返回至该代理端;以由代理端继续在本地执行针对目标容器的网络配置删除处理。
在本公开的实施例中,代理端在接收到的第二响应消息表示成功回收目标网络地址的情况下,可以先连接预设的网桥,例如OVS网桥,并删除连接至该网桥上的第一虚拟设备接口,之后,删除为该目标容器创建的虚拟设备接口对,以及删除Etcd中存储的对应该目标容器的目标网桥网口信息等信息,即成功清理掉针对目标容器的网络配置,在完成上述清理处理之后,代理端可以将执行结果返回至对于CNI插件,以由该CNI插件根据规范结果输出至标准输出;主节点在获取到该标准输出之后,可以根据其所表示的执行成功或失败状态,决定是否进行下一步清理容器的工作或者根据预设失败重试机制,再次进行网络配置清理处理。
综上可知,本公开实施例提供的容器网络配置方法,通过由设置在计算节点中的代理端向主节点发送网络地址分配请求,以由统一管理所有机房中不同网段的网络地址的主节点集中的为目标容器分配网络地址;在代理端接收到主节点返回的第一响应消息之后,通过获取该第一响应消息中的目标网络信息,根据该目标网络信息,基于预设的虚拟网络设备可以以配置路由的形式灵活的 对目标容器进行网络配置,以使得目标容器可以实现跨机房、跨网段、跨容器以及跨物理机的进行网络通信。该方法通过以Kubernetes集群中的主节点为中心管理网络,相对相关技术可以精细到IP维度管理,以达到按需分配不浪费IP地址的效果;同时通过以机房为维度管理多个网络,可以允许不同机房之间VLANID相同,以减少VLAN号(只能在1-4096)可能存在的不足问题。另外,通过设置在计算节点中的代理端读取本机的机房信息并结合主节点的机房网段管理,能够准确的将不同机房不同网段进行正确的分配。此外,该方法通过在所有计算节点中均基于单独的CNI插件实现Kubernetes CNI规范的方式,可以降低系统的耦合性,便于系统的迭代升级。
<方法实施例二>
与上述方法实施例一相对应,在本实施例中,还提供另一种容器网络配置方法,请参看图5,其是本公开实施例提供的另一种容器网络配置方法的流程示意图。该方法可以应用于Kubernetes集群的主节点中,如图5所示,本实施例的方法可以包括如下步骤S5100-S5300。
步骤S5100,所述Kubernetes集群的主节点接收计算节点中的代理端发送的、针对目标容器的网络地址分配请求,其中,所述计算节点为所述Kubernetes集群中的任意一计算节点。
步骤S5200,响应于所述网络地址分配请求,基于预设映射数据,获得目标网络地址,其中,所述预设映射数据反映机房与机房网段的对应关系。
步骤S5300,根据所述目标网络地址,生成第一响应消息,并将所述第一响应消息发送至所述代理端,以由所述代理端根据所述第一响应消息,基于预设的虚拟网络设备对所述目标容器进行网络配置。
在一个实施例中,所述网络地址分配请求包括所述计算节点所处机房的机房标识和待进行网络配置的目标容器的目标容器标识;所述基于预设映射数据,获得目标网络地址,包括:根据所述机房标识,获得所述机房对应的网段信息集合,其中,所述网段信息集合包括所述机房对应的全部网段的网段信息;从所述网段信息集合中,获取目标网段中的一个空闲网络地址作为所述目标网络地址,其中,所述空闲网络地址为所述目标网段中未被分配的网络地址,所述目标网段为所述网段信息集合中的任意一网段。
在一个实施例中,所述主节点通过位图数据结构管理每一网段下的网络地址;所述获取目标网段中的一个空闲网络地址,包括:从所述目标网段对应的目标位图的多个比特位中,获取对应比特信息表示存在所述空闲网络地址的目标比特位的索引标识;根据所述索引标识,获得所述空闲网络地址,并将所述目标比特位中的比特信息设置为表示对应网络地址已被分配的信息。
在一个实施例中,所述根据所述目标网络地址,生成第一响应消息,包括: 根据所述目标容器标识、所述机房标识、所述目标网络地址和所述目标网段的网段名称,生成所述响应消息。
<装置实施例>
与上述方法实施例一相对应,在本实施例中,还提供一种容器网络配置装置,可以应用于Kubernetes集群的任意一个计算节点的代理端中。如图6所述,该装置600可以包括请求接收模块610、请求响应模块620、网络信息获得模块630和网络配置模块640。
该请求接收模块610,设置为接收针对目标容器的网络配置请求,其中,所述目标容器为由所述Kubernetes集群的主节点调度至所述计算节点运行的任意一容器;该请求响应模块620,设置为生成网络地址分配请求,并将所述网络地址分配请求发送至所述主节点;该网络信息获得模块630,设置为接收所述主节点返回的、与所述网络地址分配请求对应的第一响应消息,并根据所述第一响应消息,获得所述目标容器对应的目标网络信息;该网络配置模块640,设置为根据所述目标网络信息,基于预设的虚拟网络设备对所述目标容器进行网络配置。
<设备实施例一>
在本实施例中,还提供一种Kubernetes集群中的计算节点,如图7所述,该计算节点700还可以包括处理器720和存储器710,该存储器710设置为存储可执行的指令;该处理器720设置为根据指令的控制运行计算节点以执行根据本公开实施例一所述的方法。
<设备实施例二>
在本实施例中,还提供一种Kubernetes集群中的主节点,如图8所述,该主节点800还可以包括处理器820和存储器810,该存储器810设置为存储可执行的指令;该处理器820设置为根据指令的控制运行主节点以执行根据本公开实施例二所述的方法。
<介质实施例>
与上述方法实施例对应,在本实施例中,还提供一种计算机可读存储介质,该计算机可读存储介质存储有可被计算机读取并运行的计算机程序,所述计算机程序设置为在被所述计算机读取运行时,执行如本公开以上任意实施例所述的方法。
附图中的流程图和框图显示了根据本公开的多个实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段或指令的一部分,所述模块、程序段或指令的一部分包含至少一个用于实现规定的逻辑功能的可执行指令。在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个连续的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或动作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。对于本领域技术人员来说公知的是,通过硬件方式实现、通过软件方式实现以及通过软件和硬件结合的方式实现都是等价的。

Claims (13)

  1. 一种容器网络配置方法,应用于Kubernetes集群的任意一个计算节点的代理端中,所述方法包括:
    接收针对目标容器的网络配置请求,其中,所述目标容器为由所述Kubernetes集群的主节点调度至所述计算节点运行的任意一容器;
    响应于所述网络配置请求,生成网络地址分配请求,并将所述网络地址分配请求发送至所述主节点;
    接收所述主节点返回的、与所述网络地址分配请求对应的第一响应消息,并根据所述第一响应消息,获得所述目标容器对应的目标网络信息;
    根据所述目标网络信息,基于预设的虚拟网络设备对所述目标容器进行网络配置。
  2. 根据权利要求1所述的方法,其中,所述网络配置请求中包括所述目标容器对应的目标网口名称和所述目标容器所处的目标网络命名空间的目标网络命名空间信息,所述目标网络信息包括为所述目标容器分配的目标网络地址和表示所述目标网络地址所处网段的目标网段信息;
    所述根据所述目标网络信息,基于预设的虚拟网络设备对所述目标容器进行网络配置,包括:
    基于所述预设的虚拟网络设备,创建虚拟设备接口对,其中,所述虚拟设备接口对包括第一虚拟设备接口和第二虚拟设备接口;
    根据所述目标网段信息,配置所述第一虚拟设备接口所属的网段,并将完成所述配置的第一虚拟设备接口连接至预设的网桥,其中,所述预设的网桥基于所述计算节点中预设的虚拟多层网络交换机创建,且以所述计算节点的物理 网卡作为级联端口;
    生成所述目标网络地址对应的目标物理地址,根据所述目标物理地址,配置所述第二虚拟设备接口的物理地址信息,并根据所述目标网络命名空间信息,将完成所述配置的第二虚拟设备接口移动至所述目标网络命名空间中;
    根据所述目标网口名称,设置所述第二虚拟设备接口的网口名,以及,配置所述第二虚拟设备接口的网络地址为所述目标网络地址并激活启动所述第二虚拟设备接口;
    通过在所述目标网络命名空间中配置所述目标容器的默认路由网关为所述网段对应的网关,完成所述网络配置。
  3. 根据权利要求2所述的方法,在完成所述网络配置之后,所述方法还包括:
    根据所述目标容器的目标容器标识、所述计算节点的网络地址、所述第一虚拟设备接口的接口信息和所述目标网络地址,生成目标网桥网口信息,并将所述目标网桥网口信息存储至集群配置数据库中。
  4. 根据权利要求3所述的方法,在完成所述网络配置之后,所述方法还包括:
    在接收到针对目标容器的网络配置删除请求的情况下,生成网络地址回收请求,并将所述网络地址回收请求发送至所述主节点;
    接收所述主节点返回的、与所述网络地址回收请求对应的第二响应消息;
    在所述第二响应消息表示成功回收所述目标网络地址的情况下,删除所述预设的网桥上的所述第一虚拟设备接口,删除所述虚拟设备接口对,以及,删 除所述集群配置数据库中的所述目标网桥网口信息。
  5. 根据权利要求1所述的方法,其中,所述生成网络地址分配请求,包括:
    从所述网络配置请求中,获得所述目标容器的目标容器标识;
    从所述计算节点存储的服务配置信息中,获取所述计算节点所处机房的机房标识;
    根据所述目标容器标识和所述机房标识,生成所述网络地址分配请求。
  6. 一种容器网络配置方法,应用于Kubernetes集群的主节点中,所述方法包括:
    接收计算节点中的代理端发送的、针对目标容器的网络地址分配请求,其中,所述计算节点为所述Kubernetes集群中的任意一计算节点;
    响应于所述网络地址分配请求,基于预设映射数据,获得目标网络地址,其中,所述预设映射数据反映机房与机房网段的对应关系;
    根据所述目标网络地址,生成第一响应消息,并将所述第一响应消息发送至所述代理端,以由所述代理端根据所述第一响应消息,基于预设的虚拟网络设备对所述目标容器进行网络配置。
  7. 根据权利要求6所述的方法,其中,所述网络地址分配请求包括所述计算节点所处机房的机房标识和待进行网络配置的目标容器的目标容器标识;
    所述基于预设映射数据,获得目标网络地址,包括:
    根据所述机房标识,获得所述机房对应的网段信息集合,其中,所述网段信息集合包括所述机房对应的全部网段的网段信息;
    从所述网段信息集合中,获取目标网段中的一个空闲网络地址作为所述目 标网络地址,其中,所述空闲网络地址为所述目标网段中未被分配的网络地址,所述目标网段为所述网段信息集合中的任意一网段。
  8. 根据权利要求7所述的方法,其中,所述主节点通过位图数据结构管理每一网段下的网络地址;
    所述获取目标网段中的一个空闲网络地址,包括:
    从所述目标网段对应的目标位图的多个比特位中,获取对应比特信息表示存在所述空闲网络地址的目标比特位的索引标识;
    根据所述索引标识,获得所述空闲网络地址,并将所述目标比特位中的比特信息设置为表示对应网络地址已被分配的信息。
  9. 根据权利要求7所述的方法,其中,所述根据所述目标网络地址,生成第一响应消息,包括:
    根据所述目标容器标识、所述机房标识、所述目标网络地址和所述目标网段的网段名称,生成所述第一响应消息。
  10. 一种容器网络配置装置,应用于Kubernetes集群的任意一个计算节点的代理端中,所述装置包括:
    请求接收模块,设置为接收针对目标容器的网络配置请求,其中,所述目标容器为由所述Kubernetes集群的主节点调度至所述计算节点运行的任意一容器;
    请求响应模块,设置为生成网络地址分配请求,并将所述网络地址分配请求发送至所述主节点;
    网络信息获得模块,设置为接收所述主节点返回的、与所述网络地址分配 请求对应的第一响应消息,并根据所述第一响应消息,获得所述目标容器对应的目标网络信息;
    网络配置模块,设置为根据所述目标网络信息,基于预设的虚拟网络设备对所述目标容器进行网络配置。
  11. 一种Kubernetes集群中的计算节点,包括:
    存储器,设置为存储可执行的指令;
    处理器,设置为根据所述指令的控制运行所述计算节点执行如权利要求1-5任意一项所述的方法。
  12. 一种Kubernetes集群中的主节点,包括:
    存储器,设置为存储可执行的指令;
    处理器,设置为根据所述指令的控制运行所述主节点执行如权利要求6-9任意一项所述的方法。
  13. 一种计算机可读存储介质,所述计算机可读存储介质存储有可被计算机读取执行的计算机程序,所述计算机程序设置为在被所述计算机读取运行时,执行根据权利要求1-9中任意一项所述的方法。
PCT/CN2022/134903 2021-12-01 2022-11-29 容器网络配置方法、装置、计算节点、主节点及存储介质 WO2023098645A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111454884.4A CN114172802B (zh) 2021-12-01 2021-12-01 容器网络配置方法、装置、计算节点、主节点及存储介质
CN202111454884.4 2021-12-01

Publications (1)

Publication Number Publication Date
WO2023098645A1 true WO2023098645A1 (zh) 2023-06-08

Family

ID=80482117

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/134903 WO2023098645A1 (zh) 2021-12-01 2022-11-29 容器网络配置方法、装置、计算节点、主节点及存储介质

Country Status (2)

Country Link
CN (1) CN114172802B (zh)
WO (1) WO2023098645A1 (zh)

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114172802B (zh) * 2021-12-01 2024-04-26 百果园技术(新加坡)有限公司 容器网络配置方法、装置、计算节点、主节点及存储介质
CN114844745B (zh) * 2022-03-29 2024-03-15 西安广和通无线软件有限公司 数据转发装置、方法、电子设备及存储介质
CN114760254B (zh) * 2022-04-15 2023-04-07 北京志凌海纳科技有限公司 虚拟网络系统及虚拟网络系统实现数据包转发处理方法
CN115086166B (zh) * 2022-05-19 2024-03-08 阿里巴巴(中国)有限公司 计算系统、容器网络配置方法及存储介质
CN115225482B (zh) * 2022-06-10 2023-10-20 中电云数智科技有限公司 一种基于Kubernetes进行Pod容器网络配置的方法及装置
CN115189948B (zh) * 2022-07-11 2023-05-12 北京志凌海纳科技有限公司 一种CaaS平台中容器网络插件的实现方法和系统
CN115277864B (zh) * 2022-07-27 2024-01-26 海通证券股份有限公司 路由确定方法及装置、计算机可读存储介质、终端
CN115987778B (zh) * 2022-12-23 2024-02-02 安超云软件有限公司 一种基于Kubernetes集群的容器通信方法
CN115801733A (zh) * 2023-02-02 2023-03-14 天翼云科技有限公司 一种网络地址分配方法、装置、电子设备及可读介质
CN116132435B (zh) * 2023-02-17 2023-09-01 成都道客数字科技有限公司 一种容器云平台的双栈跨节点通信方法和系统
CN116192937B (zh) * 2023-04-24 2023-07-11 明阳时创(北京)科技有限公司 一种Kubernetes集群系统中Service实现方法、系统、介质及设备
CN116319322B (zh) * 2023-05-16 2023-09-12 北京国电通网络技术有限公司 电力设备节点通信连接方法、装置、设备和计算机介质

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108829384A (zh) * 2018-06-13 2018-11-16 平安科技(深圳)有限公司 容器的管理方法、装置、计算机设备及存储介质
CN109587281A (zh) * 2017-09-29 2019-04-05 华为技术有限公司 容器配置方法和计算节点
CN111800523A (zh) * 2020-06-30 2020-10-20 北京金山云网络技术有限公司 虚拟机网络的管理方法、数据处理方法及系统
CN111796905A (zh) * 2020-05-22 2020-10-20 浙商银行股份有限公司 一种kubernetes容器云平台VLAN网络的实现方法及系统
CN112187671A (zh) * 2020-11-05 2021-01-05 北京金山云网络技术有限公司 一种网络接入方法及其相关设备
US20210352044A1 (en) * 2020-05-08 2021-11-11 Ribbon Communications Operating Company, Inc. Networking as a Service
CN114172802A (zh) * 2021-12-01 2022-03-11 百果园技术(新加坡)有限公司 容器网络配置方法、装置、计算节点、主节点及存储介质

Family Cites Families (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10892942B2 (en) * 2016-01-22 2021-01-12 Equinix, Inc. Container-based cloud exchange disaster recovery
US10728312B2 (en) * 2017-03-03 2020-07-28 Actifio, Inc. Data center network containers
CN107276826A (zh) * 2017-07-24 2017-10-20 郑州云海信息技术有限公司 一种容器网络配置方法和装置
CN107979493B (zh) * 2017-11-21 2019-10-29 平安科技(深圳)有限公司 平台即服务paas容器平台的构建方法、服务器及存储介质
US11074091B1 (en) * 2018-09-27 2021-07-27 Juniper Networks, Inc. Deployment of microservices-based network controller
CN109582441A (zh) * 2018-11-30 2019-04-05 北京百度网讯科技有限公司 用于提供容器服务的系统、方法和装置
CN109462511B (zh) * 2018-12-11 2021-12-24 中科曙光国际信息产业有限公司 网络的建立方法及装置
CN109995641B (zh) * 2019-03-21 2021-05-28 新华三技术有限公司 一种信息处理方法、计算节点和存储介质
US11374880B2 (en) * 2019-06-17 2022-06-28 Cyxtera Data Centers, Inc. Automated deployment of internet connectivity to rack switches in a data center
CN113037522A (zh) * 2019-12-24 2021-06-25 华为数字技术(苏州)有限公司 一种容器单元管理方法及相关设备
CN113259503B (zh) * 2021-06-24 2021-10-08 浩鲸云计算科技股份有限公司 基于Infiniband实现不同容器之间的跨网络通信方法和系统
CN113572838B (zh) * 2021-07-22 2023-04-07 北京金山云网络技术有限公司 基于Kubernetes的网络访问方法、装置、设备及介质
CN113660316B (zh) * 2021-07-29 2024-03-12 广州汇通国信科技有限公司 基于容器云平台的网络资源自适应配置方法、系统及介质

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109587281A (zh) * 2017-09-29 2019-04-05 华为技术有限公司 容器配置方法和计算节点
CN108829384A (zh) * 2018-06-13 2018-11-16 平安科技(深圳)有限公司 容器的管理方法、装置、计算机设备及存储介质
US20210352044A1 (en) * 2020-05-08 2021-11-11 Ribbon Communications Operating Company, Inc. Networking as a Service
CN111796905A (zh) * 2020-05-22 2020-10-20 浙商银行股份有限公司 一种kubernetes容器云平台VLAN网络的实现方法及系统
CN111800523A (zh) * 2020-06-30 2020-10-20 北京金山云网络技术有限公司 虚拟机网络的管理方法、数据处理方法及系统
CN112187671A (zh) * 2020-11-05 2021-01-05 北京金山云网络技术有限公司 一种网络接入方法及其相关设备
CN114172802A (zh) * 2021-12-01 2022-03-11 百果园技术(新加坡)有限公司 容器网络配置方法、装置、计算节点、主节点及存储介质

Also Published As

Publication number Publication date
CN114172802A (zh) 2022-03-11
CN114172802B (zh) 2024-04-26

Similar Documents

Publication Publication Date Title
WO2023098645A1 (zh) 容器网络配置方法、装置、计算节点、主节点及存储介质
CN107947961B (zh) 基于SDN的Kubernetes网络管理系统与方法
US11429369B2 (en) Distributed upgrade in virtualized computing environments
US10541877B2 (en) Dynamic reservation protocol for 5G network slicing
US8331362B2 (en) Methods and apparatus for distributed dynamic network provisioning
US9535730B2 (en) Communication apparatus and configuration method
EP2922238A1 (en) Resource allocation method
WO2017132570A1 (en) System and method for correlating fabric-level group membership with subnet-level partition membership in a high performance computing environment
EP3664420B1 (en) Managing address spaces across network elements
CN104734931A (zh) 一种虚拟网络功能间链路建立方法及装置
EP3373518A1 (en) Service configuration method and device for network service
WO2012157017A1 (en) Computer system for allocating ip address to communication apparatus in computer subsystem newly added and method for newly adding computer subsystem to computer system
CN107005471A (zh) 通用客户驻地设备
CN103997414A (zh) 生成配置信息的方法和网络控制单元
US20170288998A1 (en) Apparatus for processing network packet using service function chaining and method for controlling the same
CN108965094A (zh) 一种虚拟机网络连接方法和装置
US20220350637A1 (en) Virtual machine deployment method and related apparatus
CN111711536B (zh) 一种云架构下防火墙测试环境构建方法
US11863377B2 (en) Discovery and configuration in computer networks
CN109379239A (zh) 一种OpenStack环境中配置接入交换机的方法及装置
CN111769992B (zh) 一种网络数据的管理方法、云平台及存储介质
CN115334018A (zh) 基于Openstack的IaaS云架构的容器控制方法、装置及容器
US20230105269A1 (en) Virtualized network service deployment method and apparatus
US20230259387A1 (en) Data flow mirroring method and apparatus
US20240007364A1 (en) Method, Apparatus, and System for Deploying Service

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22900449

Country of ref document: EP

Kind code of ref document: A1