Cross-Kubernetes network connection method and system, storage medium and electronic equipment

By establishing virtual network links between Kubernetes clusters, the problem of difficult cross-cluster communication is solved and efficient communication and disaster recovery capabilities between clusters are achieved.

CN118869780APending Publication Date: 2024-10-29HANGZHOU YUNYUANSHENG DATA CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411142968.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-20
Publication Date
2024-10-29

AI Technical Summary

Technical Problem

In the existing technology, Pods between Kubernetes clusters cannot directly communicate across clusters, making cross-cluster communication difficult.

Method used

By establishing a long TCP connection with the network proxy server or client of the second cluster, scanning and monitoring changes in Service objects, building virtual network links, and realizing cross-cluster communication between Pods.

Benefits of technology

It enables applications in a Kubernetes cluster to directly access services in another Kubernetes cluster just like connecting services within the cluster, which facilitates upper-layer application development and provides stronger disaster recovery capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118869780A_ABST
    Figure CN118869780A_ABST
Patent Text Reader

Abstract

The invention discloses a cross-Kubernetes network connection method and system, a storage medium and electronic equipment, relates to the technical field of cross-cluster communication, and solves the problem that cross-Kubernetes cluster communication cannot be realized by Pod in the prior art. The method comprises the following steps: establishing TCP long connection between a first cluster and a second cluster, scanning and reporting Service objects and changes thereof, and sending the TCP long connection to the first cluster and the second cluster; a virtual network link for realizing communication between a Pod in a second cluster and a Pod in a first cluster is established, and communication between the Pod in the second cluster and the Pod in the first cluster is realized through virtual network connection, so that a network virtual link is maintained between the first cluster and the second cluster. The application in the first cluster and the application in the second cluster can be communicated with the service in another Kubernetes cluster like being connected with the service in the cluster, and development of upper-layer applications is greatly facilitated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of cross-cluster communication technology, and in particular to a cross-Kubernetes network connectivity method, system, storage medium, and electronic device. Background Art

[0002] Kubernetes (K8S for short) is an open source platform for automatically deploying, scaling, and managing containerized applications. It provides a powerful container orchestration system to help users efficiently manage the operation of large-scale containerized applications, where Pod is the smallest deployment unit: it contains one or more containers that share network and storage resources and run on the same host. Pods can be static or dynamic and can be publicly accessed through Service objects. Service is a service abstraction: it is used to expose the network endpoints of Pods and provide load balancing and failover capabilities.

[0003] like Figure 2 As shown in the figure, there are three Kubernetes clusters: Manager Kubernetes cluster (Manager cluster for short), Managed Kubernetes cluster X (Managed-X cluster for short), and Managed Kubernetes cluster Y (Managed-Y cluster for short). Two applications are deployed in the Manager cluster: PodApp-A and PodApp-B. The database service PodDB is deployed in the Managed-X cluster, and load balancing is performed through ServiceA. Another database service PodDB is deployed in the Managed-Y cluster, and load balancing is performed through ServiceA. It should be noted that although there are PodDB and ServiceA in both the Managed-X cluster and the Managed-Y cluster, they are different database services with the same name.

[0004] Under normal circumstances, PodApp-A in the Manager cluster cannot connect to PodDB in the Managed-X cluster. That is, in the existing technology, each Pod in the Kubernetes cluster can directly connect to other Pods through IP, domain name, etc., but when crossing Kubernetes clusters, the Pods in the two clusters may be in completely different network environments, so they cannot be directly connected. Summary of the invention

[0005] The purpose of this application is to overcome the problem in the prior art that Pod cannot communicate across Kubernetes clusters, and to provide a cross-Kubernetes network connectivity method, system, storage medium and electronic device.

[0006] First, a cross-Kubernetes network connectivity method is provided, including:

[0007] Establish a TCP persistent connection with the network proxy server in the second cluster;

[0008] Scanning the Service objects in the first cluster and reporting the scanned Service object list to the network proxy server, wherein the Service object includes a grid quadruple: source IP, source port, target IP and target port;

