Multi-cluster service gateway fusion method and device and electronic equipment

CN116866365BActive Publication Date: 2026-08-28QIZHI TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310918691.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-25
Publication Date
2026-08-28
Estimated Expiration
2043-07-25

AI Technical Summary

Benefits of technology

1、由于采用了在容器编排集群中设置Consul集群,将应用程序调度和管理集群的管理调度服务同步至Consul集群,并且在容器编排集群中配置网关管理工具,将网关管理工具与Consul集群进行集成处理,以及对网关管理工具进行路由配置的技术手段,所以,能够将多种服务在同一服务网关上管理和注册,实现多服务网关的融合,提高服务的可用性和安全性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116866365B_ABST
    Figure CN116866365B_ABST
Patent Text Reader

Abstract

The embodiment of the application provides a multi-cluster service gateway fusion method and device and electronic equipment, and relates to the field of communication. The method first installs a Consul cluster; synchronizes Consul services of the Consul cluster in a preset container orchestration cluster; configures the Consul cluster in a preset application program scheduling and management cluster, and synchronizes management scheduling services of the application program scheduling and management cluster to the Consul cluster; configures a preset gateway management tool in the preset container orchestration cluster, and integrates the gateway management tool with the Consul cluster; performs rule configuration based on the gateway management tool to obtain routing rules; and matches the routing rules with access requests obtained through an external service access mode to provide services corresponding to the access requests. The embodiment of the application can realize registration and management of different services on the same service gateway, and guarantees the availability and security of application programs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communication technology, specifically to a method, apparatus, and electronic device for merging multi-cluster service gateways. Background Technology

[0002] With the increasing prevalence of cloud computing and microservice architectures, enterprise service platforms are gradually evolving into complex systems with multiple services. Different services may reside at different network layers, using different ports and protocols. For example, Kubernetes clusters (k8s) and Nomad clusters are widely adopted container platforms, and Nomad and Kubernetes clusters employ different gateways and service registration and discovery mechanisms. When merging a Nomad cluster into a Kubernetes cluster, the issue of merging the gateways of the two systems arises. In this context, ensuring the high availability of applications is a pressing issue that needs to be addressed. Summary of the Invention

[0003] This application provides a method, apparatus, electronic device, and readable storage medium for merging multi-cluster service gateways, which enables different services to be registered and managed on the same service gateway, ensuring the availability and security of applications.

[0004] Firstly, this application provides a method for merging multi-cluster service gateways, the method comprising: Install a Consul cluster; Synchronize the Consul service of the Consul cluster in the preset container orchestration cluster, and set the service of the container orchestration cluster to external service access mode. Configure the Consul cluster in the preset application scheduling and management cluster, and synchronize the management scheduling service of the application scheduling and management cluster to the Consul cluster; Configure a preset gateway management tool in the preset container orchestration cluster, and integrate the gateway management tool with the Consul cluster. Based on the gateway management tool, rule configuration is performed to obtain routing rules; The routing rules are matched with the access requests obtained through the external service access mode to provide the service corresponding to the access request.

[0005] In the above scheme, firstly, a Consul cluster is installed; then, the Consul service of the Consul cluster is synchronized in a preset container orchestration cluster, and the services of the container orchestration cluster are set to external service access mode. The Consul cluster is configured in the container orchestration cluster to facilitate the subsequent integration of multiple service gateways; a Consul cluster is configured in a preset application scheduling and management cluster, and the management and scheduling services of the application scheduling and management cluster are synchronized to the Consul cluster. Configuring the Consul cluster in the application scheduling and management cluster facilitates the subsequent integration of multiple service gateways; a preset gateway management tool is configured in the preset container orchestration cluster, and the gateway management tool is integrated with the Consul cluster. By combining the gateway management tool with the Consul cluster, different services can be registered to the same service gateway; based on the gateway management tool, rules are configured to obtain routing rules, enabling the registration and management of various services on the same service gateway, improving the integration and unified management capabilities of services; the routing rules are matched with access requests obtained through the external service access mode to provide services corresponding to the access requests, ensuring high availability and security of applications. This application embodiment achieves the integration of multiple service gateways by registering different services to the Consul cluster and combining the Consul cluster with gateway management tools, thereby improving service availability and security.

[0006] In some embodiments of this application, the routing rules include rules for the container orchestration cluster and rules for the application scheduling and management cluster; The routing rules are obtained by configuring rules based on the gateway management tool, including: Based on the gateway management tool, a routing configuration file is created, and the routing configuration of the container orchestration cluster is added to the routing configuration file to obtain the rules of the container orchestration cluster; Add the routing configuration for the application scheduling and management cluster to the routing configuration file to obtain the rules for the application scheduling and management cluster.

