Movatterモバイル変換


[0]ホーム

URL:


CN115086312A - Method and system for realizing kubernets service cross-cluster communication - Google Patents

Method and system for realizing kubernets service cross-cluster communication
Download PDF

Info

Publication number
CN115086312A
CN115086312ACN202210504839.3ACN202210504839ACN115086312ACN 115086312 ACN115086312 ACN 115086312ACN 202210504839 ACN202210504839 ACN 202210504839ACN 115086312 ACN115086312 ACN 115086312A
Authority
CN
China
Prior art keywords
cluster
tunnel gateway
clusters
name
intermediary
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210504839.3A
Other languages
Chinese (zh)
Inventor
张绍兴
詹赵林
郑文礼
王畅
郭进
聂子璇
赵文川
王鑫
刘清
刘金华
梅金东
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Industrial Bank Co Ltd
CIB Fintech Services Shanghai Co Ltd
Original Assignee
Industrial Bank Co Ltd
CIB Fintech Services Shanghai Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Industrial Bank Co Ltd, CIB Fintech Services Shanghai Co LtdfiledCriticalIndustrial Bank Co Ltd
Priority to CN202210504839.3ApriorityCriticalpatent/CN115086312A/en
Publication of CN115086312ApublicationCriticalpatent/CN115086312A/en
Pendinglegal-statusCriticalCurrent

Links

Images

Classifications

Landscapes

Abstract

The invention provides a method and a system for realizing kubernet service cross-cluster communication, which relate to the technical field of cross-cluster communication, and the method comprises the following steps: deployment step: distributing different CIDR blocks for different clusters, selecting a cluster deployment cluster medium, deploying a network tunnel gateway and a navigation agent for each cluster, and finally deploying a routing agent for each node of each cluster; the working steps are as follows: after the corresponding deployment is completed, the network tunnel gateway, the navigation agent and the routing agent start to do preparation work: the method comprises the steps of creating necessary CRDs, mutually discovering and establishing network tunnels through cluster intermediaries by network tunnel gateways, exposing the Services of a cluster where the navigation agent is located through the cluster intermediaries and obtaining the Services of other clusters, and obtaining an endpoint CR set by the tunnel gateways through an Informer mechanism by a routing agent. The invention can realize service non-perception cross-cluster communication.

Description

Translated fromChinese
实现kubernetes服务跨集群通信的方法及系统Method and system for realizing cross-cluster communication of kubernetes services

技术领域technical field

本发明涉及跨集群通信技术领域,具体地,涉及一种实现kubernetes服务跨集群通信的方法及系统。The present invention relates to the technical field of cross-cluster communication, in particular to a method and system for realizing cross-cluster communication of kubernetes services.

背景技术Background technique

Kubernetes是一个全新的基于容器技术的分布式架构解决方案,是Google开源的一个容器集群管理系统,Kubernetes简称k8s。Kubernetes当前已经成为容器编排事实标准。随着Kubernetes被大规模使用,Kubernetes单集群承载能力有限、容灾能力有限等等问题日渐突出,单集群已经开始变得不能满足需求了,多集群编排自然的就成了解决方案,为了实现多集群编排,服务的跨集群通信是首要解决的问题。Kubernetes is a new distributed architecture solution based on container technology. It is a container cluster management system open sourced by Google. Kubernetes is referred to as k8s. Kubernetes has now become the de facto standard for container orchestration. With the large-scale use of Kubernetes, the problems of limited carrying capacity and limited disaster tolerance of a single Kubernetes cluster have become increasingly prominent, and a single cluster has begun to become unsatisfactory. Cluster orchestration, cross-cluster communication of services is the primary problem to be solved.

公开号为CN113032126A的发明专利,公开了一种高并发云工作流调度引擎跨集群通信系统及方法,该系统的控制器模块采用Service和Deployment方式容器化部署到Kubernetes的Master主集群;生成器模块采用Shell脚本方式容器化部署于各个集群,每个集群以Service和Deployment方式部署唯一的生成器容器;控制器模块和生成器模块均以Service NodePort方式对外提供访问,且以gRPC方式跨越集群通信;分布式数据库在各个集群中单独部署,用于存储调度器模块的资源请求记录;缓存数据库采用分布式架构部署,用于存储全局的工作流信息记录。The invention patent with publication number CN113032126A discloses a high-concurrency cloud workflow scheduling engine cross-cluster communication system and method. The controller module of the system adopts Service and Deployment methods to be containerized and deployed to the master master cluster of Kubernetes; the generator module Containerized and deployed in each cluster by shell script, each cluster deploys a unique generator container in Service and Deployment mode; both the controller module and the generator module provide external access in the form of Service NodePort, and communicate across the cluster in the form of gRPC; The distributed database is deployed separately in each cluster to store the resource request records of the scheduler module; the cache database is deployed in a distributed architecture to store the global workflow information records.

发明内容SUMMARY OF THE INVENTION

针对现有技术中的缺陷,本发明提供一种实现kubernetes服务跨集群通信的方法及系统。Aiming at the defects in the prior art, the present invention provides a method and system for realizing cross-cluster communication of kubernetes services.

根据本发明提供的一种实现kubernetes服务跨集群通信的方法及系统,所述方案如下:According to a method and system for realizing cross-cluster communication of kubernetes services provided by the present invention, the solution is as follows:

第一方面,提供了一种实现kubernetes服务跨集群通信的方法,所述方法包括:In a first aspect, a method for realizing cross-cluster communication of kubernetes services is provided, and the method includes:

部署步骤:为不同的集群分配不同的CIDRs,并选择一个集群部署集群中介,并为每一个集群部署网络隧道网关和导航代理,最后为每个集群的每个节点部署路由代理;Deployment steps: assign different CIDRs to different clusters, select a cluster to deploy a cluster intermediary, deploy a network tunnel gateway and navigation proxy for each cluster, and finally deploy a routing proxy for each node of each cluster;

工作步骤:相应部署完成后,网络隧道网关、导航代理和路由代理开始做准备工作:创建必要的CRDs,网络隧道网关通过集群中介互相发现并建立网络隧道,导航代理通过集群中介暴露自己所在集群的Services并获取其他集群的Services,路由代理通过Informer机制获取隧道网关设置的端点CR。Working steps: After the corresponding deployment is completed, the network tunnel gateway, navigation agent, and routing agent begin to prepare: create the necessary CRDs, the network tunnel gateway discovers each other through the cluster intermediary and establishes network tunnels, and the navigation agent exposes its own cluster through the cluster intermediary. Services and obtain the services of other clusters, and the routing agent obtains the endpoint CR set by the tunnel gateway through the Informer mechanism.

优选地,所述部署步骤中选择一个集群部署集群中介具体包括:Preferably, selecting a cluster to deploy a cluster intermediary in the deploying step specifically includes:

步骤S1.1:创建集群CRD,包含:Step S1.1: Create a cluster CRD, including:

cluster_cidr数组:不同集群分配的CIDRs;cluster_cidr array: CIDRs allocated by different clusters;

name:集群名字;name: cluster name;

service_cidr数组:每个集群分配的service、pod的CIDRs;service_cidr array: CIDRs of services and pods allocated by each cluster;

步骤S1.2:创建隧道网关端点CRD,包含:Step S1.2: Create a tunnel gateway endpoint CRD, including:

name:集群名字;name: cluster name;

private_ip:集群内ip;private_ip: ip in the cluster;

public_ip:供其他集群隧道网关访问的ip;public_ip: the ip for other cluster tunnel gateways to access;

步骤S1.3:配置ServiceAccount和RBAC规则,以供其他集群安全访问。Step S1.3: Configure ServiceAccount and RBAC rules for secure access by other clusters.

优选地,所述部署步骤中为每一个集群部署网络隧道网关具体包括:Preferably, in the deploying step, deploying a network tunnel gateway for each cluster specifically includes:

