Container network configuration method and device, computer device and readable storage medium

By creating a target bridge on the host machine, inter-container communication can be achieved directly using the host machine's network capabilities. This solves the problem of excessive resource consumption in the Calico container networking solution when there are a large number of hosts, and improves system performance and stability.

CN116827903BActive Publication Date: 2026-02-06KANG JIAN INFORMATION TECH (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310816165.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-04
Publication Date
2026-02-06
Estimated Expiration
2043-07-04

AI Technical Summary

Technical Problem

When there are a large number of hosts, the Calico container networking solution causes the routing table to consume a lot of system resources, affecting system performance and stability, and even causing network paralysis.

Method used

By determining the host machine information of a specified container, reading the network address and subnet mask, creating a target bridge, and connecting it to the network interface that manages the container, communication between containers can be achieved directly using the network capabilities of the host machine, avoiding the need to create a large number of virtual network devices or routing table entries.

Benefits of technology

It reduces system resource consumption, improves the performance and stability of container networks, avoids network paralysis, and ensures efficient communication between containers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116827903B_ABST
    Figure CN116827903B_ABST
Patent Text Reader

Abstract

The application discloses a container network configuration method and device, computer equipment and a readable storage medium, relates to the technical field of Internet and digital medical treatment, and can directly use the network capability of a host machine to realize the intercommunication of a container network and can avoid occupying a large amount of system resources. The method comprises the following steps: determining a specified container, obtaining machine information of a host machine, and reading a network address and a subnet mask recorded in the machine information; determining an available network address range according to the network address and the subnet mask, and selecting a target network address in the available network address range; determining the address type of the target network address, creating a target bridge according to the address type, connecting a bridge interface of the target bridge with a network interface where a management container is located; querying a target management container for managing the specified container, modifying the network address into the target network address and modifying bridge information into bridge information corresponding to the target bridge in a network configuration file of the target management container.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the fields of Internet technology and digital medicine, and in particular, relates to a container network configuration method and device, computer equipment and a readable storage medium. BACKGROUND

[0002] With the continuous development of Internet technology, in order to solve the problem that deploying digital medical application programs in different environments will face different configurations and dependencies, container technology has emerged. Container technology allows an application program to be packaged into a container, so that the application program can remain consistent in different environments. With the development of container technology, network communication and interconnection between containers are becoming increasingly important.

[0003] In related technologies, the Calico container network solution is used. When a container needs to communicate with other containers, Calico will select the optimal path to deliver traffic to the target container according to the pre-defined routing rules. In this way, even if the containers are on different host machines, they can interoperate through the BGP protocol (Border Gateway Protocol).

[0004] In the process of implementing the present application, the applicant found that the related technology at least has the following problems:

[0005] The BGP protocol itself is a relatively complex routing protocol, which requires storing a large amount of network information in the routing table. In the case of a large number of host machines, the routing table will occupy a large amount of system resources, thereby affecting the performance and stability of the system, and even causing the danger of network paralysis. SUMMARY

[0006] Therefore, the present application provides a container network configuration method and device, computer equipment and a readable storage medium, which mainly aims to solve the problem that the current Calico container network solution will cause the routing table to occupy a large amount of system resources in the case of a large number of host machines, thereby affecting the performance and stability of the system, and even causing the danger of network paralysis.

[0007] According to the first aspect of the present application, a container network configuration method is provided, which comprises:

[0008] determining a specified container, and obtaining machine information of a host machine, reading the network address and subnet mask recorded in the machine information, the host machine being used to indicate a host device running the specified container;

[0009] determining an available network address range according to the network address and the subnet mask, and selecting a target network address in the available network address range;

[0010] determining an address type of the target network address, creating a target bridge according to the address type, and connecting a bridge interface of the target bridge to a network interface where the management container is located;

[0011] querying a target management container that manages the specified container, modifying a network address to the target network address and modifying bridge information to bridge information corresponding to the target bridge in a network configuration file of the target management container.

[0012] Optionally, the determining the specified container comprises:

[0013] receiving an environment variable uploaded by a container management component, querying an identifier associated with a container identifier variable in the environment variable, and taking the identifier as a specified container identifier;

[0014] traversing all running containers, determining a container corresponding to the specified container identifier in the all running containers, and obtaining the specified container.

[0015] Optionally, after the determining the specified container, the method further comprises:

[0016] detecting an application type of the specified container;

[0017] if the application type of the specified container is a stateless application, obtaining machine information of the host machine, and allocating a network address for the specified container according to the machine information;

[0018] if the application type of the specified container is a stateful application, associating a network address of the specified container with a container identifier of the specified container, and modifying a network configuration associated with the specified container to use a static network address.

[0019] Optionally, the detecting the application type of the specified container comprises:

[0020] detecting whether a container image of the specified container exists a directory or a file for storing data;

[0021] if it is detected that the container image exists the directory or the file for storing data, determining that the application type of the specified container is a stateful application;

[0022] if it is detected that the container image does not exist the directory or the file for storing data, determining that the application type of the specified container is a stateless application.

[0023] Optionally, the detecting the application type of the specified container further comprises:

[0024] detecting whether an application local disk or a persistent storage volume exists in the specified container;

[0025] If it is detected that there is an application local disk or persistent storage volume in the specified container, it is determined that the application type of the specified container is a stateful application.

[0026] If it is detected that there is no application local disk or persistent storage volume in the specified container, it is determined that the application type of the specified container is a stateless application.

[0027] Optionally, the determining the available network address range according to the network address and the subnet mask, and selecting a target network address in the available network address range, comprises:

[0028] determining the address type of the network address, converting the network address and the subnet mask into binary form respectively according to the address type, and performing a bitwise AND operation on the binary form of the network address and the subnet mask to obtain an operation result;

[0029] converting the operation result into decimal form to obtain the available network address range;

[0030] scanning all available network addresses in the available network address range, and determining a plurality of network addresses that are not occupied in the all available network addresses;

[0031] sorting the plurality of network addresses in the order of addresses from front to back, and selecting the network address with the first rank as the target network address.

[0032] Optionally, after the bridge information is modified to the bridge information corresponding to the target bridge, the method further comprises:

[0033] sending the target network address and the hardware address information of the specified container to the container management component, so that the container management component aggregates the target network address and the hardware address information into a state file;

[0034] storing the state file into a storage device of the host machine.

[0035] According to the second aspect of the present application, a container network configuration device is provided, which comprises:

[0036] an acquisition module, configured to determine a specified container, and acquire machine information of a host machine, read a network address and a subnet mask recorded in the machine information, and the host machine is used to indicate a host device running the specified container;

[0037] a selection module, configured to determine an available network address range according to the network address and the subnet mask, and select a target network address in the available network address range;

[0038] determining a type of the target network address, creating a target bridge according to the type of the target network address, and connecting a bridge interface of the target bridge to a network interface where the target management container is located;

[0039] setting a network address in a network configuration file of the target management container as the target network address, and setting bridge information in the network configuration file of the target management container as bridge information corresponding to the target bridge.

[0040] Optionally, the obtaining module is configured to receive an environment variable uploaded by a container management component, query an identifier associated with a container identifier variable in the environment variable, and take the identifier as the identifier of the specified container; and traverse all running containers to determine a container corresponding to the identifier of the specified container, and obtain the specified container.

[0041] Optionally, the apparatus further comprises:

[0042] detecting an application type of the specified container;

[0043] the obtaining module is configured to, if the application type of the specified container is a stateless application, obtain machine information of the host machine, and allocate a network address to the specified container according to the machine information;

[0044] the fixing module is configured to, if the application type of the specified container is a stateful application, associate a network address of the specified container with a container identifier of the specified container, and modify a network configuration associated with the specified container to use a static network address.

[0045] Optionally, the detection module is configured to detect whether a container image of the specified container has a directory or a file for storing data; if the container image is detected to have the directory or the file for storing data, determine that the application type of the specified container is a stateful application; and if the container image is detected to not have the directory or the file for storing data, determine that the application type of the specified container is a stateless application.

[0046] Optionally, the detection module is further configured to detect whether the specified container has an application local disk or a persistent storage volume; if the specified container is detected to have the application local disk or the persistent storage volume, determine that the application type of the specified container is a stateful application; and if the specified container is detected to not have the application local disk or the persistent storage volume, determine that the application type of the specified container is a stateless application.

[0047] Optionally, the selecting module is configured to determine an address type of the network address, convert the network address and the subnet mask into binary forms according to the address type, respectively, perform a bitwise AND operation on the network address and the subnet mask in the binary forms to obtain an operation result, convert the operation result into a decimal form to obtain the available network address range, scan all available network addresses in the available network address range, determine a plurality of unoccupied network addresses from the all available network addresses, sort the plurality of network addresses according to an address sequence from front to back, and select a network address with a first rank as the target network address.

[0048] Optionally, the apparatus further comprises:

[0049] The sending module is configured to send the target network address and the hardware address information of the specified container to the container management component, so that the container management component aggregates the target network address and the hardware address information into a state file.

[0050] The storage module is configured to store the state file into a storage device of the host machine.

[0051] According to a third aspect of the present application, a computer device is provided, which comprises a memory and a processor, the memory stores a computer program, and the processor implements the steps of the method according to any one of the first aspect when executing the computer program.

[0052] According to a fourth aspect of the present application, a computer readable storage medium is provided, which stores a computer program, and the computer program implements the steps of the method according to any one of the first aspect when executed by a processor.

[0053] By the technical scheme, the container network configuration method, device, computer equipment and readable storage medium are provided, the specified container is determined first, then the machine information of the host machine corresponding to the specified container is acquired, and the network address and subnet mask recorded in the machine information are read. Next, the available network address range is determined according to the network address and subnet mask, and the target network address is selected in the available network address range. Further, the address type of the target network address is determined, the target bridge is created according to the address type, the bridge interface of the target bridge is connected with the network interface where the management container is located. Finally, the target management container managing the specified container is queried, the network address is modified as the target network address in the network configuration file of the target management container, and the bridge information is modified as the bridge information corresponding to the target bridge. According to the machine information of the host machine, the target network address of the container is determined, the network interface on the host machine is connected to the interface of the target bridge by creating the target bridge, and the communication between the containers is realized. In this process, the network capability of the host machine can be directly used to realize the intercommunication of the container network, a large number of virtual network devices or additional routing table items do not need to be established, and therefore a large number of system resources can be avoided.

[0054] The above description is only a summary of the technical scheme of the present application, in order to more clearly understand the technical means of the present application, the specific embodiments of the present application can be implemented according to the content of the specification, and in order to make the above and other purposes, characteristics and advantages of the present application more obvious and easy to understand, the following specific embodiments of the present application are described. BRIEF DESCRIPTION OF DRAWINGS

[0055] By reading the detailed description of the preferred embodiments below, various other advantages and benefits will become clear to those of ordinary skill in the art. The drawings are only for the purpose of illustrating the preferred embodiments and are not considered limiting the present application. Moreover, the same reference symbols are used throughout the drawings to represent the same components. In the drawings:

[0056] Figure 1 A container network configuration method flow diagram provided by an embodiment of the present application is shown;

[0057] Figure 2A A container network configuration method flow diagram provided by an embodiment of the present application is shown;

[0058] Figure 2B A container network configuration system architecture diagram provided by an embodiment of the present application is shown;

[0059] Figure 3 A structure diagram of a container network configuration device provided by an embodiment of the present application is shown;

[0060] Figure 4A device structure schematic diagram of a computer device provided by an embodiment of the present application is shown. DETAILED DESCRIPTION

[0061] Exemplary embodiments of the present application will be described herein below with reference to the accompanying drawings. Although exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided so that the present application can be more thoroughly understood and so that the scope of the present application can be completely conveyed to those skilled in the art.

[0062] An embodiment of the present application provides a container network configuration method, as shown in the figure, the method comprises: Figure 1

[0063] 101、determine a specified container, and obtain machine information of a host machine, read a network address and a subnet mask recorded in the machine information, the host machine is used to indicate a host device running the specified container.

[0064] ​With the continuous development of Internet technology, container technology has emerged to address the challenges of different configurations and dependencies when deploying digital healthcare applications in different environments. Container technology allows applications to be packaged into containers, ensuring consistency across different environments. As container technology advances, network communication and interconnection between containers become increasingly important. Currently, using the Calico container networking solution, when a container needs to communicate with other containers, Calico selects the optimal path to deliver traffic to the target container based on predefined routing rules. This allows containers to communicate even on different host machines via the BGP (Border Gateway Protocol). However, the applicant recognizes that the BGP protocol itself is a complex routing protocol, requiring the storage of a large amount of network information in the routing table. With a large number of hosts, this can lead to the routing table consuming significant system resources, impacting system performance and stability, and even potentially causing network paralysis. Therefore, this application provides a container network configuration method. First, a specified container is identified. Then, the machine information of the host machine corresponding to the specified container is obtained, and the network address and subnet mask recorded in the machine information are read. Next, the range of available network addresses is determined based on the network address and subnet mask, and a target network address is selected from this range. Furthermore, the address type of the target network address is determined, a target bridge is created based on the address type, and the bridge interface of the target bridge is connected to the network interface where the management container resides. Finally, the target management container managing the specified container is queried, and the network address in the target management container's network configuration file is modified to the target network address, and the bridge information is modified to the corresponding bridge information of the target bridge. This embodiment of the application determines the target network address of the container based on the host machine's machine information, and connects the network interface on the host machine to the interface of the target bridge by creating a target bridge to achieve communication between containers. In this process, the network capabilities of the host machine can be directly used to achieve inter-container network communication, without the need to establish a large number of virtual network devices or additional routing table entries, thereby avoiding the consumption of large amounts of system resources.

[0065] This method applies to the Turnsole plugin in a Kubernetes cluster. It can receive environment variables from the Kubelet component according to the CNI (Command-Network Interface) specification and determine the specified container for network configuration based on these environment variables. The Kubelet component is a proxy service running on Node worker nodes that starts, stops, and deletes containers by providing environment variables.

[0066] In the embodiments of the present application, the Turnsole plug-in determines the specified container according to the environment variable provided by the Kubelet component. Further, the host device running the specified container, that is, the host machine, is determined, and the machine information of the host machine is obtained. Finally, the network address (IP address) and subnet mask are read from the machine information. By reading the network address and subnet mask in the machine information, the IP address of the host machine can be determined subsequently, and the container can be placed in the same subnet according to the IP address of the host machine, so that the communication between the containers can be carried out in the same subnet, without the need to pass through the gateway and the router, thereby reducing the delay and network congestion and improving the application performance.

[0067] 102. Determine the available network address range according to the network address and the subnet mask, and select a target network address in the available network address range.

[0068] In the embodiments of the present application, the Turnsole plug-in determines the available network address range according to the network address and the subnet mask obtained in the previous step, and then selects an unoccupied network address in the available network address range as the target network address allocated to the specified container.

[0069] 103. Determine the address type of the target network address, create a target bridge according to the address type, and connect the bridge interface of the target bridge to the network interface where the management container is located.

[0070] In the embodiments of the present application, the Turnsole plug-in needs to determine the address type of the target network address, select appropriate bridge tools according to the network type, such as using the bridge-utils tool on Linux, and create a bridge. Further, the bridge is configured to connect the bridge interface of the target bridge to the network interface where the management container is located. For example, the following commands are used to create a bridge named br0 on Linux and connect it to the eth0 interface: $sudo brctl addbr br0 $sudo brctladdif br0 eth0.

[0071] 104. Query the target management container managing the specified container, modify the network address to the target network address and modify the bridge information to the bridge information corresponding to the target bridge in the network configuration file of the target management container.

[0072] In the embodiments of the present application, in order to ensure the intercommunication of the container network, the Turnsole plug-in also needs to update the network configuration file of the pause container, that is, the target management container managing the specified container. Specifically, the network address is modified to the target network address and the bridge information is modified to the bridge information corresponding to the target bridge in the network configuration file of the target management container.

[0073] The method provided by the embodiment of the present application first determines the specified container, then acquires machine information of a host machine corresponding to the specified container, and reads a network address and a subnet mask recorded in the machine information. Next, a range of available network addresses is determined according to the network address and the subnet mask, and a target network address is selected in the range of available network addresses. Further, an address type of the target network address is determined, a target bridge is created according to the address type, and a bridge interface of the target bridge is connected to a network interface where the management container is located. Finally, a target management container managing the specified container is queried, and the network address is modified to the target network address and the bridge information is modified to bridge information corresponding to the target bridge in a network configuration file of the target management container. The embodiment of the present application determines the target network address of the container according to the machine information of the host machine, and realizes the communication between the containers by creating the target bridge and connecting the network interface on the host machine to the interface of the target bridge. In this process, the network capability of the host machine can be directly used to realize the intercommunication of the container network, and a large number of virtual network devices or additional routing table entries do not need to be established, so that a large number of system resources can be avoided.

[0074] The embodiment of the present application provides a container network configuration method, as shown in Figure 2A The method comprises the following steps.

[0075] 201, receiving an environment variable uploaded by a container management component, and determining a specified container according to the environment variable.

[0076] The method is applicable to a Turnsole plug-in in a Kubernetes cluster, as shown in Figure 2B The Kubernetes cluster comprises a Node, a K8sapi and an etcd. It should be noted that the Node refers to a worker node in the Kubernetes cluster. The Node comprises a Kubelet component and a Pod, wherein the Kubelet component is a proxy service running on the Node, and the Kubelet component is configured to start, stop or delete a container through an environment variable. The Pod is the smallest scheduling unit of the Kubernetes, and the Pod is composed of one or more containers, and shares a network namespace and a storage volume. The Kubelet creates and manages the Pod, and ensures that all containers in the Pod run on the same Node. The K8sapi refers to a Kubernetes API, which is an entry point of all API requests. The etcd is an open source, distributed key-value storage system, which uses a Raft algorithm to realize data reliability and consistency of a distributed system, and provides an API interface based on HTTP, allowing users to store, retrieve and observe various resources in the system.

[0077] In the embodiments of the present application, when the deployed application program is a remote diagnosis and treatment platform, the Kubernetes cluster needs to allocate network addresses for patients and doctors in the remote diagnosis and treatment platform to ensure network communication between the patients and the doctors, wherein the patients and the platform are the specified containers in the method. In actual operation, after the Turnsole plug-in receives the CNI environment variable sent by Kubernetes, it checks the CNI_COMMAND field in the environment variable to determine the expected operation type. When the Turnsole checks the ADD operation, it means that the network needs to be configured for the container, and the container indicated in the environment variable is the specified container. Specifically, after the Turnsole plug-in receives the environment variable uploaded by the container management component, it queries the identifier associated with the container identifier variable in the environment variable and takes the identifier as the specified container identifier. That is, after the Turnsole reads the ADD operation, it further reads the CNI_CONTAINERID field and the CNI_NETNS field to determine the unique identifier and network namespace of the container. Among them, CNI_CONTAINERID is the container identifier variable, and the identifier content associated with it is the specified container identifier. Further, all running containers are traversed to determine the container corresponding to the specified container identifier among all running containers to obtain the specified container. It should be noted that in the container technology, through the network namespace, different containers on the same host can be isolated in different network environments, so that they can independently access the network and improve the network security and reliability of the container. This network isolation method can isolate container application programs from each other and reduce the risk of network mutual influence between containers. In addition, the expected operation type also includes the DEL operation, that is, releasing the IP address used by the deleted container and deleting other network resources associated with the container. The CHECK operation, that is, checking whether the IP address has been used and confirming whether the container network configuration is correct. The VERSION operation, that is, returning the version number of the Turnsole. In fact, the environment variable includes the following contents: CNI_COMMAND: defines the expected operation, which can be ADD, DEL, CHECK or VERSION. CNI_CONTAINERID: container ID, which is the unique identifier of the container managed by the container runtime. CNI_NETNS: path of the container network namespace. CNI_IFNAME: network interface name to be created. CNI_ARGS: additional parameters passed in when the runtime is called. CNI_PATH: path of the CNI plug-in executable file.

[0078] 202、Detect the application program type of the specified container.

[0079] In the embodiments of the present application, before assigning a network to the specified container, the Turnsole plug-in also needs to determine the application type of the specified container. If the specified container is a stateful application, a fixed IP address is used to ensure that the network address and network configuration of the container remain unchanged when the container fails or migrates, thereby avoiding the situation that the communication between the patient and the doctor in the remote diagnosis and treatment platform is interrupted or the communication link is unavailable. For stateless containers, there is no need to guarantee the IP address, and the Turnsole plug-in can perform subsequent steps 203 to 207. That is, by rotating the use of the IP pool, a dynamic network address is assigned to the specified container, which can effectively utilize network resources and avoid network congestion and delay.

[0080] In actual operation, the Turnsole plug-in can select to detect whether the container image of the specified container exists a directory or file for storing data. If it is detected that the container image exists a directory or file for storing data, it is determined that the application type of the specified container is a stateful application. If it is detected that the container image does not exist a directory or file for storing data, it is determined that the application type of the specified container is a stateless application. In addition, the Turnsole plug-in can also select to detect whether the specified container exists an application local disk or a persistent storage volume. If it is detected that the specified container exists an application local disk or a persistent storage volume, it can also be determined that the application type of the specified container is a stateful application. If it is detected that the specified container does not exist an application local disk or a persistent storage volume, it can also be determined that the application type of the specified container is a stateless application.

[0081] It should be noted that if the application type of the specified container is a stateless application, the machine information of the host machine is obtained, and a network address is assigned to the specified container according to the machine information. That is, steps 203 to 207 are performed. If the application type of the specified container is a stateful application, the network address of the specified container is associated with the container identifier of the specified container. The network configuration associated with the specified container is modified to use a static network address.

[0082] 203, Obtain the machine information of the host machine, and read the network address and subnet mask recorded in the machine information.

[0083] In the medical field, the real-time and stability of network communication is very important. In the embodiments of the present application, the Turnsole plug-in can determine the host device running the specified container, that is, the host machine, after determining the specified container according to the environment variables provided by the Kubelet component. By obtaining the machine information of the host machine, reading the network address (IP address) and subnet mask, the effect of placing the container in the same subnet is achieved, which can improve the response speed and network stability of the application program, and make the communication between containers faster and more reliable. At the same time, placing the container in the same subnet can avoid unnecessary network bandwidth consumption and improve network utilization. In the medical field, network data communication speed and response speed are very important for the normal operation of medical devices and application programs. By placing the container in the same subnet, network congestion and delay can be effectively reduced, the response speed and network performance of the application program can be improved, and the real-time transmission and processing of medical data can be ensured. In summary, the Turnsole plug-in can effectively improve the network performance and reliability of medical applications by obtaining the network address and subnet mask in the machine information and placing the container in the same subnet, ensuring the normal operation of medical devices and application programs, and thus improving the quality and efficiency of medical services.

[0084] 204. Determine the available network address range according to the network address and subnet mask, and select a target network address in the available network address range.

[0085] In the embodiments of the present application, the Turnsole plug-in determines the available network address range according to the network address and subnet mask obtained in the previous step, and then selects an unoccupied network address in the available network address range as the target network address allocated to the specified container.

[0086] Specifically, the Turnsole plugin first determines the address type of the network address (IPv4 or IPv6), and further, according to the address type, respectively converts the network address and the subnet mask into binary form, and performs a bitwise AND operation on the binary form of the network address and the subnet mask to obtain an operation result. Subsequently, the operation result is converted into decimal form to obtain the available network address range. For example, the network address is an IPv4 address: 192.168.1.100, the subnet mask is 255.255.255.0, the IPv4 address type is a 32-bit address, the subnet mask is converted into binary form 11111111.11111111.11111111.00000000, the binary IPv4 address and the subnet mask are bitwise ANDed to obtain the operation result 1100000.10101000.00000001.00000000, the result is converted into decimal form 192.168.1.0, and the available network address range is obtained as 192.168.1.1 to 192.168.1.254. Next, all available network addresses in the available network address range are scanned, and a plurality of network addresses that are not occupied are determined in all available network addresses. The plurality of network addresses are sorted in the order of the addresses from front to back, and the network address ranked first is selected as the target network address.

[0087] 205、Determine the address type of the target network address, create a target network bridge according to the address type, and connect the network interface of the target network bridge to the network interface where the management container is located.

[0088] In the medical field, the Turnsole plugin can be used to optimize the network architecture and connection of the hospital, ensuring efficient transmission and sharing of data. For example, when the hospital needs to connect medical devices, patient information, and doctor workstations to the same network, the Turnsole plugin can achieve this connection by creating a network bridge. In the embodiments of the present application, the plugin needs to determine the address type of the target network address, select the appropriate network bridge tool according to the network type, such as using the bridge-utils tool on Linux, and create a network bridge. Further, configure the network bridge to connect the network interface of the target network bridge to the network interface where the management container is located. For example, use the following commands on Linux to create a network bridge named br0 and connect it to the eth0 interface: $sudo brctl addbr br0 $sudo brctl addif br0 eth0. In this way, all devices connected to the br0 network bridge can communicate with each other, thereby supporting information exchange between medical devices, patient information, and doctor workstations.

[0089] 206、The Turnsole plug-in modifies the network configuration file of the target management container to change the network address to the target network address and the bridge information to the bridge information corresponding to the target bridge.

[0090] In the embodiments of the present application, in order to ensure the intercommunication of the container network, the Turnsole plug-in also needs to update the pause container, that is, the network configuration file of the target management container that manages the designated container. Specifically, in the network configuration file of the target management container, the network address is modified to the target network address, and the bridge information is modified to the bridge information corresponding to the target bridge. For example, a medical facility usually has many management containers, such as running electronic medical record systems, medical image management systems, real-time positioning systems, etc. These containers need to communicate with each other and share data, so it is necessary to ensure the intercommunication of the container network. If the information in the network configuration file of a certain management container is incorrect, the corresponding container will not be able to join the target network, so it will not be able to realize communication and data sharing with other containers. In this case, the Turnsole plug-in can solve this problem by updating the pause container. Specifically, the Turnsole plug-in modifies the network configuration file of the target management container, and modifies the network address and bridge information in it to the information corresponding to the target network address and the target bridge. In this way, the target management container can join the target network and communicate and share data with other management containers and devices.

[0091] 207、The Turnsole plug-in sends the target network address and the hardware address information of the designated container to the container management component, so that the container management component aggregates the target network address and the hardware address information into a state file and stores the state file in the storage device of the host machine.

[0092] In the embodiments of the present application, the Turnsole plug-in sends the target network address and the hardware address information of the designated container to the container management component kubelet, and kubelet aggregates them into a state file and saves the state file on the local disk of the host. Kubelet will always keep the state file up to date and share it with the container runtime, so that any component that needs to access network state information can use it. For example, in a medical facility, there are many components that need to use network state information, such as real-time positioning systems, patient monitoring systems, medical data transmission systems, etc. The Turnsole plug-in sends the target network address and the hardware address information to kubelet and saves them in the state file, so that these components can easily access the network state information, thereby improving the efficiency and performance of medical services.

[0093] The method provided by the embodiment of the present application firstly determines a specified container, then acquires machine information of a host machine corresponding to the specified container, and reads a network address and a subnet mask recorded in the machine information. Next, a range of available network addresses is determined according to the network address and the subnet mask, and a target network address is selected in the range of available network addresses. Further, an address type of the target network address is determined, a target bridge is created according to the address type, and a bridge interface of the target bridge is connected with a network interface where a management container is located. Finally, a target management container managing the specified container is queried, a network address is modified to the target network address, and bridge information is modified to bridge information corresponding to the target bridge in a network configuration file of the target management container. The embodiment of the present application determines a target network address of a container according to machine information of a host machine, and realizes communication between containers by creating a target bridge and connecting a network interface on the host machine to an interface of the target bridge. In this process, the network capability of the host machine can be directly used to realize intercommunication of container networks, and a large number of virtual network devices or additional routing table entries do not need to be established, so that a large number of system resources can be avoided.

[0094] Further, as Figure 1 a specific implementation of the method, the embodiment of the present application provides a container network configuration device, as shown in Figure 3 The device comprises an acquisition module 301, a selection module 302, a determination module 303, and a setting module 304.

[0095] The acquisition module 301 is configured to determine a specified container, acquire machine information of a host machine, and read a network address and a subnet mask recorded in the machine information, wherein the host machine is used to indicate a host device running the specified container.

[0096] The selection module 302 is configured to determine a range of available network addresses according to the network address and the subnet mask, and select a target network address in the range of available network addresses.

[0097] The determination module 303 is configured to determine an address type of the target network address, create a target bridge according to the address type, and connect a bridge interface of the target bridge with a network interface where a management container is located.

[0098] The setting module 304 is configured to query a target management container managing the specified container, modify a network address to the target network address, and modify bridge information to bridge information corresponding to the target bridge in a network configuration file of the target management container.

[0099] In a specific application scenario, the obtaining module 301 is configured to receive an environment variable uploaded by a container management component, query an identifier associated with a container identifier variable in the environment variable, and take the identifier as a specified container identifier; traverse all running containers, determine a container corresponding to the specified container identifier in the all running containers, and obtain the specified container.

[0100] In a specific application scenario, the apparatus further includes a detection module 305 and a fixing module 306.

[0101] The detection module 305 is configured to detect an application type of the specified container.

[0102] The obtaining module 301 is configured to, if the application type of the specified container is a stateless application, obtain machine information of the host machine, and allocate a network address to the specified container according to the machine information.

[0103] The fixing module 306 is configured to, if the application type of the specified container is a stateful application, associate a network address of the specified container with a container identifier of the specified container, and modify a network configuration associated with the specified container to use a static network address.

[0104] In a specific application scenario, the detection module 305 is configured to detect whether a container image of the specified container has a directory or a file for storing data; if it is detected that the container image has the directory or the file for storing data, it is determined that the application type of the specified container is a stateful application; and if it is detected that the container image does not have the directory or the file for storing data, it is determined that the application type of the specified container is a stateless application.

[0105] In a specific application scenario, the detection module 305 is further configured to detect whether an application local disk or a persistent storage volume exists in the specified container; if it is detected that the application local disk or the persistent storage volume exists in the specified container, it is determined that the application type of the specified container is a stateful application; and if it is detected that the application local disk or the persistent storage volume does not exist in the specified container, it is determined that the application type of the specified container is a stateless application.

[0106] In a specific application scenario, the selecting module 302 is configured to determine an address type of the network address, convert the network address and the subnet mask into binary forms according to the address type, and perform a bitwise AND operation on the network address and the subnet mask in binary forms to obtain an operation result; convert the operation result into a decimal form to obtain the available network address range; scan all available network addresses in the available network address range, and determine a plurality of unoccupied network addresses from the all available network addresses; sort the plurality of network addresses according to an address sequence from front to back, and select a network address ranked first as the target network address.

[0107] In a specific application scenario, the apparatus further includes a sending module 307 and a storage module 308.

[0108] The sending module 307 is configured to send the target network address and the hardware address information of the specified container to the container management component, so that the container management component aggregates the target network address and the hardware address information into a state file.

[0109] The storage module 308 is configured to store the state file into a storage device of the host machine.

[0110] The apparatus provided by the embodiment of the present application first determines a specified container, then obtains machine information of a host machine corresponding to the specified container, and reads a network address and a subnet mask recorded in the machine information. Next, an available network address range is determined according to the network address and the subnet mask, and a target network address is selected from the available network address range. Further, an address type of the target network address is determined, a target bridge is created according to the address type, and a network interface of the target bridge is connected to a network interface where a management container is located. Finally, a target management container managing the specified container is queried, and the network address is modified to the target network address and the bridge information is modified to bridge information corresponding to the target bridge in a network configuration file of the target management container. The embodiment of the present application determines a target network address of a container according to machine information of a host machine, connects a network interface on the host machine to an interface of a target bridge by creating the target bridge, and realizes communication between containers. In this process, the network capability of the host machine can be directly used to realize intercommunication of container networks, and a large number of virtual network devices or additional routing table items do not need to be established, so that a large number of system resources can be avoided.

[0111] It should be noted that other corresponding descriptions of the functions of the container network configuration apparatus provided by the embodiment of the present application can be referred to the corresponding descriptions in the Figure 1 and FIG. 2, which will not be described herein again.

[0112] Based on the above description, it can be seen that the container network configuration apparatus provided by the embodiment of the present applicationFigure 1 According to the method shown in FIG. 2, the embodiment also provides a storage medium having a computer program stored thereon, and the computer program is executed by a processor to implement the steps of the container network configuration method.

[0113] Based on the understanding, the technical solution of the present application can be embodied in the form of a software product. The software product to be identified can be stored in a non-volatile storage medium (which can be a CD-ROM, a U disk, a mobile hard disk, etc.), and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the method described in various implementation scenarios of the present application.

[0114] Based on the above Figure 1 The method shown in FIG. 2, and Figure 3 The container network configuration device embodiment shown in FIG. 2, in order to achieve the above purpose, in the exemplary embodiment, referring to Figure 4 A device is also provided, which includes a communication bus, a processor, a memory, and a communication interface, and can also include an input / output interface and a display device, wherein the communication between various functional units can be completed through the bus. The memory stores a computer program, and the processor is configured to execute the program stored in the memory to execute the container network configuration method in the above embodiment.

[0115] Optionally, the entity device can also include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface can include a display screen (Display), an input unit such as a keyboard (Keyboard), etc. The optional user interface can also include a USB interface, a card reader interface, etc. The network interface can optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), etc.

