K8s bridge plug-in implementation method, device, electronic equipment and readable storage medium
By generating virtual bridges for pods in a Kubernetes cluster and configuring fixed IPs and VLANs, the problem of containers in a Kubernetes cluster not having independent IPs is solved, achieving efficient resource utilization and network environment simulation, and enhancing Kubernetes compatibility.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING KNOWS THE FUTURE INFORMATION TECH CO LTD
- Filing Date
- 2022-10-18
- Publication Date
- 2026-06-09
AI Technical Summary
When Kubernetes (k8s) technology simulates a host running containers in a real environment, it cannot assign an independent IP address to each container. This results in an inability to effectively simulate the network environment in a real environment, as well as wasted resources and difficulties in maintaining the network environment.
By generating a virtual bridge for each pod in the Kubernetes cluster and configuring fixed IPs and VLANs for containers, a host-plus-container environment is simulated, which conforms to the Kubernetes container network specification.
This allows each container to have an independent IP address within the Kubernetes cluster, simulating a host-plus-container environment in a non-Kubernetes cluster. This improves resource utilization and network environment management efficiency, and enhances Kubernetes' compatibility with traditional network services.
Smart Images

Figure CN115622878B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of network technology, and more specifically, to a method, apparatus, electronic device, and readable storage medium for implementing a k8s bridge plugin. Background Technology
[0002] In the Kubernetes network model, the smallest network unit is the Pod. The network design principle for Pods is IP-per-Pod, meaning that containers within a Pod share the same network protocol stack and have the same network namespace. Containers within a Pod are accessed via localhost + port, similar to process access in Linux. Kubernetes' cluster network design principles include the following: all containers can communicate with other containers without NAT (Network Address Translation); all nodes can communicate with all containers without NAT, and vice versa; the container's address and the address seen externally are the same; within the same pod, communication between containers is via pod-ip + container-mapped port.
[0003] In traditional Kubernetes (k8s) applications in attack and defense testbeds, a k8s namespace functions as a cluster network environment (an independent subnet environment), and each pod functions as a virtual host running containers. However, according to traditional k8s pod technology, the pod is the smallest network unit, and containers within a pod share the pod-ip resource, without their own individual IP addresses. This makes it impossible to use k8s technology to simulate a real-world host environment where each container has its own target virtual environment with its own IP address. Summary of the Invention
[0004] The objectives of this invention include, for example, providing a k8s bridge plugin implementation method, apparatus, electronic device, and readable storage medium that can simulate a host-plus-container environment in a non-k8s cluster and can be directly managed by k8s.
[0005] The embodiments of the present invention can be implemented as follows:
[0006] In a first aspect, the present invention provides a method for implementing a Kubernetes bridge plugin, applied to nodes in a Kubernetes cluster, the method comprising:
[0007] The bridge plugin is invoked to configure and generate virtual bridges for pods, and to configure fixed IPs and perform VLAN segmentation for the corresponding Docker containers;
[0008] When a pod is created, the bridge plugin is invoked to add the virtual bridge, VLAN tag, and network segment to the pod;
[0009] When adding a container to the pod, configure the added virtual bridge, the fixed IP address, and the VLAN tag for the container, wherein the fixed IP address of the container and the virtual bridge gateway IP address are in the same network segment.
[0010] In an optional implementation, the Kubernetes cluster has a pod virtual network resource sharing interface container, and the container port of the pod virtual network resource sharing interface container is mapped to the pod.
[0011] In an optional implementation, the virtual bridge, VLAN tag, and network segment added to the pod may include multiple sets.
[0012] In an optional implementation, the method further includes:
[0013] The virtual bridge configuration information of the pod and the fixed IP and VLAN division information of the Docker container are sent to the storage system for storage through the service interface.
[0014] In an optional implementation, the method further includes:
[0015] Upon receiving a remote connection login request from a user terminal, the system sends the fixed IP information of the Docker container back to the user terminal.
[0016] After the user terminal successfully logs into the Docker container, a network diagnostic tool is invoked to obtain the IP addresses of Docker containers in the same VLAN and Docker containers in different VLANs, in order to verify whether the Docker containers have been configured for networking and VLAN division.
[0017] In an optional implementation, the method further includes:
[0018] When a container image from an existing production or R&D environment is received from a user terminal, the configuration file for generating the pod is written.
[0019] Run the written configuration file to migrate existing host and container environments as pods to the Kubernetes cluster.
[0020] In an optional implementation, the step of writing the configuration file for generating the pod includes:
[0021] Based on the container image information in the existing production or R&D environment, obtain the container bridge information and container network information used by the containers in the existing production or R&D environment.
[0022] The container bridge information is used as the pod bridge information, and the container network information is used as the network information when regenerating the container using its image information, in order to write the configuration file for generating the pod.
[0023] Secondly, the present invention provides a k8s bridge plugin implementation device, applied to nodes in a k8s cluster, the device comprising:
[0024] The calling module is used to call the bridge plugin to configure and generate virtual bridges for pods, and to configure fixed IPs and perform VLAN segmentation for the corresponding Docker containers;
[0025] The generation module is used to call the bridge plugin to add the virtual bridge, VLAN tag and network segment to the pod when generating the pod;
[0026] An add module is used to configure the added virtual bridge, fixed IP address, and VLAN tag for the container when adding a container to the pod, wherein the fixed IP address of the container and the virtual bridge gateway IP address are in the same network segment.
[0027] Thirdly, the present invention provides an electronic device comprising: a memory and at least one processor, wherein the memory stores instructions; the at least one processor invokes the instructions in the memory to cause the electronic device to execute the k8s bridge plugin implementation method as described in any of the foregoing embodiments.
[0028] Fourthly, the present invention provides a computer-readable storage medium storing instructions that, when executed by a processor, implement the method implemented by the k8s bridge plugin as described in any of the foregoing embodiments.
[0029] The beneficial effects of the embodiments of the present invention include, for example:
[0030] This application provides a method, apparatus, electronic device, and readable storage medium for implementing a Kubernetes bridge plugin. The plugin is invoked to configure and generate virtual bridges for pods, and to configure fixed IPs and perform VLAN segmentation for the corresponding Docker containers. When creating a pod, the bridge plugin is invoked to add a virtual bridge, VLAN tag, and network segment to the pod. When adding a container to a pod, the added virtual bridge, the fixed IP, and the VLAN tag are configured for the container, wherein the container's fixed IP and the virtual bridge gateway IP are in the same network segment. This solution can generate a virtual bridge for each pod running in a Kubernetes cluster and use the virtual bridge to allocate IPs to containers within the pod, simulating a host-container environment outside of a Kubernetes cluster. It also conforms to the container network specifications used by Kubernetes and can be directly managed by Kubernetes. Attached Figure Description
[0031] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0032] Figure 1 A flowchart illustrating the implementation method of the k8s bridge plugin provided in this application embodiment;
[0033] Figure 2 Another flowchart of the k8s bridge plugin implementation method provided in the embodiments of this application;
[0034] Figure 3 The flowchart of the verification method in the Kubernetes bridge plugin implementation method provided in this application embodiment;
[0035] Figure 4 The flowchart of the translation method in the Kubernetes bridge plugin implementation method provided in this application embodiment;
[0036] Figure 5 for Figure 4 A flowchart of the sub-steps included in step S301;
[0037] Figure 6 A structural block diagram of the electronic device provided in the embodiments of this application;
[0038] Figure 7 A functional block diagram of the k8s bridge plugin implementation device provided in the embodiments of this application.
[0039] Icons: 110 - Storage medium; 120 - Processor; 130 - Kubernetes bridge plugin implementation device; 131 - Calling module; 132 - Generation module; 133 - Adding module; 140 - Communication interface. Detailed Implementation
[0040] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0041] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0042] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0043] It should be noted that, where there is no conflict, the features in the embodiments of the present invention can be combined with each other.
[0044] The following is an explanation of some of the technical terms used in this application:
[0045] K8s: Kubernetes is an open-source application used to manage containerized applications across multiple hosts in a cloud platform. Kubernetes aims to make deploying containerized applications simple and powerful. Kubernetes provides a mechanism for application deployment, planning, updating, and maintenance.
[0046] Containers: A container is a sandbox technology primarily designed to run applications within an isolated environment, allowing the sandbox to be easily migrated to other host machines. Essentially, it's a special type of process. It uses namespaces, control groups, and chroot techniques to divide resources, files, devices, states, and configurations into an independent space.
[0047] Namespace: Namespace is also called k8s namespace. Kubernetes supports multiple virtual clusters that depend on the same physical cluster at the underlying level. These virtual clusters are called namespaces.
[0048] Pod: A Pod is the smallest unit of scheduling in Kubernetes. A Pod can contain one or more containers, so it can be viewed as a logical host for the containers inside. The design philosophy of Pods is to support multiple containers sharing network and file systems within a single Pod.
[0049] OpenvSwitch: OpenvSwitch, abbreviated as OVS, is a high-quality, multi-tiered virtual switching software. Its purpose is to support large-scale network automation through programmable extensions, while also supporting standard management interfaces and protocols.
[0050] Pod Bridge: The Pod Bridge is a virtual bridge added to pods running in Kubernetes using OpenVSwich in this invention. This bridge connects the pod's virtual network interface to the network interface of the containers within the pod, and assigns fixed IP addresses and VLANs to designated containers within the pod, enabling the designated containers to form independent local area networks and allowing for communication compatible with Kubernetes networks. Ultimately, this achieves the goal of mimicking a container environment running on a host machine.
[0051] Currently, the technologies used to ensure that each container in a Kubernetes cluster has its own independent IP address include single-container pods, where only one container runs within a single Kubernetes pod, thus guaranteeing that each container has a unique IP address. Alternatively, Kubernetes virtualization uses KVM virtual machines as Kubernetes container units, running virtual or container environments within the KVM. This provides a network environment within the virtual machine that is similar to a traditional host network environment.
[0052] However, the single-container technology used in existing technologies cannot migrate an existing application into a single pod when multiple container services are used for an application. Deploying a single application in multiple pods within a Kubernetes NamSpace will result in wasted resources and a chaotic and difficult-to-maintain network environment.
[0053] Furthermore, the virtualization technology used in the existing technology, compared with direct container deployment, uses virtual machines, which seriously waste physical resources. Moreover, the resources within the virtual machines cannot be directly managed by Kubernetes, increasing cluster complexity and operation and maintenance costs.
[0054] To address the problems existing in the prior art, this application provides a k8s bridge plugin implementation scheme. This scheme can generate a virtual bridge for each pod running in a k8s cluster and use the virtual bridge to allocate IPs to containers within the pod, simulating a host plus container environment in a non-k8s cluster. It also conforms to the container network specifications used by k8s and can be directly managed by k8s.
[0055] Please see Figure 1 This is a flowchart of a Kubernetes bridge plugin implementation method provided in this application embodiment. The method steps defined in the flowchart of this Kubernetes bridge plugin implementation method can be implemented by an electronic device, for example, the electronic device can be a node in a Kubernetes cluster. The following will describe... Figure 1 The specific process shown will be explained in detail.
[0056] S101 calls the bridge plugin to configure and generate a virtual bridge for the pod, and configures a fixed IP address and performs VLAN segmentation for the corresponding Docker container.
[0057] S102, when generating a pod, the bridge plugin is invoked to add the virtual bridge, VLAN tag and network segment to the pod.
[0058] S103, when adding a container to the pod, configure the added virtual bridge, the fixed IP address, and the VLAN tag for the container, wherein the fixed IP address of the container and the virtual bridge gateway IP address are in the same network segment.
[0059] In this embodiment, a bridge plugin can be used to configure a virtual bridge for each pod in the Kubernetes cluster. This virtual bridge can connect the pod's virtual network interface card (NIC) to the pod's internal network interface card (NIC), thereby combining the pod's internal network into a local area network (LAN).
[0060] In this embodiment, the bridge plugin can run on nodes of the Kubernetes cluster and can generate and configure virtual bridges for pods by manipulating Openv Switch. The operation interface of this bridge plugin can be accessed through the kubectl tool (a command-line tool for operating the Kubernetes cluster). Furthermore, it can also perform operations such as configuring fixed IP addresses for Docker containers and partitioning VLANs (Virtual Local Area Networks).
[0061] In this embodiment, the first step is to write a YAML file to generate the pod using kubectl. YAML is a highly readable format used to express data serialization, and it can easily express data formats such as lists, hash tables, and scalars.
[0062] For example, the content of the written YAML file may include adding a pod bridge named br0 with a gateway address of 192.168.56.1 / 24 to vpc1-pod, adding a fixed IP address of 192.168.56.2 to the nginx container in vpc1-pod, and adding a fixed IP address of 192.168.56.3 to the redis container in vpc1-pod, etc.
[0063] The kubectl command in Kubernetes can be used to run the YAML file to generate a pod. When running the configured YAML file, the kubectl command can invoke the bridge plugin in this embodiment and operate OpenvSwitch to generate the corresponding virtual bridge, and configure a fixed IP address and VLAN segmentation for the corresponding Docker container.
[0064] When using kubectl to create a pod, you can configure the pod through the yml file or command-line parameters. You can enable the bridge plugin to generate a virtual bridge, a network segment (gateway address / subnet mask), and a VLAN tag. Of course, the VLAN tag can be left blank, with a default value of 0.
[0065] When pods are configured to not use virtual bridges via YAML files or command-line settings, the default pod-IP resource sharing technology will be used, meaning all Docker containers will share a single pod IP.
[0066] In this embodiment, the virtual bridge, VLAN tag, and network segment added to the pod include multiple sets.
[0067] When adding a container to a pod using kubectl, you can configure the added virtual bridge and a fixed IP address and VLAN tag for the container (the VLAN tag can be left blank, defaulting to 0). However, the container's IP address must be in the same network segment as the virtual bridge gateway's IP address.
[0068] In this embodiment, the Kubernetes cluster has a pod virtual network resource sharing interface container, and the container port of the pod virtual network resource sharing interface container is mapped to the pod.
[0069] In this embodiment, regardless of whether the pod uses the bridge plugin to generate a virtual bridge, and regardless of whether the pod container is configured with a fixed IP using the bridge plugin, the original Kubernetes pod virtual network resource sharing interface container Paxe exists, and the container port is mapped to the pod.
[0070] Please see Figure 2 After the pod and Docker container are configured, the method in this embodiment may further include the following steps:
[0071] S104, the virtual bridge configuration information of the pod and the fixed IP and VLAN division information of the Docker container are sent to the storage system for storage through the service interface.
[0072] The storage system mentioned can be a key-value data storage system like etcd. Information such as the container's IP address can be centrally managed by other storage systems.
[0073] When a user uses kubectl to query the corresponding pod, they can obtain information such as the virtual bridge name, virtual bridge IP, and container IP within the pod.
[0074] The Kubernetes bridge plugin implementation method provided in this embodiment extends the network mode of pods in Kubernetes by adding the function of configuring fixed IPs and VLANs for individual containers, thus fully simulating the host-plus-container environment in a non-Kubernetes cluster. This overcomes the deficiency of existing Kubernetes network attack and defense range network environment simulation methods that cannot simulate host-plus-container environments using pods.
[0075] Please see Figure 3 Based on the above, the Kubernetes bridge plugin implementation method provided in this embodiment may further include the following steps:
[0076] S201, upon receiving a remote connection login request from a user terminal, the system sends the fixed IP information of the Docker container back to the user terminal.
[0077] S202, after the user terminal successfully logs into the Docker container, the network diagnostic tool is called to obtain the IP addresses of Docker containers in the same VLAN and Docker containers in different VLANs, in order to verify whether the Docker containers have been configured for networking and VLAN division.
[0078] In this embodiment, users can remotely connect via SSH (Secure Shell) or log in to the generated Docker container using kubectl (Docker) and use commands such as ip add to view the container's fixed IP address.
[0079] Once a user successfully logs into a Docker container, they can use network diagnostic tools to obtain the IP addresses of containers in the same VLAN (or the same network segment) and containers in different VLANs (or different network segments). This allows verification that the bridge plugin in this embodiment has configured the containers for networking and VLAN segmentation.
[0080] Further, please refer to Figure 4 In this embodiment, the k8s bridge plugin implementation method may further include the following steps:
[0081] S301, upon receiving a container image from an existing production or R&D environment sent by a user terminal, executes the writing of configuration files for generating pods.
[0082] S302 runs the written configuration file to migrate existing host and container environments to the Kubernetes cluster as pods.
[0083] In this embodiment, the configuration file can be a YAML file, and the file format of the YAML file can be the same as the file format used to generate pods. The configuration file can be run using kubectl, allowing the original host + container environment to be migrated to the Kubernetes cluster as pods.
[0084] Please see Figure 5 In this embodiment, when writing the configuration file used to generate the pod, it can be achieved in the following way:
[0085] S3011, Based on the container image information in the existing production environment or R&D environment, obtain the container bridge information and container network information used by the containers in the existing production environment or R&D environment.
[0086] S3012, the container bridge information is used as pod bridge information, and the container network information is used as network information when regenerating the container using its image information, in order to write a configuration file for generating the pod.
[0087] In this embodiment, the container bridge information used by containers in the existing production or R&D environment includes, for example, the bridge name and gateway address. This existing container bridge information is used as the pod bridge information for the pod to be generated.
[0088] In addition, existing container network information used in production or R&D environments includes things like IP addresses and VLAN tags. This existing container network information is used as the network information when recreating containers.
[0089] By running configuration files written in the above manner, enterprises can be assisted in migrating their existing container environments from non-Kubernetes clusters to Kubernetes clusters.
[0090] The Kubernetes bridge plugin implementation method provided in this embodiment extends the network modes of pods in Kubernetes, adding the ability to configure fixed IPs and VLANs for individual containers. It fully simulates the host + container environment in a non-Kubernetes cluster. This overcomes the limitation of existing Kubernetes network attack and defense test environment simulations, which cannot simulate host + container environments using pods. It can assist enterprises in migrating existing container environments from non-Kubernetes clusters to Kubernetes clusters.
[0091] By modifying the network namespace within a Kubernetes pod, you can configure whether the pod's contents share a pod IP or are assigned a dedicated IP via a virtual bridge within the pod. This configuration not only meets the network requirements of virtual simulation attack and defense testbeds but also enhances Kubernetes' compatibility with traditional network services, facilitating enterprises' migration of existing network applications to Kubernetes clusters.
[0092] Please see Figure 6 This is a schematic diagram of exemplary components of an electronic device provided in an embodiment of this application. The electronic device may be a node in a Kubernetes cluster, etc. The electronic device may include a storage medium 110, a processor 120, a Kubernetes bridge plugin implementation device 130, and a communication interface 140. In this embodiment, the storage medium 110 and the processor 120 are both located within the electronic device and are separately configured. However, it should be understood that the storage medium 110 may also be independent of the electronic device and can be accessed by the processor 120 through a bus interface. Alternatively, the storage medium 110 may also be integrated into the processor 120, for example, as a cache and / or general-purpose registers.
[0093] The k8s bridge plugin implementation device 130 can be understood as the aforementioned electronic device, or the processor 120 of the electronic device, or as a software functional module that implements the aforementioned k8s bridge plugin implementation method under the control of the electronic device, independent of the aforementioned electronic device or processor 120.
[0094] like Figure 7 As shown, the above-mentioned k8s bridge plugin implementation device 130 may include a calling module 131, a generation module 132, and an adding module 133. The functions of each functional module of the k8s bridge plugin implementation device 130 will be described in detail below.
[0095] Module 131 is invoked to call the bridge plugin to configure and generate a virtual bridge for the pod, and to configure a fixed IP address and perform VLAN segmentation for the corresponding Docker container.
[0096] It is understood that the calling module 131 can be used to execute the above step S101. For details on the implementation of the calling module 131, please refer to the above content related to step S101.
[0097] The generation module 132 is used to call the bridge plugin to add the virtual bridge, VLAN tag and network segment to the pod when generating the pod;
[0098] It is understood that the generation module 132 can be used to perform the above step S102. For details on the implementation of the generation module 132, please refer to the above content related to step S102.
[0099] Add module 133, which is used to configure the added virtual bridge, fixed IP, and VLAN tag for the container when adding a container to the pod, wherein the fixed IP of the container and the virtual bridge gateway IP are in the same network segment.
[0100] It is understood that the addition module 133 can be used to perform the above step S103. For details on the implementation of the addition module 133, please refer to the above content related to step S103.
[0101] In one possible implementation, the Kubernetes cluster has a pod virtual network resource sharing interface container, and the container port of the pod virtual network resource sharing interface container is mapped to the pod.
[0102] In one possible implementation, the virtual bridge, VLAN tag, and network segment added to the pod may include multiple sets.
[0103] In one possible implementation, the Kubernetes bridge plugin implementation device 130 further includes a storage module, which can be used for:
[0104] The virtual bridge configuration information of the pod and the fixed IP and VLAN division information of the Docker container are sent to the storage system for storage through the service interface.
[0105] In one possible implementation, the Kubernetes bridge plugin implementation device 130 further includes a verification module, which can be used for:
[0106] Upon receiving a remote connection login request from a user terminal, the system sends the fixed IP information of the Docker container back to the user terminal.
[0107] After the user terminal successfully logs into the Docker container, a network diagnostic tool is invoked to obtain the IP addresses of Docker containers in the same VLAN and Docker containers in different VLANs, in order to verify whether the Docker containers have been configured for networking and VLAN division.
[0108] In one possible implementation, the Kubernetes bridge plugin implementation device 130 further includes a translation module, which can be used for:
[0109] When a container image from an existing production or R&D environment is received from a user terminal, the configuration file for generating the pod is written.
[0110] Run the written configuration file to migrate existing host and container environments as pods to the Kubernetes cluster.
[0111] In one possible implementation, the translation module described above can specifically be used for:
[0112] Based on the container image information in the existing production or R&D environment, obtain the container bridge information and container network information used by the containers in the existing production or R&D environment.
[0113] The container bridge information is used as the pod bridge information, and the container network information is used as the network information when regenerating the container using its image information, in order to write the configuration file for generating the pod.
[0114] The processing flow of each module in the device and the interaction flow between each module can be referred to the relevant descriptions in the above method embodiments, and will not be detailed here.
[0115] Furthermore, this application embodiment also provides a computer-readable storage medium storing machine-executable instructions, which, when executed, implement the k8s bridge plugin implementation method provided in the above embodiment.
[0116] Specifically, the computer-readable storage medium can be a general-purpose storage medium, such as a removable disk or hard disk. When the computer program on the computer-readable storage medium is run, it can execute the above-described Kubernetes bridge plugin implementation method. The processes involved in the execution of the executable instructions on the computer-readable storage medium can be referred to the relevant descriptions in the above method embodiments, and will not be detailed here.
[0117] In summary, the Kubernetes bridge plugin implementation method, apparatus, electronic device, and readable storage medium provided in this application configure and generate virtual bridges for pods by calling the bridge plugin, and configure fixed IPs and perform VLAN segmentation for the corresponding Docker containers. When generating a pod, the bridge plugin is called to add a virtual bridge, VLAN tag, and network segment to the pod. When adding a container to a pod, the added virtual bridge, the fixed IP, and the segmented VLAN tag are configured for the container, wherein the container's fixed IP and the virtual bridge gateway IP are in the same network segment. This solution can generate a virtual bridge for each pod running in a Kubernetes cluster, and use the virtual bridge to allocate IPs to containers within the pod, simulating a host-container environment outside of a Kubernetes cluster. Furthermore, it conforms to the container network specifications used by Kubernetes and can be directly managed by Kubernetes.
[0118] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A k8s bridge plugin implementation method, characterized in that, The method, applied to nodes in a Kubernetes cluster, includes: The bridge plugin is invoked to configure and generate virtual bridges for pods, and to configure fixed IPs and perform VLAN segmentation for the corresponding Docker containers; When a pod is created, the bridge plugin is invoked to add the virtual bridge, VLAN tag, and network segment to the pod; When adding a container to the pod, configure the added virtual bridge, the fixed IP address, and the VLAN tag for the container, wherein the fixed IP address of the container and the virtual bridge gateway IP address are in the same network segment; The method further includes: When receiving a container image generated in an existing production or R&D environment from a user terminal, the container bridge information and container network information used by the container in the existing production or R&D environment are obtained based on the container image information in the existing production or R&D environment. The container bridge information is used as the pod bridge information, and the container network information is used as the network information when regenerating the container using its image information, in order to write a configuration file for generating the pod. Run the written configuration file to migrate existing host and container environments as pods to the Kubernetes cluster.
2. The k8s bridge plugin implementation method according to claim 1, characterized in that, The Kubernetes cluster has a pod virtual network resource sharing interface container, and the container port of the pod virtual network resource sharing interface container is mapped to the pod.
3. The k8s bridge plugin implementation method according to claim 1, characterized in that, The virtual bridge, VLAN tag, and network segment added to the pod include multiple sets.
4. The method for implementing a Kubernetes bridge plugin according to claim 1, characterized in that, The method further includes: The virtual bridge configuration information of the pod and the fixed IP and VLAN division information of the Docker container are sent to the storage system for storage through the service interface.
5. The method for implementing a Kubernetes bridge plugin according to claim 1, characterized in that, The method further includes: Upon receiving a remote connection login request from a user terminal, the system sends the fixed IP information of the Docker container back to the user terminal. After the user terminal successfully logs into the Docker container, a network diagnostic tool is invoked to obtain the IP addresses of Docker containers in the same VLAN and Docker containers in different VLANs, in order to verify whether the Docker containers have been configured for networking and VLAN division.
6. A Kubernetes bridge plugin implementation device, characterized in that, An apparatus for use on nodes in a Kubernetes cluster to implement the Kubernetes bridge plugin implementation method according to any one of claims 1-5, the apparatus comprising: The calling module is used to call the bridge plugin to configure and generate virtual bridges for pods, and to configure fixed IPs and perform VLAN segmentation for the corresponding Docker containers; The generation module is used to call the bridge plugin to add the virtual bridge, VLAN tag and network segment to the pod when generating the pod; An add module is used to configure the added virtual bridge, fixed IP address, and VLAN tag for the container when adding a container to the pod, wherein the fixed IP address of the container and the virtual bridge gateway IP address are in the same network segment.
7. An electronic device, characterized in that, The electronic device includes: a memory and at least one processor, wherein the memory stores instructions; the at least one processor invokes the instructions in the memory to cause the electronic device to execute the k8s bridge plugin implementation method as described in any one of claims 1 to 5.
8. A computer-readable storage medium storing instructions thereon, characterized in that, When the instruction is executed by the processor, it implements the k8s bridge plugin implementation method as described in any one of claims 1 to 5.