[0007] In the above scheme, by using a Consul cluster as the service registration and discovery center and then configuring routing, automatic service discovery and failover can be achieved, which greatly improves service availability and security.

[0008] In some embodiments of this application, the routing rules are matched with access requests obtained through the external service access pattern to provide services corresponding to the access requests, including: The rules of the container orchestration cluster are prefixed using a pre-defined middleware to obtain the first service address corresponding to the container orchestration cluster. Prefix clearing is performed on the rules of the application scheduling and management cluster using preset middleware to obtain a second service address corresponding to the application scheduling and management cluster; The access request is matched with the first service address and the second service address respectively to provide the service corresponding to the access request.

[0009] In the above scheme, prefix clearing through middleware can provide services corresponding to access requests, enabling correct routing of requests among different services.

[0010] In some embodiments of this application, synchronizing the Consul service of the Consul cluster in a preset container orchestration cluster includes: Create a Consul namespace in the preset container orchestration cluster, and deploy the Consul service in the Consul namespace; Create a Consul service resource file and configure the port of the Consul service in the Consul service resource file; Create an application file for the Consul service, and associate the Consul service with the application file based on the port of the Consul service; Synchronize the Consul service resource files and the application files in the container orchestration cluster.

[0011] In the above solution, the Consul service is deployed and synchronized in the container orchestration cluster, which allows other applications to easily integrate with Consul, so as to achieve the convergence of multiple service gateways on the container orchestration cluster.

[0012] In some embodiments of this application, configuring the Consul cluster in a preset application scheduling and management cluster, and synchronizing the management scheduling service of the application scheduling and management cluster to the Consul cluster, includes: Obtain the scheduling configuration file of the application scheduling and management cluster, and add the address of the Consul cluster and the access identifier of the Consul cluster to the scheduling configuration file; Based on the address of the Consul cluster and the access identifier, the management scheduling service is synchronized to the Consul cluster.

[0013] In the above scheme, a Consul cluster is configured in the preset application scheduling and management cluster so that the Consul cluster can be used as a service registration and discovery center, which facilitates the subsequent integration of different service gateways.

[0014] In some embodiments of this application, installing the Consul cluster includes: Install the Consul cluster in the container orchestration cluster, or, Install the Consul cluster on a predetermined odd number of bare metal machines.

[0015] In the above scheme, installing a Consul cluster can provide support for configuring Consul services in subsequent clusters, so as to realize the registration platform for multiple different services and the discovery of different services.

[0016] In some embodiments of this application, the external service access mode is either Nodeport mode or LoadBalancer mode.

[0017] In the above scheme, the Nodeport mode or LoadBalancer mode allows external traffic to be imported into the cluster, enabling other applications within the cluster to access the services in the cluster.

[0018] Secondly, embodiments of this application provide a multi-cluster service gateway fusion device, characterized in that the device comprises: The software installation module is used to install a Consul cluster. The first configuration module is used to synchronize the Consul service of the Consul cluster in the preset container orchestration cluster, and set the service of the container orchestration cluster to external service access mode. The second configuration module is used to configure the Consul cluster in the preset application scheduling and management cluster, and to synchronize the management scheduling service of the application scheduling and management cluster to the Consul cluster. The third configuration module is used to configure a preset gateway management tool in a preset container orchestration cluster and integrate the gateway management tool with the Consul cluster. The rule configuration module is used to configure rules based on the gateway management tool to obtain routing rules; The access settings module is used to match the routing rules with the access requests obtained through the external service access mode, so as to provide the service corresponding to the access request.

[0019] Thirdly, embodiments of this application provide an electronic device, including a processor, a memory, a user interface, and a network interface. The memory is used to store instructions, the user interface and the network interface are used to communicate with other devices, and the processor is used to execute the instructions stored in the memory to cause the electronic device to perform any of the methods provided in the first aspect above.

[0020] Fourthly, embodiments of this application provide a computer-readable storage medium storing instructions that, when executed, perform the method described in any one of the methods provided in the first aspect above.

[0021] In summary, one or more technical solutions provided in the embodiments of this application have at least the following technical effects or advantages: 1. By using the technology of setting up a Consul cluster in the container orchestration cluster, synchronizing the application scheduling and management scheduling services of the management cluster to the Consul cluster, configuring gateway management tools in the container orchestration cluster, integrating the gateway management tools with the Consul cluster, and configuring routing for the gateway management tools, it is possible to manage and register multiple services on the same service gateway, realize the integration of multiple service gateways, and improve the availability and security of services.