[0009] Monitor the change information of the Service object in the first cluster, and report the change information to the network proxy server;

[0010] Building a virtual network link for realizing communication between the Pod in the second cluster and the Pod in the first cluster according to the mesh quadruple;

[0011] The communication between the Pod in the second cluster and the Pod in the first cluster is achieved through the virtual network connection.

[0012] In some possible implementations, before establishing a TCP persistent connection with the network proxy server in the second cluster, the process further includes:

[0013] Get the IP address and login credentials of the network proxy server and initiate a login request.

[0014] In some possible implementations, building a virtual network link for implementing communication between a Pod in the second cluster and a Pod in the first cluster according to the mesh quadruple includes:

[0015] Report the source port and source IP to the network proxy server, wherein the source port is the port used by the Pod in the first cluster to provide services to the outside world, and the source IP is the IP used by the Pod in the first cluster to provide services to the outside world;

[0016] Receive the target port and target IP provided by the network proxy server, wherein the target port is the port for the Pod in the second cluster to provide services to the outside, and the target IP is the IP for the Pod in the second cluster to provide services to the outside;

[0017] Create and save the mapping relationship between source port and destination port.

[0018] Secondly, another cross-Kubernetes network connectivity method is provided, including:

[0019] Establishing a TCP persistent connection with the network proxy client in the first cluster;

[0020] Receive a list of Service objects and / or Service object change information from a network proxy client;

[0021] Create or update a mirror Service object in the corresponding Namespace of the second cluster according to the Service object list and / or the change information of the Service object, wherein both the Service object and the mirror Service object contain a grid quadruple: source IP, source port, target IP and target port;

[0022] Building a virtual network link for realizing communication between the Pod in the second cluster and the Pod in the first cluster according to the mesh quadruple;

[0023] The communication between the Pod in the second cluster and the Pod in the first cluster is achieved through the virtual network connection.

[0024] In some possible implementations, before establishing a TCP persistent connection with the network proxy client in the first cluster, the method further includes:

[0025] Receive login requests from network proxy clients and perform authentication.

[0026] In some possible implementations, creating or updating a mirrored Service object in a corresponding Namespace of the second cluster according to the Service object list and / or the change information of the Service object includes:

[0027] Traverse the Service object list and / or Service object change information;

[0028] Obtain the ID of the first cluster corresponding to the network proxy server, wherein the ID of the first cluster uniquely corresponds to a Namespace of the second cluster;

[0029] Construct the name of the mirrored Service object corresponding to the Service object according to the name of the Service object in the first cluster and the Namespace where the Service object is located;

[0030] Determine the type of the Service object list and / or the change information of the Service object;

[0031] If the type is new or updated, the mirrored Service object is searched in the corresponding Namespace according to its name. If found, the mirrored Service object is updated. If not found, the corresponding mirrored Service object is created in the corresponding Namespace.

[0032] If the type is delete, the corresponding image Service object will be deleted in the corresponding Namespace.

[0033] Building a virtual network link for realizing communication between the Pod in the second cluster and the Pod in the first cluster according to the mesh quadruple includes:

[0034] Receive a source port and a source IP from a network proxy client, wherein the source port is a port for the Pod in the first cluster to provide services to the outside, and the source IP is an IP for the Pod in the first cluster to provide services to the outside;

[0035] Allocate a target port and a target IP and return them to the network proxy client, wherein the target port is the port for the Pod in the second cluster to provide services to the outside, and the target IP is the IP for the Pod in the second cluster to provide services to the outside;

[0036] Create and save the mapping relationship between source port and destination port.

[0037] Thirdly, a cross-Kubernetes network connectivity system is provided, including:

[0038] A network proxy client disposed in the first cluster, used to implement the method in any one of the implementations of the first aspect above;

[0039] The network proxy server disposed in the second cluster is used to implement the method in any one of the implementations of the second aspect described above.