[0116] Those skilled in the art can understand that the entity device structure provided by the embodiment for container network configuration does not constitute a limitation on the entity device, and can include more or fewer components, or combine certain components, or different component arrangements.

[0117] The storage medium can also include an operating system and a network communication module. The operating system is a program for managing the hardware and software resources of the entity device, supporting the running of information processing programs and other software and / or programs. The network communication module is used to realize the communication between the components in the storage medium, and the communication between the other hardware and software in the information processing entity device.

[0118] Through the description of the above embodiments, those skilled in the art can clearly understand that the present application can be implemented by means of software with a necessary general hardware platform, or by hardware. Through the application of the technical solutions of the present application, first, the specified container is determined, then the machine information of the host machine corresponding to the specified container is obtained, and the network address and subnet mask recorded in the machine information are read. Next, the available network address range is determined according to the network address and subnet mask, and the target network address is selected in the available network address range. Further, the address type of the target network address is determined, the target bridge is created according to the address type, and the bridge interface of the target bridge is connected with the network interface where the management container is located. Finally, the target management container managing the specified container is queried, the network address is modified to the target network address and the bridge information is modified to the bridge information corresponding to the target bridge in the network configuration file of the target management container. Compared with the prior art, the present application determines the target network address of the container according to the machine information of the host machine, creates the target bridge, and connects the network interface on the host machine to the interface of the target bridge to realize the communication between the containers. In this process, the network capability of the host machine can be directly used to realize the intercommunication of the container network, and a large number of virtual network devices or additional routing table entries do not need to be established, so that a large number of system resources can be avoided.