[0022] 2. By combining the Consul cluster with gateway management tools, multiple services can be managed in a unified manner, simplifying service management and operation. Attached Figure Description

[0023] Figure 1 This is a flowchart illustrating a multi-cluster service gateway fusion method provided in one embodiment of this application; Figure 2 yes Figure 1 A flowchart illustrating a sub-step of step S200; Figure 3 yes Figure 1 A flowchart illustrating a sub-step of step S300; Figure 4 yes Figure 1 A flowchart illustrating a sub-step of step S500; Figure 5 yes Figure 1 A flowchart illustrating a sub-step of step S600; Figure 6 This is a schematic diagram of the structure of a multi-cluster service gateway fusion device provided in one embodiment of this application; Figure 7 This is a schematic diagram of the structure of an electronic device provided in one embodiment of this application. Detailed Implementation

[0024] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments.

[0025] In the description of the embodiments of this application, the words "for example" or "for instance" are used to indicate examples, illustrations, or explanations. Any embodiment or design that is described as "for example" or "for instance" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design options. Rather, the use of the words "for example" or "for instance" is intended to present the relevant concepts in a specific manner.

[0026] In the description of the embodiments of this application, the term "multiple" means two or more. For example, multiple systems means two or more systems, and multiple screen terminals means two or more screen terminals. Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the indicated technical features. Thus, a feature defined with "first" or "second" may explicitly or implicitly include one or more of that feature. The terms "comprising," "including," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.

[0027] In related technologies, Nomad clusters and Kubernetes clusters use different gateways and different service registration and discovery mechanisms. When migrating a Nomad cluster to a Kubernetes cluster, it is necessary to consider the interaction and management issues between different services, as well as the integration and management issues of service gateways, which presents a migration difficulty problem.

[0028] Based on this, embodiments of this application provide a method, apparatus, electronic device, and readable storage medium for merging multi-cluster service gateways. The method first installs a Consul cluster; synchronizes the Consul service of the Consul cluster in a preset container orchestration cluster, and sets the services of the container orchestration cluster to external service access mode; configures the Consul cluster in the container orchestration cluster so that subsequent merging of multiple service gateways can be achieved through the Consul cluster; configures the Consul cluster in a preset application scheduling and management cluster, and synchronizes the management and scheduling services of the application scheduling and management cluster to the Consul cluster; and then... Configuring a Consul cluster facilitates the subsequent integration of multiple service gateways. A pre-defined gateway management tool is configured within the pre-defined container orchestration cluster, and integrated with the Consul cluster. This integration allows different services to be registered to the same service gateway. Routing rules are configured based on the gateway management tool, enabling the registration and management of various services on the same service gateway, thus improving service integration and unified management capabilities. Matching the routing rules with access requests obtained through external service access patterns provides the corresponding services, ensuring high availability and security of the application. This embodiment of the application, by registering different services to the Consul cluster and integrating the Consul cluster with the gateway management tool, enables the integration of multiple service gateways, improving service availability and security.

[0029] It should be noted that this multi-cluster service gateway fusion method is applied to the fusion of gateways for Kubernetes clusters and Nomad clusters, as well as the fusion of gateways for different container orchestration clusters and application scheduling and management clusters. It can manage and register multiple services on the same service gateway, realize the fusion of multiple service gateways, and improve the availability and security of services.

[0030] The technical solutions provided in the embodiments of this application will be further described below with reference to the accompanying drawings.

[0031] Reference Figure 1 , Figure 1 This is a flowchart illustrating the multi-cluster service gateway fusion method provided in this application embodiment. The multi-cluster service gateway fusion method includes steps S100, S200, S300, S400, S500, and S600.

[0032] Step S100: Install Consul cluster.

[0033] In some embodiments, before installing the Consul cluster, first download the Consul cluster installation file from the address provided in the official Consul documentation, obtain the downloaded installation file, and then install it. The Consul cluster can be installed in a container orchestration cluster or on a preset odd number of bare metal machines. Installing the Consul cluster provides a registration platform for multiple different services and enables the discovery of different services. The container orchestration cluster is a Kubernetes cluster, and the preset odd number of bare metal machines is an odd number of bare metal machines greater than 3, which can be 5 or 7, depending on the requirements; details are not elaborated here.

[0034] Step S200: Synchronize the Consul service of the Consul cluster in the preset container orchestration cluster, and set the service of the container orchestration cluster to external service access mode.