步骤S2.1:每个集群选择两个节点分别作为主/从节点;Step S2.1: Each cluster selects two nodes as master/slave nodes;

步骤S2.2:配置访问集群中介K8s API的ServiceAccount和访问地址。Step S2.2: Configure the ServiceAccount and access address for accessing the cluster broker K8s API.

优选地,所述部署步骤中为每一个集群部署导航代理包括:Preferably, in the deploying step, deploying the navigation agent for each cluster includes:

步骤S3.1:创建集群ServiceExport CRD,包含:Step S3.1: Create a cluster ServiceExport CRD, including:

name和namespace:为service的名字和命名空间,包含在默认的metadata中;name and namespace: the name and namespace of the service, included in the default metadata;

status:为service导出状态,包括成功和失败;status: export status for service, including success and failure;

步骤S3.2:创建集群ServiceImport CRD,包含:Step S3.2: Create a cluster ServiceImport CRD, including:

name和namespace:service的名字和命名空间,包含在默认的metadata中;name and namespace: the name and namespace of the service, included in the default metadata;

ports数组:暴露的端口列表;ports array: list of exposed ports;

ips数组:ip列表;ips array: ip list;

步骤S3.3:部署导航代理组件到节点上,将每个集群的CIDR信息和集群名字映射关系通过配置文件进行配置;Step S3.3: deploy the navigation agent component to the node, and configure the CIDR information of each cluster and the cluster name mapping relationship through the configuration file;

步骤S3.4:部署导航代理CoreDNS插件,配置CoreDNS将clusterset.local域名的DNS请求转发至插件。Step S3.4: Deploy the navigation proxy CoreDNS plug-in, and configure CoreDNS to forward DNS requests for the clusterset.local domain name to the plug-in.

优选地,所述工作步骤中隧道网关部署后开始做准备工作包括:Preferably, in the working step, the preparatory work after the tunnel gateway is deployed includes:

步骤S4.1:从节点定时通过网络连接向主节点发送心跳数据包,当发现主节点失去响应,则认为主节点出现故障,将自己切换为主节点继续工作;Step S4.1: The slave node regularly sends a heartbeat data packet to the master node through the network connection. When it is found that the master node fails to respond, it is considered that the master node is faulty, and it switches itself to the master node to continue working;

步骤S4.2:隧道网关将自己集群的集群信息CR和隧道网关信息CR在集群中介中创建;Step S4.2: the tunnel gateway creates the cluster information CR of its own cluster and the tunnel gateway information CR in the cluster intermediary;

步骤S4.3:隧道网关通过informer机制查询并实时获取其他节点的集群CR和隧道网关CR,并缓存到当前集群的ETCD中;Step S4.3: The tunnel gateway queries and obtains the cluster CR and tunnel gateway CR of other nodes in real time through the informer mechanism, and caches them in the ETCD of the current cluster;

步骤S4.4:当隧道网关获取到其他集群的隧道网关端点CR创建事件,则从中获取隧道网关的public_ip字段值,并尝试建立网络连接,如果失败,稍后重试连接;Step S4.4: When the tunnel gateway obtains the creation event of the tunnel gateway endpoint CR of other clusters, it obtains the public_ip field value of the tunnel gateway from it, and tries to establish a network connection, and if it fails, retry the connection later;

步骤S4.5:当集群隧道网关收到其他集群隧道网关创建连接时,从自己集群的缓存中查询创建连接的集群隧道,如果查询到,则完成连接创建,如果未查询到,则拒绝连接。Step S4.5: When the cluster tunnel gateway receives a connection created by another cluster tunnel gateway, it queries the cluster tunnel for which the connection is created from the cache of its own cluster. If the query is found, the connection creation is completed, and if the query is not found, the connection is rejected.

优选地,所述工作步骤中导航代理开始做准备工作包括:Preferably, the preparatory work for the navigation agent to start in the work step includes:

步骤S5.1:通过K8s API调用在集群中介中给每一个需要暴露给其他集群的Service创建ServiceExport CR,让其他集群得知当前集群有哪些Service能够供其他集群访问;Step S5.1: Create a ServiceExport CR for each Service that needs to be exposed to other clusters in the cluster intermediary through K8s API calls, so that other clusters know which services in the current cluster can be accessed by other clusters;

步骤S5.2:通过K8s API调用在集群中介中为每个创建的ServiceExport都创建对应的ServiceImport CR,让其他集群得知当前集群暴露的Service的ip和端口在内的相关信息;Step S5.2: Create a corresponding ServiceImport CR for each created ServiceExport through the K8s API call in the cluster intermediary, so that other clusters can know the relevant information including the ip and port of the Service exposed by the current cluster;

步骤S5.3:通过Informer机制,持续获取ServiceImport和ServiceExport,并通过本集群K8s API将ServiceImport缓存在ETCD中。Step S5.3: Continuously obtain ServiceImport and ServiceExport through the Informer mechanism, and cache the ServiceImport in the ETCD through the K8s API of the cluster.

优选地,所述工作步骤中路由代理开始做准备工作包括:Preferably, in the working step, the routing agent starts to do the preparatory work including:

步骤S6.1:路由代理通过Informer机制获取隧道网关设置的端点CR,进而获取当前集群的隧道网关的IP地址;Step S6.1: the routing agent obtains the endpoint CR set by the tunnel gateway through the Informer mechanism, and then obtains the IP address of the tunnel gateway of the current cluster;

步骤S6.2:路由代理通过CNI插件将跨集群的流量路发送到隧道网关,隧道网关再将流量发送到对应的集群隧道网关,相反,从隧道网关出来的流量会根据流量数据包的目的IP发往不同的节点。Step S6.2: The routing agent sends the cross-cluster traffic to the tunnel gateway through the CNI plug-in, and the tunnel gateway sends the traffic to the corresponding cluster tunnel gateway. On the contrary, the traffic from the tunnel gateway will be based on the destination IP of the traffic packet. sent to different nodes.

第二方面,提供了一种实现kubernetes服务跨集群通信的系统,所述系统包括:In a second aspect, a system for realizing cross-cluster communication of kubernetes services is provided, and the system includes:

部署模块:为不同的集群分配不同的CIDRs,并选择一个集群部署集群中介,并为每一个集群部署网络隧道网关和导航代理,最后为每个集群的每个节点部署路由代理;Deployment module: assign different CIDRs to different clusters, select a cluster to deploy a cluster intermediary, deploy a network tunnel gateway and navigation proxy for each cluster, and finally deploy a routing proxy for each node of each cluster;

工作模块:相应部署完成后,网络隧道网关、导航代理和路由代理开始做准备工作:创建必要的CRDs,网络隧道网关通过集群中介互相发现并建立网络隧道,导航代理通过集群中介暴露自己所在集群的Services并获取其他集群的Services,路由代理通过Informer机制获取隧道网关设置的端点CR。Working module: After the corresponding deployment is completed, the network tunnel gateway, navigation agent and routing agent begin to prepare: create the necessary CRDs, the network tunnel gateway discovers each other through the cluster intermediary and establishes network tunnels, and the navigation agent exposes the information of the cluster where it is located through the cluster intermediary. Services and obtain the services of other clusters, and the routing agent obtains the endpoint CR set by the tunnel gateway through the Informer mechanism.

优选地,所述部署模块中选择一个集群部署集群中介具体包括:Preferably, selecting a cluster to deploy a cluster intermediary in the deployment module specifically includes:

模块M1.1:创建集群CRD,包含:Module M1.1: Create a cluster CRD, containing:

cluster_cidr(数组):不同集群分配的CIDRs;cluster_cidr (array): CIDRs allocated by different clusters;

name:集群名字;name: cluster name;

service_cidr(数组):每个集群分配的service、pod的CIDRs;service_cidr (array): CIDRs of services and pods allocated by each cluster;

