Method and device for automatically adapting a plurality of external registries to service grid Istio
Technical Field
The invention relates to the technical field of cloud native program control, in particular to a method and a device for automatically adapting a plurality of external registries to service grid Istio.
Background
With the development of information technology, the system complexity is higher and higher, and the data interaction is more and more complex. The single application, as a traditional application deployment approach, has gradually failed to meet the requirements of high-concurrency, high-performance systems. Therefore, there is a need to solve the problems faced by monolithic applications through distributed applications. With the application of distributed system architectures, more and more single-responsibility microservice has emerged. These services network interactions, traffic management, information security are also becoming increasingly challenging. In order to solve the problem of landing and application of a distributed architecture, more and more frames are developed in the technical field to meet the existing requirements. The service grid is just a management mode for the micro-services in the frameworks, and the essential purpose is to control the flow of the micro-services, monitor the state of the micro-services and display the calling link in real time.
The registration center appears to solve the problems of multiple micro services, complex routing and fast application state change in the distributed architecture. The distributed micro services are ordered and easy to manage by registering all the micro services in a registration center, automatically discovering the states of the services and dynamically reporting the routes of the services. When the external registry registers the service into the service grid, the external registry is required to separately develop codes to support the proprietary protocol of the service grid. And this protocol is a proprietary protocol specific to the service grid. Sometimes, it is necessary to satisfy that a plurality of external registries register services in a service grid, each registry is required to implement a proprietary protocol of the service grid, and a large amount of adaptive development work exists. Based on this scenario, it is conventional to implement a set of protocol codes for each registry code to complete the function according to the new protocol type. As more registries are accessed, each time a registry is accessed, a new set of code needs to be developed to support the new access. The development cost and the labor cost are high. And when the registration center does not realize the protocol, the service cannot be registered in the service grid, and the adaptability is poor.
Therefore, how to provide a method for automatically adapting a plurality of external registries to service grid idio becomes a technical problem to be solved urgently.
Disclosure of Invention
In view of this, the present invention is directed to solving the problem that when a plurality of external registries register a service into a service grid isio, each registry is required to separately develop a proprietary protocol XDS that code supports the service grid isio. A method and a device for automatically converting services of a plurality of external registries into service resource services entry which can be identified by the service resources index are provided, so that the services in the plurality of external registries can be automatically injected into the service grid service index.
In one aspect, the present invention provides a method for automatically adapting a plurality of external registries to a service grid Istio, comprising:
s1: acquiring original service services of a plurality of external registration centers;
s2: filtering the obtained original service, and screening out target services which accord with rules;
s3: performing data conversion on a target field in a target service, assembling the converted data, and generating a standard resource of a service grid Istio;
s4: the standard resource is parsed by the XDS protocol and registered to the service grid Istio.
Further, the step S1 of obtaining original service services of a plurality of external registries includes:
s11: configuring an address of an external registry;
s12: accessing the address of an external registration center through a polling algorithm and an HTTP (hyper text transport protocol);
s13: and acquiring the detailed information of each service in the original service of the external registry.
Further, in step S13, the detailed information of each service includes: network address ip, port servicePort, service name serviceName, service status and cluster to which it belongs.
4. The method for automatically adapting a plurality of external registries to a service grid Istio according to claim 1, wherein the step S2 of filtering the obtained original service comprises: and filtering the obtained original service according to the service state status of the service, or filtering the obtained original service according to the cluster to which the service belongs.
Further, in step S3, the data conversion of the target field in the target service includes:
s31: converting the network address ip of the target service into an Endpoint field of a service resource ServiceEntry in the service grid Istio;
s32: converting the port servicePort of the target service into a numerical Number field below a port Ports field of a service resource ServiceEntry in the service grid Istio;
s33: the service name serviceName of the target service is converted into the domain name hosts field of the service resource ServiceEntry in the service grid isitio.
Further, in step S31, the converting the network address ip of the target service into the Endpoint field of the service resource service entry in the service grid isitio includes: and comparing the network address ip in the target service with the Endpoint field of the service resource entry in the service grid Istio, and assigning the network address ip in the target service to the Endpoint field of the service resource entry in the service grid Istio when the network address ip in the target service is inconsistent with the Endpoint field of the service resource entry in the service grid Istio.
Further, in step S32, the port servicePort of the target service is converted into the Number field of the port Ports field of the service resource ServiceEntry in the service grid isio, which includes: and comparing the port servicePort field in the target service with the numerical Number field under the port Ports field in the service resource Entry in the service grid Istio, and assigning the port servicePort field in the target service to the numerical Number field under the port Ports field in the service resource ServiceEntry in the service grid idio when the port servicePort field in the target service and the numerical Number field do not meet the numerical Number field.
Further, in step S33, the converting the service name serviceName of the target service into the domain name field of the service resource ServiceEntry in the service grid Istio includes: and comparing the service name field in the target service with the domain name field in the service resource service entry in the service grid Istio, and assigning the service name field in the target service to the domain name field in the service resource service entry in the service grid Istio when the service name field in the target service and the domain name field in the service resource service entry in the service grid Istio are not consistent.
Further, in step S3, the assembling the converted data includes: and assembling the converted data according to an API format required by the service resource ServiceEntry of the service grid Istio.
In another aspect, the present invention further provides an apparatus for automatically adapting a plurality of external registries to a service grid isitio, comprising:
the system comprises an input module, a service module and a service module, wherein the input module is used for acquiring original service of a plurality of external registration centers;
the filter module is used for filtering the original service obtained by the input unit and screening out target services conforming to the rules;
the resource conversion module is used for carrying out data conversion on the target fields in the target service screened by the filter unit;
the generator module is used for assembling the data obtained by the conversion of the resource conversion unit according to an API format required by the service resource entry of the service grid Istio to generate standard resources of the service grid Istio;
and the output module is used for outputting the standard resources generated by the generator unit to the service grid Istio.
The method and the device for automatically adapting a plurality of external registries to the service grid Istio have the following advantages that:
1) support to access various external registration centers;
2) automatically registering a service in an external registry with a service grid;
3) and when the external registry does not realize the service grid private protocol, the external registry has the capability of accessing the service grid.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a flow chart of a method for automatically adapting a plurality of external registries to a service grid Istio in accordance with an exemplary first embodiment of the present invention.
FIG. 2 is a flowchart of a method for automatically adapting a plurality of external registries to a service grid Istio in accordance with an exemplary second embodiment of the present invention.
FIG. 3 is a flowchart of a method for automatically adapting a plurality of external registries to a service grid Istio in accordance with an exemplary third embodiment of the present invention.
FIG. 4 is a block diagram of an exemplary fourth embodiment of the present invention for automatically adapting a plurality of external registries to a service grid Istio.
Detailed Description
Embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
It should be noted that, in the case of no conflict, the features in the following embodiments and examples may be combined with each other; moreover, all other embodiments that can be derived by one of ordinary skill in the art from the embodiments disclosed herein without making any creative effort fall within the scope of the present disclosure.
It is noted that various aspects of the embodiments are described below within the scope of the appended claims. It should be apparent that the aspects described herein may be embodied in a wide variety of forms and that any specific structure and/or function described herein is merely illustrative. Based on the disclosure, one skilled in the art should appreciate that one aspect described herein may be implemented independently of any other aspects and that two or more of these aspects may be combined in various ways. For example, an apparatus may be implemented and/or a method practiced using any number of the aspects set forth herein. Additionally, such an apparatus may be implemented and/or such a method may be practiced using other structure and/or functionality in addition to one or more of the aspects set forth herein.
The terms related to the embodiments of the present invention are explained as follows:
serving the grid: a way to deploy traffic communication and governance at runtime by intercepting services.
The registration center: centralized service capable of automatically discovering service in software industry distributed service system
Istio is one of the service grid technologies, the main component that governs by injecting sidecar into the service.
And the sidecar agent is added in front of the application when the application runs, and the data traffic is intercepted.
ServiceEntry a service resource in the service grid idio can automatically access an external service to the registry.
name: the name of the service resource entry is indicated, and the name corresponds to the service name serviceName of the service in the external registry.
ports: the service resource corresponds to the detailed information of all ports of the service.
number: the specific value of a port.
endpoints: and the endpoint information corresponding to the registered service in the service grid indicates the network address information.
XDS is a dynamic service discovery protocol which supports the issue of service configuration increment.
status is the online and offline status of the service resources in the registry.
cluster, which the service instance runtime in the registry belongs to.
hosts, domain name information for service resources in the service grid.
HTTP, an application layer protocol in network communication, and supports mutual access between applications.
servicePort, the running port of the service in the registry.
serviceName-the name of the service in the registry.
API, application interface address, through which application data can be accessed.
Fig. 1 is a flowchart of a method for automatically adapting a plurality of external registries to a service grid isitio according to an exemplary first embodiment of the present invention, as shown in fig. 1, the method of the present embodiment includes:
s1: acquiring original service services of a plurality of external registration centers;
s2: filtering the obtained original service, and screening out target services which accord with rules;
s3: performing data conversion on a target field in a target service, assembling the converted data, and generating a standard resource of a service grid Istio;
s4: the standard resource is parsed by the XDS protocol and registered to the service grid Istio.
In step S2 of this embodiment, the filtering the acquired original service includes: and filtering the obtained original service according to the service state status of the service, or filtering the obtained original service according to the cluster to which the service belongs.
In step S3 of the present embodiment, the assembling of the converted data includes: and assembling the converted data according to an API format required by the service resource ServiceEntry of the service grid Istio.
Fig. 2 is a flowchart of a method for automatically adapting a plurality of external registries to a service grid isitio according to an exemplary second embodiment of the present invention, where this embodiment is a preferred embodiment of the method shown in fig. 1, and as shown in fig. 1 and fig. 2, the obtaining of original service of the plurality of external registries in step S1 of this embodiment includes:
s11: configuring an address of an external registry;
s12: accessing the address of an external registration center through a polling algorithm and an HTTP (hyper text transport protocol);
s13: and acquiring the detailed information of each service in the original service of the external registry.
In step S13 of the present embodiment, the detailed information of each service includes: network address ip, port servicePort, service name serviceName, service status and cluster to which it belongs.
Fig. 3 is a flowchart of a method for automatically adapting a plurality of external registries to a service grid isitio according to an exemplary third embodiment of the present invention, where this embodiment is a preferred embodiment of the method shown in fig. 1 and fig. 2, and as shown in fig. 3, in step S3 of this embodiment, data conversion is performed on a target field in a target service, where the method includes:
s31: converting the network address ip of the target service into an Endpoint field of a service resource ServiceEntry in the service grid Istio; the steps are realized in the following mode: and comparing the network address ip in the target service with the Endpoint field of the service resource entry in the service grid Istio, and assigning the network address ip in the target service to the Endpoint field of the service resource entry in the service grid Istio when the network address ip in the target service is inconsistent with the Endpoint field of the service resource entry in the service grid Istio.
S32: converting the port servicePort of the target service into a numerical Number field below a port Ports field of a service resource ServiceEntry in the service grid Istio; the steps are realized in the following mode: and comparing the port servicePort field in the target service with the numerical Number field under the port Ports field in the service resource Entry in the service grid Istio, and assigning the port servicePort field in the target service to the numerical Number field under the port Ports field in the service resource ServiceEntry in the service grid idio when the port servicePort field in the target service and the numerical Number field do not meet the numerical Number field.
S33: converting the service name serviceName of the target service into a domain name field of a service resource ServiceEntry in the service grid Istio; the steps are realized in the following mode: and comparing the service name field in the target service with the domain name field in the service resource service entry in the service grid Istio, and assigning the service name field in the target service to the domain name field in the service resource service entry in the service grid Istio when the service name field in the target service and the domain name field in the service resource service entry in the service grid Istio are not consistent.
Fig. 4 is a block diagram of automatically adapting a plurality of external registries to a service grid isitio according to an exemplary fourth embodiment of the present invention, where this embodiment is a preferred embodiment of the method shown in fig. 1, fig. 2, and fig. 3, and as shown in fig. 4, an apparatus for automatically adapting a plurality of external registries to a service grid isiio of this embodiment includes:
the system comprises an input module, a service module and a service module, wherein the input module is used for acquiring original service of a plurality of external registration centers;
the filter module is used for filtering the original service obtained by the input unit and screening out target services conforming to the rules;
the resource conversion module is used for carrying out data conversion on the target fields in the target service screened by the filter unit;
the generator module is used for assembling the data obtained by the conversion of the resource conversion unit according to an API format required by the service resource entry of the service grid Istio to generate standard resources of the service grid Istio;
and the output module is used for outputting the standard resources generated by the generator unit to the service grid Istio.
The above description is only for the specific embodiment of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present invention are included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.