Service calling method and device
By backing up and modifying the service information in the container orchestration system, making its domain name consistent with the domain name of the preset exposed service tool for external communication, the problem of services outside the container orchestration system being unable to call services within the system is solved, and cross-system service calls are successfully achieved. .
Patent Information
- Application Number
- CN201910937349.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-09-30
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2039-09-30
AI Technical Summary
In the existing technology, services located outside the container orchestration system cannot call services within the container orchestration system, causing cross-system service calls to fail.
When receiving a service request from outside the container orchestration system, back up the service information within the container orchestration system, modify its IP address to the domain name of the preset exposure service tool, and modify the regional address to the address of the region to which the requested service belongs, and send it to service discovery Middleware to implement cross-system service calls.
It realizes that services outside the container orchestration system can successfully call services within the container orchestration system, solves the problem of cross-system calls, and ensures the external and internal functions of services.
Smart Images

Figure CN112579310B
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to the field of Internet technology, and in particular, to a method and device for service invocation. Background Art
[0002] Eureka is a service discovery framework developed by Netflix. It is a REST (Representational State Transfer)-based service that is mainly used to locate middle-tier services running in the AWS domain to achieve load balancing and middle-tier service failover. At present, when doing service discovery based on Eureka, some services are deployed in the container orchestration system (such as Kubernetes), and some services are deployed outside the container orchestration system. Different networks are deployed inside and outside the container orchestration system. Services within a network can call each other. Between the two networks, since the network from the inside of the container orchestration system to the outside is connected, the services inside the container orchestration system can call the services outside the container orchestration system. However, since the network from the outside of the container orchestration system to the inside is not connected, the services outside the container orchestration system cannot call the services inside the container orchestration system. Summary of the invention
[0003] In view of this, the service calling method and device provided by the embodiments of the present disclosure aim to solve the problem in the prior art that services outside the container orchestration system cannot call services within the container orchestration system.
[0004] The embodiments of the present disclosure mainly provide the following technical solutions:
[0005] In a first aspect, an embodiment of the present disclosure provides a method for invoking a service, the method comprising:
[0006] Receive a service name of a second service called by a first service request outside the container orchestration system;
[0007] If there is a service located in the container orchestration system among the services of the service name, backing up application information of the service located in the container orchestration system;
[0008] Modify the IP address in the backed-up application information into the domain name of the preset exposure service tool deployed in the container orchestration system, and modify the regional address in the backed-up application information into the regional address of the region to which the first service belongs;
[0009] The modified application information is sent to the first service.
[0010] In some embodiments, the method further comprises:
[0011] sending the unmodified application information to the first service;
[0012] The first service is controlled to call the second service based on a preset area mechanism.
[0013] In some embodiments, the preset area mechanism includes that the calling priority of the same-area service is higher than the calling priority of the cross-area service.
[0014] In some embodiments, the preset exposure service tool includes Ingress.
[0015] In a second aspect, an embodiment of the present disclosure provides a device for invoking a service, the device comprising:
[0016] A receiving unit, configured to receive a service name of a second service called by a first service request outside the container orchestration system;
[0017] a backup unit, configured to back up application information of the service located in the container orchestration system when there is a service located in the container orchestration system among the services of the service name;
[0018] A modification unit, configured to modify the IP address in the backed-up application information into the domain name of the preset exposure service tool deployed in the container orchestration system, and modify the regional address in the backed-up application information into the regional address of the region to which the first service belongs;
[0019] A sending unit is used to send the modified application information to the first service.
[0020] In some embodiments, the sending unit is further configured to send the unmodified application information to the first service;
[0021] The device also includes:
[0022] A control unit is used to control the first service to call the second service based on a preset area mechanism.
[0023] In some embodiments, the preset area mechanism includes that the calling priority of the same-area service is higher than the calling priority of the cross-area service.
[0024] In some embodiments, the preset exposure service tool includes Ingress.
[0025] In a third aspect, an embodiment of the present disclosure provides a storage medium, wherein the storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the service calling method described in the first aspect.
[0026] In a fourth aspect, an embodiment of the present disclosure provides a device for service calling, the device comprising a storage medium; and one or more processors, the storage medium is coupled to the processor, and the processor is configured to execute program instructions stored in the storage medium; when the program instructions are executed, the method for service calling described in the first aspect is executed.
[0027] By means of the above technical scheme, the service calling method and device provided by the embodiments of the present disclosure can, after the service discovery middleware receives the service name of the second service called by the first service request located outside the container orchestration system, if there is a service located within the container orchestration system in the service of the service name, first back up the application information of the service located within the container orchestration system, then modify the IP address in the backed-up application information to the domain name of the preset exposed service tool deployed in the container orchestration system, and modify the regional address to the regional address of the region to which the first service belongs, and finally send the modified application information to the first service instead of directly sending the application information of the service to the first service, so that when the first service located outside the container orchestration system calls the second service located within the container orchestration system, since the modified second service has the same regional address as the first service, and the domain name of the second service is the domain name of the preset exposed service tool that can communicate with the outside world, the first service can successfully call the second service, thereby realizing the external-to-internal function of the service across the container orchestration system.
[0028] The above description is only an overview of the technical solutions of the embodiments of the present disclosure. In order to more clearly understand the technical means of the embodiments of the present disclosure, which can be implemented in accordance with the contents of the specification, and to make the above and other purposes, features and advantages of the embodiments of the present disclosure more obvious and easy to understand, the specific implementation methods of the embodiments of the present disclosure are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the embodiments of the present disclosure. Also, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0030] Figure 1 A flow chart showing a method for service invocation provided by an embodiment of the present disclosure is shown;
[0031] Figure 2 A flowchart showing another service calling method provided by an embodiment of the present disclosure;
[0032] Figure 3 An example diagram of a service call provided by an embodiment of the present disclosure is shown;
[0033] Figure 4 A block diagram showing a composition of a device for service invocation provided by an embodiment of the present disclosure;
[0034] Figure 5 A composition block diagram of another service calling device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0035] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0036] In a first aspect, an embodiment of the present disclosure provides a method for service invocation, such as Figure 1 As shown, the method mainly includes:
[0037] 101. Receive a service name of a second service called by a first service request outside a container orchestration system.
[0038] The container orchestration system includes Kuberentes, Mesos, Swarm, etc. When a first service outside the container orchestration system wants to call a second service, the service name of the second service is sent to a service discovery middleware (such as Eureka), and the service discovery middleware provides the application information of the second service.
[0039] 102. If there is a service located in the container orchestration system among the services of the service name, back up application information of the service located in the container orchestration system.
[0040] After receiving the service name to be called, the service discovery middleware searches for all services that meet the service name, that is, searches for all services whose service name is the received service name, and determines whether each service is located in the container orchestration system based on the application information of the found service. If there is a service located in the container orchestration system, there will be a problem that the first service cannot successfully call the second service. In order to solve this problem, the application information of the service located in the container orchestration system can be backed up first, and then the backed-up application information can be modified so that the modified application information can enable the first service to successfully call the second service, that is, to achieve connectivity between the first service and the second service.
[0041] The application information includes service name, IP address and regional address.
[0042] 103. Modify the IP address in the backed-up application information into the domain name of the preset exposed service tool deployed in the container orchestration system, and modify the regional address in the backed-up application information into the regional address of the region to which the first service belongs.
[0043] The preset exposed service tool includes Ingress. The domain name of the preset exposed service tool is formed by concatenating the service name of the service to be called in the container orchestration system and a fixed suffix. The fixed suffix is the same as the fixed suffix in the domain name of the service outside the container orchestration system.
[0044] For example, if the service name of the service to be called in Kuberentes is a, the domain name is a.xyz.com.
[0045] 104. Send the modified application information to the first service.
[0046] The service calling method provided by the embodiment of the present disclosure can, after the service discovery middleware receives the service name of the second service called by the first service outside the container orchestration system, if there is a service located in the container orchestration system among the services of the service name, first back up the application information of the service located in the container orchestration system, then modify the IP address in the backed-up application information to the domain name of the preset exposed service tool deployed in the container orchestration system, and modify the regional address to the regional address of the region to which the first service belongs, and finally send the modified application information to the first service instead of directly sending the application information of the service to the first service. Therefore, when the first service outside the container orchestration system calls the second service located in the container orchestration system, since the modified second service has the same regional address as the first service, and the domain name of the second service is the domain name of the preset exposed service tool that can communicate with the outside world, the first service can successfully call the second service, thereby realizing the external-to-internal function of services across container orchestration systems.
[0047] In a second aspect, according to the above method embodiment, another embodiment of the present disclosure further provides a method for service invocation, such as Figure 2 As shown, the method mainly includes:
[0048] 201. Receive a service name of a second service called by a first service request outside a container orchestration system.
[0049] 202. If the service of the service name includes a service located in the container orchestration system, back up application information of the service located in the container orchestration system.
[0050] 203. Modify the IP address in the backed-up application information into the domain name of the preset exposure service tool deployed in the container orchestration system, and modify the regional address in the backed-up application information into the regional address of the region to which the first service belongs.
[0051] 204. Send the modified application information to the first service.
[0052] 205. Send the unmodified application information to the first service.
[0053] The unmodified application information includes the original application information of the service whose application information is modified and the application information of the service outside the container orchestration system. Although sending the modified application information to the first service can enable the first service to successfully call the second service, when there are multiple second services, there are more or less some differences between the multiple second services, and for the same second service, there are both unmodified application information and modified application information. As for which second service the first service wants to call, it should be determined by the first service or by the system that controls the first service. Therefore, in addition to sending the modified application information to the first service, the unmodified application information can also be sent to the first service.
[0054] 206. Control the first service to call the second service based on a preset area mechanism.
[0055] The preset regional mechanism includes that the priority of calling services in the same region is higher than that of calling services across regions. That is, when a first service calls a second service, the first service is controlled to call the second service in the same region first, and if there is no second service in the same region, the second service in a different region is called.
[0056] The service calling method provided by the embodiment of the present disclosure can, after the service discovery middleware receives the service name of the second service called by the first service outside the container orchestration system, if there is a service located in the container orchestration system in the service of the service name, first back up the application information of the service located in the container orchestration system, then modify the IP address in the backed-up application information to the domain name of the preset exposed service tool deployed in the container orchestration system, and modify the regional address to the regional address of the region to which the first service belongs, finally send the modified application information and the unmodified application information to the first service, and control the first service to preferentially call the second service in the same region instead of randomly calling it, so that compared with the second service located in the container orchestration system whose application information is not modified, the first service will definitely preferentially call the second service located in the container orchestration system whose application information is modified, and then because the modified second service has the same regional address as the first service, and the domain name of the second service is the domain name of the preset exposed service tool that can communicate with the outside world, the first service can successfully call the second service, thereby realizing the external-to-internal function of the service across the container orchestration system.
[0057] For example, Figure 3 As shown, it is known that there is an area with a zone address of zone-1 in K8S (short for Kuberentes), and there are services A-1 and B-1 in this area. There is an area with a zone address of zone-2 outside K8S, and there are services A-2 and B-2 in this area. In the prior art, A-1 can call B-1 and B-2, B-1 can call A-1 and A-2, and A-2 and B-2 can call each other, but it is impossible for A-2 to call B-1, and it is impossible for B-2 to call A-1, that is, it is impossible for services outside K8S to call services within K8S. Among them, the service names of services A-1 and A-2 are both A, and the service names of services B-1 and B-2 are both B. In order to solve this technical problem, the method provided by the embodiment of the present disclosure is explained by taking A-2 calling B-1 as an example:
[0058] When service A-2 wants to call service B, it can send the service name of service B to Eureka. Eureka searches for all service Bs based on the service name. The services B found include services B-1 and B-2, and determines that service B-1 is located in Eureka. At this time, Eureka can first back up the application information of service B-1, change the IP address in the backed-up application information to the domain name of Ingress, change zone-1 to zone-2, and then send both the modified application information of service B and the unmodified application information of service B to service A-2. Based on the preset zone mechanism, service A-2 will give priority to accessing service B in the same zone, that is, it will give priority to accessing service B with the zone address of zone-2, including service B-2 and the backed-up modified service B-1, thereby achieving the purpose of service A-2 successfully calling service B-1.
[0059] In a third aspect, according to the above method embodiment, another embodiment of the present disclosure further provides a device for service invocation, such as Figure 4 As shown, the device comprises:
[0060] A receiving unit 31 is used to receive a service name of a second service called by a first service request outside the container orchestration system;
[0061] A backup unit 32, configured to back up application information of the service located in the container orchestration system when there is a service located in the container orchestration system among the services of the service name;
[0062] A modification unit 33 is used to modify the IP address in the backed-up application information into the domain name of the preset exposure service tool deployed in the container orchestration system, and modify the regional address in the backed-up application information into the regional address of the region to which the first service belongs;
[0063] The sending unit 34 is used to send the modified application information to the first service.
[0064] In some embodiments, the sending unit 34 is further configured to send the unmodified application information to the first service;
[0065] like Figure 5 As shown, the device also includes:
[0066] The control unit 35 is configured to control the first service to call the second service based on a preset area mechanism.
[0067] In some embodiments, the preset area mechanism includes that the calling priority of the same-area service is higher than the calling priority of the cross-area service.
[0068] In some embodiments, the preset exposure service tool includes Ingress.
[0069] The service calling device provided by the embodiment of the present disclosure can, after the service discovery middleware receives the service name of the second service called by the first service request located outside the container orchestration system, if there is a service located in the container orchestration system among the services of the service name, first back up the application information of the service located in the container orchestration system, then modify the IP address in the backed-up application information to the domain name of the preset exposed service tool deployed in the container orchestration system, and modify the regional address to the regional address of the region to which the first service belongs, and finally send the modified application information to the first service instead of directly sending the application information of the service to the first service. Therefore, when the first service located outside the container orchestration system calls the second service located in the container orchestration system, since the modified second service has the same regional address as the first service, and the domain name of the second service is the domain name of the preset exposed service tool that can communicate with the outside world, the first service can successfully call the second service, thereby realizing the external-to-internal function of the service across the container orchestration system.
[0070] The service calling device provided in the embodiment of the third aspect can be used to execute the service calling method provided in the embodiments of the first and second aspects. The relevant meanings and specific implementation methods can be found in the relevant descriptions in the embodiments of the first and second aspects and will not be described in detail here.
[0071] In a fourth aspect, another embodiment of the present disclosure further provides a storage medium, wherein the storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the service calling method described in the first and second aspects.
[0072] The program stored in the storage medium provided by the embodiment of the present disclosure can, after the service discovery middleware receives the service name of the second service called by the first service request located outside the container orchestration system, if there is a service located in the container orchestration system among the services of the service name, first back up the application information of the service located in the container orchestration system, then modify the IP address in the backed-up application information to the domain name of the preset exposed service tool deployed in the container orchestration system, and modify the regional address to the regional address of the region to which the first service belongs, and finally send the modified application information to the first service instead of directly sending the application information of the service to the first service, so that when the first service located outside the container orchestration system calls the second service located in the container orchestration system, since the modified second service has the same regional address as the first service, and the domain name of the second service is the domain name of the preset exposed service tool that can communicate with the outside world, the first service can successfully call the second service, thereby realizing the external-to-internal function of the service across the container orchestration system.
[0073] In the fifth aspect, another embodiment of the present disclosure further provides a device for service calling, the device comprising a storage medium; and one or more processors, the storage medium is coupled to the processor, and the processor is configured to execute program instructions stored in the storage medium; when the program instructions are executed, the service calling method described in the first and second aspects is executed.
[0074] The service calling method and device provided by the embodiments of the present disclosure can, after the service discovery middleware receives the service name of the second service called by the first service outside the container orchestration system, if there is a service located in the container orchestration system in the service of the service name, first back up the application information of the service located in the container orchestration system, then modify the IP address in the backed-up application information to the domain name of the preset exposed service tool deployed in the container orchestration system, and modify the regional address to the regional address of the region to which the first service belongs, and finally send the modified application information to the first service instead of directly sending the application information of the service to the first service, so that when the first service outside the container orchestration system calls the second service located in the container orchestration system, since the modified second service has the same regional address as the first service, and the domain name of the second service is the domain name of the preset exposed service tool that can communicate with the outside world, the first service can successfully call the second service, thereby realizing the external-to-internal function of the service across the container orchestration system.
[0075] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the embodiments of the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0076] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products of the embodiments of the present disclosure. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0077] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0078] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0079] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0080] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0081] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0082] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0083] It should be understood by those skilled in the art that the embodiments of the present disclosure may be provided as methods, systems or computer program products. Therefore, the embodiments of the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the embodiments of the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0084] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A method for service invocation, characterized in that: The method comprises: Receive a service name of a second service called by a first service request outside the container orchestration system; If there is a service located in the container orchestration system among the services of the service name, backing up application information of the service located in the container orchestration system; Modify the IP address in the backed-up application information into the domain name of the preset exposure service tool deployed in the container orchestration system, and modify the regional address in the backed-up application information into the regional address of the region to which the first service belongs; Sending the modified application information to the first service; The method further comprises: sending the unmodified application information to the first service; The first service is controlled to call the second service based on a preset area mechanism, wherein the preset area mechanism includes that a calling priority of a same-area service is higher than a calling priority of a cross-area service.
2. The method according to claim 1, characterized in that The preset exposure service tool includes Ingress.
3. A device for service invocation, characterized in that: The device comprises: A receiving unit, configured to receive a service name of a second service called by a first service request outside the container orchestration system; a backup unit, configured to back up application information of the service located in the container orchestration system when there is a service located in the container orchestration system among the services of the service name; A modification unit, configured to modify the IP address in the backed-up application information into the domain name of the preset exposed service tool deployed in the container orchestration system, and modify the regional address in the backed-up application information into the regional address of the region to which the first service belongs; A sending unit, configured to send the modified application information to the first service; The sending unit is further configured to send the unmodified application information to the first service; The device also includes: A control unit is used to control the first service to call the second service based on a preset area mechanism, wherein the preset area mechanism includes that a calling priority of a same-area service is higher than a calling priority of a cross-area service.
4. The device according to claim 3, characterized in that The preset exposure service tool includes Ingress.
5. A storage medium, characterized in that: The storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the service calling method described in any one of claims 1 to 2.
6. A device for service invocation, characterized in that: The device includes a storage medium; and one or more processors, the storage medium is coupled to the processor, and the processor is configured to execute program instructions stored in the storage medium; when the program instructions are executed, the method for service invocation described in any one of claims 1 to 2 is executed.
Citation Information
Patent Citations
Security service for receiving sensitive information through nested iframes
CN105989305A
Proxy application for host system with service container and system
CN106331065A
Connecting method and connecting device for JMX (Java Management Extensions) client
CN106453686A
Kubernetes-based PaaS platform domain name configuration method and device and electronic device
CN107302604A
Method for configuring external IP of Overlay network container and Docker cluster
CN107454207A