模块M1.2:创建隧道网关端点CRD,包含:Module M1.2: Create Tunnel Gateway Endpoint CRD, containing:

name:集群名字;name: cluster name;

private_ip:集群内ip;private_ip: ip in the cluster;

public_ip:供其他集群隧道网关访问的ip;public_ip: the ip for other cluster tunnel gateways to access;

模块M1.3:配置ServiceAccount和RBAC规则,以供其他集群安全访问。Module M1.3: Configure ServiceAccount and RBAC rules for secure access by other clusters.

优选地,所述部署步骤中为每一个集群部署网络隧道网关具体包括:Preferably, in the deploying step, deploying a network tunnel gateway for each cluster specifically includes:

模块M2.1:每个集群选择两个节点分别作为主/从节点;Module M2.1: Each cluster selects two nodes as master/slave nodes;

模块M2.2:配置访问集群中介K8s API的ServiceAccount和访问地址。Module M2.2: Configure the ServiceAccount and access address for accessing the K8s API of the cluster intermediary.

与现有技术相比,本发明具有如下的有益效果:Compared with the prior art, the present invention has the following beneficial effects:

1、本发明尽可能使用Kubernetes现有基础设施,例如:利用k8s现有的CRD机制来存储和高效查询各种元信息,使用CNI插件将流量在集群内网络隧道网关和计算节点间路由,减少部署和使用难度;1. The present invention uses the existing infrastructure of Kubernetes as much as possible, for example: using the existing CRD mechanism of k8s to store and efficiently query various meta-information, using the CNI plug-in to route traffic between the network tunnel gateway and computing nodes in the cluster, reducing Difficulty of deployment and use;

2、本发明利用官方的设计“KEP-645”实现跨集群Service发现机制,增加了通用性和可理解性;2. The present invention utilizes the official design "KEP-645" to realize the cross-cluster Service discovery mechanism, which increases the versatility and understandability;

3、本发明集群中介失败容忍度高,失败不会影响到当前的跨集群服务间通信;3. The cluster intermediary of the present invention has a high failure tolerance, and the failure will not affect the current communication between cross-cluster services;

4、本发明中的服务能够无感知跨集群通信。4. The service in the present invention can communicate across clusters without perception.

附图说明Description of drawings

通过阅读参照以下附图对非限制性实施例所作的详细描述,本发明的其它特征、目的和优点将会变得更明显:Other features, objects and advantages of the present invention will become more apparent by reading the detailed description of non-limiting embodiments with reference to the following drawings:

图1为本发明整体示意图。FIG. 1 is an overall schematic diagram of the present invention.

具体实施方式Detailed ways

下面结合具体实施例对本发明进行详细说明。以下实施例将有助于本领域的技术人员进一步理解本发明,但不以任何形式限制本发明。应当指出的是,对本领域的普通技术人员来说,在不脱离本发明构思的前提下,还可以做出若干变化和改进。这些都属于本发明的保护范围。The present invention will be described in detail below with reference to specific embodiments. The following examples will help those skilled in the art to further understand the present invention, but do not limit the present invention in any form. It should be noted that, for those skilled in the art, several changes and improvements can be made without departing from the inventive concept. These all belong to the protection scope of the present invention.

本发明实施例提供了一种实现kubernetes服务跨集群通信的方法,能够让服务像访问本集群服务一样访问其他集群的服务,该方法中涉及到的主要组件包括以下部分:The embodiment of the present invention provides a method for realizing cross-cluster communication of kubernetes services, which enables services to access services of other clusters as if they access services in this cluster. The main components involved in the method include the following parts:

1、集群中介:利用k8s现有的CRD机制(Custom Resource Definition,自定义资源定义,定义了自定义资源(CR)对象的模式定义(schema),可以通过Kubernetes API根据CRD和具体数据生成自定义资源对象),集中存储各种集群元信息,并且可以通过k8s客户端自带的informer机制来让所有集群方便高效查询和实时获取信息变更。以下是一些存储数据示例:集群相关的静态信息:Pod(Kubernetes里一种对象,由相关容器组成的容器组)和Service(为一组Pods应用程序公开为网络服务的代理机制)的CIDRs等;集群之间用来相互通信的网络隧道网关的ip地址等。1. Cluster intermediary: Using the existing CRD mechanism of k8s (Custom Resource Definition, custom resource definition, the schema definition (schema) of the custom resource (CR) object is defined, and the custom resource can be generated according to the CRD and specific data through the Kubernetes API Resource objects), centrally store various cluster meta information, and through the informer mechanism that comes with the k8s client, all clusters can easily and efficiently query and obtain information changes in real time. The following are some examples of stored data: cluster-related static information: CIDRs of Pod (an object in Kubernetes, a container group composed of related containers) and Service (a proxy mechanism exposed as a network service for a group of Pods applications), etc.; The ip address of the network tunnel gateway used by clusters to communicate with each other, etc.

2、隧道网关:不同集群间的隧道网关之间通过建立安全的网络隧道来实现集群间网络通信,隧道网关被部署在每一个集群中。网络隧道已有很多成熟的实现,所以通信网关只提供插件的接口,具体实现可以依赖现有工具:IPSec(网络安全协议)的各种实现,WireGuard(VPN程序),VXLAN(虚拟局域网扩展,一种隧道技术,在三层网络中实现虚拟二层交换机)等。由于通信网关的高可用非常重要,隧道网关支持主从模式高可用,正常情况由主负责通信,当主失效,从切换为主,继续工作。2. Tunnel gateway: A secure network tunnel is established between tunnel gateways between different clusters to realize inter-cluster network communication, and the tunnel gateway is deployed in each cluster. There are many mature implementations of network tunnels, so the communication gateway only provides plug-in interfaces, and the specific implementation can rely on existing tools: various implementations of IPSec (Internet Security Protocol), WireGuard (VPN program), VXLAN (Virtual Local Area Network Extension, a tunneling technology, and implement virtual Layer 2 switches in Layer 3 networks), etc. Because the high availability of the communication gateway is very important, the tunnel gateway supports the high availability of the master-slave mode. Normally, the master is responsible for communication. When the master fails, the slave switches to the master and continues to work.

3、导航代理:通过实现官方设计“KEP-1645”来实现跨集群服务发现。导航代理被部署在每一个集群中,负责将本集群暴露给其他集群的Service信息(ServiceExport CRD)存储到集群中介中,供其他集群查询,同时也能在集群中介中查询到其他集群暴露的Service(ServiceImport CRD);导航代理利用CoreDNS插件机制,创建一个DNS服务,拥有“clusterset.local”域名,配置集群的CoreDns将该域名的请求转发到导航DNS服务,导航DNS服务器同样拥有ServiceImport的缓存,用来解析DNS查询。3. Navigation agent: realize cross-cluster service discovery by implementing the official design "KEP-1645". The navigation agent is deployed in each cluster and is responsible for storing the service information (ServiceExport CRD) exposed by the cluster to other clusters in the cluster broker for other clusters to query, and can also query the services exposed by other clusters in the cluster broker. (ServiceImport CRD); The navigation agent uses the CoreDNS plug-in mechanism to create a DNS service with the "clusterset.local" domain name, and configures the cluster's CoreDns to forward the request of the domain name to the navigation DNS service. The navigation DNS server also has the cache of ServiceImport, using to resolve DNS queries.

4、路由代理:路由代理利用现有CNI(Container Network Interface容器网络接口,用户管理容器的网络资源)插件机制来将请求路由到其他集群端点的流量通过到本集群的导航代理,同样地,其他集群进来的流量将从导航代理路由到目的端点。4. Routing agent: The routing agent uses the existing CNI (Container Network Interface container network interface, the user manages the network resources of the container) plug-in mechanism to route requests to other cluster endpoints through the navigation agent of the cluster. Similarly, other Incoming traffic to the cluster will be routed from the navigation proxy to the destination endpoint.