[0040] In a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable medium stores a program code for execution by a device, wherein the program code includes steps for executing the method in any one of the implementations of the first and second aspects described above.

[0041] In a fifth aspect, an electronic device is provided, comprising a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements a method as in any one of the implementations of the first and second aspects described above.

[0042] The present application has the following beneficial effects: By mirroring the Service objects in one Kubernetes cluster to another Kubernetes cluster and maintaining a network virtual link between the two, the applications in the Kubernetes cluster can connect to the services in another Kubernetes cluster just like connecting to the services within the cluster, which greatly facilitates the development of upper-layer applications and makes it feasible for applications to provide stronger disaster recovery capabilities by deploying across Kubernetes clusters. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application.

[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0045] Figure 1 This is a flowchart of the cross-Kubernetes network connectivity method of Example 1 of the present application;

[0046] Figure 2 It is a structural diagram of three cluster systems including a Manager Kubernetes cluster, a Managed Kubernetes cluster X, and a Managed Kubernetes cluster Y in the prior art;

[0047] Figure 3 It is a structural diagram of three cluster systems, namely, the ManagerKubernetes cluster, the Managed Kubernetes cluster X, and the Managed Kubernetes cluster Y, built according to the cross-Kubernetes network connectivity method of Example 1 of the present application;

[0048] Figure 4 It is a schematic diagram of communication between Pods in the Manager Kubernetes cluster and the Managed Kubernetes cluster X in the cross-Kubernetes network connectivity method of Example 1 of the present application;

[0049] Figure 5 It is a schematic diagram of a virtual network link in the cross-Kubernetes network connectivity method of Example 1 of the present application;

[0050] Figure 6 This is a flowchart of the cross-Kubernetes network connectivity method of Example 2 of the present application;

[0051] Figure 7 This is a structural block diagram of the cross-Kubernetes network connectivity system of Example 3 of the present application;

[0052] Figure 8 It is a schematic diagram of the internal structure of the electronic device of Example 5 of the present application. DETAILED DESCRIPTION

[0053] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0054] Example 1

[0055] A cross-Kubernetes network connectivity method involved in Example 1 of the present application includes: establishing a TCP long connection with a network proxy server in a second cluster; scanning the Service objects in the first cluster and reporting the scanned Service object list to the network proxy server, wherein the Service object contains a grid quadruple: source IP, source port, target IP and target port; monitoring the change information of the Service object in the first cluster, and reporting the change information to the network proxy server; building a virtual network link for realizing communication between Pods in the second cluster and Pods in the first cluster based on the grid quadruple; realizing communication between Pods in the second cluster and Pods in the first cluster through the virtual network connection, and this method enables a Pod to directly access the Pod behind the Service object by accessing the Service object in another Kubernetes cluster, thereby realizing cross-Kubernetes network connectivity. This usage method is very friendly to application development with cross-cluster communication requirements.

[0056] Specifically, Figure 3 As shown in the figure, the Managed cluster (the abbreviation of the Managed Kubernetes cluster, i.e. the first cluster) and the Manager cluster (the abbreviation of the Manager Kubernetes cluster, i.e. the second cluster, including the Manager Kubernetes cluster X and the Manager Kubernetes cluster Y) are used as examples to illustrate that a network proxy server is added to the Manager cluster and a network proxy client is added to the Managed cluster. Figure 1 A flow chart of a cross-Kubernetes network connectivity method using a network proxy client as an execution subject in application embodiment 1 is shown, including:

[0057] S110, obtaining the IP address and login credentials of the network proxy server and initiating a login request;

[0058] Specifically, when the network proxy client starts, it first obtains the network proxy server address and login credentials from the configuration file, and then initiates the login process. The code example is as follows:

[0059]

[0060]

[0061] S120, establishing a TCP persistent connection with the network proxy server in the second cluster, that is, establishing a TCP persistent connection between the network proxy client in the first cluster and the network proxy server in the second cluster;