[0035] In some embodiments, the Consul service of the Consul cluster is synchronized in a preset container orchestration cluster, exposing the services of the container orchestration cluster in either Nodeport or LoadBalancer mode. Deploying and synchronizing the Consul service in the container orchestration cluster allows other applications to easily integrate with Consul, enabling the convergence of multiple service gateways on the container orchestration cluster.

[0036] like Figure 2 As shown, synchronizing the Consul service of the Consul cluster in a preset container orchestration cluster includes, but is not limited to, the following steps: Step S210: Create a Consul namespace in the preset container orchestration cluster, and deploy the Consul service in the Consul namespace.

[0037] In some possible embodiments of this application, a Consul cluster is first configured in a container orchestration cluster, and then a Consul namespace is created in the container orchestration cluster. This Consul namespace is used to deploy Consul services and related resources, thus allowing Consul services to be deployed within the Consul namespace. By first creating a space for deploying the Consul cluster, and then subsequently deploying and synchronizing the Consul cluster in the container orchestration cluster, the Consul cluster can be implemented as a service registration and discovery center. This solves the service registration and discovery problem, making service invocation and registration simpler and more convenient.

[0038] Step S220: Create a Consul service resource file and configure the Consul service port in the Consul service resource file.

[0039] In some possible embodiments of this application, the Consul service is deployed in step S210, and then a Consul service resource file is created. For example, the Consul service resource file is a Consul-service.yaml configuration file. Subsequently, the port of the Consul service is configured in this file. Specifically, a Service resource named Consul is defined, set to Transmission Control Protocol (TCP) and port 8500, and TCP traffic is directed to Consul's port 8500 for communication.

[0040] Step S230: Create an application file for the Consul service and associate the Consul service with the application file based on the port of the Consul service.

[0041] In some possible embodiments of this application, based on the configuration of steps S210 and S220 above, an application file for the Consul service is created. The application can be defined using a Deployment or a StatefulSet. For example, a Deployment configuration file for the Consul service is created, which can be named Consul-deployment.yaml. Defining the Consul Deployment resource in this application file will create three Pods, each using the latest version of the Consul image, and exposing container port 8500 to provide access.

[0042] Step S240: Synchronize Consul service resource files and application files in the container orchestration cluster.

[0043] In some possible embodiments of this application, Consul service resource files and application files are synchronized in the container orchestration cluster, enabling the container orchestration cluster to register and discover within the Consul cluster. The kubectl command can be used to deploy and synchronize the Consul service resource files and application files to the container orchestration cluster. The container orchestration cluster will automatically deploy three Consul Pods, completing the deployment of the Consul service within the container orchestration cluster.

[0044] Step S300: Configure the Consul cluster in the preset application scheduling and management cluster, and synchronize the management scheduling service of the application scheduling and management cluster to the Consul cluster.

[0045] In some embodiments, to enable the Nomad cluster to migrate to a Kubernetes cluster, a Consul cluster is configured in a pre-defined application scheduling and management cluster, and the management scheduling service of the application scheduling and management cluster is synchronized to the Consul cluster to facilitate the subsequent integration of different service gateways. The application scheduling and management cluster is a Nomad cluster.

[0046] like Figure 3 As shown, configuring a Consul cluster in a preset application scheduling and management cluster, and synchronizing the management scheduling service of the application scheduling and management cluster to the Consul cluster, includes, but is not limited to, the following steps: Step S310: Obtain the scheduling configuration file for the application scheduling and management cluster, and add the address of the Consul cluster and the access identifier of the Consul cluster to the scheduling configuration file.

[0047] In some possible embodiments of this application, before obtaining the scheduling configuration file for the application scheduling and management cluster, the Consul cluster is installed and configured on each node of the application scheduling and management cluster. Installation can be performed according to the instructions in the official Consul documentation, ensuring that Consul runs on each node and that all nodes can communicate with each other. The scheduling configuration file for the application scheduling and management cluster is then obtained and configured. On each node of the application scheduling and management cluster, the aforementioned scheduling configuration file is edited, adding the address of the Consul cluster and the access identifier for the Consul cluster. The access identifier for the Consul cluster includes information such as the client service name and the server service name.

[0048] Step S320: Synchronize the management scheduling service to the Consul cluster based on the Consul cluster's address and access identifier.

[0049] In some possible embodiments of this application, based on the Consul cluster address and access identifier information configured in step S310, the Nomad service is started on each node of the application scheduling and management cluster. The application scheduling and management cluster will use Consul as the backend for service discovery and health checks, and work in conjunction with the Consul cluster to synchronize the management scheduling service to the Consul cluster. After the above configuration, the application scheduling and management cluster will use Consul for service discovery and automatically join the Consul cluster.