参照图1所示,本发明提供的一种实现kubernetes服务跨集群通信的方法,主要流程包括以下步骤:Referring to Fig. 1, a method for realizing cross-cluster communication of kubernetes services provided by the present invention, the main process includes the following steps:

部署步骤:为不同的集群分配不同的CIDRs,并选择一个集群部署集群中介,并为每一个集群部署网络隧道网关和导航代理,最后为每个集群的每个节点部署路由代理。Deployment steps: Assign different CIDRs to different clusters, select a cluster to deploy a cluster mediator, deploy a network tunnel gateway and navigation proxy for each cluster, and finally deploy a routing proxy for each node of each cluster.

工作步骤:相应部署完成后,网络隧道网关、导航代理和路由代理开始做准备工作:创建必要的CRDs,网络隧道网关通过集群中介互相发现并建立网络隧道,导航代理通过集群中介暴露自己所在集群的Services并获取其他集群的Services,路由代理通过Informer机制获取隧道网关设置的端点CR。Working steps: After the corresponding deployment is completed, the network tunnel gateway, navigation agent, and routing agent begin to prepare: create the necessary CRDs, the network tunnel gateway discovers each other through the cluster intermediary and establishes network tunnels, and the navigation agent exposes its own cluster through the cluster intermediary. Services and obtain the services of other clusters, and the routing agent obtains the endpoint CR set by the tunnel gateway through the Informer mechanism.

具体地部署步骤中,选择一个集群部署集群中介具体包括:In the specific deployment steps, selecting a cluster to deploy the cluster intermediary specifically includes:

步骤S1.1:创建集群CRD,包含:Step S1.1: Create a cluster CRD, including:

cluster_cidr(数组):不同集群分配的CIDRs(Classless Inter-DomainRouting,误分类域间路由选择,可用于ip表示和ip段表示);cluster_cidr (array): CIDRs assigned by different clusters (Classless Inter-DomainRouting, misclassified inter-domain routing, can be used for ip representation and ip segment representation);

name:集群名字;name: cluster name;

service_cidr(数组):每个集群分配的service、pod的CIDRs;service_cidr (array): CIDRs of services and pods allocated by each cluster;

步骤S1.2:创建隧道网关端点CRD,包含:Step S1.2: Create a tunnel gateway endpoint CRD, including:

name:集群名字;name: cluster name;

private_ip:集群内ip;private_ip: ip in the cluster;

public_ip:供其他集群隧道网关访问的ip;public_ip: the ip for other cluster tunnel gateways to access;

步骤S1.3:配置ServiceAccount(用于身份验证的账户信息)和RBAC(基于角色的访问控制)规则,以供其他集群安全访问。Step S1.3: Configure ServiceAccount (account information for authentication) and RBAC (role-based access control) rules for secure access by other clusters.

部署步骤中,为每一个集群部署网络隧道网关具体包括:In the deployment step, deploying a network tunnel gateway for each cluster specifically includes:

步骤S2.1:每个集群选择两个节点分别作为主/从节点,保证网络隧道网关高可用。Step S2.1: Each cluster selects two nodes as master/slave nodes respectively to ensure high availability of the network tunnel gateway.

步骤S2.2:配置访问集群中介Kubernetes API(Kubernetes服务网络接口)的ServiceAccount和访问地址。Step S2.2: Configure the ServiceAccount and access address for accessing the cluster intermediary Kubernetes API (Kubernetes service network interface).

部署步骤中,为每一个集群部署导航代理包括:In the deployment step, deploying the navigation agent for each cluster includes:

步骤S3.1:创建集群ServiceExport CRD(已解释),包含:Step S3.1: Create a cluster ServiceExport CRD (explained), including:

name和namespace:为service的名字和命名空间,包含在默认的metadata字段中;name and namespace: the name and namespace of the service, contained in the default metadata field;

status:为service导出状态,包括成功和失败;status: export status for service, including success and failure;

步骤S3.2:创建集群ServiceImport CRD,包含:Step S3.2: Create a cluster ServiceImport CRD, including:

name和namespace:service的名字和命名空间,包含在默认的metadata中;name and namespace: the name and namespace of the service, included in the default metadata;

ports数组:暴露的端口列表;ports array: list of exposed ports;

ips数组:ip列表;ips array: ip list;

步骤S3.3:部署导航代理组件到节点上,将每个集群的CIDR信息和集群名字映射关系通过配置文件进行配置;Step S3.3: deploy the navigation agent component to the node, and configure the CIDR information of each cluster and the cluster name mapping relationship through the configuration file;

步骤S3.4:部署导航代理CoreDNS(Kubernetes的一个组件,实现DNS功能)插件,配置CoreDNS将“clusterset.local”域名的DNS请求转发至插件。Step S3.4: Deploy the navigation proxy CoreDNS (a component of Kubernetes that implements the DNS function) plug-in, and configure CoreDNS to forward the DNS request of the "clusterset.local" domain name to the plug-in.

接下来,在工作步骤中,隧道网关部署后开始做准备工作包括:Next, in the work step, the preparatory work after the deployment of the tunnel gateway includes:

步骤S4.1:从节点定时通过网络连接向主节点发送心跳数据包,当发现主节点失去响应,则认为主节点出现故障,将自己切换为主节点,继续工作。Step S4.1: The slave node periodically sends a heartbeat data packet to the master node through the network connection. When it is found that the master node fails to respond, it is considered that the master node is faulty, and it switches itself to the master node and continues to work.

步骤S4.2:隧道网关使用步骤S1.1所述的集群CRD和自己所在集群的信息通过集群中介Kubernetes API创建集群CR(CR(Custom Resource),自定义资源,可通过Kubernetes API对其进行增删改查,并能够实时获知变更),使用步骤S1.2所述的隧道网关端点CRD和自己所在集群的隧道网关信息通过集群中介Kubernetes API创建隧道网关CR。Step S4.2: The tunnel gateway uses the cluster CRD described in step S1.1 and the information of its own cluster to create a cluster CR (CR (Custom Resource) through the cluster intermediary Kubernetes API, and custom resources can be added to it through the Kubernetes API. Delete, modify and check, and be able to know the changes in real time), use the tunnel gateway endpoint CRD described in step S1.2 and the tunnel gateway information of the cluster where you are located to create a tunnel gateway CR through the cluster intermediary Kubernetes API.

步骤S4.3:隧道网关通过informer机制查询并实时获取其他节点的集群CR和隧道网关CR,并缓存到当前集群的ETCD(Kubernetes数据库组件)中。Step S4.3: The tunnel gateway queries and obtains the cluster CR and tunnel gateway CR of other nodes in real time through the informer mechanism, and caches them in the ETCD (Kubernetes database component) of the current cluster.

步骤S4.4:当隧道网关获取到其他集群的隧道网关端点CR创建事件,则从中获取隧道网关的public_ip字段值,并尝试建立网络连接,如果失败,稍后重试连接。Step S4.4: When the tunnel gateway obtains the tunnel gateway endpoint CR creation event of other clusters, it obtains the public_ip field value of the tunnel gateway from it, and tries to establish a network connection. If it fails, retry the connection later.

步骤S4.5:当集群隧道网关收到其他集群隧道网关创建连接时,从自己集群的缓存中查询创建连接的集群隧道,如果查询到,则完成连接创建,如果未查询到,则拒绝连接。Step S4.5: When the cluster tunnel gateway receives a connection created by another cluster tunnel gateway, it queries the cluster tunnel for which the connection is created from the cache of its own cluster. If the query is found, the connection creation is completed, and if the query is not found, the connection is rejected.

工作步骤中,导航代理开始做准备工作包括:In the work step, the navigation agent starts to do preparations including:

