CN114697231B - Gateway-based service discovery and service registration method and device - Google Patents
Gateway-based service discovery and service registration method and device Download PDFInfo
- Publication number
- CN114697231B CN114697231B CN202011640534.2A CN202011640534A CN114697231B CN 114697231 B CN114697231 B CN 114697231B CN 202011640534 A CN202011640534 A CN 202011640534A CN 114697231 B CN114697231 B CN 114697231B
- Authority
- CN
- China
- Prior art keywords
- service
- gateway
- registration
- cluster
- information
- 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.)
- Active
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L41/00—Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
- H04L41/50—Network service management, e.g. ensuring proper service fulfilment according to agreements
- H04L41/5058—Service discovery by the service manager
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L63/00—Network architectures or network communication protocols for network security
- H04L63/08—Network architectures or network communication protocols for network security for authentication of entities
- H04L63/0807—Network architectures or network communication protocols for network security for authentication of entities using tickets, e.g. Kerberos
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer Hardware Design (AREA)
- Computer Security & Cryptography (AREA)
- Computing Systems (AREA)
- General Engineering & Computer Science (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
The invention provides a gateway-based service discovery and registration function extension method and device, wherein the method comprises the following steps: a service deployment step of configuring a service discovery and registration address as a predetermined gateway address when deploying a service; a service registration step comprising: receiving a service registration request from a pod through a gateway, determining a cluster corresponding to the service based on the request, wherein the service registration request at least carries a podIP and a service name; corresponding service inquiry is carried out on the Nacos server based on the service registration request, and a registered service list is obtained; service registration is carried out based on the registered service list, and a service node is newly added for the service under the condition that registration service is requested to be registered; and a service discovery step, wherein the gateway is used as a middleware to process a service discovery request, obtain registered services, obtain cluster information corresponding to the registered services through database inquiry, and provide available service information for a service discovery party based on the obtained services and the cluster information.
Description
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a gateway-based service discovery and service registration method and apparatus.
Background
Along with the continuous development of internet informatization, the importance degree of each enterprise on informatization construction is increasingly promoted, new technologies and tools are continuously introduced and put into service, and micro services among the technologies are 'late-onset' in a distributed architecture, and the micro services rapidly 'turn on the red' in the enterprise informatization field with the characteristics of fine granularity, agility, modularization and the like. Since the early days of the internet, system architecture has generally undergone several processes, namely a single architecture, a vertical application architecture, a distributed architecture, an SOA (Service Oriented Architecture ), and a micro-service architecture, which is the next step in the development of a service oriented architecture SOA to some extent, more emphasizes the "thorough splitting" of services. The micro-service architecture simply divides a complete system into individual subsystems according to service functions, and each subsystem is called a service in the micro-service architecture. These subsystems can run independently in a Web container, with communication between them being possible via RPC (Remote Procedure Call ). The micro-service architecture belongs to a distributed system, and different modules can be deployed on different servers, but the deployment mode is different from that of the distributed architecture. Multiple servers can deploy the same application to form a cluster to provide services to the outside through the load balancing device. Service registration and discovery are one of the key principles of a micro-service architecture, because the micro-service architecture is a network structure formed by a series of fine-grained services with single responsibility, and the services communicate through a lightweight mechanism, which necessarily introduces service registration and discovery, that is, service providers need to register and report service addresses, and service invokers need to discover target services. Because the service provider provides the service in a cluster manner, the registration and discovery of the service are also provided in a cluster manner in the process of building the micro-service architecture. Currently, there are several components for registering, discovering, and configuration management of micro services, such as Eureka, zookeeper, nacos and Consul, etc., where Nacos is an easy-to-use platform for the Ababa group to open, and is designed for dynamic service discovery, configuration, and service management. Nacos provides a simple and easy-to-use set of features that help enable dynamic service discovery, service configuration management, service and traffic management, enabling micro-service platforms to be built, delivered and managed more quickly and easily. Nacos is a service infrastructure that builds modern application architectures (e.g., micro-service paradigm, yun Yuansheng paradigm) centered on "services". Nacos, a new generation of service management middleware, is simply on hand, both deployed and in use, being used by an increasing number of people.
The Spring Cloud is a set of complete micro-service development suite based on a Spring Boot framework, and development convenience of the Spring Boot is utilized to simplify development of a micro-service distributed system, such as service discovery, service gateway, service routing, link tracking and the like. The Spring Cloud does not repeatedly manufacture wheels, but integrates modules which are well developed in the market, and packages the modules, so that the development cost of each module is reduced.
Kubernetes (also known as k8s or simply "kube") is an open source platform that can automatically implement Linux container operations. It can help the user omit many manual deployment and expansion operations of the application containerization process. After aggregating groups of hosts running Linux containers together, these clusters can be easily and efficiently managed by Kubernetes. Moreover, these clusters may deploy hosts across public, private, or hybrid clouds. Thus, kubernetes is an ideal hosting platform for cloud native applications that require rapid expansion.
However, although the Nacos realizes service discovery and registration, the support for Spring group+kubernetes is not perfected, that is, in the case of cooperatively using Spring group and kubernetes, the existing function of the Nacos cannot realize functional support for Spring group+kubernetes, so that many problems of difficult registration of services to the Nacos, incompatibility of micro-service versions and the like occur, which has been a problem to be solved.
Disclosure of Invention
In view of the problems in the prior art, the invention provides a gateway-based service discovery and registration function extension method and device to perfect the Nacos support of spring group+kubernetes, thereby solving one or more problems in the prior art.
In one aspect of the present invention, a gateway-based service discovery and service registration method is provided, the method comprising the steps of:
a service deployment step of configuring a service discovery and registration address as a predetermined gateway address when deploying a service;
a service registration step, the service registration step comprising:
receiving a service registration request from a pod through the gateway, and determining a cluster corresponding to a service based on the service registration request, wherein the service registration request at least carries a podIP and a service name;
corresponding service inquiry is carried out on the Nacos server based on the service registration request, and a registered service list is obtained; and
service registration is carried out based on a registered service list, and a service node is newly added for the service under the condition that the service registration request is registered;
and a service discovery step, wherein the gateway is used as a middleware to process a service discovery request, obtain registered services, obtain cluster information corresponding to the registered services through database inquiry, and provide available service information for a service discovery party based on the obtained services and the cluster information.
In an embodiment of the present invention, the determining, based on the service registration request, a cluster corresponding to a service includes: under the condition that the service registration request does not carry the service IP and the cluster IP, inquiring a database which stores the service related mapping relation in advance based on the service name carried in the service registration request to obtain the cluster, the service IP and the nodeIP corresponding to the service; and under the condition that the service registration request also carries the service IP and the cluster IP, determining the cluster, the service IP and the nodeIP corresponding to the service based on the information carried in the service registration request, and storing the determined information as a service related mapping relation in a database.
In some embodiments of the invention, the service registration step further comprises: the service registration is performed by converting the podIP to the service IP based on the service registration request.
In some embodiments of the invention, the service discovery step includes: receiving a service discovery request sent by a service consumer by the gateway, and inquiring an available service list to the Nacos server based on the service discovery request; inquiring a database according to the service related information returned by the Nacos server, obtaining cluster information corresponding to the service based on the service related mapping relation in the database, and accessing and finding the service based on the service and the corresponding cluster information.
In some embodiments of the present invention, the querying the database according to the service related information returned by the Nacos server, obtaining cluster information corresponding to the service based on the service related mapping relationship in the database, accessing and finding the service based on the service and the corresponding cluster corresponding information, and includes: under the condition that a first service in a first cluster accesses a second service in a second cluster, acquiring cluster attribution of the first service and the second service based on service related mapping relations in a first service and second service query database, and returning only a service list which is the same name as the second service and is the same with the first cluster and a node IP of the first cluster in the available service list to a service consumer.
In some embodiments of the present invention, in the gateway, service IPs of the same service in different clusters are fixed and different, and the corresponding relationship between the clusters to which the service belongs, the service IPs, and the node IPs of the clusters is stored in the service-related mapping relationship in the database.
In some embodiments of the present invention, at the time of service registration, a service instance version allowing invocation is configured on the gateway based on the current service instance version, and instance version invocation is performed based on the configured information.
In some embodiments of the invention, the method further comprises an authentication step comprising: receiving, by a gateway, a request from a service provider or sender, the request accompanied by a token; the gateway determines rights information for the service based on the token and processes the received request based on the determined rights information.
In some embodiments of the invention, the gateway determining rights information for a service based on the token includes: and inquiring the corresponding information of the tokens and the rights in the database according to the tokens, and determining the rights corresponding to the tokens based on the inquired information.
In some embodiments of the present invention, the gateway receives the service registration execution result from the Nacos server and forwards the service registration execution result to the service provider.
In another aspect of the present invention, there is also provided a gateway-based service discovery and service registration apparatus comprising a processor and a memory, the memory having stored therein computer instructions for executing the computer instructions stored in the memory, the apparatus implementing the steps of the method as described above when the computer instructions are executed by the processor.
In another aspect of the invention, there is also provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the method as described above.
The gateway-based service discovery and registration function expansion method and device can utilize the gateway as a middleware, process data through the gateway to obtain expected data during service discovery and registration, and return the processed data to realize Naocs function expansion, thereby solving one or more problems caused by the fact that the existing function of Nacos cannot realize support of Spring closed+kubernetes functionally.
In some embodiments, the method and apparatus of the present invention may solve the service discovery problem and the cluster priority call problem when there are multiple copies on a node.
Further, the embodiment of the invention can also solve the service call problem caused by incompatible versions.
Additional advantages, objects, and features of the invention will be set forth in part in the description which follows and in part will become apparent to those having ordinary skill in the art upon examination of the following or may be learned from practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims thereof as well as the appended drawings.
It will be appreciated by those skilled in the art that the objects and advantages that can be achieved with the present invention are not limited to the above-described specific ones, and that the above and other objects that can be achieved with the present invention will be more clearly understood from the following detailed description.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate and together with the description serve to explain the invention.
Fig. 1 is a schematic diagram of a conventional service discovery and service registration.
FIG. 2 is an overall architecture diagram of service discovery and service registration in accordance with one embodiment of the present invention.
Fig. 3 is a flowchart illustrating a service discovery and service registration method in an embodiment of the present invention.
Fig. 4 is a schematic diagram of a service registration procedure according to an embodiment of the invention.
Fig. 5 is a schematic diagram of a service discovery process according to an embodiment of the invention.
Detailed Description
The present invention will be described in further detail with reference to the following embodiments and the accompanying drawings, in order to make the objects, technical solutions and advantages of the present invention more apparent. The exemplary embodiments of the present invention and the descriptions thereof are used herein to explain the present invention, but are not intended to limit the invention.
It should be noted here that, in order to avoid obscuring the present invention due to unnecessary details, only structures and/or processing steps closely related to the solution according to the present invention are shown in the drawings, while other details not greatly related to the present invention are omitted.
It should be emphasized that the term "comprises/comprising" when used herein is taken to specify the presence of stated features, elements, steps or components, but does not preclude the presence or addition of one or more other features, elements, steps or components.
Fig. 1 is a schematic diagram of a conventional service discovery and service registration. As shown in fig. 1, at the time of service registration, a service provider provides its own service information (such as podIP, service name, etc.) to a Nacos registry, requesting service registration. The Nacos registry performs service registration based on the service registration request of the service provider and stores all registered service instances. After successful service registration, the service provider maintains a heartbeat with the Nacos registry. The service consumer can then perform a service discovery process, and the service consumer can subscribe to the Nacos registry for the service or service instance required by the service consumer, and the service consumer initiates a request to the Nacos registry, and the Nacos registry returns an available service instance or service instance list to the service consumer for the service consumer to subscribe to service.
Existing Nacos are used for service registration and discovery, service configuration and service management, and although it implements service discovery and registration, support for springgroup+kubernetes has not been perfected yet, for example: (1) If a spring group deploys a service in Kubernetes through a deployment module (deployment), there is no solution at present how a pod registers a service to a Nacos with a number of (e.g., 3) copies of the pod. Because the containerized deployment is a virtual network card, service registration will be pod IP addresses on Naocs, service discovery can not be realized across clusters, and if a node IP address where a pod is located is selected to register on Nacos if parameters are configured, service registration will be problematic when multiple pod copies are on a node. (2) The Nacos realizes the functions of service discovery and service registration, but the functions can be still expanded, such as how to preferentially call and support Nacos weights for the same cluster when a plurality of service instances exist on the remote kubernetes, which is a still-to-be-solved problem. (3) In actual projects, the problem of multi-version coexistence may be faced, i.e., one microservice may have instances of different versions, and the instances of different versions may be incompatible with each other. For example, the v1 version instance of micro service a cannot call the v2 version instance of micro service b, but only the v1 version instance of micro service b. As an example, if there are two micro-services on-line, one as a service provider (or service provider) and one as a service consumer (or service consumer), they all have different versions of the instance as follows:
there are two versions of the service provider: v1, v2
There are also two versions of service consumers: v1, v2
If version v1 and version v2 are incompatible, then the service consumer's micro-package version v1 can only invoke the service provider's version v1 instance; the micro-package version v2 of the service consumer can only call the v2 version instance of the service provider, and the call problem caused by the coexistence of multiple versions needs to be solved at this time.
Based on the problem that the Nacos function is imperfect and the support to the springgroup+kubernetes is not perfect, the invention provides a series of problems brought by the problem that the gateway expands the Nacos function to perfect the support to the springgroup+kubernetes. That is, in the embodiment of the present invention, a gateway is introduced as a communication intermediary between the server and the Nacos. When the gateway serves as an intermediate, the gateway can process data to obtain expected data during service discovery and registration, and the processed data is returned, so that the function expansion of Naocs is realized. In the embodiment of the invention, besides the self function of the gateway, a data processing plug-in is configured in the gateway serving as a middleware, so that the gateway can perform corresponding data processing according to the service registration request of the service provider and the service discovery request of the service consumer, and after the request of the service provider or the service consumer is sent to the gateway, the data is processed through the preset data processing logic in the data processing plug-in, and then the processed data is forwarded to the real service. The data processing performed by the data processing plug-in configured in the gateway will be described below.
FIG. 2 is a diagram of an overall architecture for service discovery and service registration in accordance with one embodiment of the present invention. As shown in fig. 2, in the embodiment of the present invention, the gateway is used as a communication intermediary between the service provider and the Nacos server (Nacos registry), so that the gateway can be used as a middleware for flexible data processing to solve the problem of pod multiple copies during service registration. Meanwhile, when cross-cluster access is performed, the svc IP addresses in the clusters of other clusters can be converted into accessible nodeIP (node IP) addresses or gateway addresses through gateway processing when service discovery is performed.
Fig. 3 is a flowchart illustrating a service discovery and service registration method in an embodiment of the present invention. As shown in fig. 3, the method includes a service deployment step S110, a service registration step S120, and a service discovery step S130, wherein:
in step S110, when the service is deployed, the service discovery and registration address is configured as an address of a gateway determined in advance to acquire data through the gateway.
In this step, a gateway (e.g., kong) capable of flexibly adding a function plug-in can be selected as the middleware.
The embodiment of the invention also realizes the functions of data processing, authentication and the like of the middleware by writing the gateway plug-in. By configuring the service discovery and registration address as the address of the selected gateway, the gateway can receive data, such as service registration requests and service discovery requests, from the service provider and the service consumer as middleware. In addition, addresses of the Nacos registry are configured in the gateway, so that the gateway can interact with the service provider, the service consumer and the Nacos registry and process data from the service provider and the service consumer to solve the problem of pod multiple copies and cross-cluster call during service registration.
In step S120, the gateway receives a service registration request sent by a service provider, determines a cluster corresponding to a service based on service registration information carried in the service registration request, and converts podIP information into service IP (svccip) information at the gateway to register with the Nacos server.
The service registration is for registering service information of a service instance to a Nacos registry. In the prior art, in the case where multiple pod copies are deployed, when each pod copy runs, a service registration request is directly sent to the Nacos server to register services respectively. The service registration request carries the podIP address, but when multiple pod copies correspond to the same service, it may result in that when one pod copy requests to register a service, the registered service list returned by the Nacos server already contains the service and cannot register the service of the copy.
In the embodiment of the invention, the gateway analyzes the service registration request from the service provider and the service list from the Nacos server, and when the registered service list contains the corresponding service, the node IP address of the service of the current pod copy is modified, so that the pod copy cannot be registered due to NodeIP address conflict is prevented.
More specifically, the present step S120 includes the steps of:
step S121, receiving a service registration request from a pod through the gateway, and determining a cluster corresponding to the service based on the service registration request, wherein the service registration request at least carries pod information such as pod IP and service name.
After receiving the service registration request, the gateway can obtain the cluster, service IP (SVC IP for short) and node IP (nodeip) to which the service belongs by querying the service related mapping relation stored in advance in the database mysql according to the pod information, and converts the pod IP into the service IP in the gateway so as to request registration based on the service IP. The database mysql may store a service related mapping relationship in advance, where the mapping relationship may include correspondence between podIP and service IP, cluster, and node IP.
Alternatively, the service registration request may directly carry the information such as podIP, service name, cluster, nodeIP, etc., where the gateway does not need to query the database mysql, but needs to store the related information into the service related mapping relationship of the database mysql.
And step S122, corresponding service inquiry is carried out to the Nacos server based on the service registration request, and a registered service list is obtained.
The Nacos server returns a registered service list to the gateway based on the service query request, the registered service list containing service names.
Step S123, service registration is carried out based on the registered service list, and a service node is newly added for the service under the condition that the requested registration service is already registered.
More specifically, in the case that the gateway determines that the corresponding service has been registered based on the registered service list, a service node is newly added for the corresponding service in the gateway, so that the node IP is available, and information such as the newly added service node and the corresponding cluster is stored in a service related mapping relationship of the database mysql.
And if the gateway determines that the corresponding service is not registered, adding the service requesting registration into a registered service list, and informing the Nacos server of updating the registered service list.
In this case, by adding a service node for the service, the service that the pod requests to register can be registered at the Nacos server.
Accordingly, after the gateway sends the updated registered service to the Nacos server, the gateway may receive the execution result returned by the Nacos. And meanwhile, the gateway also returns execution result information to the service provider.
Fig. 4 is a schematic diagram of a service registration procedure according to an embodiment of the invention. As shown in fig. 4, the pod of the service provider sends a service registration request to the middleware gateway, where the service registration request carries pod information such as the pod ip and the service name. The gateway, which has been configured with a data processing plug-in, queries from the database mysql based on information in the service registration request. The database mysql stores cluster information, service IP and nodeIP information corresponding to each podip, so that cluster information, service IP and nodeIP address corresponding to the podip address can be obtained from the database, and service IP information is recorded in the gateway so as to register based on the service IP. The gateway further transmits query service registration information to the Nacos server, wherein the service registration information carries service name information. The Nacos server then returns a registered service list that carries the registered service name. The gateway determines whether the service requesting registration is registered or not based on the registered service in the registered service list returned by the Nacos server; if so, this means registered for the other pod copies, and then the service node is newly added for the current pod copy, making the node IP available. If not already registered, the gateway adds the service information requesting registration in the registered service list. After adding new service node or updating registered service list, gateway returns updated registered information to Nacos server, and Nacos server returns execution result after receiving. Further, the gateway feeds back the execution result to the pod. Thereby completing the service registration process. In this service registration process, registration information can be updated based on registered service information, so that registration can be successfully performed on the Nacos server.
And a service discovery step of processing a service discovery request by using the gateway as a middleware to obtain registered services, obtaining cluster information corresponding to the registered services through database query, and providing available service information to a service discovery party based on the obtained services and the cluster information in step S130.
Service discovery step service instances request the registry to obtain the dependent service information. In the embodiment of the invention, the following is set in advance: the svc IP (service IP) of the same service in different clusters is fixed and unrepeatable, and the corresponding relation between the svc IP and the node IP of the service in the clusters is recorded in a database mysql.
In addition, in the embodiment of the present invention, in order to implement preferential scheduling of services in the present cluster when cross-cluster scheduling is implemented, the data processing plug-in the gateway may be configured to execute logic, where when a first service a in a first cluster a accesses a second service B in a second cluster B, the data processing plug-in first queries the database to determine cluster attributions of the first service a and the second service B, and then forwards the accessible node IP to a service consumer.
Fig. 5 is a schematic diagram of a service discovery process according to an embodiment of the invention. As shown in fig. 5, the service discovery step S130 specifically includes the following steps:
(1) And receiving a service discovery request sent by a service consumer by the gateway, and inquiring an available service list from the Nacos server based on the service discovery request.
The service discovery request may not carry any information, and may also carry service information that it is desired to access. The Nacos server returns registered service related information to the gateway based on the request.
(2) Inquiring a database according to the service related information returned by the Nacos server, obtaining cluster information corresponding to the service based on the service related mapping relation in the database, and accessing and finding the service based on the service and the corresponding cluster information.
The step can realize the preferential calling of the same cluster by inquiring the database. For example, to solve the same cluster priority call, support the Nacos weight, only when the service is found, after all the service lists are obtained through the gateway, the cluster where each service in the service list is located is obtained through the database query, for the service with the same name, only the service list of the same cluster as the current pod is returned, and other service ips are not processed if processed through dns, otherwise, the node ips can be converted, so as to prevent the node ips from being not communicated. That is, when cross-cluster access is performed, the gateway process converts the svc IP address in the cluster of the other cluster into an accessible nodeIP (node IP) address or gateway address at the time of service discovery, thereby preventing the node IP from being unavailable.
In the case that a first service a in a first cluster A of a current pod is to access a second service B in a second cluster B, a data query request of a gateway to a database can carry the first service a and the second service B, a data processing plug-in of the gateway can judge cluster attribution of the first service a and the second service B by querying the database, and then the accessible node IP is forwarded to a service consumer (pod).
Based on the service discovery process, the same cluster priority call can be realized.
In addition, in the embodiment of the present invention, in order to solve the problem of multi-version coexistence, the Client (Client) is further configured with Nacos metadata, where the configured metadata is as follows:
with this metadata, when a service is registered, the gateway can configure the service to the gateway, and the call problem caused by the coexistence of multiple versions can be solved. An authentication and authorization plug-in can be added to realize authentication and authorization and judge whether other services have authority to access the service.
More specifically, the authentication and authorization process of the gateway comprises the following steps:
(1) A request from a service provider or sender is received by a gateway that is middleware, with a token (e.g., jwt token, password, etc.) attached to the request.
(2) The gateway determines rights information for the service based on the token and processes the received request based on the determined rights information.
More specifically, the permission list may be set in advance to be stored in the database, the tokens and the permission correspondence information in the database are queried according to the tokens, and the permissions corresponding to the tokens are determined based on the queried information. Based on the obtained rights information, the gateway can decide whether to forward the request to the real service.
The invention solves the problems of service discovery and registration when the containerized service deployed on kubernetes is in butt joint with Nacos, optimizes the service call of the containerized service (the cluster is preferential under the condition of multiple instances and can limit access under the condition of multiple versions coexistence), and solves the problems of cross-cluster service discovery and registration and service call of the containerized service.
Because the gateway performance is excellent, performance problems are not introduced while solving the problems.
In addition, the gateway is used as a middleware, the function plug-in can be dynamically deleted, and the service side does not need to change code adaptation when the Naocs updates a version.
Correspondingly, the invention also provides a gateway-based service discovery and registration function extension device, which comprises a processor and a memory, wherein the memory is stored with computer instructions, the processor is used for executing the computer instructions stored in the memory, and the device realizes the steps of the method when the computer instructions are executed by the processor.
The present invention also relates to a storage medium having stored thereon computer program code which when executed may implement various embodiments of the method of the present invention, the storage medium may be a tangible storage medium such as an optical disk, random Access Memory (RAM), memory, read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of tangible storage medium known in the art.
It should be understood that the invention is not limited to the particular arrangements and instrumentality described above and shown in the drawings. For the sake of brevity, a detailed description of known methods is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method processes of the present invention are not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between steps, after appreciating the spirit of the present invention.
Those of ordinary skill in the art will appreciate that the various illustrative components, systems, and methods described in connection with the embodiments disclosed herein can be implemented as hardware, software, or a combination of both. The particular implementation is hardware or software dependent on the specific application of the solution and the design constraints. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention. When implemented in hardware, it may be, for example, an electronic circuit, an Application Specific Integrated Circuit (ASIC), suitable firmware, a plug-in, a function card, or the like. When implemented in software, the elements of the invention are the programs or code segments used to perform the required tasks. The program or code segments may be stored in a machine readable medium or transmitted over transmission media or communication links by a data signal carried in a carrier wave. A "machine-readable medium" may include any medium that can store or transfer information. Examples of machine-readable media include electronic circuitry, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio Frequency (RF) links, and the like. The code segments may be downloaded via computer networks such as the internet, intranets, etc.
It should also be noted that the exemplary embodiments mentioned in this disclosure describe some methods or systems based on a series of steps or devices. However, the present invention is not limited to the order of the above-described steps, that is, the steps may be performed in the order mentioned in the embodiments, or may be performed in a different order from the order in the embodiments, or several steps may be performed simultaneously.
In this disclosure, features that are described and/or illustrated with respect to one embodiment may be used in the same way or in a similar way in one or more other embodiments and/or in combination with or instead of the features of the other embodiments.
The above description is only of the preferred embodiments of the present invention and is not intended to limit the present invention, and various modifications and variations can be made to the embodiments of the present invention by those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims (12)
1. A gateway-based service discovery and service registration method, the method comprising the steps of:
a service deployment step of configuring a service discovery and registration address as a predetermined gateway address when deploying a service;
a service registration step, the service registration step comprising:
receiving a service registration request from a pod through the gateway, and determining a cluster corresponding to a service based on the service registration request, wherein the service registration request at least carries a podIP and a service name;
corresponding service inquiry is carried out on the Nacos server based on the service registration request, and a registered service list is obtained; and
service registration is carried out based on a registered service list, and a service node is newly added for the service under the condition that the service requiring registration is registered;
and a service discovery step, wherein the gateway is used as a middleware to process a service discovery request, obtain registered services, obtain cluster information corresponding to the registered services through database inquiry, and provide available service information for a service discovery party based on the obtained services and the cluster information.
2. The method of claim 1, wherein the determining a cluster to which a service corresponds based on the service registration request comprises:
under the condition that the service registration request does not carry the service IP and the cluster IP, inquiring a database which stores the service related mapping relation in advance based on the service name carried in the service registration request to obtain the cluster, the service IP and the nodeIP corresponding to the service;
and under the condition that the service registration request also carries the service IP and the cluster IP, determining the cluster, the service IP and the nodeIP corresponding to the service based on the information carried in the service registration request, and storing the determined information as a service related mapping relation in a database.
3. The method of claim 1, wherein the service registration step further comprises:
the service registration is performed by converting the podIP to the service IP based on the service registration request.
4. The method of claim 1, wherein the service discovery step comprises:
receiving a service discovery request sent by a service consumer by the gateway, and inquiring an available service list to the Nacos server based on the service discovery request;
inquiring a database according to the service related information returned by the Nacos server, obtaining cluster information corresponding to the service based on the service related mapping relation in the database, and accessing and finding the service based on the service and the corresponding cluster information.
5. The method of claim 4, wherein the querying the database according to the service-related information returned by the Nacos server, obtaining cluster information corresponding to the service based on the service-related mapping relationship in the database, and accessing and discovering the service based on the service and the corresponding cluster-related information, comprises:
under the condition that a first service in a first cluster accesses a second service in a second cluster, acquiring cluster attribution of the first service and the second service based on service related mapping relations in a first service and second service query database, and returning only a service list which is the same name as the second service and is the same with the first cluster and a node IP of the first cluster in the available service list to a service consumer.
6. The method according to claim 5, wherein in the gateway, service IPs of the same service within different clusters are fixed and different, and clusters to which the service belongs, service IPs and node IP correspondence of the clusters are stored in the service related mapping of a database.
7. The method according to claim 1, wherein the method further comprises:
and when the service is registered, configuring the service instance version allowing calling on the gateway based on the current service instance version, and calling the instance version based on the configured information.
8. The method of claim 1, further comprising an authentication step comprising:
receiving, by a gateway, a request from a service provider or sender, the request accompanied by a token;
the gateway determines rights information for the service based on the token and processes the received request based on the determined rights information.
9. The method of claim 8, wherein the gateway determining rights information for a service based on the token comprises:
and inquiring the corresponding information of the tokens and the rights in the database according to the tokens, and determining the rights corresponding to the tokens based on the inquired information.
10. The method of claim 8, wherein the service registration step further comprises:
and receiving a service registration execution result from the Nacos server by the gateway and forwarding the service registration execution result to the service provider.
11. A gateway-based service discovery and registration function extension device comprising a processor and a memory, wherein the memory has stored therein computer instructions for executing the computer instructions stored in the memory, which device, when executed by the processor, implements the steps of the method according to any of claims 1-10.
12. A computer readable storage medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 10.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011640534.2A CN114697231B (en) | 2020-12-31 | 2020-12-31 | Gateway-based service discovery and service registration method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011640534.2A CN114697231B (en) | 2020-12-31 | 2020-12-31 | Gateway-based service discovery and service registration method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114697231A CN114697231A (en) | 2022-07-01 |
CN114697231B true CN114697231B (en) | 2023-08-01 |
Family
ID=82136371
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011640534.2A Active CN114697231B (en) | 2020-12-31 | 2020-12-31 | Gateway-based service discovery and service registration method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114697231B (en) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US11914637B2 (en) * | 2022-07-25 | 2024-02-27 | Sap Se | Image scaling cloud database |
CN115378993B (en) * | 2022-07-26 | 2023-07-21 | 上海道客网络科技有限公司 | Method and system for supporting namespace-aware service registration and discovery |
CN116319505A (en) * | 2023-02-10 | 2023-06-23 | 安芯网盾(北京)科技有限公司 | Route distribution method and device |
CN116112569B (en) * | 2023-02-23 | 2023-07-21 | 安超云软件有限公司 | Micro-service scheduling method and management system |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2017185961A1 (en) * | 2016-04-26 | 2017-11-02 | 中兴通讯股份有限公司 | Method and apparatus for processing service discovery |
CN107888444A (en) * | 2017-09-29 | 2018-04-06 | 深圳市牛鼎丰科技有限公司 | Service monitoring method, service monitoring device, computer equipment and storage medium |
CN109104305A (en) * | 2018-07-26 | 2018-12-28 | 广东浪潮大数据研究有限公司 | A kind of node increases method and relevant apparatus |
CN110321115A (en) * | 2018-03-30 | 2019-10-11 | 中移(苏州)软件技术有限公司 | A kind of Pod creation method and equipment |
CN111552672A (en) * | 2020-02-19 | 2020-08-18 | 中国船舶工业系统工程研究院 | ZooKeeper-based distributed service state consistency maintenance method and device |
CN112087333A (en) * | 2020-09-07 | 2020-12-15 | 上海浦东发展银行股份有限公司 | Micro-service registration center cluster and information processing method thereof |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108989372B (en) * | 2017-06-02 | 2021-04-09 | 华为技术有限公司 | Service discovery method, registration center and equipment |
EP3543853A1 (en) * | 2018-03-20 | 2019-09-25 | Siemens Healthcare GmbH | Providing microservice information |
-
2020
- 2020-12-31 CN CN202011640534.2A patent/CN114697231B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2017185961A1 (en) * | 2016-04-26 | 2017-11-02 | 中兴通讯股份有限公司 | Method and apparatus for processing service discovery |
CN107888444A (en) * | 2017-09-29 | 2018-04-06 | 深圳市牛鼎丰科技有限公司 | Service monitoring method, service monitoring device, computer equipment and storage medium |
CN110321115A (en) * | 2018-03-30 | 2019-10-11 | 中移(苏州)软件技术有限公司 | A kind of Pod creation method and equipment |
CN109104305A (en) * | 2018-07-26 | 2018-12-28 | 广东浪潮大数据研究有限公司 | A kind of node increases method and relevant apparatus |
CN111552672A (en) * | 2020-02-19 | 2020-08-18 | 中国船舶工业系统工程研究院 | ZooKeeper-based distributed service state consistency maintenance method and device |
CN112087333A (en) * | 2020-09-07 | 2020-12-15 | 上海浦东发展银行股份有限公司 | Micro-service registration center cluster and information processing method thereof |
Also Published As
Publication number | Publication date |
---|---|
CN114697231A (en) | 2022-07-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN114697231B (en) | Gateway-based service discovery and service registration method and device | |
CN111052711B (en) | Method for discovering services provided by a network repository function | |
CN109391592B (en) | Method and equipment for discovering network function service | |
KR20190118072A (en) | Method and apparatus using network slicing | |
CN114270789B (en) | Method and device for acquiring information | |
CN110661638B (en) | Communication method and device | |
CN113746887A (en) | Cross-cluster data request processing method, device and storage medium | |
US8819137B2 (en) | System and method for sharing mobile internet service | |
US8285876B2 (en) | J2EE application versioning strategy | |
WO2019223855A1 (en) | Service discovery extension in a 5g mobile communication network | |
US8572284B2 (en) | Method and apparatus for registering a mobile object on a foreign network | |
US20100198886A1 (en) | Method and Apparatus for Tracking Device Management Data Changes | |
WO2019001376A1 (en) | Nf dynamic data exposure to nrf in 5g core network | |
CN112533177A (en) | Method, device, apparatus and medium for providing and discovering moving edge calculation | |
CN115150410B (en) | Multi-cluster access method and system | |
CN109842895A (en) | A kind of network reliability configuration method, information transferring method and device and system | |
CN101074991B (en) | Method and system for processing geographic position information and middleware in geographic information system | |
CN112068968A (en) | Service access method and device for dual-system terminal | |
CN111770123B (en) | Communication method, apparatus and storage medium | |
CN118012500A (en) | Version compatible method, device, equipment and computer readable storage medium | |
US20220369212A1 (en) | Discovery of Which NEF or AF is Serving a UE | |
US20200313981A1 (en) | Method and device for processing a network service instantiation request | |
CN113542373B (en) | Route service discovery device and method for PAAS platform | |
CN114048028A (en) | Service calling method and device, storage medium and electronic equipment | |
US20240291712A1 (en) | Method and device for configuration of an access unit in a virtualized environment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |