WO2024148833A1 - 一种容器多网卡网络配置方法、装置、设备及存储介质 - Google Patents

一种容器多网卡网络配置方法、装置、设备及存储介质 Download PDF

Info

Publication number
WO2024148833A1
WO2024148833A1 PCT/CN2023/115893 CN2023115893W WO2024148833A1 WO 2024148833 A1 WO2024148833 A1 WO 2024148833A1 CN 2023115893 W CN2023115893 W CN 2023115893W WO 2024148833 A1 WO2024148833 A1 WO 2024148833A1
Authority
WO
WIPO (PCT)
Prior art keywords
network
resource configuration
created
network resource
mapping data
Prior art date
Application number
PCT/CN2023/115893
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 WO2024148833A1 publication Critical patent/WO2024148833A1/zh

Links

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
    • H04L41/0806Configuration setting for initial configuration or provisioning, e.g. plug-and-play
    • 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/0894Policy-based network configuration management
    • 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/0895Configuration of virtualised networks or elements, e.g. virtualised network function or OpenFlow elements

Definitions

  • the present application relates to the field of container technology, and in particular to a method, device, equipment and storage medium for configuring a multi-network card network in a container.
  • mainstream network plug-ins in the container network field have provided network bandwidth limitation policies at the container group (Pod) level.
  • the Kube-ovn plug-in and the Bandwidth plug-in both provide the ability to limit the upstream/downstream network bandwidth by adding annotations when creating a container group.
  • Multus-CNI plug-in a multi-container network interface plug-in
  • the current network plug-in does not provide the ability to allocate network bandwidth resources on demand for multiple network cards in a single container group, and can only allocate network bandwidth resources for a single network card.
  • FIG. 1 is a block diagram of an existing implementation of creating and configuring multiple network cards.
  • the master node (Master Node) 101 runs the container application program interface service (K8s-apiserver) to create a container group (Pod) (including container container 1, container container 2, etc.) on the worker node (Work Node) 102 according to the container group configuration file (Pod.yaml).
  • K8s-apiserver container application program interface service
  • the core component (Kubelet) of the container service (Kubernetes, K8s for short) is deployed on the worker node 102, and the multi-container network interface plug-in (Multus-CNI Plugin) is called to call the required type of network card creation plug-in (network card creation plug-in 1, network card creation plug-in 2, etc.) to create and configure the corresponding type of network card for the container group (network card 1, network card 2, etc.
  • the network card name supports user-defined naming).
  • the multi-container network interface plug-in can call the Calico plug-in to create and configure the network card eth0 (usually the main network card), or it can load the container network interface plug-in configuration file (such as the media intervention control layer virtual LAN container network interface (MacVlan CNI) configuration file) and then call the media intervention control layer virtual LAN plug-in (MacVlan Plugin) to create the network card net1.
  • the container network interface plug-in configuration file such as the media intervention control layer virtual LAN container network interface (MacVlan CNI) configuration file
  • MacVlan Plugin media intervention control layer virtual LAN plug-in
  • the purpose of this application is to provide a container multi-network card network configuration method, device, equipment and storage medium, which are used to implement network resource configuration for multiple network cards of a single container group.
  • a container multi-network card network configuration method including:
  • the third mapping data is transmitted to the operating system kernel of the target node to complete the network resource configuration of each created network card.
  • a multi-network card network resource configuration task is triggered, specifically:
  • the multi-network card container network interface plug-in After calling the multi-container network interface plug-in to complete the creation of multiple network cards of the target container group according to the workload container creation task, if the capability configuration option of the multi-container network interface plug-in corresponding to the preset multi-network card container network interface plug-in is enabled, the multi-network card container network interface plug-in is called based on the pre-created network attachment custom resource to execute the multi-network card network resource configuration task.
  • obtaining first mapping data of virtual network cable pairs between each created network card on the target container group and the target node specifically includes:
  • First mapping data is generated according to the host single interface information and the information of the created network card.
  • the container group information is used as a keyword to access the operating system kernel to query the host-side interface information of the target node corresponding to the container group information, specifically:
  • the network link socket is called to access the link query interface, and the operating system kernel is accessed to obtain the host-side interface information.
  • accessing the operating system kernel to query the host-side interface information of the target node corresponding to the container group information specifically including:
  • the operating system kernel is accessed to query the host interface information using the container group information as a keyword;
  • the target container group exception log is recorded and the target container group exception error message is thrown to the container service core component to end the multi-NIC network resource configuration task;
  • the network card exception log is recorded and the network card exception error information is thrown to the container service core component to end the multi-network card network resource configuration task.
  • determine whether the target container group is created successfully including:
  • determine whether each network card of the target container group is created successfully including:
  • obtaining second mapping data of each created network card and network resource configuration parameter specifically includes:
  • the second mapping data is generated according to the creation information of each created network card and the network resource configuration information of the network card.
  • generating second mapping data according to the creation information of each created network card and the network resource configuration information of the network card specifically includes:
  • the mapping data included in the network resource configuration information of the network card is used as the second mapping data
  • the second mapping data is generated according to a default network card resource mapping data generation sequence.
  • the second mapping data is generated according to a default network card resource mapping data generation sequence, specifically:
  • the first network resource configuration parameter is the network resource configuration parameter corresponding to the main network card in the created network card, and the network resource configuration parameters are allocated to the created network card according to the arrangement order of the remaining network resource configuration parameters and the creation order of the remaining created network cards to generate second mapping data.
  • generating second mapping data according to the creation information of each created network card and the network resource configuration information of the network card specifically includes:
  • the mapping data included in the network resource configuration information of the network card is used as the second mapping data
  • the network card network resource configuration information does not include mapping data between the created network card and the corresponding network resource configuration parameters, generating second mapping data according to a default network card resource mapping data generation sequence;
  • the second mapping data is obtained after the mapping data of the remaining created network cards and corresponding network resource configuration parameters are generated according to the default network card resource mapping data generation sequence.
  • the second mapping data is generated according to a default network card resource mapping data generation sequence, specifically:
  • the first network resource configuration parameter is the network resource configuration parameter corresponding to the primary network card in the created network card
  • the remaining network resource configuration parameters are The arrangement order of the network cards and the creation order of the remaining created network cards correspond to the allocation of network resource configuration parameters to the created network cards, and the second mapping data is generated;
  • mapping data of the remaining created network cards and the corresponding network resource configuration parameters according to the default network card resource mapping data generation sequence, specifically:
  • the network resource configuration parameters are correspondingly allocated to the remaining created network cards, and mapping data between the remaining created network cards and the corresponding network resource configuration parameters are obtained.
  • the network resource configuration information of the network card includes mapping data between the created network card and the corresponding network resource configuration parameters, specifically:
  • the network resource configuration information of the network card includes a preset character
  • the information of the created network card and the corresponding network resource configuration parameters are obtained by using the preset character as a separator, and mapping data of the created network card and the corresponding network resource configuration parameters are obtained.
  • mapping data between the created network card and the corresponding network resource configuration parameters is used as the second mapping data, specifically including:
  • the network card network resource configuration information includes mapping data between a created network card and corresponding network resource configuration parameters, determining whether the information of the created network card in the mapping data is included in the container multi-network card list of the target container group;
  • mapping data included in the network resource configuration information of the network card is used as the second mapping data
  • the custom annotation information exception log is recorded and the custom annotation information error message is thrown to the container service core component to end this multi-network card network resource configuration task.
  • generating second mapping data according to the creation information of each created network card and the network resource configuration information of the network card specifically includes:
  • the custom annotation information exception log is recorded and the custom annotation information error message is thrown to the container service core component to end this multi-network card network resource configuration task.
  • determining whether the network resource configuration parameters recorded in the network resource configuration information of the network card meet the preset network card resource configuration requirements specifically includes:
  • the network resource configuration parameters recorded in the network card network resource configuration information are all greater than 0 and are network resource configuration parameters in the agreed unit, it is determined that the network resource configuration parameters recorded in the network card network resource configuration information meet the preset network card resource configuration requirements;
  • the network resource configuration parameters recorded in the network card network resource configuration information are not all greater than 0 and are not based on the convention If the network resource configuration parameters of the unit are not met, it is determined that the network resource configuration parameters recorded in the network card network resource configuration information do not meet the preset network card resource configuration requirements.
  • the third mapping data is transmitted to the operating system kernel of the target node to complete the network resource configuration of each created network card, specifically including:
  • the multi-NIC network resource configuration mapping table is updated
  • the multi-NIC network resource configuration mapping table does not exist, generating the multi-NIC network resource configuration mapping table according to the third mapping data;
  • queue rule data is assembled and a network link message is sent to the operating system kernel to implement network resource configuration for each created NIC.
  • the method further includes:
  • check the configuration results of the network resource configuration for each created network card specifically:
  • the log file corresponding to the multi-NIC network resource configuration task is queried to obtain the configuration result of the network resource configuration for each created NIC.
  • check the configuration results of the network resource configuration for each created network card including:
  • the network resource configuration status is the configuration result of the network resource configuration of the created network card.
  • check the configuration results of the network resource configuration for each created network card including:
  • the network status of each created network card is used as the configuration result of the network resource configuration of each created network card.
  • the present application also provides a container multi-network card network configuration device, including:
  • a parameter judgment module is used to obtain first mapping data of virtual network cable pairs between each created network card on the target container group and the target node after completing the creation of multiple network cards of the target container group on the target node of the target container cluster according to the workload container creation task and triggering the multi-network card network resource configuration task;
  • a container group network card network resource configuration information acquisition module used to obtain second mapping data between each created network card and network resource configuration parameter
  • the multi-NIC network resource configuration information mapping module is used to generate third mapping data of the created network cards, network resource configuration parameters and virtual network cable pairs according to the first mapping data and the second mapping data, and transmit the third mapping data to the operating system kernel of the target node to complete the network resource configuration of each created network card.
  • the present application also provides a container multi-NIC network configuration device, including:
  • a processor is used to execute a computer program, and when the computer program is executed by the processor, any of the above items is realized. Steps of the multi-NIC network configuration method.
  • the present application also provides a storage medium on which a computer program is stored.
  • the computer program is executed by a processor, the steps of any of the above container multi-NIC network configuration methods are implemented.
  • the container multi-network card network configuration method provided in the present application triggers a multi-network card network resource configuration task after completing the creation of multiple network cards of a target container group on a target node of a target container cluster according to a workload container creation task, thereby respectively obtaining first mapping data of each created network card on the target container group and a virtual network cable pair of the target node, and second mapping data of each created network card and a network resource configuration parameter, so as to generate third mapping data of the created network card, the network resource configuration parameter and the virtual network cable pair according to the first mapping data and the second mapping data, and then pass the third mapping data to the operating system kernel of the target node to complete the network resource configuration of each created network card, thereby realizing the network resource configuration of each network card on the container group, and providing a finer-grained network resource allocation strategy for the application scenario of multi-network fusion deployment with isolation of the production network and the management network.
  • the present application also provides a container multi-NIC network configuration device, equipment and storage medium, which have the above-mentioned beneficial effects.
  • FIG1 is a block diagram of an existing implementation of multiple network card creation and configuration
  • FIG2 is a flow chart of a method for configuring a container multi-NIC network according to an embodiment of the present application
  • FIG3 is a block diagram of an implementation of multiple network card creation and configuration provided by an embodiment of the present application.
  • FIG4 is a schematic diagram of a mapping relationship of first mapping data provided in an embodiment of the present application.
  • FIG5 is a schematic diagram of a mapping relationship of third mapping data provided in an embodiment of the present application.
  • FIG6 is a schematic diagram of a storage structure of a third mapping data provided in an embodiment of the present application.
  • FIG. 7 is a flowchart of a specific implementation of S202 provided in an embodiment of the present application.
  • FIG8 is a flow chart of a specific implementation of S203 provided in an embodiment of the present application.
  • FIG9 is a flow chart of a specific implementation of S205 provided in an embodiment of the present application.
  • FIG10 is a schematic diagram of the structure of a container multi-NIC network configuration device provided in an embodiment of the present application.
  • FIG11 is a schematic diagram of the structure of a container multi-NIC network configuration device provided in an embodiment of the present application.
  • the core of this application is to provide a container multi-network card network configuration method, device, equipment and storage medium, which are used to implement network resource configuration for multiple network cards of a single container group.
  • FIG. 2 is a flow chart of a method for configuring a container multi-NIC network according to an embodiment of the present application
  • FIG. 3 is a flow chart of a method for configuring a container multi-NIC network according to an embodiment of the present application
  • Figure 4 is a schematic diagram of the mapping relationship of a first mapping data provided in an embodiment of the present application
  • Figure 5 is a schematic diagram of the mapping relationship of a third mapping data provided in an embodiment of the present application
  • Figure 6 is a schematic diagram of the storage structure of a third mapping data provided in an embodiment of the present application.
  • the container multi-NIC network configuration method includes:
  • S201 After completing the creation of multiple network cards of a target container group on a target node of a target container cluster according to a workload container creation task, trigger a multi-network card network resource configuration task.
  • S202 Acquire first mapping data of virtual network cable pairs between each created network card on the target container group and the target node.
  • S203 Acquire second mapping data between each created network card and network resource configuration parameter.
  • S204 Generate third mapping data of the created network card, network resource configuration parameters, and virtual network cable pairs according to the first mapping data and the second mapping data.
  • the container multi-NIC network configuration method provided in the embodiment of the present application can be implemented based on a multi-NIC container network interface plug-in (MultiNic-Qos CNI Plugin) pre-deployed in a container cluster.
  • the multi-NIC container network interface plug-in is used to be called by the multi-container network interface plug-in (Multus-CNI Plugin) to obtain the network resource configuration information of multiple created network cards on the target container group, automatically generate mapping data and write the mapping data into the operating system kernel of the host machine to implement the network resource configuration of each created network card of the target container group.
  • the master node (Master Node) 301 runs the container application program interface service (K8s-apiserver) to create a container group (Pod) (including container container 1, container container 2...) on the work node (Work Node) 302 according to the container group configuration file (Pod.yaml), deploys the core component (Kubelet) of the container service (Kubernetes, K8s for short) on the work node 302, and calls the multi-container network interface plug-in (Multus-CNI Plugin) to call the required type of network card creation plug-in (network card creation plug-in 1, network card creation plug-in 2...) to create and configure the corresponding type of network card for the target container group (network card 1, network card 2...
  • K8s-apiserver container application program interface service
  • the network card name supports user-defined naming).
  • the multi-container network interface plug-in can call the Calico plug-in to create and configure the network card eth0 (usually the primary network card), or it can load the container network interface plug-in configuration file (such as the media intervention control layer virtual LAN container network interface (MacVlan CNI) configuration file) and then call the media intervention control layer virtual LAN plug-in (MacVlan Plugin) to create the network card net1.
  • the container network interface plug-in configuration file such as the media intervention control layer virtual LAN container network interface (MacVlan CNI) configuration file
  • MacVlan Plugin media intervention control layer virtual LAN plug-in
  • the core component calls the multi-container network interface plug-in (Multus-CNI Plugin) to complete the creation and configuration of multiple network cards of the target container group according to the container group configuration file (Pod.yaml), it assembles the container multi-network card list (ifNameList), container group name (PodName), container group namespace (PodNameSpace) and other parameters and calls the multi-network card container network interface plug-in (MultiNic-Qos CNI Plugin) provided in the embodiment of the present application, thereby triggering the multi-network card network resource configuration task.
  • the container group configuration file Pod.yaml
  • the configuration file of the Multi-Container Network Interface Plugin (Multus-CNI Plugin) is modified in advance, the capabilities configuration option is added, and the Network Attachment Definition CRD is created according to the actual scenario requirements. Then in S201, after the creation of multiple network cards of the target container group on the target node of the target container cluster is completed according to the workload container creation task, the multi-network card network resource configuration task is triggered.
  • the multi-container network interface plug-in After the multi-container network interface plug-in is called to complete the creation of multiple network cards of the target container group according to the workload container creation task, if the multi-container When the capability configuration option of the network interface plug-in corresponding to the preset multi-NIC container network interface plug-in is enabled, the multi-NIC container network interface plug-in is called based on the pre-created network attachment custom resource to perform the multi-NIC network resource configuration task.
  • the MultiNic-Qos CNI Plugin when the newly added capability configuration option is MultiNic-Qos CNI Plugin, the value is enabled (true), the MultiNic-Qos CNI Plugin is called after the creation of multiple network cards of the target container group is completed; if the capability configuration option is MultiNic-Qos CNI Plugin, the value is disabled (false), the MultiNic-Qos CNI Plugin is not called after the creation of multiple network cards of the target container group is completed.
  • a network resource configuration portal can be provided to users for users to configure the bidirectional network resource configuration parameters of the ingress direction (ingress) and egress direction (egress) of each NIC of the target container group.
  • This configuration mainly relies on the custom annotation information service (Kubernetes Annotation) of the container service.
  • the network resource configuration parameters can be specifically bandwidth speed limit values.
  • the configuration implementation of multiple network cards in the ingress and egress directions is roughly the same.
  • the network resource configuration parameters for the ingress direction (ingress) of each network card in the target container group can be specifically:
  • Keyword for speed limit in the inbound direction of multiple network cards KY: bandwidth speed limit value 1, bandwidth speed limit value 2, ..., bandwidth speed limit value n;
  • multiple network card inbound speed limit keywords (KEY): network card name 1@bandwidth speed limit value 1, network card name 2@bandwidth speed limit value 2, ..., network card name n@bandwidth speed limit value n.
  • outbound rate limit keywords for multiple network cards: network card name 1@bandwidth rate limit value 1, network card name 2@bandwidth rate limit value 2, ..., network card name n@bandwidth rate limit value n.
  • the network resource configuration parameters of multiple network cards added by the custom annotation information (Annotation) in the container group configuration file (Pod.yaml) of the created workload can be specifically selected as "[Multi-network card speed limit KEY]: [bandwidth speed limit value 1, bandwidth speed limit value 2, ..., bandwidth speed limit value n]" or "[Multi-network card speed limit KEY]: [network card name 1@bandwidth speed limit value 1, network card name 2@bandwidth speed limit value 2, ..., network card name n@bandwidth speed limit value n]".
  • the user is provided with optional units of network resource configuration parameters, such as the bandwidth speed limit value in units of kilobits/megabits/gigabits (Kbits/Mbits/Gbits).
  • MultiNic-Qos CNI Plugin Design a multi-NIC container network interface plug-in (MultiNic-Qos CNI Plugin) to execute S202 to S205 after being called.
  • the key to realizing the network resource configuration of multiple NICs of the target container group is to obtain the mapping relationship between each created NIC of the target container group, the network resource configuration parameters corresponding to each created NIC, and the virtual network cable pair of the target node. Among them, there can be no order relationship between S202 and S203, and they can be executed one after another or at the same time. Executed when.
  • the MultiNic-Qos CNI Plugin parses and verifies the parameters passed by the Multus-CNI Plugin to determine the information of the created network cards of the target container group and the virtual network cable pairs (Veth-Pair pairs) corresponding to the created network cards on the target node, so as to generate the first mapping data of the virtual network cable pairs of each created network card on the target container group and the target node.
  • the first mapping data can be the mapping data of the names of the created network cards and the names of the virtual network cable pairs of network cards.
  • the names of the created network cards are specifically the master network card (PodMasterIf), the created network card 1 (PodIfName 1), the created network card 2 (PodIfName 2), ..., the created network card N (PodIfNameN), which correspond to the names of the virtual network cable pairs of network cards: the host master network card (HostMasterIf), the host network card 1 (HostIfName 1), the host network card 2 (HostIfName 2), ..., the host network card N (HostIfName N).
  • the multi-NIC container network interface plug-in accesses the container application program interface service (K8s-apiserver) to access the container group configuration file (Pod.yaml), obtains the network resource configuration parameters in the custom annotation information (Annotation), and generates the second mapping data of the created network card and the network resource configuration parameters according to the information of the created network card obtained by parsing the parameters passed by the container service core component (kubelet).
  • the second mapping data may include the name of the created network card and the corresponding inbound network resource configuration parameters and the corresponding outbound network resource configuration parameters, and the network resource configuration parameters may specifically be bandwidth speed limit values.
  • the generated third mapping data of the created network card, network resource configuration parameters and virtual network cable pair can be specifically mapping data of the name of the created network card, the inbound network resource configuration parameters, the outbound network resource configuration parameters and the name of the virtual network cable pair of the network card.
  • the names of the created network cards are specifically the master network card (PodMasterIf), created network card 1 (PodIfName 1), created network card 2 (PodIfName 2), ..., created network card N (PodIfName N), which respectively correspond to the names of the virtual network cable pairs of network cards: host master network card (HostMasterIf), host network card 1 (HostIfName 1), host network card 2 (HostIfName 2), ..., host network card N (HostIfName N), which respectively correspond to the inbound network card pairs of the network cards.
  • the bandwidth speed limit values in the ingress direction are: ingress speed limit value 0 (IngressRate 0), ingress speed limit value 1 (IngressRate 1), ingress speed limit value 2 (IngressRate 2), ..., ingress speed limit value N (IngressRate N), and the bandwidth speed limit values in the outbound direction of the network card are: outbound speed limit value 0 (EgressRate 0), outbound speed limit value 1 (EgressRate 1), outbound speed limit value 2 (EgressRate 2), ..., outbound speed limit value N (EgressRate N).
  • the storage structure of the third mapping data can be as shown in Figure 6, constructing a multi-network card network resource configuration mapping table, which corresponds to the name keywords (PodIfNameKey) of N+1 created network cards in sequence under the identification keyword (PodIDKey) of the target container group; the name keyword (PodIfNameKey) of each created network card corresponds to a host network card name keyword (HostIfNameKey), and the name keyword (PodIfNameKey) of each created network card also corresponds to the ingress network resource configuration parameter (IngressRateKey), the ingress bandwidth speed limit value (IngressRate) and the egress network resource configuration parameter (EgressRateKey), and the egress bandwidth speed limit value (EgressRate).
  • the operating system kernel is sent to create a queue rule (Qdisc) to implement the network resource configuration of each created network card of the target container group.
  • the operating system kernel can be specifically the kernel of the Linux operating system.
  • the container multi-network card network configuration method triggers the multi-network card network resource configuration task after completing the creation of multiple network cards of the target container group on the target node of the target container cluster according to the workload container creation task, thereby respectively obtaining the first mapping data of the virtual network cable pair of each created network card on the target container group and the target node, and the second mapping data of each created network card and the network resource configuration parameter, so as to generate the third mapping data of the created network card, the network resource configuration parameter and the virtual network cable pair according to the first mapping data and the second mapping data, and then pass the third mapping data to the operating system kernel of the target node to complete the network resource configuration of each created network card, thereby realizing the network resource configuration of each network card on the container group, and providing a finer-grained network resource allocation strategy for the application scenario of multi-network fusion deployment with isolation of production network and management network.
  • FIG. 7 is a flowchart of a specific implementation of S202 provided in an embodiment of the present application.
  • the embodiment of the present application further describes a method for generating the first mapping data.
  • S202 obtaining the first mapping data of the virtual network cable pairs of each created network card and the target node on the target container group, specifically including:
  • S702 Using the container group information as a keyword, access the operating system kernel to query the host-side interface information of the target node corresponding to the container group information.
  • S703 Generate first mapping data according to the host single interface information and the information of the created network card.
  • the parameters passed by the multi-container network interface plug-in can be parsed to obtain the container group information of the target container group, including the container multi-network card list (ifNameList), container group namespace (PodNameSpace), container group name (PodName), etc.
  • the container group information is used as a keyword, specifically the container group namespace (PodNameSpace) and the container group name (PodName) are used as keywords (KEY) to access the operating system kernel to query the host-side interface information of the target node corresponding to the container group information.
  • S702 may specifically be: using the container group information as a keyword, calling the network link socket to access the link query interface, and accessing the operating system kernel to obtain the host-side interface information.
  • the network link (NetLink) socket is a special inter-process communication (IPC) used to implement communication between the user process and the kernel, and is also the most commonly used interface for network applications to communicate with the kernel. Therefore, the network link (NetLink) socket can be called to call the link query interface to access the operating system kernel to obtain the host-side interface information.
  • IPC inter-process communication
  • S702 using the container group information as a keyword, accessing the operating system kernel to query the host-side interface information of the target node corresponding to the container group information, which may specifically include:
  • the operating system kernel is accessed to query the host interface information using the container group information as a keyword;
  • the target container group exception log is recorded and the target container group exception error message is thrown to the container service core component to end the multi-NIC network resource configuration task;
  • the network card exception log is recorded and a network card exception is thrown to the container service core component.
  • An error message is often reported to end the multi-NIC network resource configuration task.
  • Determining whether the target container group is created successfully may specifically include: using the container group information as a keyword, querying the container application interface service for the target container group information; determining whether the target container group information can be queried; if the target container group information can be queried, determining that the target container group is created successfully; if the target container group information cannot be queried, determining that the target container group is not created successfully. That is, by trying to query the target container group information through the container application interface service (K8s-apiserver), if the information can be queried, it means that the target container group has been created successfully. If the information cannot be queried, it means that the target container group has not been created successfully.
  • K8s-apiserver container application interface service
  • Determining whether each network card of the target container group is successfully created may specifically include: accessing the operating system kernel to query the host-side interface information of the target node; determining whether the host-side interface information corresponding to each network card exists; if the host-side interface information corresponding to each network card exists, it is determined that each network card is successfully created; if the host-side interface information corresponding to each network card does not exist, it is determined that each network card is not successfully created. Since the container group uses the virtual machine network cable to connect to the kernel protocol stack of the host, the container multi-network card list (ifNameList) in the container group information can be traversed to obtain the information of the created network cards provided by the multi-container network interface plug-in (Multus-CNI Plugin).
  • the container group information can be used as a keyword, specifically the container group namespace (PodNameSpace) and the container group name (PodName) can be used as keywords (KEY), and the network link (NetLink) socket can be called to access the link (Link) query interface, and the operating system kernel can be accessed to obtain the corresponding host-side interface information. If the host-side interface information corresponding to all created network cards can be obtained, it is determined that these network cards are successfully created. Otherwise, the creation of multiple network cards of the target container group fails.
  • the container group information can be used as a keyword, specifically the container group namespace (PodNameSpace) and the container group name (PodName) can be used as keywords (KEY), and the network link (NetLink) socket can be called to access the link (Link) query interface, and the operating system kernel can be accessed to obtain the corresponding host-side interface information. If the host-side interface information corresponding to all created network cards can be obtained, it is determined that these network cards are successfully created. Otherwise, the creation of multiple network cards of the target container group
  • the first mapping data of the virtual network cable pair (Veth-Pair pair) of each created network card and the target node is generated.
  • the data structure of the first mapping data can be specifically referred to in the first embodiment of the present application and FIG. 4, which will not be repeated here.
  • FIG8 is a flowchart of a specific implementation of S203 provided in an embodiment of the present application.
  • the embodiment of the present application further describes a method for generating the second mapping data.
  • S203 obtaining the second mapping data of each created network card and network resource configuration parameter, specifically including:
  • S801 Requesting a container application program interface service to access a container group configuration file of a target container group to obtain custom annotation information of the target container group.
  • S802 Parse the custom annotation information to obtain the network card network resource configuration information of the target container group.
  • S803 Generate second mapping data according to the creation information of each created network card and the network resource configuration information of the network card.
  • the network resource configuration parameter (such as bandwidth speed limit value) can be used as a keyword (KEY) to identify the network card network resource configuration information of the target container group in the custom annotation information (Annotation).
  • KY a keyword
  • the first is user-defined mapping configuration
  • the second is default mapping configuration.
  • the user-defined mapping configuration is preferred. If the user has not customized the mapping configuration, the default mapping configuration is used.
  • S803 generating second mapping data according to the creation information of each created network card and the network resource configuration information of the network card, which may specifically include:
  • the mapping data included in the network resource configuration information of the network card is used as the second mapping data
  • the second mapping data is generated according to a default network card resource mapping data generation sequence.
  • the network card network resource configuration information includes mapping data of the created network card and the corresponding network resource configuration parameters, which can be specifically: if the network card network resource configuration information includes preset characters, the information of the created network card and the corresponding network resource configuration parameters are obtained with the preset characters as the segmentation characters, and the mapping data of the created network card and the corresponding network resource configuration parameters are obtained.
  • the preset character can be "@”.
  • the user sets the network card network resource configuration information in the custom annotation information (Annotation) as "network card name 1@bandwidth limit value 1, network card name 2@bandwidth limit value 2,..., network card name n@bandwidth limit value n", then when identifying the custom annotation information (Annotation), the preset character "@” is also identified in this way, and pairs of network card names and bandwidth limit values are obtained by segmentation, that is, the second mapping data is obtained.
  • the second mapping data is generated according to the default network card resource mapping data generation order, which can be specifically: according to the order of network resource configuration parameters contained in the network card network resource configuration information, the first network resource configuration parameter is the network resource configuration parameter corresponding to the primary network card in the created network card, and the network resource configuration parameters are allocated to the created network card according to the arrangement order of the remaining network resource configuration parameters and the creation order of the remaining created network cards, and the second mapping data is generated. That is, according to the order in which the multi-container network interface plug-in (Multus-CNI Plugin) creates the network card, and the arrangement order of the network resource configuration parameters in the custom annotation information (Annotation), the network resource configuration parameters are allocated to each created network card in turn.
  • the multi-container network interface plug-in Multus-CNI Plugin
  • mapping data between the created network card and the corresponding network resource configuration parameters is used as the second mapping data, which may specifically include:
  • the network card network resource configuration information includes mapping data between a created network card and corresponding network resource configuration parameters, determining whether the information of the created network card in the mapping data is included in the container multi-network card list of the target container group;
  • mapping data included in the network resource configuration information of the network card is used as the second mapping data
  • the custom annotation information exception log is recorded and the custom annotation information error message is thrown to the container service core component to end the This completes the multi-NIC network resource configuration task.
  • the preset character "@" can be used as a separator to obtain the network card name and the corresponding network resource configuration parameters in the network card network resource configuration information, and it is determined whether the network card exists in the container multi-network card list (ifnameList) of the container group information of the target container group provided by the multi-container network interface plug-in (Multus-CNI Plugin).
  • the subsequent process will continue to be executed; if the network card does not exist in the container multi-network card list (ifnameList) of the container group information of the target container group provided by the multi-container network interface plug-in (Multus-CNI Plugin), an error message is thrown to the container service core component (kubelet) to end the call to the multi-network card container network interface plug-in (MultiNic-Qos CNI Plugin) and end this multi-network card network resource configuration task.
  • kubelet container service core component
  • the network resource configuration parameters are also verified to avoid configuration failure due to abnormal network resource configuration parameters. That is, S803: generating the second mapping data according to the creation information of each created network card and the network resource configuration information of the network card, which may specifically include:
  • the custom annotation information exception log is recorded and the custom annotation information error message is thrown to the container service core component to end this multi-network card network resource configuration task.
  • the unit of the optional network resource configuration parameter is provided to the user in advance. Then, judging whether the network resource configuration parameter recorded in the network card network resource configuration information meets the preset network card resource configuration requirements may specifically include:
  • the network resource configuration parameters recorded in the network card network resource configuration information are all greater than 0 and are network resource configuration parameters in the agreed unit, it is determined that the network resource configuration parameters recorded in the network card network resource configuration information meet the preset network card resource configuration requirements;
  • the network resource configuration parameters recorded in the network card network resource configuration information are not all greater than 0 and are in agreed units, it is determined that the network resource configuration parameters recorded in the network card network resource configuration information do not meet the preset network card resource configuration requirements.
  • the network resource configuration parameter of the agreed unit may be a bandwidth speed limit value of kilobits/megabits/gigabits (Kbits/Mbits/Gbits).
  • the preset network card resource configuration requirement may also be a network resource configuration parameter whose network resource configuration parameter meets other preset ranges and adopts an agreed unit.
  • mapping data of the created network cards and the network resource configuration parameters can be generated according to the custom annotation information (Annotation), and then the mapping data of the remaining created network cards and the network resource configuration parameters can be generated according to the default mapping configuration.
  • S803 Generate the second mapping data according to the creation information of each created network card and the network resource configuration information of the network card, which can specifically include:
  • the mapping data included in the network resource configuration information of the network card is used as the second mapping data
  • the network card network resource configuration information does not include mapping data between the created network card and the corresponding network resource configuration parameters, generating second mapping data according to a default network card resource mapping data generation sequence;
  • the second mapping data is obtained after the mapping data of the remaining created network cards and corresponding network resource configuration parameters are generated according to the default network card resource mapping data generation sequence.
  • the network card network resource configuration information includes the mapping data of all created network cards, and the case where the mapping data is not included, can be implemented with reference to the above description.
  • the mapping data of these created network cards and the network resource configuration parameters are first generated according to the custom annotation information (Annotation), and then the mapping data of the remaining created network cards and the corresponding network resource configuration parameters are generated according to the default network card resource mapping data generation order, and the second mapping data is obtained by summarizing.
  • the second mapping data is generated according to the default network card resource mapping data generation sequence, specifically:
  • the first network resource configuration parameter is the network resource configuration parameter corresponding to the primary network card in the created network cards
  • the network resource configuration parameters are allocated to the created network cards in accordance with the arrangement order of the remaining network resource configuration parameters and the creation order of the remaining network cards
  • the second mapping data is generated.
  • the mapping data of the remaining created network cards and the corresponding network resource configuration parameters are generated according to the default network card resource mapping data generation order, specifically: the network resource configuration parameters are allocated to the remaining created network cards in accordance with the arrangement order of the remaining network resource configuration parameters and the creation order of the remaining network cards, and the mapping data of the remaining created network cards and the corresponding network resource configuration parameters are obtained.
  • the method of verifying the network card name in the mapping data, and the method of verifying the network resource configuration parameters contained in the network card network resource configuration information can refer to the description of Example 4 of the present application.
  • FIG. 9 is a flow chart of a specific implementation of S205 provided in an embodiment of the present application.
  • the embodiment of the present application further describes the execution steps for implementing the multi-network card network resource configuration.
  • S205 passing the third mapping data to the operating system kernel of the target node to complete the network resource configuration of each created network card, which may specifically include:
  • S901 Determine whether a multi-NIC network resource configuration mapping table corresponding to the third mapping data exists; if the multi-NIC network resource configuration mapping table corresponding to the third mapping data exists, proceed to S902; if the multi-NIC network resource configuration mapping table corresponding to the third mapping data does not exist, proceed to S904.
  • S902 Determine whether the network resource configuration parameters in the multi-NIC network resource configuration mapping table have changed. If the network resource configuration parameters in the multi-NIC network resource configuration mapping table have changed, proceed to S903.
  • S903 Update the multi-NIC network resource configuration mapping table and proceed to S905.
  • S904 Generate a multi-NIC network resource configuration mapping table according to the third mapping data, and proceed to S905.
  • S905 Assembling queue rule data based on the multi-NIC network resource configuration mapping table, and sending a network link message to the operating system kernel to implement network resource configuration for each created NIC.
  • the multi-NIC network resource configuration mapping table can refer to the storage structure of the third mapping data provided in the first embodiment of the present application and Figure 6.
  • the third mapping data is maintained in the form of a multi-NIC network resource configuration mapping table. If the target container group is the first time to create multiple NICs, it is necessary to generate a multi-NIC network resource configuration mapping table. If the NIC of the target container group changes, it is necessary to update the multi-NIC network resource configuration mapping table.
  • the container group information of the target container group can be used as the keyword to query the data record under the identification keyword (PodIDKey) of the target container group in the multi-network card network resource configuration mapping table, and the bandwidth speed limit value in the input and output directions of each network card is compared in turn to see whether it has changed. If the bandwidth speed limit value in the input and output directions of the network card has changed, S903 is executed to update the multi-network card network resource configuration mapping table and record the change log. If the bandwidth speed limit value in the input and output directions of the network card has not changed, S905 is executed.
  • S905 For S905, it obtains the data entry indexed by the identification keyword (PodIDKey) of the target container group, and constructs a network link (NetLink) message with the host network card name (HostIfNameKey) and the bandwidth limit value (IngressRate/EgressRate) in the ingress and egress directions. It calls the traffic control (TC) module of the operating system kernel and creates a queue discipline (Qdisc) of the token bucket (TBF) type to implement the network resource configuration function of the network card.
  • TC traffic control
  • Qdisc queue discipline
  • TBF token bucket
  • the traffic control (TC) module implements the network resource configuration of multiple network cards of the target container group.
  • logs can be recorded for each execution link to trace the execution status and facilitate process analysis and troubleshooting.
  • the container multi-network card network configuration method provided by the embodiment of the present application may further include:
  • the creation of multiple network cards, and the execution of the multi-network card network resource configuration task that is, after completing the creation of the workload, you can check the status of the workload (whether it is in the running state) to determine whether the creation is successful. At the same time, you can query the log to check whether the processing flow is correct. Then check the configuration results of the network resource configuration of each created network card, specifically: query the log file corresponding to the multi-network card network resource configuration task, and obtain the configuration results of the network resource configuration of each created network card.
  • TC flow control
  • the network resource configuration status is the configuration result of the network resource configuration of the created network card.
  • the network status of each created network card is used as the configuration result of the network resource configuration of each created network card.
  • the preset stress test tool may adopt an iperf stress test tool, which may specifically measure the bandwidth speed limit value of each created network card of the target container group, and compare it with the corresponding data in the multi-network card network resource configuration mapping table to determine the network resource configuration of the network card of the target container group.
  • the present application also discloses a container multi-NIC network configuration device, equipment and storage medium corresponding to the above method.
  • FIG10 is a schematic diagram of the structure of a container multi-NIC network configuration device provided in an embodiment of the present application.
  • the container multi-NIC network configuration device provided in the embodiment of the present application includes:
  • the parameter judgment module 1001 is used to obtain first mapping data of virtual network cable pairs between each created network card on the target container group and the target node after completing the creation of multiple network cards of the target container group on the target node of the target container cluster according to the workload container creation task and triggering the multi-network card network resource configuration task;
  • the container group network card network resource configuration information acquisition module 1002 is used to obtain the second mapping data between each created network card and the network resource configuration parameter;
  • the multi-NIC network resource configuration information mapping module 1003 is used to generate third mapping data of the created network cards, network resource configuration parameters and virtual network cable pairs according to the first mapping data and the second mapping data, and transmit the third mapping data to the operating system kernel of the target node to complete the network resource configuration of each created network card.
  • the container multi-NIC network configuration device provided in the embodiment of the present application may also include:
  • the event reporting module 1004 is used to generate error information and report to the container service core component (kubelet) according to the errors generated during the execution of the parameter judgment module 1001, the container group network card network resource configuration information acquisition module 1002, and the multi-network card network resource configuration information mapping module 1003;
  • the log collection module 1005 is used to generate logs according to the execution process of each module, namely, the parameter judgment module 1001, the container group network card network resource configuration information acquisition module 1002, and the multi-network card network resource configuration information mapping module 1003, and to generate exception logs according to errors generated during the execution of each module.
  • FIG11 is a schematic diagram of the structure of a container multi-NIC network configuration device provided in an embodiment of the present application.
  • the container multi-NIC network configuration device provided in the embodiment of the present application includes:
  • a memory 1110 used for storing a computer program 1111
  • the processor 1120 is used to execute the computer program 1111.
  • the steps of the container multi-NIC network configuration method in any of the above embodiments are implemented.
  • the processor 1120 may include one or more processing cores, such as a 3-core processor, an 8-core processor, etc.
  • the processor 1120 may be implemented in at least one hardware form of a digital signal processing DSP (Digital Signal Processing), a field-programmable gate array FPGA (Field-Programmable Gate Array), and a programmable logic array PLA (Programmable Logic Array).
  • the processor 1120 may also include a main processor and a coprocessor.
  • the main processor is a processor for processing data in the awake state, also known as a central processing unit CPU (Central Processing Unit);
  • the coprocessor is a low-power processor for processing data in the standby state.
  • the processor 1120 may be integrated with a graphics processor GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen.
  • the processor 1120 may also include an artificial intelligence AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
  • AI Artificial Intelligence
  • the memory 1110 may include one or more storage media, which may be non-transitory.
  • the memory 1110 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices.
  • the memory 1110 is at least used to store the following computer program 1111, wherein, after the computer program 1111 is loaded and executed by the processor 1120, it can implement the relevant steps in the container multi-NIC network configuration method disclosed in any of the aforementioned embodiments.
  • the resources stored in the memory 1110 may also include an operating system 1112 and data 1113, etc., and the storage method may be short-term storage or permanent storage.
  • the operating system 1112 may be Windows.
  • Data 1113 may include, but is not limited to, the data involved in the above method.
  • the container multi-NIC network configuration device may further include a display screen 1130 , a power supply 1140 , a communication interface 1150 , an input and output interface 1160 , a sensor 1170 , and a communication bus 1180 .
  • FIG. 11 does not constitute a limitation on the container multi-NIC network configuration device, and may include more or fewer components than shown in the figure.
  • the container multi-NIC network configuration device provided in the embodiment of the present application includes a memory and a processor.
  • the processor executes the program stored in the memory, it can implement the above container multi-NIC network configuration method, and the effect is the same as above.
  • the above-described device and equipment embodiments are merely schematic.
  • the division of modules is merely a logical function division. There may be other division methods in actual implementation, such as multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed.
  • Another point is that the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection of devices or modules, which may be electrical, mechanical or other forms.
  • the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment.
  • each functional module in each embodiment of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module.
  • the above integrated modules can be implemented in the form of hardware or software functional modules.
  • the integrated modules are implemented as software function modules and sold or used as independent products, they can be Stored in a storage medium.
  • the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium and executes all or part of the steps of the various embodiments of the present application.
  • an embodiment of the present application also provides a storage medium, on which a computer program is stored.
  • the computer program is executed by a processor, the steps of the container multi-network card network configuration method are implemented.
  • the storage medium may include: U disk, mobile hard disk, read-only memory ROM (Read-Only Memory), random access memory RAM (Random Access Memory), disk or CD and other media that can store program code.
  • the computer program contained in the storage medium provided in this embodiment can implement the steps of the above container multi-NIC network configuration method when executed by the processor, and the effect is the same as above.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Stored Programmes (AREA)