步骤S5.1:通过K8s API调用在集群中介中给每一个需要暴露给其他集群的Service创建ServiceExport CR,让其他集群得知当前集群有哪些Service能够供其他集群访问。Step S5.1: Create a ServiceExport CR for each Service that needs to be exposed to other clusters in the cluster intermediary through K8s API calls, so that other clusters know which services in the current cluster can be accessed by other clusters.

步骤S5.2:通过K8s API调用在集群中介中为每个创建的ServiceExport CR都创建对应的ServiceImport CR,让其他集群得知当前集群暴露的Service的ip和端口等信息。Step S5.2: Create a corresponding ServiceImport CR for each ServiceExport CR created in the cluster intermediary by calling the K8s API, so that other clusters can know the ip and port information of the Service exposed by the current cluster.

步骤S5.3:通过Informer机制,持续获取ServiceImport CR和ServiceExport CR,并通过本集群K8s API将ServiceImport CR缓存在ETCD中。Step S5.3: Continuously obtain ServiceImport CR and ServiceExport CR through the Informer mechanism, and cache the ServiceImport CR in the ETCD through the K8s API of the cluster.

工作步骤中,路由代理开始做准备工作包括:In the working steps, the routing agent starts to prepare for the following steps:

步骤S6.1:路由代理通过Informer机制获取隧道网关设置的端点CR,进而获取当前集群的隧道网关的IP地址。Step S6.1: The routing agent obtains the endpoint CR set by the tunnel gateway through the Informer mechanism, and then obtains the IP address of the tunnel gateway of the current cluster.

步骤S6.2:路由代理通过CNI插件将跨集群的流量路发送到隧道网关,隧道网关再将流量发送到对应的集群隧道网关,相反,从隧道网关出来的流量会根据流量数据包的目的IP发往不同的Pod或者Service。Step S6.2: The routing agent sends the cross-cluster traffic to the tunnel gateway through the CNI plug-in, and the tunnel gateway sends the traffic to the corresponding cluster tunnel gateway. On the contrary, the traffic from the tunnel gateway will be based on the destination IP of the traffic packet. Send to different Pod or Service.

至此,准备工作已完成,接下来以一个跨集群通信的场景描述来说明工作流程:集群1的pod1通过集群2命名空间default下的service2域名解析到的ip连接并访问service2。So far, the preparations have been completed. Next, a scenario description of cross-cluster communication is used to illustrate the workflow: pod1 of cluster 1 connects and accesses service2 through the IP resolved to the domain name of service2 under the default namespace of cluster 2.

当集群1的pod1通过:“service2.default.service.clusterset.local”域名解析的IP连接访问集群2的service2时,请求数据包将被转发至集群1的隧道网关节点,集群1隧道网关将该流量转发到目的集群2的隧道网关,集群2的隧道网关又将流量转发到service2,请求处理完成后,响应的数据包将原路返回。When pod1 of cluster 1 accesses service2 of cluster 2 through the IP connection of "service2.default.service.clusterset.local" domain name resolution, the request packet will be forwarded to the tunnel gateway node of cluster 1, and the tunnel gateway of cluster 1 will send the The traffic is forwarded to the tunnel gateway of the destination cluster 2, and the tunnel gateway of the cluster 2 forwards the traffic to service2. After the request processing is completed, the response data packet will be returned to the original route.

具体包括如下步骤:Specifically include the following steps:

(1):集群1的pod1通过DNS查询(1): pod1 of cluster 1 queries through DNS

“service2.default.service.clusterset.local”域名的ip,DNS查询请求被发送到CoreDNS。The ip of the "service2.default.service.clusterset.local" domain name, the DNS query request is sent to CoreDNS.

(2):CoreDNS解析“service2.default.service.cluster.local”域名,得到service2的ip。(2): CoreDNS resolves the "service2.default.service.cluster.local" domain name to obtain the ip of service2.

上述步骤(2)包括如下步骤:Above-mentioned step (2) comprises the steps:

(2.1):集群1的导航代理插件获取域名对应的Service;(2.1): The navigation proxy plug-in of cluster 1 obtains the Service corresponding to the domain name;

(2.2):通过步骤S5.3缓存的ServiceImport CR查询Service对应的ServiceImport的信息,如果没有成功暴露,返回NXDomain错误,如果成功暴露,通过步骤S5.3缓存的ServiceExport CR查询Service对应的ip信息,如果查询成功,返回ip,如果查询失败返回NXDomain错误;(2.2): Query the information of the ServiceImport corresponding to the Service through the ServiceImport CR cached in step S5.3. If it is not successfully exposed, an NXDomain error is returned. If it is successfully exposed, query the ip information corresponding to the Service through the ServiceExport CR cached in step S5.3. If the query is successful, return ip, if the query fails, return NXDomain error;

(3):根据步骤S6.2路由代理配置的规则,目的ip不在本集群,数据包将被转发到集群1的隧道网关节点。(3): According to the rules configured by the routing agent in step S6.2, if the destination IP is not in the cluster, the data packet will be forwarded to the tunnel gateway node of cluster 1.

(4):集群1隧道网关收到数据包时,将流量转发到与当前目的ip匹配的集群2的隧道网关。(4): When the tunnel gateway of cluster 1 receives the data packet, it forwards the traffic to the tunnel gateway of cluster 2 that matches the current destination IP.

上述步骤(4)包括如下步骤:Above-mentioned step (4) comprises the steps:

(4.1):通过步骤S3.3配置的集群和集群分配的CIDRs信息,查询到该ip对应的集群名字为集群2;(4.1): Through the cluster configured in step S3.3 and the CIDRs information allocated by the cluster, the cluster name corresponding to the ip is queried as cluster 2;

(4.2):通过Informer机制在集群中介中查询步骤S4.3在集群1中缓存的隧道网关CR,找到(4.1)查询的集群2对应的隧道网关CR;(4.2): query the tunnel gateway CR cached in the cluster 1 in step S4.3 through the Informer mechanism in the cluster intermediary, and find the tunnel gateway CR corresponding to the queried cluster 2 in (4.1);

(4.3):集群1与集群2由步骤S4.4和S4.5步骤所述已经建立连接,所以将当前数据包发往集群2的隧道网关;(4.3): Cluster 1 and cluster 2 have established connections as described in steps S4.4 and S4.5, so the current data packet is sent to the tunnel gateway of cluster 2;

(5):集群2隧道收到集群1发来的数据包时,检查当前数据包的目的IP是否属于集群2的CIDR块,若不属于,则拒绝;若属于,根据步骤S6.2所述创建的路由规则将流量转发到目的IP对应的service2。(5): When the cluster 2 tunnel receives the data packet sent by the cluster 1, it checks whether the destination IP of the current data packet belongs to the CIDR block of the cluster 2. If it does not belong to the CIDR block of the cluster 2, it will be rejected; The created routing rule forwards the traffic to service2 corresponding to the destination IP.

(6):当service2代理的Pod处理完请求后由service2发出响应数据包,如步骤(3)所述原理,响应数据包被转发到集群2隧道网关节点。(6): When the Pod of the service2 agent finishes processing the request, the service2 sends a response data packet. According to the principle described in step (3), the response data packet is forwarded to the cluster 2 tunnel gateway node.

(7):当集群2隧道网关收到数据包,根据步骤(4)所述原理,响应数据包被转发到与响应的数据包的目的ip匹配的集群1的隧道网关。(7): When the cluster 2 tunnel gateway receives the data packet, according to the principle described in step (4), the response data packet is forwarded to the cluster 1 tunnel gateway matching the destination IP of the response data packet.

(8):集群1隧道网关收到请求响应数据包时,根据步骤(5)所述原理,响应数据包被转发到与当前响应数据包目的ip匹配的pod1。(8): When the cluster 1 tunnel gateway receives the request response data packet, according to the principle described in step (5), the response data packet is forwarded to the pod1 that matches the destination ip of the current response data packet.