[0050] Step S400: Configure a preset gateway management tool in the preset container orchestration cluster, and integrate the gateway management tool with the Consul cluster.

[0051] In some embodiments, before configuring a preset gateway management tool in a preset container orchestration cluster, the gateway management tool is installed in the container orchestration cluster, or installed on other bare metal. The gateway management tool is Traefik, which is downloaded from the address provided in the official Traefik documentation and installed according to the installation instructions. After installation, the Traefik tool is configured in the container orchestration cluster, integrating it with the Consul cluster so that Consul can be used as the service discovery backend within Traefik. Integration can be achieved using the Consul Catalog Provider provided by Traefik. By integrating the gateway management tool with the Consul cluster, different services can be registered to the same service gateway. By using the Consul cluster as the service registration and discovery center, registering different services to the Consul cluster at runtime, and using Traefik as the gateway management tool, automatic service discovery and failover can be achieved, significantly improving service availability and security.

[0052] Step S500: Configure rules based on the gateway management tool to obtain routing rules.

[0053] In some embodiments, rule configuration is based on a gateway management tool. This mainly involves configuring access rules for container orchestration clusters and application scheduling and management clusters in the gateway management tool to obtain routing rules. This enables the registration and management of various services on the same service gateway, improving the ability to integrate and manage services in a unified manner.

[0054] In one embodiment, the routing rules include rules for container orchestration clusters and rules for application scheduling and management clusters, such as... Figure 4 As shown, the routing rules are obtained by configuring rules based on the gateway management tool, including but not limited to the following steps: Step S510: Create a routing configuration file based on the gateway management tool, add the routing configuration of the container orchestration cluster to the routing configuration file, and obtain the rules of the container orchestration cluster.

[0055] In some possible embodiments of this application, a routing configuration file is created based on the gateway management tool configured above. Routing configuration for the container orchestration cluster is added to the routing configuration file, specifically configuring routing rules related to the container orchestration cluster. For example, the hostname, path information, service information of the container orchestration cluster, and middleware information are configured to obtain rules for the container orchestration cluster, enabling the matching of service requests from the container orchestration cluster.

[0056] Step S520: Add the routing configuration for application scheduling and management cluster to the routing configuration file to obtain the rules for application scheduling and management cluster.

[0057] In some possible embodiments of this application, based on the gateway management tool configured above, a routing configuration file is created using the gateway management tool. Routing configuration for the application scheduling and management cluster is added to the routing configuration file, specifically configuring routing rules related to the application scheduling and management cluster. For example, hostname, path information, service information of the application scheduling and management cluster, and middleware information are configured to obtain rules for the application scheduling and management cluster, enabling the matching of service requests from the application scheduling and management cluster.

[0058] In some other possible embodiments of this application, based on the configuration of steps S510 and S520 above, requests can be routed to different services by matching the prefix of the request link.

[0059] Step S600: Match the routing rules with the access requests obtained through the external service access mode to provide the services corresponding to the access requests.

[0060] like Figure 5 As shown, routing rules are matched with access requests obtained through external service access patterns to provide services corresponding to the access requests, including but not limited to the following steps: Step S610: Use the preset middleware to perform prefix clearing on the rules of the container orchestration cluster to obtain the first service address corresponding to the container orchestration cluster.

[0061] In some possible embodiments of this application, according to the rule configuration in step S500, the rules of the container orchestration cluster are prefixed using preset middleware. For example, the request prefix "k8s-stripprefix@file" of the container orchestration cluster is cleared, and the Traefik address is provided to obtain the first service address corresponding to the container orchestration cluster. This enables correct routing of requests among different services.

[0062] Step S620: Use the preset middleware to perform prefix clearing on the rules of application scheduling and management cluster to obtain the second service address corresponding to the application scheduling and management cluster.

[0063] In some possible embodiments of this application, according to the rule configuration in step S500, the rules for application scheduling and management clusters are prefixed using preset middleware. For example, the request prefix "nomad-stripprefix@file" for application scheduling and management clusters is cleared, and the Traefik address is provided to obtain the second service address corresponding to the application scheduling and management cluster. This enables correct routing of requests among different services.

[0064] In step S630, the access request is matched with the first service address and the second service address respectively to provide the service corresponding to the access request.

[0065] In some possible embodiments of this application, according to steps S610 and S620, after prefix clearing of the container orchestration cluster and application scheduling and management cluster, a first service address and a second service address are obtained. These first and second service addresses are linked to the same address provided by Traefik. The access request is then matched with both the first and second service addresses to provide the service corresponding to the access request.