[0062] Specifically, after a successful login, the network proxy client will maintain a TCP persistent connection with the network proxy server through a heartbeat mechanism. If the persistent connection is disconnected due to factors such as network jitter, the network proxy client will automatically log in again and obtain a TCP persistent connection.

[0063] After receiving the login credentials of the network proxy client, the network proxy server will perform authentication. If the authentication is successful, it will record the Kubernetes cluster ID where the network proxy client is located.

[0064] S130, scanning the Service objects in the first cluster and reporting the scanned Service object list to the network proxy server, wherein the Service object includes a grid quadruple: source IP, source port, target IP and target port;

[0065] Specifically, after the network proxy client is started, it will first scan the existing Service objects in the cluster and report them to the network proxy server.

[0066] S140, monitoring change information of Service objects in the first cluster, and reporting the change information to the network proxy server;

[0067] Specifically, the network proxy client will monitor the changes of all Service objects in the cluster, including creation, update and deletion, and report these changes to the network proxy server in real time when changes are found.

[0068] After receiving the Service object list or changes reported by the network proxy client, the network proxy server will process it according to the following process:

[0069] 1. Traverse all Service object lists or changes

[0070] 2. According to the information recorded when the network proxy client logs in, find the Kubernetes cluster ID corresponding to the Service object. This ID uniquely corresponds to a Namespace in a Manager cluster.

[0071] It should be noted that Namespace is a concept in K8s and is used for resource isolation. A K8s cluster can achieve resource isolation by further creating multiple Namespaces. All resources managed by K8s are abstracted into an object type, and each object belongs to a Namespace. In addition, some object types are shared by the entire cluster and do not belong to a Namespace.

[0072] 3. Find the Service name and Namespace information through the information in the Service object, and use these two pieces of information to build the image Service name;

[0073] 4. If the type of the change information of the Service object is new or updated;

[0074] a. Search the name of the image service built in step 3 in the Namespace obtained in step 2;

[0075] b. If found, update the object; if not found, create a mirror service in the Namespace

[0076] c. If the type of the change information of the Service object is deletion, delete the image Service built in step 3 from the Namespace obtained in step 2.

[0077] It should be noted that the method of using the original Service name and Namespace to construct the mirror Service name is not unique. This application does not limit the specific method, but requires that the method can ensure a one-to-one mapping relationship before and after construction.

[0078] A feasible implementation is: connect the name string of the original Service object and the Namespace string through a short line "-" to form the name of the mirrored Service object. For example, if the name of the original Service object is "hello", and the Namespace is "world", the name of the mirrored Service object constructed based on this implementation is "hello-world".

[0079] The construction code of the mirror Service object is as follows:

[0080]

[0081]

[0082]

[0083]

[0084] The Service object essentially records a series of network quad-tuples, and a network quad-tuple consists of: {source IP, source port, destination IP, destination port}.

[0085] S150: Building a virtual network link for realizing communication between the Pod in the second cluster and the Pod in the first cluster according to the mesh quadruple, specifically comprising the following steps:

[0086] Report the source port and source IP to the network proxy server, wherein the source port is the port used by the Pod in the first cluster to provide services to the outside world, and the source IP is the IP used by the Pod in the first cluster to provide services to the outside world;

[0087] Receive the target port and target IP provided by the network proxy server, wherein the target port is the port for the Pod in the second cluster to provide services to the outside, and the target IP is the IP for the Pod in the second cluster to provide services to the outside;

[0088] Create and save the mapping relationship between source port and destination port.

[0089] like Figure 4 As shown in the figure, taking the MySQL database as an example, the IP and port of the database service provided by PodDB in the Managed-X cluster are 192.168.0.100:3306, and the domain name of the ServiceA object bound to it is a.db.cluster.local. The mapping relationship between port 3306 and target port 3306 is recorded in the ServiceA object.

[0090] When the network proxy client reports the ServiceA object to the network proxy server, the network proxy server will assign a local port to the ServiceA object, that is, port 13306. Then the information will be synchronized to the network proxy client. After receiving it, the network proxy client will record a mapping relationship, that is, the mapping from 13306 to a.db.cluster.local:3006.