[0119] Those skilled in the art can understand that the modules in the apparatus in the embodiments are not necessarily indispensable to the implementation of the present application.

[0120] Those skilled in the art can understand that the modules in the apparatus in the embodiments can be distributed in the apparatus in the embodiments according to the description of the embodiments, or can be changed and located in one or more apparatuses different from the embodiments. The modules in the above embodiments can be combined as one module, or can be further split into multiple sub-modules.

Claims

1. A method of configuring a network of containers, characterized by, The method comprises the following steps: determining a specified container, and obtaining machine information of a host machine, reading a network address and a subnet mask recorded in the machine information, the host machine being used to indicate a host device running the specified container; determining an available network address range according to the network address and the subnet mask, and selecting a target network address in the available network address range; determining an address type of the target network address, creating a target bridge according to the address type, and connecting a bridge interface of the target bridge to a network interface where a management container is located; inquiring a target management container managing the specified container, and modifying a network address to the target network address and bridge information to bridge information corresponding to the target bridge in a network configuration file of the target management container; after the step of determining the specified container, the method further comprises the following steps: detecting an application type of the specified container; if the application type of the specified container is a stateless application, obtaining machine information of the host machine, and allocating a network address to the specified container according to the machine information; if the application type of the specified container is a stateful application, associating a network address of the specified container with a container identifier of the specified container, and modifying a network configuration associated with the specified container to use a static network address.