Abstract

本申请涉及容器技术领域,具体公开了一种容器多网卡网络配置方法、装置、设备及存储介质,在根据工作负载容器创建任务完成对目标容器集群的目标节点上的目标容器组的多个网卡的创建后,触发多网卡网络资源配置任务,以分别获取目标容器组上各已创建网卡与目标节点的虚拟网线对的第一映射数据,以及各已创建网卡与网络资源配置参数的第二映射数据,进而生成已创建网卡、网络资源配置参数与虚拟网线对的第三映射数据,而后将第三映射数据传递至目标节点的操作系统内核以完成对各已创建网卡的网络资源配置,实现了对容器组上各个网卡的网络资源配置,为生产网络与管理网络隔离的多网络融合部署的应用场景提供了粒度更细的网络资源分配策略。

Description

一种容器多网卡网络配置方法、装置、设备及存储介质
相关申请的交叉引用
本申请要求于2023年01月09日提交中国专利局,申请号为202310025089.6,申请名称为“一种容器多网卡网络配置方法、装置、设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及容器技术领域,特别是涉及一种容器多网卡网络配置方法、装置、设备及存储介质。
背景技术
目前,以容器化技术为基础的云计算广泛应用,IP网络向集成数据、语音、视频等多业务网络转变。网络中所承载的数据呈几何级倍数增长,而且这些业务对网络的带宽、时延有着极高的要求。在有限的带资源下,能够按需为各业务分配带宽资源为其提供更高的端到端服务质量,是云计算应用场景中迫切需求。
针对此问题,在容器网络领域中主流的网络插件已经提供了容器组(Pod)级别的网络带宽限制策略,如Kube-ovn插件和Bandwidth(带宽)插件都提供了在创建容器组时通过添加注解方式来实现对上行/下行的网络带宽的限制能力。
在某些应用场景中(例如生产网络和测试网络隔离的场景),需要利用Multus-CNI插件(一款多容器网络接口插件)为容器组创建多网卡以满足网络隔离的需求(如容器组对外提供不同的服务时,各服务使用的网络之间的隔离)。然而,目前的网络插件并没有提供为单个容器组的多网卡按需分配网络带宽资源的能力,只能为其中单个网卡分配网络带宽资源。
图1为现有的一种多网卡创建及配置的实现框图。
如图1所示,主节点(Master Node)101运行容器应用程序接口服务(K8s-apiserver)根据容器组配置文件(Pod.yaml)在工作节点(Work Node)102上创建容器组(Pod)(包含容器container 1、容器container 2……),具体为将容器服务(Kubernetes,简称K8s)的核心组件(Kubelet)部署于工作节点102,调用多容器网络接口插件(Multus-CNI Plugin)以调用所需类型的网卡创建插件(网卡创建插件1、网卡创建插件2……)以为容器组创建及配置对应类型的网卡(网卡1、网卡2……网卡名称支持用户自命名)。如多容器网络接口插件可以调用Calico插件来创建并配置网卡eth0(通常为主网卡),也可以加载容器网络接口插件配置文件(如媒体介入控制层虚拟局域网容器网络接口(MacVlan CNI)配置文件)后调用媒体介入控制层虚拟局域网插件(MacVlan Plugin)来创建网卡net1。如调用Kube-ovn插件和Bandwidth插件等创建来创建单个网卡时,则可以实现对各自所创建的单个网卡的带宽资源的配置,但并不能实现对所有类型的网卡进行带宽资源配置。且这种分别对单个网卡进行带宽资源配置的方案在实现上非常繁琐。
发明内容
本申请的目的是提供一种容器多网卡网络配置方法、装置、设备及存储介质,用于实现对单个容器组的多网卡进行网络资源配置。
为解决上述技术问题,本申请提供一种容器多网卡网络配置方法,包括:
在根据工作负载容器创建任务完成对目标容器集群的目标节点上的目标容器组的多个网卡的创建后,触发多网卡网络资源配置任务;
获取目标容器组上各已创建网卡与目标节点的虚拟网线对的第一映射数据;
获取各已创建网卡与网络资源配置参数的第二映射数据;
根据第一映射数据和第二映射数据生成已创建网卡、网络资源配置参数与虚拟网线对的第三映射数据;
将第三映射数据传递至目标节点的操作系统内核以完成对各已创建网卡的网络资源配置。
可选的,在根据工作负载容器创建任务完成对目标容器集群的目标节点上的目标容器组的多个网卡的创建后,触发多网卡网络资源配置任务,具体为:
在调用多容器网络接口插件根据工作负载容器创建任务完成对目标容器组的多个网卡的创建后,若多容器网络接口插件的与预设的多网卡容器网络接口插件对应的能力配置选项为启用时,基于预先创建的网络附件自定义资源调用多网卡容器网络接口插件以执行多网卡网络资源配置任务。
可选的,获取目标容器组上各已创建网卡与目标节点的虚拟网线对的第一映射数据,具体包括:
获取目标容器组的容器组信息;
以容器组信息为关键字,访问操作系统内核查询与容器组信息对应的目标节点的宿主机端接口信息;
根据宿主机单接口信息和已创建网卡的信息,生成第一映射数据。
可选的,以容器组信息为关键字,访问操作系统内核查询与容器组信息对应的目标节点的宿主机端接口信息,具体为:
以容器组信息为关键字,调用网络链接套接字以访问链接查询接口,访问操作系统内核获取宿主机端接口信息。
可选的,以容器组信息为关键字,访问操作系统内核查询与容器组信息对应的目标节点的宿主机端接口信息,具体包括:
判断目标容器组是否创建成功;
若目标容器组创建成功,则以容器组信息为关键字,访问操作系统内核查询与宿主机端接口信息;
若目标容器组未创建成功,则记录目标容器组异常日志并向容器服务核心组件抛出目标容器组异常报错信息以结束本次多网卡网络资源配置任务;
判断目标容器组的各网卡是否创建成功;
若各网卡均创建成功,则获取并记录与各已创建网卡对应的宿主机端接口信息;
若各网卡未全部创建成功,则记录网卡异常日志并向容器服务核心组件抛出网卡异常报错信息以结束本次多网卡网络资源配置任务。
可选的,判断目标容器组是否创建成功,具体包括:
以容器组信息为关键字,向容器应用程序接口服务查询目标容器组的信息;
判断是否能够查询到目标容器组的信息;
如果能够查询到目标容器组的信息,则确定目标容器组创建成功;
如果不能够查询到目标容器组的信息,则确定目标容器组未创建成功。
可选的,判断目标容器组的各网卡是否创建成功,具体包括:
访问操作系统内核查询目标节点的宿主机端接口信息;
判断是否各网卡对应的宿主机端接口信息是否均存在;
如果各网卡对应的宿主机端接口信息均存在,则确定各网卡均创建成功;
如果各网卡对应的宿主机端接口信息不是均存在,则确定各网卡未全部创建成功。
可选的,获取各已创建网卡与网络资源配置参数的第二映射数据,具体包括:
向容器应用程序接口服务请求访问目标容器组的容器组配置文件以获取目标容器组的自定义注解信息;
解析自定义注解信息得到目标容器组的网卡网络资源配置信息;
根据各已创建网卡的创建信息与网卡网络资源配置信息,生成第二映射数据。
可选的,根据各已创建网卡的创建信息与网卡网络资源配置信息,生成第二映射数据,具体包括:
若网卡网络资源配置信息包含已创建网卡与对应的网络资源配置参数的映射数据,则以网卡网络资源配置信息包含的映射数据为第二映射数据;
若网卡网络资源配置信息不包含已创建网卡与对应的网络资源配置参数的映射数据,则根据默认网卡资源映射数据生成顺序生成第二映射数据。
可选的,根据默认网卡资源映射数据生成顺序生成第二映射数据,具体为:
根据网卡网络资源配置信息中包含的网络资源配置参数的顺序,以首个网络资源配置参数为已创建网卡中的主网卡对应的网络资源配置参数,按照其余网络资源配置参数的排列顺序和其余已创建网卡的创建顺序对应为已创建网卡分配网络资源配置参数,生成第二映射数据。
可选的,根据各已创建网卡的创建信息与网卡网络资源配置信息,生成第二映射数据,具体包括:
若网卡网络资源配置信息包含全部已创建网卡与对应的网络资源配置参数的映射数据,则以网卡网络资源配置信息包含的映射数据为第二映射数据;
若网卡网络资源配置信息不包含已创建网卡与对应的网络资源配置参数的映射数据,则根据默认网卡资源映射数据生成顺序生成第二映射数据;
若网卡网络资源配置信息仅包含部分已创建网卡与对应的网络资源配置参数的映射数据,则根据默认网卡资源映射数据生成顺序生成其余已创建网卡与对应的网络资源配置参数的映射数据后,得到第二映射数据。
可选的,根据默认网卡资源映射数据生成顺序生成第二映射数据,具体为:
根据网卡网络资源配置信息中包含的网络资源配置参数的顺序,以首个网络资源配置参数为已创建网卡中的主网卡对应的网络资源配置参数,按照其余网络资源配置参数 的排列顺序和其余已创建网卡的创建顺序对应为已创建网卡分配网络资源配置参数,生成第二映射数据;
根据默认网卡资源映射数据生成顺序生成其余已创建网卡与对应的网络资源配置参数的映射数据,具体为:
根据其余网络资源配置参数的排列顺序和其余已创建网卡的创建顺序对应为其余已创建网卡分配网络资源配置参数,得到其余已创建网卡与对应的网络资源配置参数的映射数据。
可选的,网卡网络资源配置信息包含已创建网卡与对应的网络资源配置参数的映射数据,具体为:
若网卡网络资源配置信息包含预设字符,则以预设字符为分割字符获取已创建网卡的信息和对应的网络资源配置参数,得到已创建网卡与对应的网络资源配置参数的映射数据。
可选的,若网卡网络资源配置信息包含已创建网卡与对应的网络资源配置参数的映射数据,则以网卡网络资源配置信息包含的映射数据为第二映射数据,具体包括:
若网卡网络资源配置信息包含已创建网卡与对应的网络资源配置参数的映射数据,则判断映射数据中的已创建网卡的信息是否包含于目标容器组的容器多网卡列表;
如果映射数据中的已创建网卡的信息包含于目标容器组的容器多网卡列表,则以网卡网络资源配置信息包含的映射数据为第二映射数据;
如果映射数据中的已创建网卡的信息未包含于目标容器组的容器多网卡列表,则记录自定义注解信息异常日志并向容器服务核心组件抛出自定义注解信息报错信息以结束本次多网卡网络资源配置任务。
可选的,根据各已创建网卡的创建信息与网卡网络资源配置信息,生成第二映射数据,具体包括:
判断网卡网络资源配置信息中记载的网络资源配置参数是否满足预设网卡资源配置要求;
如果网卡网络资源配置信息中记载的网络资源配置参数满足预设网卡资源配置要求,则根据各已创建网卡的创建信息与网卡网络资源配置信息,生成第二映射数据;
如果网卡网络资源配置信息中记载的网络资源配置参数不满足预设网卡资源配置要求,则记录自定义注解信息异常日志并向容器服务核心组件抛出自定义注解信息报错信息以结束本次多网卡网络资源配置任务。
可选的,判断网卡网络资源配置信息中记载的网络资源配置参数是否满足预设网卡资源配置要求,具体包括:
判断网卡网络资源配置信息中记载的网络资源配置参数是否均为大于0且采用约定单位的网络资源配置参数;
如果网卡网络资源配置信息中记载的网络资源配置参数均为大于0且采用约定单位的网络资源配置参数,则确定网卡网络资源配置信息中记载的网络资源配置参数满足预设网卡资源配置要求;
如果网卡网络资源配置信息中记载的网络资源配置参数不是均为大于0且采用约定 单位的网络资源配置参数,则确定网卡网络资源配置信息中记载的网络资源配置参数不满足预设网卡资源配置要求。
可选的,将第三映射数据传递至目标节点的操作系统内核以完成对各已创建网卡的网络资源配置,具体包括:
判断第三映射数据对应的多网卡网络资源配置映射表是否存在;
若多网卡网络资源配置映射表存在,则判断多网卡网络资源配置映射表中的网络资源配置参数是否发生变化;
如果网络资源配置参数发生变化,则更新多网卡网络资源配置映射表;
如果多网卡网络资源配置映射表不存在,则根据第三映射数据生成多网卡网络资源配置映射表;
基于多网卡网络资源配置映射表组装队列规则数据,向操作系统内核发送网络链接消息,以实现对各已创建网卡的网络资源配置。
可选的,在将第三映射数据传递至目标节点的操作系统内核以完成对各已创建网卡的网络资源配置之后,还包括:
检查并生成对各已创建网卡的网络资源配置的配置结果。
可选的,检查对各已创建网卡的网络资源配置的配置结果,具体为:
查询与多网卡网络资源配置任务对应的日志文件,得到对各已创建网卡的网络资源配置的配置结果。
可选的,检查对各已创建网卡的网络资源配置的配置结果,具体包括:
获取与目标容器组对应的虚拟网线对的信息;
利用流量控制命令携带虚拟网线对的信息访问操作系统内核,查询对应的目标节点的宿主机端接口信息对应的网络资源配置状态;
以网络资源配置状态为已创建网卡的网络资源配置的配置结果。
可选的,检查对各已创建网卡的网络资源配置的配置结果,具体包括:
调用预设压力测试工具测试各已创建网卡的网络状态;
以各已创建网卡的网络状态为各已创建网卡的网络资源配置的配置结果。
为解决上述技术问题,本申请还提供一种容器多网卡网络配置装置,包括:
参数判决模块,用于在根据工作负载容器创建任务完成对目标容器集群的目标节点上的目标容器组的多个网卡的创建并触发多网卡网络资源配置任务后,获取目标容器组上各已创建网卡与目标节点的虚拟网线对的第一映射数据;
容器组网卡网络资源配置信息获取模块,用于获取各已创建网卡与网络资源配置参数的第二映射数据;
多网卡网络资源配置信息映射模块,用于根据第一映射数据和第二映射数据生成已创建网卡、网络资源配置参数与虚拟网线对的第三映射数据,将第三映射数据传递至目标节点的操作系统内核以完成对各已创建网卡的网络资源配置。
为解决上述技术问题,本申请还提供一种容器多网卡网络配置设备,包括:
存储器,用于存储计算机程序;
处理器,用于执行计算机程序,计算机程序被处理器执行时实现如上述任意一项容 器多网卡网络配置方法的步骤。
为解决上述技术问题,本申请还提供一种存储介质,其上存储有计算机程序,计算机程序被处理器执行时实现如上述任意一项容器多网卡网络配置方法的步骤。
本申请所提供的容器多网卡网络配置方法,在根据工作负载容器创建任务完成对目标容器集群的目标节点上的目标容器组的多个网卡的创建后,触发多网卡网络资源配置任务,从而分别获取目标容器组上各已创建网卡与目标节点的虚拟网线对的第一映射数据,以及各已创建网卡与网络资源配置参数的第二映射数据,以根据第一映射数据和第二映射数据生成已创建网卡、网络资源配置参数与虚拟网线对的第三映射数据,进而将第三映射数据传递至目标节点的操作系统内核以完成对各已创建网卡的网络资源配置,实现了对容器组上各个网卡的网络资源配置,为生产网络与管理网络隔离的多网络融合部署的应用场景提供了粒度更细的网络资源分配策略。
本申请还提供一种容器多网卡网络配置装置、设备及存储介质,具有上述有益效果。
附图说明
为了更清楚的说明本申请实施例或现有技术的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单的介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为现有的一种多网卡创建及配置的实现框图;
图2为本申请实施例提供的一种容器多网卡网络配置方法的流程图;
图3为本申请实施例提供的一种多网卡创建及配置的实现框图;
图4为本申请实施例提供的一种第一映射数据的映射关系示意图;
图5为本申请实施例提供的一种第三映射数据的映射关系示意图;
图6为本申请实施例提供的一种第三映射数据的存储结构示意图;
图7为本申请实施例提供的一种S202的具体实施方式的流程图;
图8为本申请实施例提供的一种S203的具体实施方式的流程图;
图9为本申请实施例提供的一种S205的具体实施方式的流程图;
图10为本申请实施例提供的一种容器多网卡网络配置装置的结构示意图;
图11为本申请实施例提供的一种容器多网卡网络配置设备的结构示意图。
具体实施方式
本申请的核心是提供一种容器多网卡网络配置方法、装置、设备及存储介质,用于实现对单个容器组的多网卡进行网络资源配置。
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
实施例一
图2为本申请实施例提供的一种容器多网卡网络配置方法的流程图;图3为本申请实 施例提供的一种多网卡创建及配置的实现框图;图4为本申请实施例提供的一种第一映射数据的映射关系示意图;图5为本申请实施例提供的一种第三映射数据的映射关系示意图;图6为本申请实施例提供的一种第三映射数据的存储结构示意图。
如图2所示,本申请实施例提供的容器多网卡网络配置方法包括:
S201:在根据工作负载容器创建任务完成对目标容器集群的目标节点上的目标容器组的多个网卡的创建后,触发多网卡网络资源配置任务。
S202:获取目标容器组上各已创建网卡与目标节点的虚拟网线对的第一映射数据。
S203:获取各已创建网卡与网络资源配置参数的第二映射数据。
S204:根据第一映射数据和第二映射数据生成已创建网卡、网络资源配置参数与虚拟网线对的第三映射数据。
S205:将第三映射数据传递至目标节点的操作系统内核以完成对各已创建网卡的网络资源配置。
在具体实施中,本申请实施例提供的容器多网卡网络配置方法可以基于预先部署于容器集群的多网卡容器网络接口插件(MultiNic-Qos CNI Plugin)实现,该多网卡容器网络接口插件用于受多容器网络接口插件(Multus-CNI Plugin)调用以获取目标容器组上多个已创建网卡的网卡网络资源配置信息,自动生成映射数据并将映射数据写入宿主机的操作系统内核以实现对目标容器组的各已创建网卡的网络资源配置。
则如图3所示,对于S201来说,主节点(Master Node)301运行容器应用程序接口服务(K8s-apiserver)根据容器组配置文件(Pod.yaml)在工作节点(Work Node)302上创建容器组(Pod)(包含容器container 1、容器container 2……),将容器服务(Kubernetes,简称K8s)的核心组件(Kubelet)部署于工作节点302,调用多容器网络接口插件(Multus-CNI Plugin)以调用所需类型的网卡创建插件(网卡创建插件1、网卡创建插件2……)以为目标容器组创建及配置对应类型的网卡(网卡1、网卡2……网卡名称支持用户自命名)。多容器网络接口插件可以调用Calico插件来创建并配置网卡eth0(通常为主网卡),也可以加载容器网络接口插件配置文件(如媒体介入控制层虚拟局域网容器网络接口(MacVlan CNI)配置文件)后调用媒体介入控制层虚拟局域网插件(MacVlan Plugin)来创建网卡net1。
在核心组件(Kubelet)调用多容器网络接口插件(Multus-CNI Plugin)根据容器组配置文件(Pod.yaml)完成对目标容器组的多网卡的创建与配置后,组装容器多网卡列表(ifNameList)、容器组名称(PodName)、容器组命名空间(PodNameSpace)等参数并调用本申请实施例提供的多网卡容器网络接口插件(MultiNic-Qos CNI Plugin),即触发多网卡网络资源配置任务。
为实现调用多网卡容器网络接口插件(MultiNic-Qos CNI Plugin),预先修改多容器网络接口插件(Multus-CNI Plugin)的配置文件,增加能力(capabilities)配置选项,并根据实际场景需求,创建网络附件自定义资源(Network Attachment Definition CRD)。则S201中在根据工作负载容器创建任务完成对目标容器集群的目标节点上的目标容器组的多个网卡的创建后,触发多网卡网络资源配置任务,具体可以为:在调用多容器网络接口插件根据工作负载容器创建任务完成对目标容器组的多个网卡的创建后,若多容器 网络接口插件的与预设的多网卡容器网络接口插件对应的能力配置选项为启用时,基于预先创建的网络附件自定义资源调用多网卡容器网络接口插件以执行多网卡网络资源配置任务。
其中,多容器网络接口插件(Multus-CNI Plugin)的配置文件的能力(capabilities)配置选项参考如下:
"capabilities":{
       "multiNic-Qos":true
}
即当该新增的能力配置选项为多网卡容器网络接口插件(MultiNic-Qos CNI Plugin)赋值为启用(true)时,在完成对目标容器组的多个网卡的创建后调用多网卡容器网络接口插件(MultiNic-Qos CNI Plugin);若能力配置选项为多网卡容器网络接口插件(MultiNic-Qos CNI Plugin)赋值为禁用(false)时,则在完成对目标容器组的多个网卡的创建后不调用多网卡容器网络接口插件(MultiNic-Qos CNI Plugin)。
此外,在执行多网卡网络资源配置任务之前,还需要进行对目标容器组的各网卡的网络资源配置参数的配置。具体可以给用户提供网络资源配置入口,供用户对目标容器组的各网卡的入方向(ingress)和各网卡的出方向(egress)的双向网络资源配置参数的配置。该配置主要依赖于容器服务的自定义注解信息服务(Kubernetes Annotation)实现。
网络资源配置参数具体可以为带宽限速值。多网卡入方向和出方向的配置实现大致相同。对目标容器组各网卡的入方向(ingress)的网络资源配置参数具体可以为:
多网卡入方向限速关键字(KEY):带宽限速值1,带宽限速值2,……,带宽限速值n;
或,多网卡入方向限速关键字(KEY):网卡名称1@带宽限速值1,网卡名称2@带宽限速值2,……,网卡名称n@带宽限速值n。
多网卡出方向限速关键字(KEY):带宽限速值1,带宽限速值2,……,带宽限速值n;
或,多网卡出方向限速关键字(KEY):网卡名称1@带宽限速值1,网卡名称2@带宽限速值2,……,网卡名称n@带宽限速值n。
则创建的工作负载的容器组配置文件(Pod.yaml)中的自定义注解信息(Annotation)增加的多网卡的网络资源配置参数,具体可以选择“[多网卡限速KEY]:[带宽限速值1,带宽限速值2,…,带宽限速值n]”或“[多网卡限速KEY]:[网卡名称1@带宽限速值1,网卡名称2@带宽限速值2,…,网卡名称n@带宽限速值n]”的配置方式。
为保证识别成功,给用户提供可选的网络资源配置参数的单位。如带宽限速值的单位可以为千比特/兆比特/吉比特(Kbits/Mbits/Gbits)。
设计多网卡容器网络接口插件(MultiNic-Qos CNI Plugin)在被调用后执行S202~S205。实现对目标容器组的多网卡的网络资源配置的关键在于获取目标容器组的各已创建网卡、各已创建网卡对应的网络资源配置参数以及所在的目标节点的虚拟网线对三者之间的映射关系。其中,S202和S203之间可以无顺序关系,可以先后执行也可以同 时执行。
对于S202来说,多网卡容器网络接口插件(MultiNic-Qos CNI Plugin)解析并校验多容器网络接口插件(Multus-CNI Plugin)传递的参数,以确定目标容器组的已创建网卡的信息以及已创建网卡在目标节点上对应的虚拟网线对(Veth-Pair对),来生成目标容器组上各已创建网卡与目标节点的虚拟网线对的第一映射数据。如图4所示,第一映射数据可以为已创建网卡的名称与虚拟网线对网卡的名称的映射数据,已创建网卡的名称具体为主网卡(PodMasterIf)、已创建网卡1(PodIfName 1)、已创建网卡2(PodIfName 2)、……、已创建网卡N(PodIfNameN),分别对应虚拟网线对网卡的名称:主机主网卡(HostMasterIf)、主机网卡1(HostIfName 1)、主机网卡2(HostIfName 2)、……、主机网卡N(HostIfName N)。
对于S203来说,如图3所示,多网卡容器网络接口插件(MultiNic-Qos CNI Plugin)访问容器应用程序接口服务(K8s-apiserver)以访问容器组配置文件(Pod.yaml),从中获取自定义注解信息(Annotation)中的网络资源配置参数,根据解析容器服务核心组件(kubelet)传递的参数得到的已创建网卡的信息,来生成已创建网卡与网络资源配置参数的第二映射数据。第二映射数据可以包括已创建网卡的名称与对应的入方向网络资源配置参数以及对应的出方向网络资源配置参数,网络资源配置参数具体可以为带宽限速值。
则对于S204来说,生成的已创建网卡、网络资源配置参数与虚拟网线对的第三映射数据,具体可以为已创建网卡的名称、入方向网络资源配置参数、出方向网络资源配置参数以及虚拟网线对网卡的名称的映射数据。如图5所示,已创建网卡的名称具体为主网卡(PodMasterIf)、已创建网卡1(PodIfName 1)、已创建网卡2(PodIfName 2)、……、已创建网卡N(PodIfName N),分别对应虚拟网线对网卡的名称:主机主网卡(HostMasterIf)、主机网卡1(HostIfName 1)、主机网卡2(HostIfName 2)、……、主机网卡N(HostIfName N),进而分别对应网卡入方向带宽限速值:入方向限速值0(IngressRate 0)、入方向限速值1(IngressRate 1)、入方向限速值2(IngressRate 2)、……、入方向限速值N(IngressRate N),以及网卡出方向带宽限速值:出方向限速值0(EgressRate 0)、出方向限速值1(EgressRate 1)、出方向限速值2(EgressRate 2)、……、出方向限速值N(EgressRate N)。
第三映射数据的存储结构可以如图6所示,构建多网卡网络资源配置映射表,该多网卡网络资源配置映射表在目标容器组的标识关键字(PodIDKey)下,依次对应N+1个已创建网卡的名称关键字(PodIfNameKey);每个已创建网卡的名称关键字(PodIfNameKey)对应一个主机网卡名称关键字(HostIfNameKey),每个已创建网卡的名称关键字(PodIfNameKey)还对应入方向网络资源配置参数(IngressRateKey)、入方向带宽限速值(IngressRate)以及出方向网络资源配置参数(EgressRateKey)、出方向带宽限速值(EgressRate)。
对于S205来说,根据S204生成的第三映射数据,下发操作系统内核创建队列规则(Qdisc)实现对目标容器组的各已创建网卡的网络资源配置。其中,操作系统内核具体可以为Linux操作系统的内核
本申请实施例提供的容器多网卡网络配置方法,在根据工作负载容器创建任务完成对目标容器集群的目标节点上的目标容器组的多个网卡的创建后,触发多网卡网络资源配置任务,从而分别获取目标容器组上各已创建网卡与目标节点的虚拟网线对的第一映射数据,以及各已创建网卡与网络资源配置参数的第二映射数据,以根据第一映射数据和第二映射数据生成已创建网卡、网络资源配置参数与虚拟网线对的第三映射数据,进而将第三映射数据传递至目标节点的操作系统内核以完成对各已创建网卡的网络资源配置,实现了对容器组上各个网卡的网络资源配置,为生产网络与管理网络隔离的多网络融合部署的应用场景提供了粒度更细的网络资源分配策略。
实施例二
图7为本申请实施例提供的一种S202的具体实施方式的流程图。
在上述实施例的基础上,本申请实施例进一步对生成第一映射数据的方法进行说明。如图7所示,S202:获取目标容器组上各已创建网卡与目标节点的虚拟网线对的第一映射数据,具体包括:
S701:获取目标容器组的容器组信息。
S702:以容器组信息为关键字,访问操作系统内核查询与容器组信息对应的目标节点的宿主机端接口信息。
S703:根据宿主机单接口信息和已创建网卡的信息,生成第一映射数据。
在具体实施中,对于S701来说,具体可以解析多容器网络接口插件(Multus-CNI Plugin)传递的参数得到目标容器组的容器组信息,具体包括容器多网卡列表(ifNameList)、容器组命名空间(PodNameSpace)、容器组名称(PodName)等。
对于S702来说,以容器组信息为关键字,具体可以以容器组命名空间(PodNameSpace)、容器组名称(PodName)为关键字(KEY),访问操作系统内核查询与容器组信息对应的目标节点的宿主机端接口信息。
S702具体可以为:以容器组信息为关键字,调用网络链接套接字以访问链接查询接口,访问操作系统内核获取宿主机端接口信息。其中,网络链接(NetLink)套接字为用于实现用户进程与内核通信的一种特殊的进程间通信(IPC),也是网络应用程序与内核通信的最常用的接口。故可以调用网络链接(NetLink)套接字来调用链接(Link)查询接口,来访问操作系统内核获取宿主机端接口信息。
而为了提高执行流畅度,S702:以容器组信息为关键字,访问操作系统内核查询与容器组信息对应的目标节点的宿主机端接口信息,具体可以包括:
判断目标容器组是否创建成功;
若目标容器组创建成功,则以容器组信息为关键字,访问操作系统内核查询与宿主机端接口信息;
若目标容器组未创建成功,则记录目标容器组异常日志并向容器服务核心组件抛出目标容器组异常报错信息以结束本次多网卡网络资源配置任务;
判断目标容器组的各网卡是否创建成功;
若各网卡均创建成功,则获取并记录与各已创建网卡对应的宿主机端接口信息;
若各网卡未全部创建成功,则记录网卡异常日志并向容器服务核心组件抛出网卡异 常报错信息以结束本次多网卡网络资源配置任务。
即在获取宿主机接口信息时,首先校验目标容器组是否被成功创建,其次校验各网卡是否均被成功创建。对其中不成功的流程,记录相应的异常日志,并向容器服务核心组件(kubelet)抛出报错信息以结束对多网卡容器网络接口插件(MultiNic-Qos CNI Plugin)的调用,结束本次多网卡网络资源配置任务。均成功后才获取并记录各已创建网卡对应的宿主机端接口信息。
判断目标容器组是否创建成功,具体可以包括:以容器组信息为关键字,向容器应用程序接口服务查询目标容器组的信息;判断是否能够查询到目标容器组的信息;如果能够查询到目标容器组的信息,则确定目标容器组创建成功;如果不能够查询到目标容器组的信息,则确定目标容器组未创建成功。即是说,通过容器应用程序接口服务(K8s-apiserver)尝试查询目标容器组的信息,如果能够查询到,则说明目标容器组已被创建成功。如果无法查询到,则说明目标容器组未被创建成功。
判断目标容器组的各网卡是否创建成功,具体可以包括:访问操作系统内核查询目标节点的宿主机端接口信息;判断是否各网卡对应的宿主机端接口信息是否均存在;如果各网卡对应的宿主机端接口信息均存在,则确定各网卡均创建成功;如果各网卡对应的宿主机端接口信息不是均存在,则确定各网卡未全部创建成功。由于容器组采用虚拟机网线对于宿主机的内核协议栈连接,故可以在遍历容器组信息中的容器多网卡列表(ifNameList),得到由多容器网络接口插件(Multus-CNI Plugin)提供的已创建网卡的信息,此时并不确定这些网卡均已被创建成功,可以如上文所介绍的,以容器组信息为关键字,具体可以以容器组命名空间(PodNameSpace)、容器组名称(PodName)为关键字(KEY),调用网络链接(NetLink)套接字以访问链接(Link)查询接口,访问操作系统内核获取对应的宿主机端接口信息。若能够获取到所有已创建网卡对应的宿主机端接口信息,则确定这些网卡均被创建成功,否则,则该目标容器组的多网卡创建失败。
对于S703来说,根据与已创建网卡的对应的宿主机端接口信息,生成各已创建网卡与目标节点的虚拟网线对(Veth-Pair对)的第一映射数据。第一映射数据的数据结构具体可以参考本申请实施例一以及图4所示,在此不再赘述。
实施例三
图8为本申请实施例提供的一种S203的具体实施方式的流程图。
在上述实施例的基础上,本申请实施例进一步对生成第二映射数据的方法进行说明。如图8所示,S203:获取各已创建网卡与网络资源配置参数的第二映射数据,具体包括:
S801:向容器应用程序接口服务请求访问目标容器组的容器组配置文件以获取目标容器组的自定义注解信息。
S802:解析自定义注解信息得到目标容器组的网卡网络资源配置信息。
S803:根据各已创建网卡的创建信息与网卡网络资源配置信息,生成第二映射数据。
在具体实施中,对于S801来说,通过向容器应用程序接口服务(K8s-apiserver)请求 容器组配置文件(Pod.yaml)以获取自定义注解信息(Annotation)。
对于S802来说,可以以网络资源配置参数(如带宽限速值)为关键字(KEY),在自定义注解信息(Annotation)中识别得到目标容器组的网卡网络资源配置信息。
对于S803来说,请结合本申请实施例一,预先为用户提供的配置多网卡的网络资源的方式有两种,第一种为用户自定义映射配置,第二种为默认映射配置。当用户进行了自定义映射配置时,则优先采用用户自定义映射配置。若用户未进行自定义映射配置,才采用默认映射配置。
则S803:根据各已创建网卡的创建信息与网卡网络资源配置信息,生成第二映射数据,具体可以包括:
若网卡网络资源配置信息包含已创建网卡与对应的网络资源配置参数的映射数据,则以网卡网络资源配置信息包含的映射数据为第二映射数据;
若网卡网络资源配置信息不包含已创建网卡与对应的网络资源配置参数的映射数据,则根据默认网卡资源映射数据生成顺序生成第二映射数据。
其中,网卡网络资源配置信息中包含已创建网卡与对应的网络资源配置参数的映射数据,具体可以为:若网卡网络资源配置信息包含预设字符,则以预设字符为分割字符获取已创建网卡的信息和对应的网络资源配置参数,得到已创建网卡与对应的网络资源配置参数的映射数据。如本申请实施例一介绍的,预设字符可以为“@”。即预先约定用户在自定义注解信息(Annotation)中设置网卡网络资源配置信息的方式为“网卡名称1@带宽限速值1,网卡名称2@带宽限速值2,……,网卡名称n@带宽限速值n”,则在识别自定义注解信息(Annotation)时,也按照该方式识别预设字符“@”,并分割得到一对对的网卡名称和带宽限速值,即得到第二映射数据。
而根据默认网卡资源映射数据生成顺序生成第二映射数据,具体可以为:根据网卡网络资源配置信息中包含的网络资源配置参数的顺序,以首个网络资源配置参数为已创建网卡中的主网卡对应的网络资源配置参数,按照其余网络资源配置参数的排列顺序和其余已创建网卡的创建顺序对应为已创建网卡分配网络资源配置参数,生成第二映射数据。即根据多容器网络接口插件(Multus-CNI Plugin)创建网卡的顺序,以及网络资源配置参数在自定义注解信息(Annotation)中的排列顺序,依次为各已创建网卡分配网络资源配置参数。
可以理解的是,还可以设置其他的默认映射配置。
为了提高执行流畅度,在执行过程中进行校验与报错。在S803中,若网卡网络资源配置信息包含已创建网卡与对应的网络资源配置参数的映射数据,则以网卡网络资源配置信息包含的映射数据为第二映射数据,具体可以包括:
若网卡网络资源配置信息包含已创建网卡与对应的网络资源配置参数的映射数据,则判断映射数据中的已创建网卡的信息是否包含于目标容器组的容器多网卡列表;
如果映射数据中的已创建网卡的信息包含于目标容器组的容器多网卡列表,则以网卡网络资源配置信息包含的映射数据为第二映射数据;
如果映射数据中的已创建网卡的信息不是包含于目标容器组的容器多网卡列表,则记录自定义注解信息异常日志并向容器服务核心组件抛出自定义注解信息报错信息以结 束本次多网卡网络资源配置任务。
具体地,在确定网卡网络资源配置信息中包含已创建网卡与对应的网络资源配置参数的映射数据时,可以以预设字符“@”为分割字符获取网卡网络资源配置信息中的网卡名称和对应的网络资源配置参数,并判断该网卡是否存在于多容器网络接口插件(Multus-CNI Plugin)提供的目标容器组的容器组信息的容器多网卡列表(ifnameList)中,若该网卡存在于多容器网络接口插件(Multus-CNI Plugin)提供的目标容器组的容器组信息的容器多网卡列表(ifnameList)中,才继续执行后续流程;若该网卡不存在于多容器网络接口插件(Multus-CNI Plugin)提供的目标容器组的容器组信息的容器多网卡列表(ifnameList)中,则向容器服务核心组件(kubelet)抛出报错信息以结束对多网卡容器网络接口插件(MultiNic-Qos CNI Plugin)的调用,结束本次多网卡网络资源配置任务。
同样在S803中,在根据自定义注解信息(Annotation)中记载的网络资源配置参数生成第二映射数据时,也对网络资源配置参数进行校验以避免因网络资源配置参数异常而配置失败。即S803:根据各已创建网卡的创建信息与网卡网络资源配置信息,生成第二映射数据,具体可以包括:
判断网卡网络资源配置信息中记载的网络资源配置参数是否满足预设网卡资源配置要求;
如果网卡网络资源配置信息中记载的网络资源配置参数满足预设网卡资源配置要求,则根据各已创建网卡的创建信息与网卡网络资源配置信息,生成第二映射数据;
如果网卡网络资源配置信息中记载的网络资源配置参数不满足预设网卡资源配置要求,则记录自定义注解信息异常日志并向容器服务核心组件抛出自定义注解信息报错信息以结束本次多网卡网络资源配置任务。
如本申请实施例一介绍的,预先给用户提供可选的网络资源配置参数的单位。则判断网卡网络资源配置信息中记载的网络资源配置参数是否满足预设网卡资源配置要求,具体可以包括:
判断网卡网络资源配置信息中记载的网络资源配置参数是否均为大于0且采用约定单位的网络资源配置参数;
如果网卡网络资源配置信息中记载的网络资源配置参数均为大于0且采用约定单位的网络资源配置参数,则确定网卡网络资源配置信息中记载的网络资源配置参数满足预设网卡资源配置要求;
如果网卡网络资源配置信息中记载的网络资源配置参数不是均为大于0且采用约定单位的网络资源配置参数,则确定网卡网络资源配置信息中记载的网络资源配置参数不满足预设网卡资源配置要求。
其中,约定单位的网络资源配置参数可以千比特/兆比特/吉比特(Kbits/Mbits/Gbits)的带宽限速值。
此外,预设网卡资源配置要求还可以为网络资源配置参数满足其他的预设范围且采用约定单位的网络资源配置参数。
实施例四
除此以外,可能还存在用户仅制定了部分网卡对应的网络资源配置参数的情况,此 时可以先按照自定义注解信息(Annotation)生成这部分已创建网卡与网络资源配置参数的映射数据,再按照默认映射配置生成剩余已创建网卡与网络资源配置参数的映射数据。则S803:根据各已创建网卡的创建信息与网卡网络资源配置信息,生成第二映射数据,具体可以包括:
若网卡网络资源配置信息包含全部已创建网卡与对应的网络资源配置参数的映射数据,则以网卡网络资源配置信息包含的映射数据为第二映射数据;
若网卡网络资源配置信息不包含已创建网卡与对应的网络资源配置参数的映射数据,则根据默认网卡资源映射数据生成顺序生成第二映射数据;
若网卡网络资源配置信息仅包含部分已创建网卡与对应的网络资源配置参数的映射数据,则根据默认网卡资源映射数据生成顺序生成其余已创建网卡与对应的网络资源配置参数的映射数据后,得到第二映射数据。
其中,网卡网络资源配置信息包含全部已创建网卡的映射数据的情况,以及未包含映射数据的情况,可以参考上文的介绍实施。而网卡网络资源配置信息仅包含部分已创建网卡的映射数据的场景下,则先按照自定义注解信息(Annotation)生成这部分已创建网卡与网络资源配置参数的映射数据,再根据默认网卡资源映射数据生成顺序生成其余已创建网卡与对应的网络资源配置参数的映射数据,汇总得到第二映射数据。
此时,根据默认网卡资源映射数据生成顺序生成第二映射数据,具体为:
根据网卡网络资源配置信息中包含的网络资源配置参数的顺序,以首个网络资源配置参数为已创建网卡中的主网卡对应的网络资源配置参数,按照其余网络资源配置参数的排列顺序和其余已创建网卡的创建顺序对应为已创建网卡分配网络资源配置参数,生成第二映射数据。根据默认网卡资源映射数据生成顺序生成其余已创建网卡与对应的网络资源配置参数的映射数据,具体为:根据其余网络资源配置参数的排列顺序和其余已创建网卡的创建顺序对应为其余已创建网卡分配网络资源配置参数,得到其余已创建网卡与对应的网络资源配置参数的映射数据。
其中,在网卡网络资源配置信息中包含全部或部分已创建网卡对应的映射数据时,对映射数据中的网卡名称进行校验的方式,以及对网卡网络资源配置信息中包含的网络资源配置参数进行的方式,可以参考本申请实施例四的说明。
实施例五
图9为本申请实施例提供的一种S205的具体实施方式的流程图。
在上述实施例的基础上,本申请实施例进一步对实现多网卡网络资源配置的执行步骤进行说明。如图9所示,S205:将第三映射数据传递至目标节点的操作系统内核以完成对各已创建网卡的网络资源配置,具体可以包括:
S901:判断第三映射数据对应的多网卡网络资源配置映射表是否存在;如果第三映射数据对应的多网卡网络资源配置映射表存在,则进入S902;如果第三映射数据对应的多网卡网络资源配置映射表不存在,则进入S904。
S902:判断多网卡网络资源配置映射表中的网络资源配置参数是否发生变化,如果多网卡网络资源配置映射表中的网络资源配置参数发生变化,则进入S903。
S903:更新多网卡网络资源配置映射表,并进入S905。
S904:根据第三映射数据生成多网卡网络资源配置映射表,并进入S905。
S905:基于多网卡网络资源配置映射表组装队列规则数据,向操作系统内核发送网络链接消息,以实现对各已创建网卡的网络资源配置。
在具体实施中,对于S901~S904来说,多网卡网络资源配置映射表可以参考本申请实施例一以及附图6提供的第三映射数据的存储结构。在执行过程中,以多网卡网络资源配置映射表的形式维护第三映射数据,如果目标容器组为初次创建多网卡,则需要生成多网卡网络资源配置映射表,如果目标容器组的网卡发生变动,则需要更新多网卡网络资源配置映射表。
对于S902来说,判断多网卡网络资源配置映射表中的网络资源配置参数是否发生变化,具体可以通过以目标容器组的容器组信息为关键字,查询多网卡网络资源配置映射表中目标容器组的标识关键字(PodIDKey)下的数据记录,依次对比每个网卡的出入方向带宽限速值是否改变,若网卡的出入方向带宽限速值改变则执行S903更新多网卡网络资源配置映射表,并记录变更日志,若网卡的出入方向带宽限速值未改变则执行S905。
对于S905来说,获取目标容器组的标识关键字(PodIDKey)为索引的数据条目,并以主机网卡名称(HostIfNameKey)、出入方向带宽限速值(IngressRate/EgressRate)数据构建网络链接(NetLink)消息,调用操作系统内核的流量控制(traffic control,TC)模块,创建令牌桶(TBF)类型的队列规则(Qdisc)实现网卡网络资源配置功能。
操作系统内核收到网络链接(NetLink)消息后,由流量控制(TC)模块实现对目标容器组的多网卡的网络资源配置。
实施例六
在上述实施例中,介绍了通过日志来记录多网卡网络资源配置任务执行过程中的异常事件,并通过向容器服务核心组件(kubelet)抛出报错信息来结束本次多网卡网络资源配置任务,即结束多网卡容器网络接口插件(MultiNic-Qos CNI Plugin)的调用。
则具体可以在多网卡网络资源配置任务的执行过程中,对执行环节均记录日志,以便追溯执行情况,方便对流程分析与排错处理。
实施例七
在上述实施例的基础上,在S205:将第三映射数据传递至目标节点的操作系统内核以完成对各已创建网卡的网络资源配置之后,本申请实施例提供的容器多网卡网络配置方法还可以包括:
检查并生成对各已创建网卡的网络资源配置的配置结果。
在完成对目标容器组的创建、多网卡的创建以及执行多网卡网络资源配置任务之后,即完成对工作负载的创建之后,可以通过检查工作负载的状态(是否为运行状态)来确定是否创建成功。同时可以通过查询日志来查看处理流程是否正确。则检查对各已创建网卡的网络资源配置的配置结果,具体可以为:查询与多网卡网络资源配置任务对应的日志文件,得到对各已创建网卡的网络资源配置的配置结果。
或者,还可以通过操作系统内核中维护的队列队列规则(Qdisc)来查看目标容器组的网卡网络资源配置情况。则检查对各已创建网卡的网络资源配置的配置结果,具体可以包括:
获取与目标容器组对应的虚拟网线(veth-pair)对的信息;
利用流量控制(TC)命令携带虚拟网线对的信息访问操作系统内核,查询对应的目标节点的宿主机端接口信息对应的网络资源配置状态;
以网络资源配置状态为已创建网卡的网络资源配置的配置结果。
或者,还可以通过测试目标容器组的各网卡对应的实际网络状态来查看目标容器组的网卡网络资源配置情况。则检查对各已创建网卡的网络资源配置的配置结果,具体可以包括:
调用预设压力测试工具测试各已创建网卡的网络状态;
以各已创建网卡的网络状态为各已创建网卡的网络资源配置的配置结果。
其中,预设压力测试工具可以采用iperf压测工具,具体可以测量目标容器组的各已创建网卡的带宽限速值,与多网卡网络资源配置映射表中的对应数据进行对比,以确定目标容器组的网卡网络资源配置情况。
上文详述了容器多网卡网络配置方法对应的各个实施例,在此基础上,本申请还公开了与上述方法对应的容器多网卡网络配置装置、设备及存储介质。
实施例八
图10为本申请实施例提供的一种容器多网卡网络配置装置的结构示意图。
如图10所示,本申请实施例提供的容器多网卡网络配置装置包括:
参数判决模块1001,用于在根据工作负载容器创建任务完成对目标容器集群的目标节点上的目标容器组的多个网卡的创建并触发多网卡网络资源配置任务后,获取目标容器组上各已创建网卡与目标节点的虚拟网线对的第一映射数据;
容器组网卡网络资源配置信息获取模块1002,用于获取各已创建网卡与网络资源配置参数的第二映射数据;
多网卡网络资源配置信息映射模块1003,用于根据第一映射数据和第二映射数据生成已创建网卡、网络资源配置参数与虚拟网线对的第三映射数据,将第三映射数据传递至目标节点的操作系统内核以完成对各已创建网卡的网络资源配置。
进一步的,本申请实施例提供的容器多网卡网络配置装置还可以包括:
事件上报模块1004,用于根据参数判决模块1001、容器组网卡网络资源配置信息获取模块1002、多网卡网络资源配置信息映射模块1003各模块的执行过程中产生的错误生成报错信息并上报容器服务核心组件(kubelet);
日志收集模块1005,用于根据参数判决模块1001、容器组网卡网络资源配置信息获取模块1002、多网卡网络资源配置信息映射模块1003各模块的执行流程生成日志,以及根据各模块的执行过程中产生的错误生成异常日志。
由于装置部分的实施例与方法部分的实施例相互对应,因此装置部分的实施例请参见方法部分的实施例的描述,这里暂不赘述。
实施例九
图11为本申请实施例提供的一种容器多网卡网络配置设备的结构示意图。
如图11所示,本申请实施例提供的容器多网卡网络配置设备包括:
存储器1110,用于存储计算机程序1111;
处理器1120,用于执行计算机程序1111,该计算机程序1111被处理器1120执行时实现如上述任意一项实施例容器多网卡网络配置方法的步骤。
其中,处理器1120可以包括一个或多个处理核心,比如3核心处理器、8核心处理器等。处理器1120可以采用数字信号处理DSP(Digital Signal Processing)、现场可编程门阵列FPGA(Field-Programmable Gate Array)、可编程逻辑阵列PLA(Programmable Logic Array)中的至少一种硬件形式来实现。处理器1120也可以包括主处理器和协处理器,主处理器是用于对在唤醒状态下的数据进行处理的处理器,也称中央处理器CPU(Central Processing Unit);协处理器是用于对在待机状态下的数据进行处理的低功耗处理器。在一些实施例中,处理器1120可以集成有图像处理器GPU(Graphics Processing Unit),GPU用于负责显示屏所需要显示的内容的渲染和绘制。一些实施例中,处理器1120还可以包括人工智能AI(Artificial Intelligence)处理器,该AI处理器用于处理有关机器学习的计算操作。
存储器1110可以包括一个或多个存储介质,该存储介质可以是非暂态的。存储器1110还可包括高速随机存取存储器,以及非易失性存储器,比如一个或多个磁盘存储设备、闪存存储设备。本实施例中,存储器1110至少用于存储以下计算机程序1111,其中,该计算机程序1111被处理器1120加载并执行之后,能够实现前述任一实施例公开的容器多网卡网络配置方法中的相关步骤。另外,存储器1110所存储的资源还可以包括操作系统1112和数据1113等,存储方式可以是短暂存储或者永久存储。其中,操作系统1112可以为Windows。数据1113可以包括但不限于上述方法所涉及到的数据。
在一些实施例中,容器多网卡网络配置设备还可包括有显示屏1130、电源1140、通信接口1150、输入输出接口1160、传感器1170以及通信总线1180。
本领域技术人员可以理解,图11中示出的结构并不构成对容器多网卡网络配置设备的限定,可以包括比图示更多或更少的组件。
本申请实施例提供的容器多网卡网络配置设备,包括存储器和处理器,处理器在执行存储器存储的程序时,能够实现如上的容器多网卡网络配置方法,效果同上。
实施例十
需要说明的是,以上所描述的装置、设备实施例仅仅是示意性的,例如,模块的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个模块或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或模块的间接耦合或通信连接,可以是电性,机械或其它的形式。作为分离部件说明的模块可以是或者也可以不是物理上分开的,作为模块显示的部件可以是或者也可以不是物理模块,即可以位于一个地方,或者也可以分布到多个网络模块上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能模块可以集成在一个处理模块中,也可以是各个模块单独物理存在,也可以两个或两个以上模块集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。
集成的模块如果以软件功能模块的形式实现并作为独立的产品销售或使用时,可以 存储在一个存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,执行本申请各个实施例方法的全部或部分步骤。
为此,本申请实施例还提供一种存储介质,该存储介质上存储有计算机程序,计算机程序被处理器执行时实现如容器多网卡网络配置方法的步骤。
该存储介质可以包括:U盘、移动硬盘、只读存储器ROM(Read-Only Memory)、随机存取存储器RAM(Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。
本实施例中提供的存储介质所包含的计算机程序能够在被处理器执行时实现如上的容器多网卡网络配置方法的步骤,效果同上。
以上对本申请所提供的一种容器多网卡网络配置方法、装置、设备及存储介质进行了详细介绍。说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似部分互相参见即可。对于实施例公开的装置、设备及存储介质而言,由于其与实施例公开的方法相对应,所以描述的比较简单,相关之处参见方法部分说明即可。应当指出,对于本技术领域的普通技术人员来说,在不脱离本申请原理的前提下,还可以对本申请进行若干改进和修饰,这些改进和修饰也落入本申请权利要求的保护范围内。
还需要说明的是,在本说明书中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括要素的过程、方法、物品或者设备中还存在另外的相同要素。

Claims (24)

  1. 一种容器多网卡网络配置方法,其特征在于,包括:
    在根据工作负载容器创建任务完成对目标容器集群的目标节点上的目标容器组的多个网卡的创建后,触发多网卡网络资源配置任务;
    获取所述目标容器组上各已创建网卡与所述目标节点的虚拟网线对的第一映射数据;
    获取各所述已创建网卡与网络资源配置参数的第二映射数据;
    根据所述第一映射数据和所述第二映射数据生成所述已创建网卡、所述网络资源配置参数与所述虚拟网线对的第三映射数据;
    将所述第三映射数据传递至所述目标节点的操作系统内核以完成对各所述已创建网卡的网络资源配置。
  2. 根据权利要求1所述的容器多网卡网络配置方法,其特征在于,所述在根据工作负载容器创建任务完成对目标容器集群的目标节点上的目标容器组的多个网卡的创建后,触发多网卡网络资源配置任务,具体为:
    在调用多容器网络接口插件根据所述工作负载容器创建任务完成对所述目标容器组的多个网卡的创建后,若所述多容器网络接口插件的与预设的多网卡容器网络接口插件对应的能力配置选项为启用时,基于预先创建的网络附件自定义资源调用所述多网卡容器网络接口插件以执行所述多网卡网络资源配置任务。
  3. 根据权利要求1所述的容器多网卡网络配置方法,其特征在于,所述获取所述目标容器组上各已创建网卡与所述目标节点的虚拟网线对的第一映射数据,具体包括:
    获取所述目标容器组的容器组信息;
    以所述容器组信息为关键字,访问所述操作系统内核查询与所述容器组信息对应的所述目标节点的宿主机端接口信息;
    根据所述宿主机单接口信息和所述已创建网卡的信息,生成所述第一映射数据。
  4. 根据权利要求3所述的容器多网卡网络配置方法,其特征在于,所述以所述容器组信息为关键字,访问所述操作系统内核查询与所述容器组信息对应的所述目标节点的宿主机端接口信息,具体为:
    以所述容器组信息为关键字,调用网络链接套接字以访问链接查询接口,访问所述操作系统内核获取所述宿主机端接口信息。
  5. 根据权利要求3所述的容器多网卡网络配置方法,其特征在于,所述以所述容器组信息为关键字,访问所述操作系统内核查询与所述容器组信息对应的所述目标节点的宿主机端接口信息,具体包括:
    判断所述目标容器组是否创建成功;
    若所述目标容器组创建成功,则以所述容器组信息为关键字,访问所述操作系统内核查询与所述宿主机端接口信息;
    若所述目标容器组未创建成功,则记录目标容器组异常日志并向容器服务核心组件抛出目标容器组异常报错信息以结束本次所述多网卡网络资源配置任务;
    判断所述目标容器组的各网卡是否创建成功;
    若各网卡均创建成功,则获取并记录与各所述已创建网卡对应的所述宿主机端接口 信息;
    若各网卡未全部创建成功,则记录网卡异常日志并向所述容器服务核心组件抛出网卡异常报错信息以结束本次所述多网卡网络资源配置任务。
  6. 根据权利要求5所述的容器多网卡网络配置方法,其特征在于,所述判断所述目标容器组是否创建成功,具体包括:
    以所述容器组信息为关键字,向容器应用程序接口服务查询所述目标容器组的信息;
    判断是否能够查询到所述目标容器组的信息;
    如果是,则确定所述目标容器组创建成功;
    如果否,则确定所述目标容器组未创建成功。
  7. 根据权利要求5所述的容器多网卡网络配置方法,其特征在于,所述判断所述目标容器组的各网卡是否创建成功,具体包括:
    访问所述操作系统内核查询所述目标节点的所述宿主机端接口信息;
    判断是否各网卡对应的所述宿主机端接口信息是否均存在;
    如果是,则确定各网卡均创建成功;
    如果否,则确定各网卡未全部创建成功。
  8. 根据权利要求1所述的容器多网卡网络配置方法,其特征在于,所述获取各所述已创建网卡与网络资源配置参数的第二映射数据,具体包括:
    向容器应用程序接口服务请求访问所述目标容器组的容器组配置文件以获取所述目标容器组的自定义注解信息;
    解析所述自定义注解信息得到所述目标容器组的网卡网络资源配置信息;
    根据各所述已创建网卡的创建信息与所述网卡网络资源配置信息,生成所述第二映射数据。
  9. 根据权利要求8所述的容器多网卡网络配置方法,其特征在于,所述根据各所述已创建网卡的创建信息与所述网卡网络资源配置信息,生成所述第二映射数据,具体包括:
    若所述网卡网络资源配置信息包含所述已创建网卡与对应的所述网络资源配置参数的映射数据,则以所述网卡网络资源配置信息包含的所述映射数据为所述第二映射数据;
    若所述网卡网络资源配置信息不包含所述已创建网卡与对应的所述网络资源配置参数的映射数据,则根据默认网卡资源映射数据生成顺序生成所述第二映射数据。
  10. 根据权利要求9所述的容器多网卡网络配置方法,其特征在于,所述根据默认网卡资源映射数据生成顺序生成所述第二映射数据,具体为:
    根据所述网卡网络资源配置信息中包含的所述网络资源配置参数的顺序,以首个所述网络资源配置参数为所述已创建网卡中的主网卡对应的所述网络资源配置参数,按照其余所述网络资源配置参数的排列顺序和其余所述已创建网卡的创建顺序对应为所述已创建网卡分配所述网络资源配置参数,生成所述第二映射数据。
  11. 根据权利要求8所述的容器多网卡网络配置方法,其特征在于,所述根据各所述已创建网卡的创建信息与所述网卡网络资源配置信息,生成所述第二映射数据,具体 包括:
    若所述网卡网络资源配置信息包含全部所述已创建网卡与对应的所述网络资源配置参数的映射数据,则以所述网卡网络资源配置信息包含的所述映射数据为所述第二映射数据;
    若所述网卡网络资源配置信息不包含所述已创建网卡与对应的所述网络资源配置参数的映射数据,则根据默认网卡资源映射数据生成顺序生成所述第二映射数据;
    若所述网卡网络资源配置信息仅包含部分所述已创建网卡与对应的所述网络资源配置参数的映射数据,则根据所述默认网卡资源映射数据生成顺序生成其余所述已创建网卡与对应的所述网络资源配置参数的映射数据后,得到所述第二映射数据。
  12. 根据权利要求11所述的容器多网卡网络配置方法,其特征在于,所述根据默认网卡资源映射数据生成顺序生成所述第二映射数据,具体为:
    根据所述网卡网络资源配置信息中包含的所述网络资源配置参数的顺序,以首个所述网络资源配置参数为所述已创建网卡中的主网卡对应的所述网络资源配置参数,按照其余所述网络资源配置参数的排列顺序和其余所述已创建网卡的创建顺序对应为所述已创建网卡分配所述网络资源配置参数,生成所述第二映射数据;
    所述根据所述默认网卡资源映射数据生成顺序生成其余所述已创建网卡与对应的所述网络资源配置参数的映射数据,具体为:
    根据其余所述网络资源配置参数的排列顺序和其余所述已创建网卡的创建顺序对应为其余所述已创建网卡分配所述网络资源配置参数,得到其余所述已创建网卡与对应的所述网络资源配置参数的映射数据。
  13. 根据权利要求9所述的容器多网卡网络配置方法,其特征在于,所述网卡网络资源配置信息包含所述已创建网卡与对应的所述网络资源配置参数的映射数据,具体为:
    若所述网卡网络资源配置信息包含预设字符,则以所述预设字符为分割字符获取所述已创建网卡的信息和对应的所述网络资源配置参数,得到所述已创建网卡与对应的所述网络资源配置参数的映射数据。
  14. 根据权利要求9所述的容器多网卡网络配置方法,其特征在于,所述若所述网卡网络资源配置信息包含所述已创建网卡与对应的所述网络资源配置参数的映射数据,则以所述网卡网络资源配置信息包含的所述映射数据为所述第二映射数据,具体包括:
    若所述网卡网络资源配置信息包含所述已创建网卡与对应的所述网络资源配置参数的映射数据,则判断所述映射数据中的所述已创建网卡的信息是否包含于所述目标容器组的容器多网卡列表;
    如果是,则以所述网卡网络资源配置信息包含的所述映射数据为所述第二映射数据;
    如果否,则记录自定义注解信息异常日志并向容器服务核心组件抛出自定义注解信息报错信息以结束本次所述多网卡网络资源配置任务。
  15. 根据权利要求8所述的容器多网卡网络配置方法,其特征在于,所述根据各所述已创建网卡的创建信息与所述网卡网络资源配置信息,生成所述第二映射数据,具体包括:
    判断所述网卡网络资源配置信息中记载的所述网络资源配置参数是否满足预设网卡资源配置要求;
    如果是,则根据各所述已创建网卡的创建信息与所述网卡网络资源配置信息,生成所述第二映射数据;
    如果否,则记录自定义注解信息异常日志并向容器服务核心组件抛出自定义注解信息报错信息以结束本次所述多网卡网络资源配置任务。
  16. 根据权利要求15所述的容器多网卡网络配置方法,其特征在于,所述判断所述网卡网络资源配置信息中记载的所述网络资源配置参数是否满足预设网卡资源配置要求,具体包括:
    判断所述网卡网络资源配置信息中记载的所述网络资源配置参数是否均为大于0且采用约定单位的所述网络资源配置参数;
    如果是,则确定所述网卡网络资源配置信息中记载的所述网络资源配置参数满足所述预设网卡资源配置要求;
    如果否,则确定所述网卡网络资源配置信息中记载的所述网络资源配置参数不满足所述预设网卡资源配置要求。
  17. 根据权利要求1所述的容器多网卡网络配置方法,其特征在于,将所述第三映射数据传递至所述目标节点的操作系统内核以完成对各所述已创建网卡的网络资源配置,具体包括:
    判断所述第三映射数据对应的多网卡网络资源配置映射表是否存在;
    若所述多网卡网络资源配置映射表存在,则判断所述多网卡网络资源配置映射表中的所述网络资源配置参数是否发生变化;
    如果所述网络资源配置参数发生变化,则更新所述多网卡网络资源配置映射表;
    如果所述多网卡网络资源配置映射表不存在,则根据所述第三映射数据生成所述多网卡网络资源配置映射表;
    基于所述多网卡网络资源配置映射表组装队列规则数据,向所述操作系统内核发送网络链接消息,以实现对各所述已创建网卡的网络资源配置。
  18. 根据权利要求1所述的容器多网卡网络配置方法,其特征在于,在所述将所述第三映射数据传递至所述目标节点的操作系统内核以完成对各所述已创建网卡的网络资源配置之后,还包括:
    检查并生成对各所述已创建网卡的网络资源配置的配置结果。
  19. 根据权利要求18所述的容器多网卡网络配置方法,其特征在于,检查对各所述已创建网卡的网络资源配置的配置结果,具体为:
    查询与所述多网卡网络资源配置任务对应的日志文件,得到对各所述已创建网卡的网络资源配置的配置结果。
  20. 根据权利要求18所述的容器多网卡网络配置方法,其特征在于,检查对各所述已创建网卡的网络资源配置的配置结果,具体包括:
    获取与所述目标容器组对应的所述虚拟网线对的信息;
    利用流量控制命令携带所述虚拟网线对的信息访问所述操作系统内核,查询对应的所述目标节点的宿主机端接口信息对应的网络资源配置状态;
    以所述网络资源配置状态为所述已创建网卡的网络资源配置的配置结果。
  21. 根据权利要求18所述的容器多网卡网络配置方法,其特征在于,检查对各所述已创建网卡的网络资源配置的配置结果,具体包括:
    调用预设压力测试工具测试各所述已创建网卡的网络状态;
    以各所述已创建网卡的网络状态为各所述已创建网卡的网络资源配置的配置结果。
  22. 一种容器多网卡网络配置装置,其特征在于,包括:
    参数判决模块,用于在根据工作负载容器创建任务完成对目标容器集群的目标节点上的目标容器组的多个网卡的创建并触发多网卡网络资源配置任务后,获取所述目标容器组上各已创建网卡与所述目标节点的虚拟网线对的第一映射数据;
    容器组网卡网络资源配置信息获取模块,用于获取各所述已创建网卡与网络资源配置参数的第二映射数据;
    多网卡网络资源配置信息映射模块,用于根据所述第一映射数据和所述第二映射数据生成所述已创建网卡、所述网络资源配置参数与所述虚拟网线对的第三映射数据,将所述第三映射数据传递至所述目标节点的操作系统内核以完成对各所述已创建网卡的网络资源配置。
  23. 一种容器多网卡网络配置设备,其特征在于,包括:
    存储器,用于存储计算机程序;
    处理器,用于执行所述计算机程序,所述计算机程序被所述处理器执行时实现如权利要求1至21任意一项所述容器多网卡网络配置方法的步骤。
  24. 一种非易失性可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求1至21任意一项所述容器多网卡网络配置方法的步骤。
PCT/CN2023/115893 2023-01-09 2023-08-30 一种容器多网卡网络配置方法、装置、设备及存储介质 WO2024148833A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202310025089.6A CN115913937B (zh) 2023-01-09 2023-01-09 一种容器多网卡网络配置方法、装置、设备及存储介质
CN202310025089.6 2023-01-09

Publications (1)

Publication Number Publication Date
WO2024148833A1 true WO2024148833A1 (zh) 2024-07-18

Family

ID=85740811

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/115893 WO2024148833A1 (zh) 2023-01-09 2023-08-30 一种容器多网卡网络配置方法、装置、设备及存储介质

Country Status (2)

Country Link
CN (1) CN115913937B (zh)
WO (1) WO2024148833A1 (zh)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115913937B (zh) * 2023-01-09 2023-05-23 苏州浪潮智能科技有限公司 一种容器多网卡网络配置方法、装置、设备及存储介质
CN116132386B (zh) * 2023-04-19 2023-06-27 安超云软件有限公司 混合工作负载引流方法及计算机集群
CN116170389B (zh) * 2023-04-19 2023-07-21 安超云软件有限公司 业务容器引流方法、系统及计算机集群

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106060122A (zh) * 2016-05-20 2016-10-26 北京奇虎科技有限公司 Docker容器上传/下载特性的控制方法及装置
CN113055469A (zh) * 2021-03-11 2021-06-29 网宿科技股份有限公司 云容器存储控制方法、系统、电子设备及存储介质
CN114244717A (zh) * 2022-02-28 2022-03-25 苏州浪潮智能科技有限公司 虚拟网卡资源的配置方法、装置、计算机设备及介质
CN114647488A (zh) * 2022-03-31 2022-06-21 苏州浪潮智能科技有限公司 一种任务训练方法、装置、设备及存储介质
US20220278926A1 (en) * 2021-03-01 2022-09-01 Juniper Networks, Inc. Container networking interface for multiple types of interfaces
CN115913937A (zh) * 2023-01-09 2023-04-04 苏州浪潮智能科技有限公司 一种容器多网卡网络配置方法、装置、设备及存储介质

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110138606B (zh) * 2019-05-06 2022-03-15 携程旅游信息技术(上海)有限公司 容器网络配置方法及系统
CN111371627B (zh) * 2020-03-24 2022-05-10 广西梯度科技有限公司 一种在Kubernetes中Pod设置多IP的方法
CN111857873A (zh) * 2020-07-15 2020-10-30 浪潮云信息技术股份公司 一种实现云原生容器网络的方法
CN112398936B (zh) * 2020-11-06 2023-03-28 浪潮云信息技术股份公司 一种基于Kubernetes的多网卡容器实现方法及系统
CN112653575B (zh) * 2020-12-11 2022-08-30 网宿科技股份有限公司 一种网络配置方法、控制器及流量引导系统
CN115469961A (zh) * 2021-05-24 2022-12-13 北京金山云网络技术有限公司 容器组的创建方法和装置、电子设备和存储介质

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106060122A (zh) * 2016-05-20 2016-10-26 北京奇虎科技有限公司 Docker容器上传/下载特性的控制方法及装置
US20220278926A1 (en) * 2021-03-01 2022-09-01 Juniper Networks, Inc. Container networking interface for multiple types of interfaces
CN113055469A (zh) * 2021-03-11 2021-06-29 网宿科技股份有限公司 云容器存储控制方法、系统、电子设备及存储介质
CN114244717A (zh) * 2022-02-28 2022-03-25 苏州浪潮智能科技有限公司 虚拟网卡资源的配置方法、装置、计算机设备及介质
CN114647488A (zh) * 2022-03-31 2022-06-21 苏州浪潮智能科技有限公司 一种任务训练方法、装置、设备及存储介质
CN115913937A (zh) * 2023-01-09 2023-04-04 苏州浪潮智能科技有限公司 一种容器多网卡网络配置方法、装置、设备及存储介质

Also Published As

Publication number Publication date
CN115913937B (zh) 2023-05-23
CN115913937A (zh) 2023-04-04

Similar Documents

Publication Publication Date Title
WO2024148833A1 (zh) 一种容器多网卡网络配置方法、装置、设备及存储介质
JP7197612B2 (ja) オンデマンドネットワークコード実行システム上での補助機能の実行
US10817324B2 (en) System and method of cross-silo discovery and mapping of storage, hypervisors and other network objects
US10313380B2 (en) System and method for centralized virtual interface card driver logging in a network environment
WO2021238248A1 (zh) 一种网络流量的分类处理方法、装置、设备及介质
EP3373518B1 (en) Service configuration method and device for network service
CN112104754B (zh) 网络代理方法、系统、装置、设备及存储介质
US8554980B2 (en) Triggered notification
WO2014063463A1 (zh) 一种物理网卡管理方法、装置及物理主机
WO2020108443A1 (zh) 一种虚拟化管理方法及装置
CN113141405B (zh) 服务访问方法、中间件系统、电子设备和存储介质
CN111258627A (zh) 一种接口文档生成方法和装置
CN111490893A (zh) 一种网络转发模型的建立方法、装置及系统
US20060168014A1 (en) Highly extendable message filtering daemon for a network appliance
CN110928554A (zh) 一种部署方法、装置、设备及存储介质
CN110933152A (zh) 一种预热方法、装置、系统及电子设备
WO2021109851A1 (zh) 一种网络通信方法、装置、设备和存储介质
CN112003726B (zh) 一种快速部署Beegfs管理服务节点高可用的配置方法
CN111953540A (zh) 一种报文生成方法、装置、电子设备及存储介质
CN114244555B (zh) 一种安全策略的调整方法
CN112910910B (zh) Opcda协议报文处理方法、装置、设备以及存储介质
WO2021128936A1 (zh) 报文的处理方法及装置
CN111813621A (zh) 基于Flume数据中台的数据处理方法、装置、设备及介质
US9917742B1 (en) Hardware connection management
CN112433862A (zh) 一种数据聚合实现系统及设备

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: 23915591

Country of ref document: EP

Kind code of ref document: A1