[0091] When the network proxy server creates the mirror ServiceA-DB, it modifies the port mapping relationship in the object, that is, changes the port mapping relationship from 3306 to 3306 recorded in the original Service object to 3306 to 13306. And changes the binding relationship with PodDB in the original Service object to the binding relationship with the network proxy server (the network proxy server actually runs in a Pod).

[0092] The domain name of the mirror ServiceA-DB is a-db.managed-x.cluster.local.

[0093] like Figure 5 As shown, after the above process, a virtual network link is built.

[0094] The code for building a virtual network link is as follows:

[0095]

[0096] S160. Realize communication between the Pod in the second cluster and the Pod in the first cluster through the virtual network connection.

[0097] Specifically, when PodApp-A in the Manager cluster needs to connect to the database service PodDB in the Managed-X cluster, the connection steps are as follows:

[0098] 1. Get the Managed-X cluster ID from the metadata repository, and then find the unique corresponding Namespace in the Manager cluster, namely Managed-X.

[0099] 2. Get the Service object name and Namespace corresponding to the database service PodDB from the metadata repository, and construct the mirror object name based on the Service object name and Namespace. The construction method is to connect the name string of the original Service object and the Namespace string through a short line "-" to form the name of the mirror Service object, that is, the mirror object name is ServiceA-DB.

[0100] 3. PodApp-A initiates a connection to ServiceA-DB in Managed-XNamespace.

[0101] In this embodiment, by mirroring the Service object in one Kubernetes cluster to another Kubernetes cluster and maintaining a network virtual link between the two, the applications in the Kubernetes cluster can connect to the services in another Kubernetes cluster just like connecting to the services within the cluster. That is, a Pod can directly access the Pod behind the Service object by accessing the Service object in another Kubernetes cluster, thereby achieving cross-Kubernetes network connectivity, which greatly facilitates the development of upper-level applications and makes it feasible for applications to provide stronger disaster recovery capabilities by deploying across Kubernetes clusters.

[0102] Example 2

[0103] like Figure 3 As shown in the figure, the Managed cluster (the abbreviation of the Managed Kubernetes cluster, i.e., the first cluster) and the Manager cluster (the abbreviation of the Manager Kubernetes cluster, i.e., the second cluster, including the Manager Kubernetes cluster X and the Manager Kubernetes cluster Y) are used as examples to illustrate that a network proxy server is added to the Manager cluster and a network proxy client is added to the Managed cluster. Figure 6 A flow chart of a cross-Kubernetes network connectivity method using a network proxy server as an execution subject in application embodiment 1 is shown, including:

[0104] S210, receiving a login request from a network proxy client and performing authentication;

[0105] Specifically, when the network proxy client starts, it first obtains the network proxy server address and login credentials from the configuration file, and then initiates a login process to the network proxy server. After receiving the login request, the network proxy server performs login authentication processing.

[0106] S220, establishing a TCP long connection with the network proxy client in the first cluster;

[0107] Specifically, after a successful login, the network proxy client will maintain a TCP persistent connection with the network proxy server through a heartbeat mechanism. If the persistent connection is disconnected due to factors such as network jitter, the network proxy client will automatically log in again and obtain a TCP persistent connection.

[0108] After receiving the login credentials of the network proxy client, the network proxy server will perform authentication. If the authentication is successful, it will record the Kubernetes cluster ID where the network proxy client is located.

[0109] S230, receiving a Service object list and / or Service object change information from a network proxy client;

[0110] Specifically, after the network proxy client is started, it will first scan the existing Service objects in the cluster and report them to the network proxy server. The network proxy client will also monitor the changes of all Service objects in the cluster, including new creation, update and deletion. When changes are found, these changes will be reported to the network proxy server in real time.

[0111] S240. Create or update a mirror Service object in the corresponding Namespace of the second cluster according to the Service object list and / or the change information of the Service object, wherein both the Service object and the mirror Service object contain a grid quadruple: source IP, source port, target IP and target port.