2. The method of claim 1, wherein, The step of determining the specified container comprises the following steps: receiving an environment variable uploaded by a container management component, inquiring an identifier associated with a container identifier variable in the environment variable, and taking the identifier as a specified container identifier; traversing all running containers, determining a container corresponding to the specified container identifier in the all running containers, and obtaining the specified container.

3. The method of claim 1, wherein, The step of detecting the application type of the specified container comprises the following steps: detecting whether a container image of the specified container exists a directory or a file for storing data; if it is detected that the container image exists the directory or the file for storing data, determining that the application type of the specified container is a stateful application; if it is detected that the container image does not exist the directory or the file for storing data, determining that the application type of the specified container is a stateless application.

4. The method of claim 1, wherein, The step of detecting the application type of the specified container further comprises the following steps: detecting whether an application local disk or a persistent storage volume exists in the specified container; if it is detected that the application local disk or the persistent storage volume exists in the specified container, determining that the application type of the specified container is a stateful application; if it is detected that the application local disk or the persistent storage volume does not exist in the specified container, determining that the application type of the specified container is a stateless application.

5. The method of claim 1, wherein, The step of determining the available network address range according to the network address and the subnet mask, and selecting the target network address in the available network address range comprises the following steps: determining an address type of the network address, converting the network address and the subnet mask into binary forms respectively according to the address type, and performing a bitwise AND operation on the network address and the subnet mask in the binary forms to obtain an operation result; converting the operation result into a decimal form to obtain the available network address range. scan all available network addresses in the available network address range, and determine a plurality of unoccupied network addresses from the all available network addresses; sort the plurality of network addresses in order from front to back of address, and select a network address ranked first as the target network address.