[0066] In one embodiment, the container orchestration cluster is a Kubernetes cluster, and the application scheduling and management cluster is a Nomad cluster. A Consul cluster is installed and configured in the Kubernetes cluster. The Consul service is configured in the Kubernetes cluster and exposed in either Nodeport or LoadBalancer mode. In the Nomad cluster, the Consul cluster is configured, its scheduling configuration file is obtained, and the Consul cluster address and access identifier are added to the configuration file. Based on the Consul cluster address and access identifier, the management scheduling service is synchronized to the Consul cluster. Then, the Traefik tool is configured in the Kubernetes cluster, and its integration with the Consul cluster enables different services to be registered to the same service gateway. By configuring the Consul cluster in both the Kubernetes and Nomad clusters, and using the Consul cluster as a service registration and discovery center, different services are registered to the Consul cluster at runtime. Using Traefik as the gateway management tool enables automatic service discovery and failover, significantly improving service availability and security. By configuring routing rules based on the Traefik tool and removing prefixes, requests can be correctly routed across different services. Using Traefik for request routing and load balancing improves the operational and management efficiency of microservice architectures and reduces enterprise operational costs. It also reduces inter-service interactions and management issues, improving service availability and security.

[0067] like Figure 6As shown, this application embodiment provides a multi-cluster service gateway fusion device. The multi-cluster service gateway fusion device 100 installs a Consul cluster via a software installation module 110; it uses a first configuration module 120 to synchronize the Consul service of the Consul cluster in a preset container orchestration cluster, and sets the services of the container orchestration cluster to external service access mode, thus configuring the Consul cluster in the container orchestration cluster for subsequent fusion of multiple service gateways via the Consul cluster; then, it uses a second configuration module 130 to configure the Consul cluster in a preset application scheduling and management cluster, and synchronizes the management scheduling service of the application scheduling and management cluster to the Consul cluster, configuring the Consul cluster in the application scheduling and management cluster. The Consul cluster facilitates the subsequent integration of multiple service gateways. The third configuration module 140 then configures a pre-defined gateway management tool within the pre-defined container orchestration cluster and integrates it with the Consul cluster. This integration allows different services to be registered to the same service gateway. The rule configuration module 150 configures rules based on the gateway management tool to obtain routing rules, enabling the registration and management of various services on the same service gateway, thus improving service integration and unified management capabilities. Finally, the access setting module 160 matches the routing rules with access requests obtained through external service access modes to provide services corresponding to the access requests, ensuring high availability and security of the application.

[0068] It should be noted that the software installation module 110 is connected to the first configuration module 120, the first configuration module 120 is connected to the second configuration module 130, the second configuration module 130 is connected to the third configuration module 140, the third configuration module 140 is connected to the rule configuration module 150, and the rule configuration module 150 is connected to the access settings module 160. The above-described multi-cluster service gateway fusion method is applied to the multi-cluster service gateway fusion device 100. By registering different services to the Consul cluster and combining the Consul cluster with gateway management tools, the multi-cluster service gateway fusion device 100 can achieve the fusion of multiple service gateways, improving service availability and security.

[0069] In one embodiment, the software installation module 110 is further configured to download the Consul cluster installation file from the address provided in the Consul official documentation, obtain the downloaded installation file, and perform the installation. The Consul cluster can be installed in a container orchestration cluster or on a preset odd number of bare metal machines. Installing the Consul cluster provides a registration platform for multiple different services and enables the discovery of different services.

[0070] In one embodiment, the first configuration module 120 is further configured to configure a Consul cluster in the container orchestration cluster, and then create a Consul namespace in the container orchestration cluster. This Consul namespace is used to deploy Consul services and related resources, thus allowing Consul services to be deployed within the Consul namespace. By first creating a space to deploy the Consul cluster, the Consul cluster can be deployed and synchronized in the container orchestration cluster, thereby enabling the Consul cluster to act as a service registration and discovery center. This solves the service registration and discovery problem, making service invocation and registration simpler and more convenient. Next, a Consul service resource file is created, configuring the Consul service port in this file. Specifically, a Service resource named Consul is defined, set to Transmission Control Protocol (TCP) and port 8500, directing TCP traffic to Consul's port 8500 for communication. Finally, an application file for the Consul service is created. This application can be defined using Deployment or StatefulSet. For example, a Deployment configuration file for the Consul service is created, which can be named Consul-deployment.yaml. Defining the Consul Deployment resource in the application file will create three Pods, each using the latest version of the Consul image and exposing container port 8500 for access. Using the kubectl command, the Consul service resource file and application file are deployed and synchronized to the container orchestration cluster. The container orchestration cluster will automatically deploy the three Consul Pods, completing the deployment of the Consul service within the cluster.