[0112] Specifically, after receiving the Service object list or changes reported by the network proxy client, the network proxy server will process it according to the following process:

[0113] 1. Traverse all Service object lists or changes

[0114] 2. According to the information recorded when the network proxy client logs in, find the Kubernetes cluster ID corresponding to the Service object. This ID uniquely corresponds to a Namespace in a Manager cluster.

[0115] It should be noted that Namespace is a concept in K8s and is used for resource isolation. A K8s cluster can achieve resource isolation by further creating multiple Namespaces. All resources managed by K8s are abstracted into an object type, and each object belongs to a Namespace. In addition, some object types are shared by the entire cluster and do not belong to a Namespace.

[0116] 3. Find the Service name and Namespace information through the information in the Service object, and use these two pieces of information to build the image Service name;

[0117] 4. If the type of the change information of the Service object is new or updated;

[0118] a. Search the name of the image service built in step 3 in the Namespace obtained in step 2;

[0119] b. If found, update the object; if not found, create a mirror service in the Namespace

[0120] c. If the type of the change information of the Service object is deletion, delete the image Service built in step 3 from the Namespace obtained in step 2.

[0121] It should be noted that the method of using the original Service name and Namespace to construct the mirror Service name is not unique. This application does not limit the specific method, but requires that the method can ensure a one-to-one mapping relationship before and after construction.

[0122] A feasible implementation is: connect the name string of the original Service object and the Namespace string through a short line "-" to form the name of the mirrored Service object. For example, if the name of the original Service object is "hello", and the Namespace is "world", the name of the mirrored Service object constructed based on this implementation is "hello-world".

[0123] The Service object essentially records a series of network quad-tuples, and a network quad-tuple consists of: {source IP, source port, destination IP, destination port}.

[0124] S250: Building a virtual network link for realizing communication between the Pod in the second cluster and the Pod in the first cluster according to the mesh quadruple, specifically comprising the following steps:

[0125] Report the source port and source IP to the network proxy server, wherein the source port is the port used by the Pod in the first cluster to provide services to the outside world, and the source IP is the IP used by the Pod in the first cluster to provide services to the outside world;

[0126] Receive the target port and target IP provided by the network proxy server, wherein the target port is the port for the Pod in the second cluster to provide services to the outside, and the target IP is the IP for the Pod in the second cluster to provide services to the outside;

[0127] Create and save the mapping relationship between source port and destination port.

[0128] like Figure 4As shown in the figure, taking the MySQL database as an example, the IP and port of the database service provided by PodDB in the Managed-X cluster are 192.168.0.100:3306, and the domain name of the ServiceA object bound to it is a.db.cluster.local. The mapping relationship between port 3306 and target port 3306 is recorded in the ServiceA object.

[0129] When the network proxy client reports the ServiceA object to the network proxy server, the network proxy server will assign a local port to the ServiceA object, that is, port 13306. Then the information will be synchronized to the network proxy client. After receiving it, the network proxy client will record a mapping relationship, that is, the mapping from 13306 to a.db.cluster.local:3006.

[0130] When the network proxy server creates the mirror ServiceA-DB, it modifies the port mapping relationship in the object, that is, changes the port mapping relationship from 3306 to 3306 recorded in the original Service object to 3306 to 13306. And changes the binding relationship with PodDB in the original Service object to the binding relationship with the network proxy server (the network proxy server actually runs in a Pod).

[0131] The domain name of the mirror ServiceA-DB is a-db.managed-x.cluster.local.

[0132] like Figure 5 As shown, after the above process, a virtual network link is built.

[0133] S260. Realize communication between the Pod in the second cluster and the Pod in the first cluster through the virtual network connection.

[0134] Specifically, when PodApp-A in the Manager cluster needs to connect to the database service PodDB in the Managed-X cluster, the connection steps are as follows:

[0135] 1. Get the Managed-X cluster ID from the metadata repository, and then find the unique corresponding Namespace in the Manager cluster, namely Managed-X.

[0136] 2. Get the Service object name and Namespace corresponding to the database service PodDB from the metadata repository, and construct the mirror object name based on the Service object name and Namespace. The construction method is to connect the name string of the original Service object and the Namespace string through a short line "-" to form the name of the mirror Service object, that is, the mirror object name is ServiceA-DB.

[0137] 3. PodApp-A initiates a connection to ServiceA-DB in Managed-XNamespace.

[0138] In this embodiment, by mirroring the Service object in one Kubernetes cluster to another Kubernetes cluster and maintaining a network virtual link between the two, the applications in the Kubernetes cluster can connect to the services in another Kubernetes cluster just like connecting to the services within the cluster. That is, a Pod can directly access the Pod behind the Service object by accessing the Service object in another Kubernetes cluster, thereby achieving cross-Kubernetes network connectivity, which greatly facilitates the development of upper-layer applications and makes it feasible for applications to provide stronger disaster recovery capabilities by deploying across Kubernetes clusters.

[0139] Example 3

[0140] like Figure 7 As shown, a cross-Kubernetes network connectivity system involved in Example 3 of the present application includes:

[0141] A network proxy client disposed in the first cluster, used to implement the method in any one of the implementation modes in Embodiment 1;

[0142] The network proxy server set in the second cluster is used to implement the method in any one of the implementation modes in Example 2.

[0143] It should be noted that for other specific implementation methods of the cross-Kubernetes network connectivity system in this embodiment, reference can be made to the specific implementation methods of the above-mentioned cross-Kubernetes network connectivity method. To avoid redundancy, they will not be repeated here.

[0144] Example 4

[0145] A computer-readable storage medium according to Embodiment 4 of the present application, wherein the computer-readable storage medium stores a program code for execution by a device, wherein the program code includes steps for executing a method in any one of the implementations in Embodiment 1 of the present application;

[0146] Among them, the computer-readable storage medium can be a read-only memory (ROM), a static storage device, a dynamic storage device or a random access memory (RAM); the computer-readable storage medium can store program code, and when the program stored in the computer-readable storage medium is executed by the processor, the processor is used to execute the steps of the method in any one of the implementation methods in Example 1 of the present application.

[0147] Example 5

[0148] like Figure 8 As shown, an electronic device involved in Embodiment 5 of the present application includes a processor, a memory, and a program or instruction stored in the memory and executable on the processor, and when the program or instruction is executed by the processor, a method in any one of the implementations in Embodiment 1 of the present application is implemented;

[0149] Among them, the processor can adopt a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), a graphics processing unit (GPU) or one or more integrated circuits to execute relevant programs to implement the method in any one of the implementation methods in Example 1 of the present application.

[0150] The processor may also be an integrated circuit electronic device with signal processing capability. In the implementation process, each step of the method in any implementation of Embodiment 1 of the present application may be completed by an integrated logic circuit of hardware in the processor or by instructions in software form.

[0151] The above-mentioned processor may also be a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. The methods, steps and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed. The general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed by a hardware decoding processor, or may be executed by a combination of hardware and software modules in the decoding processor. The software module may be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in a memory, and the processor reads the information in the memory, and completes the functions required to be performed by the unit included in the data processing device of the embodiment of the present application in combination with its hardware, or executes the method in any one of the implementation modes in the embodiment 1 of the present application.

[0152] The above are only preferred specific implementations of the present application; however, the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical solution and its improved ideas of the present application within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.

Claims

1. A cross-Kubernetes network connectivity method, It is characterized in that include: Establish a TCP persistent connection with the network proxy server in the second cluster; Scanning the Service objects in the first cluster and reporting the scanned Service object list to the network proxy server, wherein the Service object includes a grid quadruple: source IP, source port, target IP and target port; Monitor the change information of the Service object in the first cluster, and report the change information to the network proxy server; Building a virtual network link for realizing communication between the Pod in the second cluster and the Pod in the first cluster according to the mesh quadruple; The communication between the Pod in the second cluster and the Pod in the first cluster is achieved through the virtual network connection.