本发明实施例提供一种实现kubernetes服务跨集群通信的方法及系统,能够实现多集群编排,无感知跨集群通信;利用官方的设计“KEP-645”实现跨集群Service发现机制,增加通用性和可理解性;集群中介失败容忍度高,且失败不会影响到当前的跨集群服务间通信。The embodiments of the present invention provide a method and system for realizing cross-cluster communication of kubernetes services, which can realize multi-cluster arrangement and non-aware cross-cluster communication; use the official design "KEP-645" to realize cross-cluster service discovery mechanism, increase versatility and Comprehensibility; cluster intermediary failures are highly tolerant, and failures will not affect current inter-cluster inter-service communication.

本领域技术人员知道,除了以纯计算机可读程序代码方式实现本发明提供的系统及其各个装置、模块、单元以外,完全可以通过将方法步骤进行逻辑编程来使得本发明提供的系统及其各个装置、模块、单元以逻辑门、开关、专用集成电路、可编程逻辑控制器以及嵌入式微控制器等的形式来实现相同功能。所以,本发明提供的系统及其各项装置、模块、单元可以被认为是一种硬件部件,而对其内包括的用于实现各种功能的装置、模块、单元也可以视为硬件部件内的结构;也可以将用于实现各种功能的装置、模块、单元视为既可以是实现方法的软件模块又可以是硬件部件内的结构。Those skilled in the art know that, in addition to implementing the system provided by the present invention and its various devices, modules and units in the form of purely computer-readable program codes, the system provided by the present invention and its various devices can be implemented by logically programming the method steps. , modules, and units realize the same function in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, the system provided by the present invention and its various devices, modules and units can be regarded as a kind of hardware components, and the devices, modules and units included in it for realizing various functions can also be regarded as hardware components. The device, module and unit for realizing various functions can also be regarded as both a software module for realizing the method and a structure within a hardware component.

以上对本发明的具体实施例进行了描述。需要理解的是,本发明并不局限于上述特定实施方式,本领域技术人员可以在权利要求的范围内做出各种变化或修改,这并不影响本发明的实质内容。在不冲突的情况下,本申请的实施例和实施例中的特征可以任意相互组合。Specific embodiments of the present invention have been described above. It should be understood that the present invention is not limited to the above-mentioned specific embodiments, and those skilled in the art can make various changes or modifications within the scope of the claims, which do not affect the essential content of the present invention. The embodiments of the present application and features in the embodiments may be combined with each other arbitrarily, provided that there is no conflict.

Claims (10)