[0071] The second configuration module 130 is also used to install and configure the Consul cluster on each node of the application scheduling and management cluster before obtaining the scheduling configuration file of the application scheduling and management cluster. Installation can be performed according to the instructions in the official Consul documentation, ensuring that Consul runs on each node and that all nodes can communicate with each other. The scheduling configuration file of the application scheduling and management cluster is obtained and configured. The aforementioned scheduling configuration file is edited on each node of the application scheduling and management cluster, adding the address and access identifier of the Consul cluster. The access identifier of the Consul cluster includes information such as the client service name and the server service name. Then, the Nomad service is started on each node of the application scheduling and management cluster. The application scheduling and management cluster will use Consul as the backend for service discovery and health checks, and will work in conjunction with the Consul cluster to synchronize the management scheduling service to the Consul cluster. After the above configuration, the application scheduling and management cluster will use Consul for service discovery and automatically join the Consul cluster.

[0072] The rule configuration module 150 is also used to create routing configuration files based on the gateway management tool configured above, and to add routing configurations for the container orchestration cluster in the routing configuration files, specifically configuring routing rules related to the container orchestration cluster. It also adds routing configurations for the application scheduling and management cluster based on the gateway management tool, specifically configuring routing rules related to the application scheduling and management cluster. Based on the above configuration, requests can be routed to different services by matching the prefix of the request link.

[0073] The access settings module 160 is also used to perform prefix clearing on the rules of the container orchestration cluster using preset middleware. For example, the request prefix "k8s-stripprefix@file" for the container orchestration cluster is cleared, and a Traefik address is provided to obtain the first service address corresponding to the container orchestration cluster. This enables correct request routing across different services. Prefix clearing is also performed on the rules of the application scheduling and management cluster using preset middleware. For example, the request prefix "nomad-stripprefix@file" for the application scheduling and management cluster is cleared, and a Traefik address is provided to obtain the second service address corresponding to the application scheduling and management cluster. This also enables correct request routing across different services. After prefix clearing for the container orchestration cluster and the application scheduling and management cluster, the resulting first and second service addresses are linked to the same address provided by Traefik. The access request is then matched against the first and second service addresses respectively to provide the service corresponding to the access request.

[0074] It should also be noted that the apparatus provided in the above embodiments is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the apparatus and method embodiments provided in the above embodiments belong to the same concept, and their specific implementation process can be found in the method embodiments, which will not be repeated here.

[0075] This application also discloses an electronic device. (See reference...) Figure 7 , Figure 7 This is a schematic diagram of the structure of an electronic device disclosed in an embodiment of this application. The electronic device 500 may include: at least one processor 501, at least one network interface 504, a user interface 503, a memory 505, and at least one communication bus 502.

[0076] The communication bus 502 is used to enable communication between these components.

[0077] The user interface 503 may include a display screen and a camera. Optionally, the user interface 503 may also include a standard wired interface and a wireless interface.

[0078] The network interface 504 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface).

[0079] The processor 501 may include one or more processing cores. The processor 501 connects to various parts of the server using various interfaces and lines, and performs various server functions and processes data by running or executing instructions, programs, code sets, or instruction sets stored in memory 505, and by calling data stored in memory 505. Optionally, the processor 501 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 501 may integrate one or a combination of several of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content to be displayed on the screen; and the modem handles wireless communication. It is understood that the modem may also not be integrated into the processor 501 and may be implemented as a separate chip.

[0080] The memory 505 may include random access memory (RAM) or read-only memory. Optionally, the memory 505 may include a non-transitory computer-readable storage medium. The memory 505 may be used to store instructions, programs, code, code sets, or instruction sets. The memory 505 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the above-described method embodiments, etc.; the data storage area may store data involved in the above-described method embodiments, etc. Optionally, the memory 505 may also be at least one storage device located remotely from the aforementioned processor 501. (Refer to...) Figure 7 The memory 505, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and an application program for a multi-cluster service gateway fusion method.

[0081] exist Figure 7In the illustrated electronic device 500, the user interface 503 is mainly used to provide an input interface for the user and to acquire user input data; while the processor 501 can be used to call an application program stored in the memory 505 for a multi-cluster service gateway fusion method. When executed by one or more processors 501, the electronic device 500 performs one or more methods as described in the above embodiments. It should be noted that, for the foregoing method embodiments, for the sake of simplicity, they are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, because according to this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0082] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.

[0083] In the various embodiments provided in this application, it should be understood that the disclosed apparatus can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some service interface; the indirect coupling or communication connection between apparatuses or units may be electrical or other forms.