6. The method of claim 1, wherein, After the bridge information is modified to the bridge information corresponding to the target bridge, the method further comprises: send the target network address and the hardware address information of the specified container to the container management component, so that the container management component aggregates the target network address and the hardware address information into a state file; store the state file into a storage device of the host machine.

7. A container network configuration device, characterized in that, comprise: an acquisition module, configured to determine a specified container, and acquire machine information of a host machine, read a network address and a subnet mask recorded in the machine information, the host machine being used to indicate a host device running the specified container; a selection module, configured to determine an available network address range according to the network address and the subnet mask, and select a target network address in the available network address range; a determination module, configured to determine an address type of the target network address, create a target bridge according to the address type, and connect a bridge interface of the target bridge with a network interface where a management container is located; a setting module, configured to query a target management container managing the specified container, modify a network address to the target network address in a network configuration file of the target management container, and modify bridge information to bridge information corresponding to the target bridge; a detection module, configured to detect an application type of the specified container; the acquisition module, configured to acquire machine information of the host machine, and allocate a network address for the specified container according to the machine information, if the application type of the specified container is a stateless application; a fixing module, configured to associate a network address of the specified container with a container identifier of the specified container, and modify a network configuration associated with the specified container to use a static network address, if the application type of the specified container is a stateful application.

8. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that, The processor executes the computer program to realize the steps of the method in any one of claims 1 to 6.

9. A readable storage medium, having stored thereon a computer program, characterized in that, The computer program is executed by the processor to realize the steps of the method in any one of claims 1 to 6.