Translated fromChinese
1.一种实现kubernetes服务跨集群通信的方法,其特征在于,包括:1. a method for realizing kubernetes service cross-cluster communication, is characterized in that, comprises:部署步骤:为不同的集群分配不同的CIDR块,并选择一个集群部署集群中介,并为每一个集群部署网络隧道网关和导航代理,最后为每个集群的每个节点部署路由代理;Deployment steps: assign different CIDR blocks to different clusters, select a cluster to deploy a cluster intermediary, deploy a network tunnel gateway and a navigation agent for each cluster, and finally deploy a routing agent for each node of each cluster;工作步骤:相应部署完成后,网络隧道网关、导航代理和路由代理开始做准备工作:创建必要的CRDs,网络隧道网关通过集群中介互相发现并建立网络隧道,导航代理通过集群中介暴露自己所在集群的Services并获取其他集群的Services,路由代理通过Informer机制获取隧道网关设置的端点CR。Working steps: After the corresponding deployment is completed, the network tunnel gateway, navigation agent, and routing agent begin to prepare: create the necessary CRDs, the network tunnel gateway discovers each other through the cluster intermediary and establishes network tunnels, and the navigation agent exposes its own cluster through the cluster intermediary. Services and obtain the services of other clusters, and the routing agent obtains the endpoint CR set by the tunnel gateway through the Informer mechanism.2.根据权利要求1所述的实现kubernetes服务跨集群通信的方法,其特征在于,所述部署步骤中选择一个集群部署集群中介具体包括:2. the method for realizing kubernetes service cross-cluster communication according to claim 1, is characterized in that, in described deployment step, selecting a cluster to deploy the cluster intermediary specifically comprises:步骤S1.1:创建集群CRD,包含:Step S1.1: Create a cluster CRD, including:cluster_cidr数组:不同集群分配的CIDRs;cluster_cidr array: CIDRs allocated by different clusters;name:集群名字;name: cluster name;service_cidr数组:每个集群分配的service、pod的CIDRs;service_cidr array: CIDRs of services and pods allocated by each cluster;步骤S1.2:创建隧道网关端点CRD,包含:Step S1.2: Create a tunnel gateway endpoint CRD, including:name:集群名字;name: cluster name;private_ip:集群内ip;private_ip: ip in the cluster;public_ip:供其他集群隧道网关访问的ip;public_ip: the ip for other cluster tunnel gateways to access;步骤S1.3:配置ServiceAccount和RBAC规则,以供其他集群安全访问。Step S1.3: Configure ServiceAccount and RBAC rules for secure access by other clusters.3.根据权利要求1所述的实现kubernetes服务跨集群通信的方法,其特征在于,所述部署步骤中为每一个集群部署网络隧道网关具体包括:3. the method for realizing kubernetes service cross-cluster communication according to claim 1, is characterized in that, in described deployment step, for each cluster deployment network tunnel gateway specifically comprises:步骤S2.1:每个集群选择两个节点分别作为主/从节点;Step S2.1: Each cluster selects two nodes as master/slave nodes;步骤S2.2:配置访问集群中介K8s API的ServiceAccount和访问地址。Step S2.2: Configure the ServiceAccount and access address for accessing the cluster broker K8s API.4.根据权利要求1所述的实现kubernetes服务跨集群通信的方法,其特征在于,所述部署步骤中为每一个集群部署导航代理包括:4. the method for realizing kubernetes service cross-cluster communication according to claim 1, is characterized in that, in described deployment step, for each cluster deployment navigation agent comprises:步骤S3.1:创建集群ServiceExport CRD,包含:Step S3.1: Create a cluster ServiceExport CRD, including:name和namespace:为service的名字和命名空间,包含在默认的metadata中;name and namespace: the name and namespace of the service, included in the default metadata;status:为service导出状态,包括成功和失败;status: export status for service, including success and failure;步骤S3.2:创建集群ServiceImport CRD,包含:Step S3.2: Create a cluster ServiceImport CRD, including:name和namespace:service的名字和命名空间,包含在默认的metadata中;name and namespace: the name and namespace of the service, included in the default metadata;ports数组:暴露的端口列表;ports array: list of exposed ports;ips数组:ip列表;ips array: ip list;步骤S3.3:部署导航代理组件到节点上,将每个集群的CIDR信息和集群名字映射关系通过配置文件进行配置;Step S3.3: deploy the navigation agent component to the node, and configure the CIDR information of each cluster and the cluster name mapping relationship through the configuration file;步骤S3.4:部署导航代理CoreDNS插件,配置CoreDNS将clusterset.local域名的DNS请求转发至插件。Step S3.4: Deploy the navigation proxy CoreDNS plug-in, and configure CoreDNS to forward DNS requests for the clusterset.local domain name to the plug-in.5.根据权利要求1所述的实现kubernetes服务跨集群通信的方法,其特征在于,所述工作步骤中隧道网关部署后开始做准备工作包括:5. the method for realizing kubernetes service cross-cluster communication according to claim 1, is characterized in that, in described working step, after tunnel gateway is deployed, begin to do preparatory work and comprise:步骤S4.1:从节点定时通过网络连接向主节点发送心跳数据包,当发现主节点失去响应,则认为主节点出现故障,将自己切换为主节点,继续工作;Step S4.1: The slave node regularly sends a heartbeat data packet to the master node through the network connection. When it is found that the master node fails to respond, it is considered that the master node is faulty, and it switches itself to the master node and continues to work;步骤S4.2:隧道网关将自己集群的集群信息CR和隧道网关信息CR在集群中介中创建;Step S4.2: the tunnel gateway creates the cluster information CR of its own cluster and the tunnel gateway information CR in the cluster intermediary;步骤S4.3:隧道网关通过informer机制查询并实时获取其他节点的集群CR和隧道网关CR,并缓存到当前集群的ETCD中;Step S4.3: The tunnel gateway queries and obtains the cluster CR and tunnel gateway CR of other nodes in real time through the informer mechanism, and caches them in the ETCD of the current cluster;步骤S4.4:当隧道网关获取到其他集群的隧道网关端点CR创建事件,则从中获取隧道网关的public_ip字段值,并尝试建立网络连接,如果失败,稍后重试连接;Step S4.4: When the tunnel gateway obtains the creation event of the tunnel gateway endpoint CR of other clusters, it obtains the public_ip field value of the tunnel gateway from it, and tries to establish a network connection, and if it fails, retry the connection later;步骤S4.5:当集群隧道网关收到其他集群隧道网关创建连接时,从自己集群的缓存中查询创建连接的集群隧道,如果查询到,则完成连接创建,如果未查询到,则拒绝连接。Step S4.5: When the cluster tunnel gateway receives a connection created by another cluster tunnel gateway, it queries the cluster tunnel for which the connection is created from the cache of its own cluster. If the query is found, the connection creation is completed, and if the query is not found, the connection is rejected.6.根据权利要求1所述的实现kubernetes服务跨集群通信的方法,其特征在于,所述工作步骤中导航代理开始做准备工作包括:6. the method for realizing kubernetes service cross-cluster communication according to claim 1, is characterized in that, in described work step, navigation agent starts to do preparatory work and comprises:步骤S5.1:通过K8s API调用在集群中介中给每一个需要暴露给其他集群的Service创建ServiceExport CR,让其他集群得知当前集群有哪些Service能够供其他集群访问;Step S5.1: Create a ServiceExport CR for each Service that needs to be exposed to other clusters in the cluster intermediary through K8s API calls, so that other clusters know which services in the current cluster can be accessed by other clusters;步骤S5.2:通过K8s API调用在集群中介中为每个创建的ServiceExport都创建对应的ServiceImport CR,让其他集群得知当前集群暴露的Service的ip和端口在内的相关信息;Step S5.2: Create a corresponding ServiceImport CR for each created ServiceExport through the K8s API call in the cluster intermediary, so that other clusters can know the relevant information including the ip and port of the Service exposed by the current cluster;步骤S5.3:通过Informer机制,持续获取ServiceImport和ServiceExport,并通过本集群K8s API将ServiceImport缓存在ETCD中。Step S5.3: Continuously obtain ServiceImport and ServiceExport through the Informer mechanism, and cache the ServiceImport in the ETCD through the K8s API of the cluster.7.根据权利要求1所述的实现kubernetes服务跨集群通信的方法,其特征在于,所述工作步骤中路由代理开始做准备工作包括:7. the method for realizing kubernetes service cross-cluster communication according to claim 1, is characterized in that, in described work step, routing agent starts to do preparatory work and comprises:步骤S6.1:路由代理通过Informer机制获取隧道网关设置的端点CR,进而获取当前集群的隧道网关的IP地址;Step S6.1: the routing agent obtains the endpoint CR set by the tunnel gateway through the Informer mechanism, and then obtains the IP address of the tunnel gateway of the current cluster;步骤S6.2:路由代理通过CNI插件将跨集群的流量路发送到隧道网关,隧道网关再将流量发送到对应的集群隧道网关,相反,从隧道网关出来的流量会根据流量数据包的目的IP发往不同的节点。Step S6.2: The routing agent sends the cross-cluster traffic to the tunnel gateway through the CNI plug-in, and the tunnel gateway sends the traffic to the corresponding cluster tunnel gateway. On the contrary, the traffic from the tunnel gateway will be based on the destination IP of the traffic packet. sent to different nodes.8.一种实现kubernetes服务跨集群通信的系统,其特征在于,包括:8. A system for realizing kubernetes service cross-cluster communication, characterized in that, comprising:部署模块:为不同的集群分配不同的CIDRs,并选择一个集群部署集群中介,并为每一个集群部署网络隧道网关和导航代理,最后为每个集群的每个节点部署路由代理;Deployment module: assign different CIDRs to different clusters, select a cluster to deploy a cluster intermediary, deploy a network tunnel gateway and navigation proxy for each cluster, and finally deploy a routing proxy for each node of each cluster;工作模块:相应部署完成后,网络隧道网关、导航代理和路由代理开始做准备工作:创建必要的CRDs,网络隧道网关通过集群中介互相发现并建立网络隧道,导航代理通过集群中介暴露自己所在集群的Services并获取其他集群的Services,路由代理通过Informer机制获取隧道网关设置的端点CR。Working module: After the corresponding deployment is completed, the network tunnel gateway, navigation agent and routing agent begin to prepare: create the necessary CRDs, the network tunnel gateway discovers each other through the cluster intermediary and establishes network tunnels, and the navigation agent exposes the information of the cluster where it is located through the cluster intermediary. Services and obtain the services of other clusters, and the routing agent obtains the endpoint CR set by the tunnel gateway through the Informer mechanism.9.根据权利要求6所述的实现kubernetes服务跨集群通信的系统,其特征在于,所述部署模块中选择一个集群部署集群中介具体包括:9. the system that realizes kubernetes service cross-cluster communication according to claim 6, it is characterised in that selecting a cluster deployment cluster intermediary in the described deployment module specifically comprises:模块M1.1:创建集群CRD,包含:Module M1.1: Create a cluster CRD, containing:cluster_cidr(数组):不同集群分配的CIDRs;cluster_cidr (array): CIDRs allocated by different clusters;name:集群名字;name: cluster name;service_cidr(数组):每个集群分配的service、pod的CIDRs;service_cidr (array): CIDRs of services and pods allocated by each cluster;模块M1.2:创建隧道网关端点CRD,包含:Module M1.2: Create Tunnel Gateway Endpoint CRD, containing:name:集群名字;name: cluster name;private_ip:集群内ip;private_ip: ip in the cluster;public_ip:供其他集群隧道网关访问的ip;public_ip: the ip for other cluster tunnel gateways to access;模块M1.3:配置ServiceAccount和RBAC规则,以供其他集群安全访问。Module M1.3: Configure ServiceAccount and RBAC rules for secure access by other clusters.10.根据权利要求6所述的实现kubernetes服务跨集群通信的系统,其特征在于,所述部署步骤中为每一个集群部署网络隧道网关具体包括:10. the system for realizing kubernetes service cross-cluster communication according to claim 6, is characterized in that, in the described deployment step, for each cluster deployment network tunnel gateway specifically comprises:模块M2.1:每个集群选择两个节点分别作为主/从节点;Module M2.1: Each cluster selects two nodes as master/slave nodes;模块M2.2:配置访问集群中介K8s API的ServiceAccount和访问地址。Module M2.2: Configure the ServiceAccount and access address for accessing the K8s API of the cluster intermediary.
CN202210504839.3A2022-05-102022-05-10Method and system for realizing kubernets service cross-cluster communicationPendingCN115086312A (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202210504839.3ACN115086312A (en)2022-05-102022-05-10Method and system for realizing kubernets service cross-cluster communication

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202210504839.3ACN115086312A (en)2022-05-102022-05-10Method and system for realizing kubernets service cross-cluster communication

Publications (1)

Publication NumberPublication Date
CN115086312Atrue CN115086312A (en)2022-09-20

Family

ID=83247462

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202210504839.3APendingCN115086312A (en)2022-05-102022-05-10Method and system for realizing kubernets service cross-cluster communication

Country Status (1)

CountryLink
CN (1)CN115086312A (en)

Cited By (11)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN115242877A (en)*2022-09-212022-10-25之江实验室 Spark collaborative computing, operation method and device for multi-K8s cluster
CN115567529A (en)*2022-09-282023-01-03联想(北京)有限公司 Heterogeneous edge network communication method and device
CN115664967A (en)*2022-10-212023-01-31济南浪潮数据技术有限公司Cross-cluster network management strategy deployment method, device, equipment and medium
CN115767786A (en)*2022-11-022023-03-07中国农业银行股份有限公司Multi-cluster communication method and device, electronic equipment and storage medium
CN115883563A (en)*2022-12-302023-03-31天翼云科技有限公司 A communication method, platform and system
CN116389484A (en)*2023-04-262023-07-04奥特酷智能科技(南京)有限公司 Cross-Kubernetes cluster network intercommunication system and method based on data distribution service
CN116896499A (en)*2023-06-122023-10-17中国铁道科学研究院集团有限公司电子计算技术研究所kubernetes Pod network error checking system and method
US11954525B1 (en)2022-09-212024-04-09Zhejiang LabMethod and apparatus of executing collaborative job for spark faced to multiple K8s clusters
CN117978406A (en)*2024-02-202024-05-03国网江苏省电力有限公司信息通信分公司Heterogeneous multi-container cluster scheduling method, system, equipment and storage medium
CN119743485A (en)*2025-03-042025-04-01中国人民解放军国防科技大学 A method for dynamically assembling a federated peer-to-peer cluster network in an edge environment
CN120321039A (en)*2025-06-162025-07-15复旦大学 A cross-cluster device access system and method suitable for edge computing environment

Citations (6)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN111885123A (en)*2020-07-062020-11-03苏州浪潮智能科技有限公司Construction method and device of cross-K8 s target service access channel
CN112751913A (en)*2020-12-222021-05-04联奕科技股份有限公司Network communication method and system across Kubernetes cluster
US20210311762A1 (en)*2020-04-022021-10-07Vmware, Inc.Guest cluster deployed as virtual extension of management cluster in a virtualized computing system
CN113572689A (en)*2021-09-242021-10-29深圳市信润富联数字科技有限公司Microservice gateway management method, system, device, readable storage medium and product
CN114153566A (en)*2021-12-202022-03-08浪潮电子信息产业股份有限公司 Cross-processor architecture multi-container inter-cluster service discovery method, apparatus and device
CN114443059A (en)*2020-10-302022-05-06中国联合网络通信集团有限公司 Deployment method, device and equipment of Kubernetes cluster

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
US20210311762A1 (en)*2020-04-022021-10-07Vmware, Inc.Guest cluster deployed as virtual extension of management cluster in a virtualized computing system
CN111885123A (en)*2020-07-062020-11-03苏州浪潮智能科技有限公司Construction method and device of cross-K8 s target service access channel
CN114443059A (en)*2020-10-302022-05-06中国联合网络通信集团有限公司 Deployment method, device and equipment of Kubernetes cluster
CN112751913A (en)*2020-12-222021-05-04联奕科技股份有限公司Network communication method and system across Kubernetes cluster
CN113572689A (en)*2021-09-242021-10-29深圳市信润富联数字科技有限公司Microservice gateway management method, system, device, readable storage medium and product
CN114153566A (en)*2021-12-202022-03-08浪潮电子信息产业股份有限公司 Cross-processor architecture multi-container inter-cluster service discovery method, apparatus and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
良凯尔: ""K8S client-go源码分析informer源码分析(1)-概要分析"", Retrieved from the Internet <URL:https://blog.csdn.net/kyle18826138721/article/details/124208952>*

Cited By (14)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
US11954525B1 (en)2022-09-212024-04-09Zhejiang LabMethod and apparatus of executing collaborative job for spark faced to multiple K8s clusters
CN115242877B (en)*2022-09-212023-01-24之江实验室Spark collaborative computing and operating method and device for multiple K8s clusters
CN115242877A (en)*2022-09-212022-10-25之江实验室 Spark collaborative computing, operation method and device for multi-K8s cluster
CN115567529A (en)*2022-09-282023-01-03联想(北京)有限公司 Heterogeneous edge network communication method and device
CN115664967A (en)*2022-10-212023-01-31济南浪潮数据技术有限公司Cross-cluster network management strategy deployment method, device, equipment and medium
CN115767786A (en)*2022-11-022023-03-07中国农业银行股份有限公司Multi-cluster communication method and device, electronic equipment and storage medium
CN115883563A (en)*2022-12-302023-03-31天翼云科技有限公司 A communication method, platform and system
CN116389484A (en)*2023-04-262023-07-04奥特酷智能科技(南京)有限公司 Cross-Kubernetes cluster network intercommunication system and method based on data distribution service
CN116896499A (en)*2023-06-122023-10-17中国铁道科学研究院集团有限公司电子计算技术研究所kubernetes Pod network error checking system and method
CN116896499B (en)*2023-06-122024-03-19中国铁道科学研究院集团有限公司电子计算技术研究所kubernetes Pod network error checking system and method
CN117978406A (en)*2024-02-202024-05-03国网江苏省电力有限公司信息通信分公司Heterogeneous multi-container cluster scheduling method, system, equipment and storage medium
CN117978406B (en)*2024-02-202024-07-19国网江苏省电力有限公司信息通信分公司Heterogeneous multi-container cluster scheduling method, system, equipment and storage medium
CN119743485A (en)*2025-03-042025-04-01中国人民解放军国防科技大学 A method for dynamically assembling a federated peer-to-peer cluster network in an edge environment
CN120321039A (en)*2025-06-162025-07-15复旦大学 A cross-cluster device access system and method suitable for edge computing environment

Similar Documents

PublicationPublication DateTitle
CN115086312A (en)Method and system for realizing kubernets service cross-cluster communication
US12238165B2 (en)Automated configuration change of virtual machines in a computing node group
CN107947961B (en)SDN-based Kubernetes network management system and method
CN108650182B (en)Network communication method, system, device, equipment and storage medium
CN108449197B (en) A method for building multi-cloud environment network based on software-defined network
CN113572831B (en)Communication method, computer equipment and medium between Kubernetes clusters
CN113268308A (en)Information processing method, device and storage medium
CN112491984B (en) Container orchestration engine cluster management system based on virtual bridge
CN113301116A (en)Cross-network communication method, device, system and equipment for microservice application
CN116132542B (en) Container network management method, container network plug-in and related equipment
CN114501593B (en)Network slice access method, device, system and storage medium
CN112165502B (en)Service discovery system, method and second server
WO2020057445A1 (en)Communication system, method, and device
CN115604120A (en)Multi-cloud cluster resource sharing method, device, equipment and storage medium
CN115379010A (en) A container network construction method, device, equipment and storage medium
CN114979262B (en)Access method and system
CN115842825B (en) Cloud service platform, cloud service deployment method and device
CN114466011B (en)Metadata service request method, device, equipment and medium
CN115776518A (en) An Accelerated Access System for Foreign Electronic Literature Resources
CN112073449B (en)Kubernetes-based environment switching processing method and equipment
CN112073358B (en)Protocol conversion processing method and device based on Kubernetes
WO2025010985A1 (en)Service governance method and apparatus, and computer-readable storage medium
CN118413471A (en) Routing management method, device, equipment, storage medium and program product
WO2025180205A1 (en)Terminal auto-discovery method, forwarding device, and readable storage medium
CN116781730A (en) A storage management method, device, management equipment and readable storage medium

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
RJ01Rejection of invention patent application after publication

Application publication date:20220920

RJ01Rejection of invention patent application after publication

[8]ページ先頭

©2009-2025 Movatter.jp