Multi-cluster architecture, multi-cluster communication method and device, equipment and medium
Through cluster gateway resolution and registry assistance in multi-cluster architecture, automatic routing and forwarding of cross-cluster communication is achieved, solving the problems of inconvenient change of service address and insufficient security in cross-cluster communication, and improving efficiency and security.
Patent Information
- Application Number
- CN202510467790.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-14
- Publication Date
- 2025-08-08
AI Technical Summary
In the prior art, service address changes in cross-cluster communications are inconvenient and insufficient security, making it impossible to achieve efficient and secure cross-domain service calls.
Using a multi-cluster architecture, it analyzes cross-cluster call requests through the cluster gateway, querys or obtains the target cluster gateway address from the registry center, and realizes cross-cluster communication.
It realizes that cross-cluster requests do not need to know the peer service address, and automatically obtain routing information for forwarding, with a fault tolerance mechanism, which improves cross-cluster call efficiency and security.
Smart Images

Figure CN120455363A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of multi-cluster communication, and in particular to a multi-cluster architecture, a multi-cluster communication method, a multi-cluster communication device, an electronic device, and a computer-readable storage medium. Background Art
[0002] With the advancement of container cluster technology, the concept and application of container clusters are becoming increasingly widespread. Currently, the most common business application deployment model used by enterprises is to run different business services in different container clusters. This requires secure and reliable service communication between clusters to ensure system continuity and consistency.
[0003] To achieve high availability and disaster recovery, business services often need to be deployed across data centers or cloud platforms, which urgently requires a cross-domain communication mechanism. For the same application, its microservices may be deployed in different container environments, requiring cross-platform service discovery and communication.
[0004] Furthermore, with the development of 5G and edge computing, business service deployment is trending towards greater distribution. This requires cross-domain container cluster communication between the network edge and core data centers. This requires abstracting the underlying network technology details and providing consistent communication abstractions and APIs (Application Programming Interfaces).
[0005] In related technologies, cross-cluster calls can be implemented by configuring a fixed call path. Specifically, configuring a fixed call path involves exposing the service on the server network by exposing the port and implementing calls by configuring a fixed service address. This approach is not conducive to service address changes and undermines service security protection. Summary of the Invention
[0006] In view of the above problems, a multi-cluster architecture, a multi-cluster communication method, a multi-cluster communication device, an electronic device, and a computer-readable storage medium are proposed to overcome the above problems or at least partially solve the above problems, including:
[0007] A multi-cluster communication method is applied to a multi-cluster architecture, the multi-cluster architecture comprising at least two clusters and a registration center, each cluster comprising a cluster gateway and at least one node corresponding to different services; the at least two clusters including a first cluster, the registration center storing cluster gateway addresses corresponding to each service, the method comprising:
[0008] When receiving the cross-cluster call request, the first cluster gateway of the first cluster parses the cross-cluster call request to determine a target service name corresponding to the cross-cluster call request;
[0009] According to the target service name, query the target cluster gateway address corresponding to the target service targeted by the cross-cluster call request;
[0010] If the target cluster gateway address corresponding to the target service is not queried, the target cluster gateway address corresponding to the target service is obtained from the registration center, and based on the target cluster gateway address, an access request is sent to the second cluster corresponding to the target cluster gateway address; the second cluster gateway of the second cluster determines the target address of the target node corresponding to the target service based on the access request, and forwards the access request to the target node.
[0011] Optionally, the method further includes:
[0012] Obtaining first node information corresponding to each node in the first cluster and first gateway information of the first cluster gateway;
[0013] Report the first node information and the first gateway information to the registration center.
[0014] Optionally, the registration center is used to perform incremental storage in a first local database based on the first node information and the first gateway information.
[0015] Optionally, obtaining the target cluster gateway address corresponding to the target service from the registration center includes:
[0016] Sending a routing request including the target service name to the registration center; the registration center is configured to query the target cluster gateway address corresponding to the target service based on the target service name in response to the routing request;
[0017] Receive the target cluster gateway address returned by the registration center.
[0018] Optionally, when the target cluster gateway address corresponding to the target service is not found in the first local database, the registration center is configured to perform cluster gateway addressing broadcast for the target service to the at least two clusters, and receive the target cluster gateway address for the target service reported by a cluster.
[0019] Optionally, the method further includes:
[0020] Upon receiving a successful access result for the access request, generating first routing information according to the target service, the target service name, and the target cluster gateway address;
[0021] The second local database is updated according to the first routing information.
[0022] An embodiment of the present invention further provides a multi-cluster architecture, comprising at least two clusters and a registration center, each cluster comprising a cluster gateway and at least one node corresponding to different services; the at least two clusters including a first cluster, the registration center storing cluster gateway addresses corresponding to each service;
[0023] The first cluster is used to execute the method described above;
[0024] The registration center is configured to determine the target cluster gateway address corresponding to the target service and return the target cluster gateway address to the first cluster if the first cluster fails to query the target cluster gateway address corresponding to the target service.
[0025] Optionally, the first cluster includes a first cluster gateway, and the first cluster gateway includes a first forwarding module and a first routing module;
[0026] The first forwarding module is configured to receive the cross-cluster call request, parse the cross-cluster call request to obtain a target service name, and send the target service name to the first routing module;
[0027] The first routing module is used to query the target cluster gateway address corresponding to the target service targeted by the cross-cluster call request based on the target service name; if the target cluster gateway address corresponding to the target service is not queried, obtain the target cluster gateway address corresponding to the target service from the registration center, and send an access request to the second cluster corresponding to the target cluster gateway address based on the target cluster gateway address.
[0028] Optionally, the first cluster gateway is deployed in the first cluster in a plug-in manner.
[0029] An embodiment of the present invention further provides a multi-cluster communication device, which is applied to a multi-cluster architecture. The multi-cluster architecture includes at least two clusters and a registration center, each cluster includes a cluster gateway and at least one node corresponding to different services; the at least two clusters include a first cluster, the registration center stores the cluster gateway address corresponding to each service, and the device includes:
[0030] a parsing module, configured for the first cluster gateway of the first cluster to parse the cross-cluster call request upon receiving the cross-cluster call request, and determine a target service name corresponding to the cross-cluster call request;
[0031] A query module, configured to query a target cluster gateway address corresponding to the target service targeted by the cross-cluster call request according to the target service name;
[0032] An access module is used to obtain the target cluster gateway address corresponding to the target service from the registration center if the target cluster gateway address corresponding to the target service is not queried, and send an access request to the second cluster corresponding to the target cluster gateway address based on the target cluster gateway address; the second cluster gateway of the second cluster determines the target address of the target node corresponding to the target service based on the access request, and forwards the access request to the target node.
[0033] Optionally, the device further comprises:
[0034] The registration module is configured to obtain first node information corresponding to each node in the first cluster and first gateway information of the first cluster gateway; and report the first node information and the first gateway information to the registration center.
[0035] Optionally, the registration center is used to perform incremental storage in a first local database based on the first node information and the first gateway information.
[0036] Optionally, the access module is used to send a routing request containing the target service name to the registration center; the registration center is used to respond to the routing request and query the target cluster gateway address corresponding to the target service based on the target service name; and receive the target cluster gateway address returned by the registration center.
[0037] Optionally, when the target cluster gateway address corresponding to the target service is not found in the first local database, the registration center is configured to perform cluster gateway addressing broadcast for the target service to the at least two clusters, and receive the target cluster gateway address for the target service reported by a cluster.
[0038] Optionally, the device further comprises:
[0039] The update module is used to generate first routing information according to the target service, target service name and target cluster gateway address when receiving a successful access result for the access request; and update the second local database according to the first routing information.
[0040] An embodiment of the present invention further provides an electronic device, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program implements the above multi-cluster communication method when executed by the processor.
[0041] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the multi-cluster communication method described above is implemented.
[0042] The embodiments of the present invention have the following advantages:
[0043] In an embodiment of the present invention, when the first cluster gateway of the first cluster receives a cross-cluster call request, it parses the cross-cluster call request and determines the target service name corresponding to the cross-cluster call request; based on the target service name, it queries the target cluster gateway address corresponding to the target service targeted by the cross-cluster call request; if the target cluster gateway address corresponding to the target service is not queried, it obtains the target cluster gateway address corresponding to the target service from the registration center, and based on the target cluster gateway address, it sends an access request to the second cluster corresponding to the target cluster gateway address; the second cluster gateway of the second cluster determines the target address of the target node corresponding to the target service based on the access request, and forwards the access request to the target node. Through the embodiment of the present invention, when making a cross-cluster request, there is no need to know the business service address of the other end, only the service name needs to be known, and the cluster gateway will automatically obtain the routing information and forward the request to the corresponding node, thereby realizing container-unaware cross-cluster calls.
[0044] And when the original path cannot be called, the cluster gateway will obtain the corresponding cluster gateway address from the registration center to forward the request, so that cross-cluster service calls have a fault-tolerant mechanism. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the technical solution of the present invention, the following briefly introduces the drawings required for use in the description of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0046] Figure 1a This is a flowchart of the steps of a multi-cluster communication method according to an embodiment of the present invention;
[0047] Figure 1b This is a schematic diagram of a multi-cluster architecture according to an embodiment of the present invention;
[0048] Figure 2 is a flowchart of another multi-cluster communication method according to an embodiment of the present invention;
[0049] Figure 3 This is a flowchart of another multi-cluster communication method according to an embodiment of the present invention;
[0050] Figure 4is a flowchart of the steps of another multi-cluster communication method according to an embodiment of the present invention;
[0051] Figure 5a is a flowchart of the steps of a communication method according to an embodiment of the present invention;
[0052] Figure 5b This is a flowchart of the steps of updating a registration center according to an embodiment of the present invention;
[0053] Figure 5c This is a flowchart of the steps of a cluster local update according to an embodiment of the present invention;
[0054] Figure 5d is a flowchart of another communication method according to an embodiment of the present invention;
[0055] Figure 6 It is a structural diagram of a multi-cluster communication device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0056] To make the above-mentioned objects, features, and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the embodiments described are only a portion of the embodiments of the present invention, not all of them. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without inventive effort are also within the scope of protection of the present invention.
[0057] Reference Figure 1a , shows a flowchart of a multi-cluster communication method according to an embodiment of the present invention, which may include the following steps:
[0058] Step 101: When receiving a cross-cluster call request, a first cluster gateway of a first cluster parses the cross-cluster call request and determines a target service name corresponding to the cross-cluster call request.
[0059] In an embodiment of the present invention, the above method can be applied to a multi-cluster architecture, such as Figure 1b As shown, the multi-cluster architecture 10 may include at least two clusters 11 and a registration center 12, each cluster including a cluster gateway 13 and at least one node 14 corresponding to different services; the at least two clusters include a first cluster, and the registration center 12 stores the cluster gateway address corresponding to each service.
[0060] In actual applications, cross-cluster calls can be implemented by injecting proxy containers. Specifically, the proxy container is injected into the service Pod in advance to intercept the registration request, and the proxy container changes the original registration information to the target registration information of the Internet Protocol address and sends it to the registration center, and implements cross-cluster calls through the server's own network. This proxy container injection method will invade the business container, affect the operation of the business container, and greatly waste container and server resources.
[0061] To address this issue, the first cluster gateway in the embodiment of the present invention can be deployed as a plug-in within the first cluster. This plug-in first cluster gateway can be ported to other clusters for reuse without modification, without intruding on service containers, and reduces server resource waste compared to injecting proxy containers into containers. Furthermore, plug-in deployment has no special requirements for the container cluster environment; as long as the network is connected, all clusters registered with the unified registration center can achieve cross-cluster communication.
[0062] In an embodiment of the present invention, a multi-cluster architecture may be registered by at least two clusters and a registration center; wherein the at least two clusters may be used to provide different services, and the registration center may be used to store cluster gateway addresses of cluster gateways corresponding to each service.
[0063] Each cluster may include a cluster gateway and at least one node POD providing different services; the at least two clusters may include a first cluster that currently issues a request, and the cluster gateway in the first cluster may be referred to as a first cluster gateway.
[0064] In actual applications, when receiving a cross-cluster call request, the first cluster gateway of the first cluster may first parse the cross-cluster call request to determine the target service name of the service to be called corresponding to the cross-cluster call request.
[0065] Step 102: According to the target service name, query the target cluster gateway address corresponding to the target service targeted by the cross-cluster call request.
[0066] After determining the target service name, the first cluster gateway may first perform a local self-check; specifically, the first cluster gateway may first query locally based on the target service name whether there is a target cluster gateway address corresponding to the target service targeted by the cross-cluster call request.
[0067] Step 103: If the target cluster gateway address corresponding to the target service is not found, obtain the target cluster gateway address corresponding to the target service from the registration center, and send an access request to the second cluster corresponding to the target cluster gateway address based on the target cluster gateway address; the second cluster gateway of the second cluster determines the target address of the target node corresponding to the target service based on the access request, and forwards the access request to the target node.
[0068] If the first cluster gateway locally queries the target cluster gateway address corresponding to the target service targeted by the cross-cluster call request, the first cluster gateway may directly forward the access request based on the target cluster gateway address.
[0069] On the contrary, if the first cluster gateway fails to locally query the target cluster gateway address corresponding to the target service targeted by the cross-cluster call request, it may obtain the target cluster gateway address corresponding to the target service from the registration center.
[0070] Specifically, the first cluster gateway may make a request to the registration center. In response to the request, the registration center may query the cluster gateway addresses corresponding to each service stored locally and return the target cluster gateway address to the first cluster gateway.
[0071] After obtaining the target cluster gateway address, the first cluster gateway can forward the access request based on the target cluster gateway address. Specifically, if the target cluster gateway address corresponds to the cluster gateway of the second cluster, the first cluster gateway can send the access request to the second cluster corresponding to the target cluster gateway address based on the target cluster gateway address, thereby cross-domain invoking the services of the second cluster.
[0072] After receiving the access request, the second cluster gateway of the second cluster can rely on the K8S internal DNS call to determine the target address of the target node corresponding to the target service, and forward the access request to the corresponding target node based on the target address. After receiving the access request, the target node can provide the corresponding target service to the first cluster.
[0073] Exemplarily, the first cluster includes a first cluster gateway, and the first cluster gateway includes a first forwarding module and a first routing module;
[0074] The first forwarding module is configured to receive the cross-cluster call request, parse the cross-cluster call request to obtain a target service name, and send the target service name to the first routing module;
[0075] The first routing module is used to query the target cluster gateway address corresponding to the target service targeted by the cross-cluster call request based on the target service name; if the target cluster gateway address corresponding to the target service is not queried, obtain the target cluster gateway address corresponding to the target service from the registration center, and send an access request to the second cluster corresponding to the target cluster gateway address based on the target cluster gateway address.
[0076] In an embodiment of the present invention, when the first cluster gateway of the first cluster receives a cross-cluster call request, it parses the cross-cluster call request and determines the target service name corresponding to the cross-cluster call request; based on the target service name, it queries the target cluster gateway address corresponding to the target service targeted by the cross-cluster call request; if the target cluster gateway address corresponding to the target service is not queried, it obtains the target cluster gateway address corresponding to the target service from the registration center, and based on the target cluster gateway address, it sends an access request to the second cluster corresponding to the target cluster gateway address; the second cluster gateway of the second cluster determines the target address of the target node corresponding to the target service based on the access request, and forwards the access request to the target node. Through the embodiment of the present invention, when making a cross-cluster request, there is no need to know the business service address of the other end, only the service name needs to be known, and the cluster gateway will automatically obtain the routing information and forward the request to the corresponding node, thereby realizing container-unaware cross-cluster calls.
[0077] And when the original path cannot be called, the cluster gateway will obtain the corresponding cluster gateway address from the registration center to forward the request, so that cross-cluster service calls have a fault-tolerant mechanism.
[0078] Reference Figure 2 , shows a flowchart of another multi-cluster communication method according to an embodiment of the present invention, which may include the following steps:
[0079] Step 201: When receiving a cross-cluster call request, the first cluster gateway of the first cluster parses the cross-cluster call request and determines a target service name corresponding to the cross-cluster call request.
[0080] When receiving the cross-cluster call request, the first cluster gateway of the first cluster may first parse the cross-cluster call request to determine the target service name of the service to be called corresponding to the cross-cluster call request.
[0081] Step 202: According to the target service name, query the target cluster gateway address corresponding to the target service targeted by the cross-cluster call request.
[0082] After determining the target service name, the first cluster gateway may first perform a local self-check; specifically, the first cluster gateway may first query locally based on the target service name whether there is a target cluster gateway address corresponding to the target service targeted by the cross-cluster call request.
[0083] Step 203: If the target cluster gateway address corresponding to the target service is not found, a routing request including the target service name is sent to the registration center; the registration center is configured to query the target cluster gateway address corresponding to the target service based on the target service name in response to the routing request.
[0084] In some feasible embodiments, if the first cluster gateway locally queries a target cluster gateway address corresponding to the target service targeted by the cross-cluster call request, the first cluster gateway may directly forward the access request based on the target cluster gateway address.
[0085] On the contrary, if the first cluster gateway fails to locally query the target cluster gateway address corresponding to the target service targeted by the cross-cluster call request, it may obtain the target cluster gateway address corresponding to the target service from the registration center.
[0086] Specifically, the first cluster gateway may send a routing request including the target service name to the registration center.
[0087] After receiving the routing request, the registration center can perform a local query based on the target service name in the routing request to determine the target cluster gateway address corresponding to the cluster corresponding to the target service.
[0088] Step 204: Receive the target cluster gateway address returned by the registration center.
[0089] After determining the target cluster gateway address, the registration center may return the target cluster gateway address to the first cluster gateway.
[0090] Step 205: According to the target cluster gateway address, an access request is sent to the second cluster corresponding to the target cluster gateway address.
[0091] After obtaining the target cluster gateway address, the first cluster gateway can forward the access request based on the target cluster gateway address. Specifically, if the target cluster gateway address corresponds to the cluster gateway of the second cluster, the first cluster gateway can send the access request to the second cluster corresponding to the target cluster gateway address based on the target cluster gateway address, thereby cross-domain invoking the services of the second cluster.
[0092] After receiving the access request, the second cluster gateway of the second cluster can rely on the K8S internal DNS call to determine the target address of the target node corresponding to the target service, and forward the access request to the corresponding target node based on the target address. After receiving the access request, the target node can provide the corresponding target service to the first cluster.
[0093] In an embodiment of the present invention, when the first cluster gateway of the first cluster receives a cross-cluster call request, it parses the cross-cluster call request and determines the target service name corresponding to the cross-cluster call request; based on the target service name, it queries the target cluster gateway address corresponding to the target service targeted by the cross-cluster call request; if the target cluster gateway address corresponding to the target service is not queried, it sends a routing request containing the target service name to the registration center; the registration center is used to respond to the routing request, query the target cluster gateway address corresponding to the target service based on the target service name; receive the target cluster gateway address returned by the registration center; and based on the target cluster gateway address, send an access request to the second cluster corresponding to the target cluster gateway address.
[0094] Through the embodiments of the present invention, when making cross-cluster requests, there is no need to know the business service address of the other end, only the service name needs to be known. The cluster gateway will automatically obtain routing information and forward the request to the corresponding node, realizing container-unaware cross-cluster calls.
[0095] And when the original path cannot be called, the cluster gateway will obtain the corresponding cluster gateway address from the registration center to forward the request, so that cross-cluster service calls have a fault-tolerant mechanism.
[0096] Reference Figure 3 , shows a flowchart of another multi-cluster communication method according to an embodiment of the present invention, which may include the following steps:
[0097] Step 301: Obtain first node information corresponding to each node in a first cluster and first gateway information of a first cluster gateway.
[0098] In some feasible embodiments, the first cluster gateway may be provided with a heartbeat program to report information to the registration center; specifically, after the first cluster gateway is started, the self-circulating heartbeat program may be started.
[0099] After the heartbeat program is started, the first cluster gateway can obtain the first node information corresponding to each node in the first cluster and the first gateway information of the first cluster gateway.
[0100] For example, the first cluster gateway can obtain service information for all services deployed in the container cluster, namely, the first node information corresponding to each node, based on the container cluster's DNS service (or by directly querying the service list). The service information can include an SVC list, which can contain service names and namespaces. Namespaces are a mechanism used in Kubernetes to organize and isolate cluster resources, similar to directories or folders in an operating system, dividing a cluster into multiple virtual subclusters.
[0101] In addition, the first cluster gateway can also obtain information about its own gateway, that is, first gateway information, such as IP:PORT. The first node information and the first cluster gateway information can be used for other cluster call services.
[0102] Step 302: Report the first node information and the first gateway information to the registration center.
[0103] After obtaining the latest first node information and first gateway information, the first cluster gateway may combine this information into structured data and report it to the registration center.
[0104] In one embodiment of the present invention, the registration center is configured to perform incremental storage in the first local database based on the first node information and the first gateway information.
[0105] After obtaining the first node information and the first gateway information, the registration center may store the information locally and set the cluster corresponding to the first cluster gateway and the corresponding services to be available.
[0106] Specifically, the registration center may perform incremental storage in a first local database deployed in the registration center based on the first node information and the first gateway information.
[0107] For example, the registration center can parse the SVC list reported by the heartbeat into a List, compare it with the originally stored SVC list belonging to the cluster, supplement the newly added SVCs, delete the reduced ones, compare the keywords with the SVC names, and compare whether the IP:PORT of the cluster gateway has changed. If there is a change, refresh the original cluster gateway address.
[0108] Step 303: When receiving the cross-cluster call request, the first cluster gateway of the first cluster parses the cross-cluster call request and determines the target service name corresponding to the cross-cluster call request.
[0109] When receiving the cross-cluster call request, the first cluster gateway of the first cluster may first parse the cross-cluster call request to determine the target service name of the service to be called corresponding to the cross-cluster call request.
[0110] Step 304: According to the target service name, query the target cluster gateway address corresponding to the target service targeted by the cross-cluster call request.
[0111] After determining the target service name, the first cluster gateway may first perform a local self-check; specifically, the first cluster gateway may first query locally based on the target service name whether there is a target cluster gateway address corresponding to the target service targeted by the cross-cluster call request.
[0112] Step 305: If the target cluster gateway address corresponding to the target service is not found, a routing request including the target service name is sent to the registration center.
[0113] In some feasible embodiments, if the first cluster gateway locally queries a target cluster gateway address corresponding to the target service targeted by the cross-cluster call request, the first cluster gateway may directly forward the access request based on the target cluster gateway address.
[0114] On the contrary, if the first cluster gateway fails to locally query the target cluster gateway address corresponding to the target service targeted by the cross-cluster call request, it may obtain the target cluster gateway address corresponding to the target service from the registration center.
[0115] Specifically, the first cluster gateway may send a routing request including the target service name to the registration center.
[0116] After receiving the routing request, the registration center can perform a local query based on the target service name in the routing request to determine the target cluster gateway address corresponding to the cluster corresponding to the target service.
[0117] In one embodiment of the present invention, the registration center is used to broadcast the cluster gateway address for the target service to at least two clusters when the target cluster gateway address corresponding to the target service is not queried in the first local database, and receive the target cluster gateway address for the target service reported by a cluster.
[0118] In some feasible embodiments, the registration center may be used to obtain new cluster gateway addresses for all clusters when the target cluster gateway address corresponding to the target service is not found in the first local database.
[0119] Specifically, when the target cluster gateway address corresponding to the target service is not found in the first local database, the registration center may broadcast the cluster gateway address of the target service to at least two clusters. In response to the broadcast, each cluster may determine whether it corresponds to the target service. If so, it may report the target cluster gateway address for the target service to the registration center.
[0120] After obtaining the target cluster gateway address, the registration center may update the first local database and return the target cluster gateway address to the first cluster gateway.
[0121] Step 306: Receive the target cluster gateway address returned by the registration center.
[0122] After the registration center determines the target cluster gateway address, the first cluster gateway may receive the target cluster gateway address for the target service returned by the registration center.
[0123] Step 307: According to the target cluster gateway address, an access request is sent to the second cluster corresponding to the target cluster gateway address.
[0124] After obtaining the target cluster gateway address, the first cluster gateway can forward the access request based on the target cluster gateway address. Specifically, if the target cluster gateway address corresponds to the cluster gateway of the second cluster, the first cluster gateway can send the access request to the second cluster corresponding to the target cluster gateway address based on the target cluster gateway address, thereby cross-domain invoking the services of the second cluster.
[0125] After receiving the access request, the second cluster gateway of the second cluster can rely on the K8S internal DNS call to determine the target address of the target node corresponding to the target service, and forward the access request to the corresponding target node based on the target address. After receiving the access request, the target node can provide the corresponding target service to the first cluster.
[0126] In an embodiment of the present invention, first node information corresponding to each node in the first cluster and first gateway information of the first cluster gateway are obtained; the first node information and the first gateway information are reported to the registration center; when the first cluster gateway of the first cluster receives a cross-cluster call request, the cross-cluster call request is parsed to determine the target service name corresponding to the cross-cluster call request; according to the target service name, the target cluster gateway address corresponding to the target service targeted by the cross-cluster call request is queried; if the target cluster gateway address corresponding to the target service is not queried, a routing request containing the target service name is sent to the registration center; the target cluster gateway address returned by the registration center is received; according to the target cluster gateway address, an access request is sent to the second cluster corresponding to the target cluster gateway address.
[0127] Through the embodiments of the present invention, when making cross-cluster requests, there is no need to know the business service address of the other end, only the service name needs to be known. The cluster gateway will automatically obtain routing information and forward the request to the corresponding node, realizing container-unaware cross-cluster calls.
[0128] And when the original path cannot be called, the cluster gateway will obtain the corresponding cluster gateway address from the registration center to forward the request, so that cross-cluster service calls have a fault-tolerant mechanism.
[0129] Reference Figure 4 , shows a flowchart of steps of another multi-cluster communication method according to an embodiment of the present invention, which may include the following steps:
[0130] Step 401: Obtain first node information corresponding to each node in a first cluster and first gateway information of a first cluster gateway.
[0131] In some feasible embodiments, the first cluster gateway may be provided with a heartbeat program to report information to the registration center; specifically, after the first cluster gateway is started, the self-circulating heartbeat program may be started.
[0132] After the heartbeat program is started, the first cluster gateway can obtain the first node information corresponding to each node in the first cluster and the first gateway information of the first cluster gateway.
[0133] Step 402: Report the first node information and the first gateway information to the registration center.
[0134] After obtaining the latest first node information and first gateway information, the first cluster gateway may combine this information into structured data and report it to the registration center.
[0135] In one embodiment of the present invention, the registration center is configured to perform incremental storage in the first local database based on the first node information and the first gateway information.
[0136] After obtaining the first node information and the first gateway information, the registration center may store the information locally and set the cluster corresponding to the first cluster gateway and the corresponding services to be available.
[0137] Specifically, the registration center may perform incremental storage in a first local database deployed in the registration center based on the first node information and the first gateway information.
[0138] Step 403: When receiving the cross-cluster call request, the first cluster gateway of the first cluster parses the cross-cluster call request and determines the target service name corresponding to the cross-cluster call request.
[0139] When receiving the cross-cluster call request, the first cluster gateway of the first cluster may first parse the cross-cluster call request to determine the target service name of the service to be called corresponding to the cross-cluster call request.
[0140] Step 404: According to the target service name, query the target cluster gateway address corresponding to the target service targeted by the cross-cluster call request.
[0141] After determining the target service name, the first cluster gateway may first perform a local self-check; specifically, the first cluster gateway may first query locally based on the target service name whether there is a target cluster gateway address corresponding to the target service targeted by the cross-cluster call request.
[0142] Step 405: If the target cluster gateway address corresponding to the target service is not found, a routing request including the target service name is sent to the registration center.
[0143] In some feasible embodiments, if the first cluster gateway locally queries a target cluster gateway address corresponding to the target service targeted by the cross-cluster call request, the first cluster gateway may directly forward the access request based on the target cluster gateway address.
[0144] On the contrary, if the first cluster gateway fails to locally query the target cluster gateway address corresponding to the target service targeted by the cross-cluster call request, it may obtain the target cluster gateway address corresponding to the target service from the registration center.
[0145] Specifically, the first cluster gateway may send a routing request including the target service name to the registration center.
[0146] After receiving the routing request, the registration center can perform a local query based on the target service name in the routing request to determine the target cluster gateway address corresponding to the cluster corresponding to the target service.
[0147] Step 406: Receive the target cluster gateway address returned by the registration center.
[0148] After the registration center determines the target cluster gateway address, the first cluster gateway may receive the target cluster gateway address for the target service returned by the registration center.
[0149] Step 407: According to the target cluster gateway address, an access request is sent to the second cluster corresponding to the target cluster gateway address.
[0150] After obtaining the target cluster gateway address, the first cluster gateway can forward the access request based on the target cluster gateway address. Specifically, if the target cluster gateway address corresponds to the cluster gateway of the second cluster, the first cluster gateway can send the access request to the second cluster corresponding to the target cluster gateway address based on the target cluster gateway address, thereby cross-domain invoking the services of the second cluster.
[0151] After receiving the access request, the second cluster gateway of the second cluster can rely on the K8S internal DNS call to determine the target address of the target node corresponding to the target service, and forward the access request to the corresponding target node based on the target address. After receiving the access request, the target node can provide the corresponding target service to the first cluster.
[0152] Step 408: When a successful access result for the access request is received, first routing information is generated according to the target service, the target service name, and the target cluster gateway address.
[0153] In some feasible embodiments, if the target service completes the call, that is, the first cluster gateway receives a successful access result for the access request, the first cluster gateway may generate first routing information according to the target service, the target service name, and the target cluster gateway address.
[0154] Step 409: Update the second local database according to the first routing information.
[0155] The first cluster gateway can then update the second local database based on the first routing information, so that the next time a service call is made, the cluster gateway address corresponding to the service can be queried based on the updated second local database. In this embodiment of the present invention, the cluster gateway has a routing self-learning mechanism. A successful cross-cluster call will send the routing information to the cluster gateway for update or new routing information to adapt to the next cross-cluster call.
[0156] For example, Figure 5a As shown, the cluster gateway is deployed in the cluster (first cluster, second cluster) in plug-in mode. The cluster gateway periodically reports heartbeats to the registration center, carrying local cluster routing information.
[0157] Cross-cluster call requests are first parsed by the forwarding module of the cluster gateway. The forwarding module finds the target cluster gateway address of the peer cluster through the routing module and forwards the request to the routing module.
[0158] The routing module will first retrieve the target cluster gateway address based on the local routing table. If the retrieval fails, the routing module will forward the request to the registration center.
[0159] After receiving the request, the registration center will search for the target cluster gateway address from the information reported by each gateway in the original storage. If the retrieval fails, the registration center will broadcast an addressing request to all reported cluster gateway addresses. The cluster gateway that returns normal is the target cluster.
[0160] The forwarding module can be used to call the service, and node PODs can be deployed under the service (for example, POD1, POD2, and POD3 are deployed under service1; POD4 and POD5 are deployed under service2).
[0161] After the cross-cluster request is successful, the routing module of the cluster gateway will perform self-learning; specifically, the routing module will combine the destination service information of the request (the service name and its namespace, so that the cluster can directly configure the service name to call it when making cross-cluster calls) and the target container cluster information (the gateway address deployed in the target container cluster: IP+PORT. When the cluster service calls the target cluster across clusters, the cluster gateway will forward the request to the target cluster gateway based on the routing table and then request the target service through the DNS of the target cluster K8S) into identifiable routing information and store it in the routing table for subsequent calls.
[0162] like Figure 5b As shown in the figure, after the cluster gateway is started, the self-circulating heartbeat program is started.
[0163] After the heartbeat program starts, the routing module obtains information about all services deployed in the cluster (for example, the SVC list, including service names and namespaces) based on the cluster's DNS service (or directly queries the service list).
[0164] The cluster gateway combines the service information obtained by the routing module with the gateway's own related information into structured data and reports it to the registration center.
[0165] The registration center stores the cluster gateway information that reports the heartbeat locally and sets the service status to available.
[0166] Parse the data reported by the cluster gateway and incrementally store the relevant information in the local database.
[0167] like Figure 5c As shown, a cross-cluster business call is made and the returned result is successful.
[0168] The forwarding module of the cluster gateway parses the call path information in the request data (the call path information includes: service name, method path; through the service name, the routing module can obtain the target cluster gateway address through cache information or from the registration center, thereby calling the target service; the method path is the Http / https request path, calling the corresponding method of the corresponding service) and sends it to the routing module.
[0169] The routing module queries the locally stored relevant routing information and determines whether the routing information of the calling path is already available. If so, the routing information is updated; if not, the routing information is incrementally stored in the routing table.
[0170] like Figure 5d As shown, the first cluster business service calls the interface of the second cluster business service.
[0171] The cross-cluster call request first enters the forwarding module for parsing and processing to extract the target service name.
[0172] After the forwarding module parses the target service name, it sends the information to the routing module. The routing module uses the local routing table to search whether there is routing information for calling the service. If so, it constructs the request information and forwards it to the second cluster gateway of the second cluster. The second cluster gateway returns the call result; if not, it reports the target service name to the registration center.
[0173] Registration center routing sub-process
[0174] 1) After the routing module reports to the registration center, the registration center retrieves the target cluster gateway address of the target service name from the routing information reported by each cluster gateway to detect whether the service exists. If the target cluster gateway address exists, the target cluster gateway address is sent to the routing module of the cluster gateway;
[0175] 2) If the target cluster gateway address is not found, send an addressing broadcast and determine whether there is a cluster that returns successfully; if there is a cluster that returns successfully, then this cluster is the target cluster being called, and return the target cluster gateway address of the target cluster. If not, return no such service
[0176] 4. After the forwarding module obtains the target cluster gateway address, it reconstructs the original request into a request that can be called to the target cluster for forwarding.
[0177] 5. The cluster gateway forwarding module receives the request and returns the result, returns the routing information to the routing module, and returns the result to the source business service.
[0178] In an embodiment of the present invention, first node information corresponding to each node in the first cluster and first gateway information of the first cluster gateway are obtained; the first node information and the first gateway information are reported to the registration center; when the first cluster gateway of the first cluster receives a cross-cluster call request, the cross-cluster call request is parsed to determine the target service name corresponding to the cross-cluster call request; according to the target service name, the target cluster gateway address corresponding to the target service targeted by the cross-cluster call request is queried; if the target cluster gateway address corresponding to the target service is not queried, a routing request containing the target service name is sent to the registration center; the target cluster gateway address returned by the registration center is received; according to the target cluster gateway address, an access request is sent to the second cluster corresponding to the target cluster gateway address; when a successful access result for the access request is received, first routing information is generated according to the target service, the target service name and the target cluster gateway address; and the second local database is updated according to the first routing information.
[0179] Through the embodiments of the present invention, when making cross-cluster requests, there is no need to know the business service address of the other end, only the service name needs to be known. The cluster gateway will automatically obtain routing information and forward the request to the corresponding node, realizing container-unaware cross-cluster calls.
[0180] And when the original path cannot be called, the cluster gateway will obtain the corresponding cluster gateway address from the registration center to forward the request, so that cross-cluster service calls have a fault-tolerant mechanism.
[0181] It should be noted that for the sake of simplicity, the method embodiments are described as a series of actions. However, those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0182] Reference Figure 6 , shows a structural schematic diagram of a multi-cluster communication device of an embodiment of the present invention, which is applied to a multi-cluster architecture. The multi-cluster architecture includes at least two clusters and a registration center. Each cluster includes a cluster gateway and at least one node corresponding to different services; the at least two clusters include a first cluster, and the registration center stores the cluster gateway address corresponding to each service.
[0183] like Figure 6 As shown, the device may include the following modules:
[0184] Parsing module 601, configured for a first cluster gateway of a first cluster to parse a cross-cluster call request upon receiving the cross-cluster call request, and determine a target service name corresponding to the cross-cluster call request;
[0185] A query module 602 is configured to query a target cluster gateway address corresponding to the target service targeted by the cross-cluster call request based on the target service name;
[0186] Access module 603 is used to obtain the target cluster gateway address corresponding to the target service from the registration center when the target cluster gateway address corresponding to the target service is not queried, and send an access request to the second cluster corresponding to the target cluster gateway address based on the target cluster gateway address; the second cluster gateway of the second cluster determines the target address of the target node corresponding to the target service based on the access request, and forwards the access request to the target node.
[0187] In an optional embodiment of the present invention, the device further comprises:
[0188] The registration module is used to obtain the first node information corresponding to each node in the first cluster and the first gateway information of the first cluster gateway; and report the first node information and the first gateway information to the registration center.
[0189] In an optional embodiment of the present invention, the registration center is configured to perform incremental storage in the first local database based on the first node information and the first gateway information.
[0190] In an optional embodiment of the present invention, the access module 603 is used to send a routing request containing the target service name to the registration center; the registration center is used to respond to the routing request and query the target cluster gateway address corresponding to the target service based on the target service name; and receive the target cluster gateway address returned by the registration center.
[0191] In an optional embodiment of the present invention, the registration center is used to broadcast the cluster gateway address for the target service to at least two clusters when the target cluster gateway address corresponding to the target service is not queried in the first local database, and receive the target cluster gateway address for the target service reported by a cluster.
[0192] In an optional embodiment of the present invention, the device further comprises:
[0193] The update module is used to generate first routing information according to the target service, the target service name and the target cluster gateway address when receiving a successful access result for the access request; and update the second local database according to the first routing information.
[0194] In an embodiment of the present invention, when the first cluster gateway of the first cluster receives a cross-cluster call request, it parses the cross-cluster call request and determines the target service name corresponding to the cross-cluster call request; based on the target service name, it queries the target cluster gateway address corresponding to the target service targeted by the cross-cluster call request; if the target cluster gateway address corresponding to the target service is not queried, it obtains the target cluster gateway address corresponding to the target service from the registration center, and based on the target cluster gateway address, it sends an access request to the second cluster corresponding to the target cluster gateway address; the second cluster gateway of the second cluster determines the target address of the target node corresponding to the target service based on the access request, and forwards the access request to the target node. Through the embodiment of the present invention, when making a cross-cluster request, there is no need to know the business service address of the other end, only the service name needs to be known, and the cluster gateway will automatically obtain the routing information and forward the request to the corresponding node, thereby realizing container-unaware cross-cluster calls.
[0195] And when the original path cannot be called, the cluster gateway will obtain the corresponding cluster gateway address from the registration center to forward the request, so that cross-cluster service calls have a fault-tolerant mechanism.
[0196] An embodiment of the present invention further provides an electronic device, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, the multi-cluster communication method described above is implemented.
[0197] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the multi-cluster communication method described above is implemented.
[0198] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0199] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0200] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, apparatus, or computer program products. Thus, embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0201] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate a device for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0202] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0203] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce computer-implemented processing, so that the instructions executed on the computer or other programmable terminal device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0204] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic creative concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0205] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.
[0206] The above provides a detailed introduction to a multi-cluster architecture, a multi-cluster communication method, a multi-cluster communication device, an electronic device, and a computer-readable storage medium. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the ideas of the present invention, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A multi-cluster communication method, characterized in that: Applied to a multi-cluster architecture, the multi-cluster architecture includes at least two clusters and a registration center, each cluster includes a cluster gateway and at least one node corresponding to different services; The at least two clusters include a first cluster, the registration center stores cluster gateway addresses corresponding to each service, and the method includes: When receiving the cross-cluster call request, the first cluster gateway of the first cluster parses the cross-cluster call request to determine a target service name corresponding to the cross-cluster call request; According to the target service name, query the target cluster gateway address corresponding to the target service targeted by the cross-cluster call request; If the target cluster gateway address corresponding to the target service is not queried, the target cluster gateway address corresponding to the target service is obtained from the registration center, and based on the target cluster gateway address, an access request is sent to the second cluster corresponding to the target cluster gateway address; the second cluster gateway of the second cluster determines the target address of the target node corresponding to the target service based on the access request, and forwards the access request to the target node.
2. The method according to claim 1, characterized in that The method further comprises: Obtaining first node information corresponding to each node in the first cluster and first gateway information of the first cluster gateway; Report the first node information and the first gateway information to the registration center.
3. The method according to claim 2, characterized in that The registration center is used to perform incremental storage in a first local database based on the first node information and the first gateway information.
4. The method according to claim 1, wherein The acquiring the target cluster gateway address corresponding to the target service from the registration center includes: Sending a routing request including the target service name to the registration center; the registration center is configured to query the target cluster gateway address corresponding to the target service based on the target service name in response to the routing request; Receive the target cluster gateway address returned by the registration center.
5. The method according to claim 4, characterized in that The registration center is configured to perform cluster gateway addressing broadcast for the target service to the at least two clusters when the target cluster gateway address corresponding to the target service is not found in the first local database, and receive the target cluster gateway address for the target service reported by a cluster.
6. The method according to claim 1, characterized in that The method further comprises: Upon receiving a successful access result for the access request, generating first routing information according to the target service, the target service name, and the target cluster gateway address; The second local database is updated according to the first routing information.
7. A multi-cluster architecture, characterized in that: The multi-cluster architecture includes at least two clusters and a registration center, each cluster includes a cluster gateway and at least one node corresponding to different services; the at least two clusters include a first cluster, and the registration center stores the cluster gateway address corresponding to each service; The first cluster is configured to execute the method according to any one of claims 1 to 6; The registration center is configured to determine the target cluster gateway address corresponding to the target service and return the target cluster gateway address to the first cluster if the first cluster fails to query the target cluster gateway address corresponding to the target service.
8. The multi-cluster architecture according to claim 7, wherein: The first cluster includes a first cluster gateway, and the first cluster gateway includes a first forwarding module and a first routing module; The first forwarding module is configured to receive the cross-cluster call request, parse the cross-cluster call request to obtain a target service name, and send the target service name to the first routing module; The first routing module is configured to query, according to the target service name, a target cluster gateway address corresponding to the target service targeted by the cross-cluster call request; If the target cluster gateway address corresponding to the target service is not found, the target cluster gateway address corresponding to the target service is obtained from the registration center, and an access request is sent to the second cluster corresponding to the target cluster gateway address according to the target cluster gateway address.
9. The multi-cluster architecture according to claim 7, wherein: The first cluster gateway is deployed in the first cluster in a plug-in manner.
10. A multi-cluster communication device, characterized in that: Applied to a multi-cluster architecture, the multi-cluster architecture includes at least two clusters and a registration center, each cluster includes a cluster gateway and at least one node corresponding to different services; The at least two clusters include a first cluster, the registration center stores cluster gateway addresses corresponding to each service, and the device includes: a parsing module, configured for the first cluster gateway of the first cluster to parse the cross-cluster call request upon receiving the cross-cluster call request, and determine a target service name corresponding to the cross-cluster call request; A query module, configured to query a target cluster gateway address corresponding to the target service targeted by the cross-cluster call request according to the target service name; An access module is used to obtain the target cluster gateway address corresponding to the target service from the registration center if the target cluster gateway address corresponding to the target service is not queried, and send an access request to the second cluster corresponding to the target cluster gateway address based on the target cluster gateway address; the second cluster gateway of the second cluster determines the target address of the target node corresponding to the target service based on the access request, and forwards the access request to the target node.
11. An electronic device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein when the computer program is executed by the processor, the multi-cluster communication method according to any one of claims 1 to 6 is implemented.
12. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the multi-cluster communication method according to any one of claims 1 to 6 is implemented.
Citation Information
Cited By
Multi-cluster network communication method, device, equipment, medium and product
CN121125592A