2. The cross-Kubernetes network connectivity method according to claim 1, It is characterized in that Before establishing a TCP persistent connection with the network proxy server in the second cluster, the method further includes: obtaining an IP address and a login credential of the network proxy server and initiating a login request.

3. The cross-Kubernetes network connectivity method according to claim 1, It is characterized in that Building a virtual network link for realizing communication between the Pod in the second cluster and the Pod in the first cluster according to the mesh quadruple includes: Report the source port and source IP to the network proxy server, wherein the source port is the port used by the Pod in the first cluster to provide services to the outside world, and the source IP is the IP used by the Pod in the first cluster to provide services to the outside world; Receive the target port and target IP provided by the network proxy server, wherein the target port is the port for the Pod in the second cluster to provide services to the outside, and the target IP is the IP for the Pod in the second cluster to provide services to the outside; Create and save the mapping relationship between source port and destination port.

4. A cross-Kubernetes network connectivity method, It is characterized in that include: Establishing a TCP persistent connection with the network proxy client in the first cluster; Receive a list of Service objects and / or Service object change information from a network proxy client; Create or update a mirror Service object in the corresponding Namespace of the second cluster according to the Service object list and / or the change information of the Service object, wherein both the Service object and the mirror Service object contain a grid quadruple: source IP, source port, target IP and target port; Building a virtual network link for realizing communication between the Pod in the second cluster and the Pod in the first cluster according to the mesh quadruple; The communication between the Pod in the second cluster and the Pod in the first cluster is achieved through the virtual network connection.

5. The cross-Kubernetes network connectivity method according to claim 4, It is characterized in that Before establishing a TCP long connection with the network proxy client in the first cluster, the method further includes: receiving a login request from the network proxy client and performing authentication.

6. The cross-Kubernetes network connectivity method according to claim 5, It is characterized in that Creating or updating a mirrored Service object in a corresponding Namespace of the second cluster according to the Service object list and / or the change information of the Service object includes: Traverse the Service object list and / or Service object change information; Obtain the ID of the first cluster corresponding to the network proxy server, wherein the ID of the first cluster uniquely corresponds to a Namespace of the second cluster; Construct the name of the mirrored Service object corresponding to the Service object according to the name of the Service object in the first cluster and the Namespace where the Service object is located; Determine the type of the Service object list and / or the change information of the Service object; If the type is new or updated, the mirrored Service object is searched in the corresponding Namespace according to its name. If found, the mirrored Service object is updated. If not found, the corresponding mirrored Service object is created in the corresponding Namespace. If the type is delete, the corresponding image Service object will be deleted in the corresponding Namespace.

7. The cross-Kubernetes network connectivity method according to claim 4, It is characterized in that Building a virtual network link for realizing communication between the Pod in the second cluster and the Pod in the first cluster according to the mesh quadruple includes: Receive a source port and a source IP from a network proxy client, wherein the source port is a port for the Pod in the first cluster to provide services to the outside, and the source IP is an IP for the Pod in the first cluster to provide services to the outside; Allocate a target port and a target IP and return them to the network proxy client, wherein the target port is the port for the Pod in the second cluster to provide services to the outside, and the target IP is the IP for the Pod in the second cluster to provide services to the outside; Create and save the mapping relationship between source port and destination port.

8. A cross-Kubernetes network connectivity system, It is characterized in that include: A network proxy client disposed in the first cluster, for implementing the method according to any one of claims 1 to 3; The network proxy server is arranged in the second cluster, and is used to implement the method described in any one of claims 4-7.

9. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a program code for execution by a device, wherein the program code includes steps for executing the method according to any one of claims 1 to 7.

10. An electronic device, It is characterized in that The electronic device comprises a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction implements the method as claimed in any one of claims 1 to 7 when executed by the processor.