[0084] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0085] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0086] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as USB flash drives, portable hard drives, magnetic disks, or optical disks.

[0087] The above are merely exemplary embodiments of this disclosure and should not be construed as limiting the scope of this disclosure. Any equivalent changes and modifications made in accordance with the teachings of this disclosure shall still fall within the scope of this disclosure. Other embodiments of this disclosure will readily conceive of those skilled in the art upon consideration of the specification and the disclosure of practical truths.

[0088] This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not described in this disclosure. The specification and embodiments are to be considered exemplary only, and the scope and spirit of this disclosure are defined by the claims.

Claims

1. A method for merging multi-cluster service gateways, characterized in that, The method includes: S100, install Consul cluster; S200. Synchronize the Consul service of the Consul cluster in the preset container orchestration cluster, and set the service of the container orchestration cluster to external service access mode, wherein the container orchestration cluster is a Kubernetes cluster. S300. Configure the Consul cluster in the preset application scheduling and management cluster, and synchronize the management scheduling service of the application scheduling and management cluster to the Consul cluster, wherein the application scheduling and management cluster is a Nomad cluster; S400. Configure a preset gateway management tool in a preset container orchestration cluster, and integrate the gateway management tool with the Consul cluster, wherein the gateway management tool is Traefik; S500. Configure rules based on the gateway management tool to obtain routing rules; The routing rules include the rules for the container orchestration cluster and the rules for the application scheduling and management cluster; Step S500 includes: Based on the gateway management tool, a routing configuration file is created, and the routing configuration of the container orchestration cluster is added to the routing configuration file to obtain the rules of the container orchestration cluster; Add the routing configuration for the application scheduling and management cluster to the routing configuration file to obtain the rules for the application scheduling and management cluster; S600. Match the routing rules with the access requests obtained through the external service access mode to provide services corresponding to the access requests; Step S600 includes: The rules of the container orchestration cluster are prefixed using a pre-defined middleware to obtain the first service address corresponding to the container orchestration cluster. Prefix clearing is performed on the rules of the application scheduling and management cluster using preset middleware to obtain a second service address corresponding to the application scheduling and management cluster; The access request is matched with the first service address and the second service address respectively to provide the service corresponding to the access request.

2. The method according to claim 1, characterized in that, Step S200 includes: Create a Consul namespace in the preset container orchestration cluster, and deploy the Consul service in the Consul namespace; Create a Consul service resource file and configure the port of the Consul service in the Consul service resource file; Create an application file for the Consul service, and associate the Consul service with the application file based on the port of the Consul service; Synchronize the Consul service resource files and the application files in the container orchestration cluster.

3. The method according to claim 1, characterized in that, Step S300 includes: Obtain the scheduling configuration file of the application scheduling and management cluster, and add the address of the Consul cluster and the access identifier of the Consul cluster to the scheduling configuration file; Based on the address of the Consul cluster and the access identifier, the management scheduling service is synchronized to the Consul cluster.

4. The method according to claim 1, characterized in that, Step S100 includes: Install the Consul cluster in the container orchestration cluster, or, Install the Consul cluster on a predetermined odd number of bare metal machines.

5. The method according to claim 1, characterized in that, The external service access mode is either Nodeport mode or LoadBalancer mode.

6. A multi-cluster service gateway fusion device, characterized in that, The apparatus for executing the multi-cluster service gateway fusion method as described in claim 1 includes: The software installation module is used to install a Consul cluster. The first configuration module is used to synchronize the Consul service of the Consul cluster in the preset container orchestration cluster and set the service of the container orchestration cluster to external service access mode, wherein the container orchestration cluster is a Kubernetes cluster. The second configuration module is used to configure the Consul cluster in a preset application scheduling and management cluster, and to synchronize the management scheduling service of the application scheduling and management cluster to the Consul cluster, wherein the application scheduling and management cluster is a Nomad cluster; The third configuration module is used to configure a preset gateway management tool in a preset container orchestration cluster and integrate the gateway management tool with the Consul cluster, wherein the gateway management tool is Traefik; The rule configuration module is used to configure rules based on the gateway management tool to obtain routing rules; The access settings module is used to match the routing rules with the access requests obtained through the external service access mode, so as to provide the service corresponding to the access request.

7. An electronic device, characterized in that, The device includes a processor, a memory, a user interface, and a network interface. The memory is used to store instructions, the user interface and the network interface are used to communicate with other devices, and the processor is used to execute the instructions stored in the memory to cause the electronic device to perform the method as described in any one of claims 1-5.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed, perform the method as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Microservice registration, discovery and forwarding method and device

    CN112187958A