Service access system, method, electronic device, and storage medium
By establishing a mapping between access requests and service address information on DNS servers and gateways outside the container cluster, the problem of inflexible service access and resource waste between cloud-native architecture and traditional architecture is solved, and flexible service access and load balancing are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-25
- Publication Date
- 2026-03-27
AI Technical Summary
Between cloud-native architectures and traditional architectures, service access methods are inflexible and resources are wasted, especially because access is required via IP address and each service depends on a load balancer.
By establishing a mapping between access requests and service address information through DNS servers and gateways outside the container cluster, flexible access to services within the container cluster can be achieved, and load balancing can be performed through gateways to avoid each service having its own load balancer.
It improves the flexibility of service access, saves resources, achieves load balancing across multiple gateways, and reduces reliance on load balancers.
Smart Images

Figure CN116545979B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of service access, and in particular to a service access system and method, an electronic device, and a storage medium. BACKGROUND
[0002] With the continuous development of cloud native technology, more and more applications adopt cloud native architecture. However, when the deployment and running mode of traditional applications moves towards cloud native, the situation that part of the services in the system run in the traditional architecture and part of the services run in the cloud native environment occurs. Because the network architecture of the cloud native environment is different from that of the traditional architecture, the services outside the cloud native architecture cannot directly access the services inside the cloud native architecture.
[0003] In the related art, the type of the services inside the cloud native architecture is set to the type of a load balancer, so that the services are published outside the cloud native architecture, and the services outside the cloud native architecture can also access the services inside the cloud native architecture. However, this method needs to access through an IP (Internet Protocol) address, and the access method is not flexible. Moreover, each service depends on a load balancer, causing resource waste. SUMMARY
[0004] To solve the above technical problems, the present application provides a service access system and method, an electronic device, and a storage medium.
[0005] According to a first aspect of the present application, a service access system is provided, comprising: a first service and a first gateway inside a container cluster, and a first domain name system (DNS) server and a second service outside the container cluster;
[0006] The second service is configured to send a first access request to the first DNS server when the second service accesses the first service.
[0007] The first DNS server is configured to determine address information of the first gateway corresponding to the first access request based on a pre-established correspondence between the first access request and the address information of the first gateway, and send the address information of the first gateway to the second service.
[0008] The second service is further configured to send the first access request to the first gateway based on the address information of the first gateway.
[0009] The first gateway is configured to determine address information of the first service corresponding to the first access request based on a pre-established correspondence between the first access request and the address information of the first service, send the first access request to the first service based on the address information of the first service, receive a first request result returned by the first service, and send the first request result to the second service.
[0010] Optionally, the service access system further comprises: a DNS controller manager in the container cluster;
[0011] The DNS controller manager is configured to, in response to a deployment request for the first service, deploy the first service in the container cluster, establish a correspondence between address information of the first gateway and the first access request, and store the correspondence between the address information of the first gateway and the first access request to the first DNS server; and
[0012] The DNS controller manager is configured to, in response to a deployment request for the first service, deploy the first service in the container cluster, establish a correspondence between address information of the first gateway and the first access request, and store the correspondence between the address information of the first gateway and the first access request to the first DNS server; and
[0013] Optionally, the DNS controller manager is further configured to, in response to a deletion request for the first service, delete the first service from the container cluster, delete the correspondence between the address information of the first gateway and the first access request from the first DNS server, and delete the correspondence between the first access request and the address information of the first service from the first gateway.
[0014] Optionally, the service access system further comprises: a third service and a second gateway in the container cluster;
[0015] The first service is configured to, when the first service accesses the third service and a second access request sent by the first service belongs to a first type of request, send the second access request to the first DNS server.
[0016] The first DNS server is further configured to, based on a correspondence between address information of the second gateway and the second access request established in advance, determine address information of the second gateway corresponding to the second access request, and send the address information of the second gateway to the first service.
[0017] The first service is further configured to, based on the address information of the second gateway, send the second access request to the second gateway.
[0018] The second gateway is configured to, based on a correspondence between the second access request and address information of the third service established in advance, determine address information of the third service corresponding to the second access request, send the second access request to the third service based on the address information of the third service, receive a second request result returned by the third service, and send the second request result to the first service.
[0019] Optionally, the service access system further comprises a second DNS server in the container cluster.
[0020] The first service is configured to send a third access request to the second DNS server when the first service accesses the third service and the third access request sent by the first service belongs to the second type of request.
[0021] The second DNS server is configured to parse the third access request, determine address information of the third service, and send the address information of the third service to the first service.
[0022] The first service is further configured to send the third access request to the third service based on the address information of the third service, and receive a third request result returned by the third service.
[0023] Optionally, the first service is configured to send a fourth access request to the second DNS server when the first service accesses the second service.
[0024] The second DNS server is further configured to send the fourth access request to the first DNS server.
[0025] The first DNS server is further configured to parse the fourth access request, obtain address information of the second service, and send the address information of the second service to the second DNS server.
[0026] The second DNS server is further configured to send the address information of the second service to the first service.
[0027] The first service is further configured to send the fourth access request to the second service based on the address information of the second service, and receive a fourth request result returned by the second service.
[0028] Optionally, the service access system further comprises a fourth service outside the container cluster.
[0029] The second service is configured to send a fifth access request to the first DNS server when the second service accesses the fourth service.
[0030] The first DNS server is configured to parse the fifth access request, obtain address information of the fourth service, and send the address information of the fourth service to the second service.
[0031] The second service is further configured to send the fifth access request to the fourth service based on the address information of the fourth service, and receive a fifth request result returned by the fourth service.
[0032] According to a second aspect of the present application, a service access method is provided, applied to a first domain name system (DNS) server outside a container cluster, the container cluster deploying a first service, and the method comprising:
[0033] receiving a first access request sent by a second service outside the container cluster when the second service accesses the first service;
[0034] determining address information of a first gateway corresponding to the first access request based on a pre-established correspondence between the first access request and the address information of the first gateway;
[0035] sending the address information of the first gateway to the second service, so that the second service sends the first access request to the first gateway, and then the first gateway determines address information of the first service corresponding to the first access request based on a pre-established correspondence between the first access request and the address information of the first service, sends the first access request to the first service based on the address information of the first service, receives a first request result returned by the first service, and sends the first request result to the second service.
[0036] According to a third aspect of the present application, a service access method is provided, applied to a first gateway inside a container cluster, the container cluster also deploying a first service, and the method comprising:
[0037] receiving a first access request sent by a second service outside the container cluster based on address information of the first gateway when the second service accesses the first service, wherein the address information of the first gateway is determined and sent to the second service by a first domain name system (DNS) server outside the container cluster based on a pre-established correspondence between the first access request and the address information of the first gateway, and the first access request is received from the second service;
[0038] determining address information of the first service corresponding to the first access request based on a pre-established correspondence between the first access request and the address information of the first service;
[0039] sending the first access request to the first service based on the address information of the first service;
[0040] receiving a first request result returned by the first service, and sending the first request result to the second service.
[0041] According to a fourth aspect of the present application, an electronic device is provided, comprising a processor configured to execute a computer program stored in a memory, the computer program being executed by the processor to implement the service access method of the second aspect or the third aspect.
[0042] According to a fifth aspect of the present application, a computer readable storage medium is provided, having stored thereon a computer program which, when executed by a processor, implements the service access method according to the second aspect or the third aspect.
[0043] According to a sixth aspect of the present application, a computer program product is provided, which, when running on a computer, causes the computer to perform the service access method according to the second aspect or the third aspect.
[0044] The technical solution provided by the embodiments of the present application has the following advantages compared with the prior art:
[0045] For the first service in the container cluster, a corresponding relationship between a first access request for accessing the first service and address information of the first gateway can be established in the first DNS server outside the container cluster in advance, and a corresponding relationship between the first access request and address information of the first service can be established in the first gateway. In this way, when the second service outside the container cluster accesses the first service in the container cluster, the first DNS server can parse the address information of the first gateway according to the first access request sent by the second service, and the first gateway can parse the address information of the first service according to the first access request, so as to forward the first access request sent by the second service to the first service. After receiving the first request result returned by the first service, the first request result is sent to the second service. The present application can parse the first access request to obtain the address information of the first service, complete the service access, and not only can the first service be accessed by pre-knowing the address information of the first service, but also the flexibility of service access is improved. Moreover, the forwarding of the first access request is realized through the gateway, and load balancing can be realized for multiple gateways, without the need of one load balancer corresponding to each service, thereby saving resources. BRIEF DESCRIPTION OF DRAWINGS
[0046] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and serve to explain the principles of the present application together with the specification.
[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced here. Obviously, for those skilled in the art, other drawings can also be obtained based on these drawings without creative labor.
[0048] Figure 1 A schematic diagram of a service access system in the embodiments of the present application;
[0049] Figure 2Another schematic diagram of a service access system in an embodiment of the present application;
[0050] Figure 3 Another schematic diagram of a service access system in an embodiment of the present application;
[0051] Figure 4 Another schematic diagram of a service access system in an embodiment of the present application;
[0052] Figure 5 Another schematic diagram of a service access system in an embodiment of the present application;
[0053] Figure 6 A flowchart of a service access method in an embodiment of the present application;
[0054] Figure 7 Another flowchart of a service access method in an embodiment of the present application;
[0055] Figure 8 An interaction flowchart of a service access method in an embodiment of the present application;
[0056] Figure 9 A schematic diagram of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0057] In order to more clearly understand the above objectives, features and advantages of the present application, the solutions of the present application will be further described below. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0058] In the following description, a lot of specific details are set forth in order to fully understand the present application, but the present application can also be implemented in other different manners from those described herein; obviously, the embodiments in the description are only some embodiments of the present application, not all the embodiments.
[0059] Figure 1 A schematic diagram of a service access system in an embodiment of the present application. As shown in Figure 1 The service access system 100 can include a container cluster 101, a first DNS (Domain Name System) server 102, the container cluster 101 internally deploying a first service 103 and a first gateway 104, and the container cluster 101 externally deploying a second service 105. The container cluster 101 can be a Kubernetes cluster. The network is a medium for providing a communication link between the second service 105 and the first DNS server 102, the first DNS server 102 and the first gateway 104, and the first gateway 104 and the first service 103. The network can include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0060] It should be understood that Figure 1 The number of gateways and services deployed in the container cluster 101, and the number of DNS servers and services deployed outside the container cluster are merely illustrative. Any number of services, gateways and DNS servers can be provided according to implementation needs.
[0061] The service access system of the embodiments of the present application can implement service access in the container cluster to services inside / outside the container cluster, and service access outside the container cluster to services inside / outside the container cluster. Moreover, when the service outside the container cluster accesses the service inside the container cluster, the domain name can be directly used for access.
[0062] The process of the service outside the container cluster accessing the service inside the container cluster is first introduced below.
[0063] The second service 105 is configured to send a first access request to the first DNS server 102 when the second service 105 accesses the first service 103, and the first access request can be a domain name access request.
[0064] The first DNS server 102 is configured to determine the address information of the first gateway corresponding to the first access request based on a pre-established correspondence between the first access request and the address information of the first gateway, and send the address information of the first gateway to the second service.
[0065] In the embodiments of the present application, when the first service 103 is deployed in the container cluster 101, the meta information (for example, a field in the meta information) configured by the first service 103 can be used to determine whether the first service 103 is published outside the cluster. If the first service 103 has no need to be accessed by the second service 105 outside the container cluster 101, the meta information can be used to determine that the first service 103 is not published outside the container cluster 101, and the service outside the container cluster 101 cannot access the first service 103 through the domain name. Otherwise, the first service 103 is published outside the container cluster 101, and the service outside the container cluster 101 can access the first service 103 through the domain name.
[0066] If the first service 103 is published outside the container cluster 101, the correspondence between the first access request and the address information of the first gateway can be established. In this way, the first DNS server 102 can parse the first access request according to the correspondence to obtain the address information of the first gateway 104, and send the address information to the second service 105, so that the second service 105 sends the first access request to the first gateway 103. It can be seen that by deploying the first gateway 104 in the container cluster 101, the parsing efficiency of the first DNS server 102 for the first access request can be improved.
[0067] The second service 105 is further configured to send the first access request to the first gateway based on the address information of the first gateway.
[0068] The first gateway 104 is configured to determine the address information of the first service corresponding to the first access request based on a pre-established correspondence between the first access request and the address information of the first service, send the first access request to the first service based on the address information of the first service, receive a first request result returned by the first service, and send the first request result to the second service.
[0069] Similarly, when establishing the correspondence between the first access request and the address information of the first gateway, the correspondence between the first access request and the address information of the first service can also be established. After receiving the first access request, the first gateway 104 can parse the address information of the first service, so as to forward the first access request to the first service 103. The first service 103 returns a corresponding first request result in response to the first access request. The first gateway 104 can forward the first request result to the second service 105.
[0070] The service access system of the embodiment of the present application can pre-establish the correspondence between the first access request for accessing the first service and the address information of the first gateway in the first DNS server outside the container cluster, and establish the correspondence between the first access request and the address information of the first service in the first gateway. In this way, when the second service outside the container cluster accesses the first service in the container cluster, the first DNS server can parse the address information of the first gateway according to the first access request sent by the second service, and the first gateway can parse the address information of the first service according to the first access request, so as to forward the first access request sent by the second service to the first service. After receiving the first request result returned by the first service, the first request result is sent to the second service. The present application can parse the first access request to obtain the address information of the first service, complete the access of the service, and not only can the first service be accessed by pre-knowing the address information of the first service, but also the flexibility of service access is improved. Moreover, the forwarding of the first access request is realized through the first gateway, so that multiple gateways can be load balanced, and a load balancer does not need to be corresponded to each service, thereby saving resources.
[0071] The processes of publishing and deleting services in the embodiment of the present application are introduced below.
[0072] Referring to Figure 2 , Figure 2 Another schematic diagram of the service access system in the embodiment of the present application is shown in FIG. 2. The service access system 100 further includes a DNS controller manager 106 in the container cluster 101.
[0073] The DNS controller manager 106 is configured to, in response to a deployment request for the first service, deploy the first service in the container cluster, establish a correspondence between the address information of the first gateway and the first access request, and store the correspondence between the address information of the first gateway and the first access request to the first DNS server; and establish a correspondence between the first access request and the address information of the first service, and store the correspondence between the first access request and the address information of the first service to the first gateway.
[0074] When the first service 103 is deployed in the container cluster 101, the correspondence between the first access request for accessing the first service 103 and the first gateway 104 can be added to the first DNS server 102 outside the container cluster, that is, the first access request corresponding to the first service 103 is published outside the container cluster 101. In addition, the correspondence between the first access request and the address information of the first service is added to the first gateway 104, so that the first access request can be forwarded to the first service 103 through the first gateway 104.
[0075] The DNS controller manager 106 is further configured to, in response to a deletion request for the first service, delete the first service from the container cluster, and delete the correspondence between the address information of the first gateway and the first access request from the first DNS server, and delete the correspondence between the first access request and the address information of the first service from the first gateway.
[0076] Corresponding to the process of deploying the first service 103 in the container cluster 101, the user can also delete the first service 103 from the container cluster 101 according to the demand. Accordingly, the correspondence between the address information of the first gateway and the first access request registered in the first DNS server 102, and the correspondence between the first access request and the address information of the first service registered in the first gateway 104 can be dynamically deleted.
[0077] The service access system of the embodiment of the application can dynamically register the services in the container cluster to the DNS server outside the container cluster, and dynamically delete from the DNS server, along with the creation and deletion of the services in the container cluster. In this way, after the first service is deployed in the container cluster, the first DNS server outside the container cluster has the corresponding resolution record. Outside the container cluster, the first service in the container cluster can be directly accessed through the domain name, thereby saving the manual configuration process.
[0078] The process of accessing the services in the container cluster by the services in the container cluster is described below.
[0079] Referring to Figure 3 , Figure 3Another schematic diagram of a service access system in the embodiments of the present application. The service access system 100 further comprises a third service 107 and a second gateway 108 in the container cluster 101;
[0080] The first service 103 is configured to send the second access request to the first DNS server 102 when the first service 103 accesses the third service 107 and the second access request sent by the first service 103 belongs to the first type of request.
[0081] In the embodiments of the present application, the access request can comprise a global domain name and a local domain name. The local domain name is a domain name in the container cluster 101, and the global domain name is a domain name outside the container cluster 101. A same service in the container cluster 101 can have both the local domain name and the global domain name, and the two domain names can be different domain names. The second access request sent by the first service 103 belongs to the first type of request, which means that the second access request belongs to the global domain name, i.e., a domain name registered outside the container cluster 101. At this time, the second access request can be resolved by the first DNS server 102 outside the container cluster 101.
[0082] The first DNS server 102 is further configured to determine the address information of the second gateway corresponding to the second access request based on a pre-established correspondence between the address information of the second gateway and the second access request, and send the address information of the second gateway to the first service.
[0083] As described above, for a service in the container cluster 101, if a corresponding domain name is registered outside the container cluster 101, a correspondence between the access request corresponding to the service and the address information of the gateway can be established. Therefore, for the first service 103, the correspondence between the address information of the second gateway and the second access request can be established in the first DNS server 102. The first DNS server 102 can resolve the second access request based on the correspondence to obtain the address information of the second gateway, and send the address information of the second gateway to the first service 103, so that the first service 103 initiates an access request to the second gateway 108. The second gateway 108 and the first gateway 104 can be the same gateway or different gateways.
[0084] The first service 103 is further configured to send the second access request to the second gateway based on the address information of the second gateway.
[0085] The second gateway 108 is configured to determine the address information of the third service corresponding to the second access request based on a pre-established correspondence between the second access request and the address information of the third service, send the second access request to the third service based on the address information of the third service, receive a second request result returned by the third service, and send the second request result to the first service.
[0086] Similarly, when establishing the mapping between the address information of the second access request and the second gateway, a mapping between the address information of the second access request and the third service can also be established. After receiving the second access request, the second gateway 108 can parse the address information of the third service, and thus forward the second access request to the third service 107. The third service 107 responds to the second access request and returns the corresponding second request result, which the second gateway 108 can then forward to the first service 103.
[0087] See Figure 4 , Figure 4 This is another schematic diagram of a service access system in an embodiment of this application. The service access system 100 also includes a second DNS server 109 within the container cluster.
[0088] The first service 103 is used to send a third access request to the second DNS server 109 when the first service 103 accesses the third service 107 and the third access request sent by the first service belongs to the second type of request.
[0089] In this embodiment, the third access request sent by the first service 103 belongs to the second type of request, meaning that the third access request belongs to a local domain name, that is, a domain name registered within the container cluster 101. In this case, the third access request can be resolved through the second DNS server 109 within the container cluster 101.
[0090] The second DNS server 109 is used to resolve third access requests, determine the address information of the third service, and send the address information of the third service to the first service.
[0091] The first service 103 is also used to send a third access request to the third service based on the address information of the third service, and to receive the third request result returned by the third service.
[0092] As can be seen, access between two services within a container cluster can take two different forms. When the third access request is a global domain name, it can be resolved through a first DNS server outside the container cluster, and then forwarded through a second gateway, as well as through the second gateway to forward the third service's response. When the third access request is a local domain name, it can be resolved through a second DNS server within the container cluster. The first service can directly initiate a request to the third service and receive the response.
[0093] The following describes the process of a service within a container cluster accessing a service outside the container cluster.
[0094] The first service 103 is configured to send a fourth access request to the second DNS server 109 when the first service 103 accesses the second service 105.
[0095] The second DNS server 109 is further configured to send the fourth access request to the first DNS server 102.
[0096] Since the domain name of the second service outside the container cluster 101 can be resolved by the first DNS server 102 outside the container cluster, but the second DNS server 109 inside the container cluster 101 cannot resolve it, the second DNS server 109 forwards the fourth access request to the first DNS server 102 outside.
[0097] The first DNS server 102 is further configured to resolve the fourth access request to obtain address information of the second service, and send the address information of the second service to the second DNS server 109.
[0098] The second DNS server 109 is further configured to send the address information of the second service to the first service 103.
[0099] The first service 103 is further configured to send the fourth access request to the second service based on the address information of the second service, and receive a fourth request result returned by the second service.
[0100] The following describes a process of accessing a service outside a container cluster by a service outside the container cluster.
[0101] Referring to Figure 5 , Figure 5 Another schematic diagram of a service access system in the embodiment of the present application is shown. The service access system 100 further includes a fourth service 110 outside the container cluster.
[0102] The second service 105 is configured to send a fifth access request to the first DNS server 102 when the second service 105 accesses the fourth service 110.
[0103] The first DNS server 102 is configured to resolve the fifth access request to obtain address information of the fourth service, and send the address information of the fourth service to the second service.
[0104] The second service 105 is further configured to send the fifth access request to the fourth service based on the address information of the fourth service, and receive a fifth request result returned by the fourth service.
[0105] When two services outside the container cluster access each other, the first DNS server outside the container cluster is directly used to resolve the address information corresponding to the two services, and then the two services directly interact with each other.
[0106] The service access system provided in the embodiments of the present application can dynamically register the first service to the first DNS server outside the container cluster and dynamically delete the first service from the first DNS server when the first service is deployed in the container cluster or deleted. In this way, the second service outside the container cluster can directly access the first service in the container cluster through the domain name, thereby saving the manual configuration process. In addition, the third service can be dynamically registered to the first DNS server and dynamically deleted from the first DNS server when the third service is deployed in the container cluster or deleted. When the first service in the container cluster accesses the third service, the first service can access the third service through the domain name registered in the first DNS server in addition to the domain name registered in the second DNS server in the container cluster, thereby improving the flexibility of service access. Moreover, the forwarding of the access request is implemented through the gateway, the load balancing can be performed on multiple gateways, and a load balancer does not need to be corresponded to each service, thereby saving resources.
[0107] The embodiments of the present application also provide a service access method, which is described below with reference to Figure 6 , Figure 6 is a flowchart of the service access method in the embodiments of the present application, applied to a first domain name system (DNS) server outside a container cluster, and a first service is deployed in the container cluster. The service access method comprises the following steps:
[0108] In step S610, when a second service outside the container cluster accesses the first service, a first access request sent by the second service is received.
[0109] In step S620, based on a pre-established correspondence between the first access request and address information of the first gateway, address information of the first gateway corresponding to the first access request is determined.
[0110] In step S630, the address information of the first gateway is sent to the second service, so that the second service sends the first access request to the first gateway. Then, the first gateway determines address information of the first service corresponding to the first access request based on a pre-established correspondence between the first access request and the address information of the first service, sends the first access request to the first service based on the address information of the first service, receives a first request result returned by the first service, and sends the first request result to the second service.
[0111] The embodiments of the present application also provide a service access method, which is described below with reference to Figure 7 , Figure 7 is another flowchart of the service access method in the embodiments of the present application, applied to a first gateway in a container cluster, and a first service is also deployed in the container cluster. The service access method can comprise the following steps:
[0112] Step S710, when the second service outside the container cluster accesses the first service, receiving the first access request sent by the second service based on the address information of the first gateway, wherein the address information of the first gateway is determined and sent to the second service based on the first access request and the address information of the first gateway corresponding relationship established in advance by the first domain name system (DNS) server outside the container cluster.
[0113] Step S720, determining the address information of the first service corresponding to the first access request based on the first access request and the address information of the first service corresponding relationship established in advance.
[0114] Step S730, sending the first access request to the first service based on the address information of the first service.
[0115] Step S740, receiving the first request result returned by the first service, and sending the first request result to the second service.
[0116] Referring to Figure 8 , Figure 8 For an interactive flowchart of the service access method in the embodiments of the present application, the following steps can be included:
[0117] Step S810, when the second service outside the container cluster accesses the first service, the second service sends the first access request to the first DNS server.
[0118] Step S820, determining the address information of the first gateway corresponding to the first access request based on the first access request and the address information of the first gateway corresponding relationship established in advance.
[0119] Step S830, sending the address information of the first gateway to the second service.
[0120] Step S840, the second service sends the first access request to the first gateway based on the address information of the first gateway.
[0121] Step S850, determining the address information of the first service corresponding to the first access request based on the first access request and the address information of the first service corresponding relationship established in advance.
[0122] Step S860, sending the first access request to the first service based on the address information of the first service.
[0123] Step S870, receiving the first request result returned by the first service.
[0124] Step S880, sending the first request result to the second service.
[0125] In some embodiments, the service access method described above further includes the following steps:
[0126] The DNS controller manager deploys the first service in the container cluster in response to the deployment request for the first service, establishes a correspondence between address information of the first gateway and the first access request, and stores the correspondence between the address information of the first gateway and the first access request to the first DNS server; and
[0127] The correspondence between the first access request and the address information of the first service is established, and the correspondence between the first access request and the address information of the first service is stored to the first gateway.
[0128] In some embodiments, the service access method further includes the following steps:
[0129] The DNS controller manager is further configured to delete the first service from the container cluster in response to a deletion request for the first service, delete the correspondence between the address information of the first gateway and the first access request from the first DNS server, and delete the correspondence between the first access request and the address information of the first service from the first gateway.
[0130] In some embodiments, the service access method further includes the following steps:
[0131] When the first service accesses the third service, and the second access request sent by the first service belongs to the first type of request, the first service sends the second access request to the first DNS server;
[0132] The first DNS server determines the address information of the second gateway corresponding to the second access request based on the pre-established correspondence between the address information of the second gateway and the second access request, and sends the address information of the second gateway to the first service;
[0133] The first service sends the second access request to the second gateway based on the address information of the second gateway;
[0134] The second gateway determines the address information of the third service corresponding to the second access request based on the pre-established correspondence between the second access request and the address information of the third service, sends the second access request to the third service based on the address information of the third service, receives the second request result returned by the third service, and sends the second request result to the first service.
[0135] In some embodiments, the service access method further includes the following steps:
[0136] When the first service accesses the third service, and the third access request sent by the first service belongs to the second type of request, the first service sends the third access request to the second DNS server;
[0137] The second DNS server resolves the third access request, determines address information of the third service, and sends the address information of the third service to the first service;
[0138] The first service sends a third access request to the third service based on the address information of the third service, and receives a third request result returned by the third service.
[0139] In some embodiments, the service access method further includes the following steps:
[0140] When the first service accesses the second service, the first service sends a fourth access request to the second DNS server;
[0141] The second DNS server sends the fourth access request to the first DNS server;
[0142] The first DNS server resolves the fourth access request to obtain address information of the second service, and sends the address information of the second service to the second DNS server;
[0143] The second DNS server sends the address information of the second service to the first service;
[0144] The first service sends a fourth access request to the second service based on the address information of the second service, and receives a fourth request result returned by the second service.
[0145] In some embodiments, the service access method further includes the following steps:
[0146] When the second service accesses a fourth service outside the container cluster, the second service sends a fifth access request to the first DNS server;
[0147] The first DNS server resolves the fifth access request to obtain address information of the fourth service, and sends the address information of the fourth service to the second service;
[0148] The second service sends a fifth access request to the fourth service based on the address information of the fourth service, and receives a fifth request result returned by the fourth service.
[0149] The specific details of each step in the above method have been described in detail in the corresponding system, and therefore will not be described here.
[0150] An electronic device is provided in the embodiments of the present application, which includes a processor configured to execute a computer program stored in a memory, and the computer program is configured to implement the above service access method when executed by the processor.
[0151] Figure 9 A structural schematic diagram of an electronic device in the embodiments of the present application. It should be noted that, Figure 9The electronic device 900 shown is merely one example, and should not be taken as limiting the scope of functionality or use of embodiments of the application.
[0152] As shown in Figure 9 The electronic device 900 includes a central processing unit (CPU) 901 that can perform various appropriate actions and processes according to programs stored in a read only memory (ROM) 902 or programs loaded into a random access memory (RAM) 903 from a storage section 908. In the RAM 903, various programs and data required for system operation are also stored. The central processing unit 901, the ROM 902, and the RAM 903 are connected to each other through a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0153] Connected to the I / O interface 905 are an input section 906 including a keyboard, a mouse, etc.; an output section 907 including a display such as a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a local area network (LAN) card, a modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as necessary. A removable media 911 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is attached to the drive 910 as necessary, so that a computer program read out therefrom is installed in the storage section 908 as necessary.
[0154] In particular, according to embodiments of the present application, the processes described above with reference to the flowcharts can be implemented as a computer software program. For example, embodiments of the present application include a computer program product comprising a computer program carried on a computer readable medium, the computer program containing program code for executing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network by the communication section 909, and / or installed from the removable media 911. When the computer program is executed by the central processing unit 901, various functions defined in the apparatus of the present application are performed.
[0155] In embodiments of the present application, there is also provided a computer readable storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the service access method described above.
[0156] Note that the computer-readable storage media described herein can be transitory or non-transitory computer-readable storage media, a non-limiting example of which includes a tangible medium that can be accessed (read) in a particular manner by a computer. Non-limiting examples of tangible computer- readable storage media include hard disks, floppy disks, magnetic tape, optical disk, magnetic hard drive, solid state hard drive (SSD) or drive, random access memory (RAM), and CD-ROM. Non-transitory computer-readable storage media do not include communication media, which can refer to any medium that can be used to carry desired program code in a modulated data signal. The modulated data signal is itself merely a carrier wave including the desired program code, and does not include the tangible storage medium described above. A non-limiting example of a communication medium includes a wired medium such as a wired network or direct-wired connection carrying the modulated data signal. Another non-limiting example of a communication medium includes a wireless medium such as an RF, Wi-Fi, or other wireless network connection, carrying the modulated data signal.
[0157] In an embodiment of the present application, a computer program product is provided, which, when running on a computer, causes the computer to perform the service access method.
[0158] It should be noted that the relational terms herein, such as first and second, and the like, are used solely to distinguish one from another entity or action without necessarily requiring or implying any actual relationship or order between such entities or actions. Moreover, the terms "comprises", "comprising", or any other variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. Additionally, the term "about" is used to indicate that a value, parameter, measurement, or other representation can have some flexibility, and is not intended to be perfect or exact.
[0159] The foregoing is considered as illustrative only of the principles of the application. Numerous modifications and changes will readily occur to those skilled in the art, which modifications and changes are to be understood as intended to be encompassed by the general scope of the application. Accordingly, the application is not to be limited to the above described ones; rather, the above described ones are to serve as a basis for the claims as they follow.
Claims
1. A service access system, characterized in that, The service access system includes: a first service and a first gateway within the container cluster, and a first Domain Name System (DNS) server and a second service outside the container cluster. The service access system also includes: a third service and a second gateway within the container cluster. The second service is used to send a first access request to the first DNS server when the second service accesses the first service; The first DNS server is used to determine the address information of the first gateway corresponding to the first access request based on the pre-established correspondence between the address information of the first access request and the address information of the first gateway, and send the address information of the first gateway to the second service. The second service is also used to send the first access request to the first gateway based on the address information of the first gateway; The first gateway is configured to determine the address information of the first service corresponding to the first access request based on a pre-established correspondence between the address information of the first access request and the address information of the first service, send the first access request to the first service based on the address information of the first service, receive the first request result returned by the first service, and send the first request result to the second service. The first service is configured to send the second access request to the first DNS server when the first service accesses the third service and the second access request sent by the first service belongs to the first type of request; The first DNS server is further configured to determine the address information of the second gateway corresponding to the second access request based on the pre-established correspondence between the address information of the second gateway and the second access request, and send the address information of the second gateway to the first service. The first service is further configured to send the second access request to the second gateway based on the address information of the second gateway; The second gateway is configured to determine the address information of the third service corresponding to the second access request based on a pre-established correspondence between the second access request and the address information of the third service, send the second access request to the third service based on the address information of the third service, receive the second request result returned by the third service, and send the second request result to the first service.
2. The system according to claim 1, characterized in that, The service access system also includes: the DNS controller manager within the container cluster; The DNS controller manager is configured to, in response to a deployment request for the first service, deploy the first service in the container cluster, establish a mapping between the address information of the first gateway and the first access request, and store the mapping between the address information of the first gateway and the first access request in the first DNS server; and Establish a correspondence between the address information of the first access request and the first service, and store the correspondence between the address information of the first access request and the first service in the first gateway.
3. The system according to claim 2, characterized in that, The DNS controller manager is further configured to, in response to a deletion request for the first service, delete the first service from the container cluster, delete the mapping between the address information of the first gateway and the first access request from the first DNS server, and delete the mapping between the address information of the first access request and the address information of the first service from the first gateway.
4. The system according to claim 1, characterized in that, The service access system also includes: a second DNS server within the container cluster; The first service is configured to send a third access request to the second DNS server when the first service accesses the third service and the third access request sent by the first service belongs to the second type of request. The second DNS server is used to resolve the third access request, determine the address information of the third service, and send the address information of the third service to the first service. The first service is further configured to send the third access request to the third service based on the address information of the third service, and receive the third request result returned by the third service.
5. The system according to claim 4, characterized in that, The first service is configured to send a fourth access request to the second DNS server when the first service accesses the second service; The second DNS server is also used to send the fourth access request to the first DNS server; The first DNS server is further configured to resolve the fourth access request, obtain the address information of the second service, and send the address information of the second service to the second DNS server; The second DNS server is also used to send the address information of the second service to the first service; The first service is further configured to send the fourth access request to the second service based on the address information of the second service, and receive the fourth request result returned by the second service.
6. The system according to claim 1, characterized in that, The service access system also includes: a fourth service outside the container cluster; The second service is used to send a fifth access request to the first DNS server when the second service accesses the fourth service; The first DNS server is used to resolve the fifth access request, obtain the address information of the fourth service, and send the address information of the fourth service to the second service; The second service is also used to send a fifth access request to the fourth service based on the address information of the fourth service, and to receive the fifth request result returned by the fourth service.
7. A service access method, characterized in that, The method is applied to a first Domain Name System (DNS) server outside a container cluster in the service access system according to any one of claims 1 to 6, wherein a first service is deployed within the container cluster included in the service access system, and the service access system further includes: a third service and a second gateway within the container cluster, and the method includes: When a second service outside the container cluster accesses the first service, the first access request sent by the second service is received. Based on the pre-established correspondence between the first access request and the address information of the first gateway, the address information of the first gateway corresponding to the first access request is determined; The address information of the first gateway is sent to the second service, so that the second service sends the first access request to the first gateway, thereby enabling the first gateway to determine the address information of the first service corresponding to the first access request based on the pre-established correspondence between the address information of the first access request and the address information of the first service; the first access request is sent to the first service based on the address information of the first service; the first request result returned by the first service is received, and the first request result is sent to the second service. When the first service accesses the third service, and the second access request sent by the first service belongs to the first type of request, the service receives the second access request sent by the first service, determines the address information of the second gateway corresponding to the second access request based on the pre-established correspondence between the address information of the second gateway and the second access request, and sends the address information of the second gateway to the first service, so that the first service sends the second access request to the second gateway based on the address information of the second gateway, thereby enabling the second gateway to determine the address information of the third service corresponding to the second access request based on the pre-established correspondence between the address information of the second access request and the third service, sends the second access request to the third service based on the address information of the third service, receives the second request result returned by the third service, and sends the second request result to the first service.
8. A service access method, characterized in that, The method is applied to a first gateway within a container cluster in the service access system according to any one of claims 1 to 6, wherein the service access system includes a first service deployed within the container cluster, and the service access system further includes: a third service and a second gateway within the container cluster, the method comprising: When a second service outside the container cluster accesses the first service, a first access request is received from the second service based on the address information of the first gateway. The address information of the first gateway is determined by the first domain name system DNS server outside the container cluster based on the pre-established correspondence between the first access request and the address information of the first gateway, and is then sent to the second service by the first access request received from the second service. Based on the pre-established correspondence between the address information of the first access request and the address information of the first service, the address information of the first service corresponding to the first access request is determined; The first access request is sent to the first service based on the address information of the first service. Receive the first request result returned by the first service, and send the first request result to the second service.
9. An electronic device, characterized in that, include: A processor for executing a computer program stored in a memory, wherein the computer program, when executed by the processor, implements the service access method of claim 7 or 8.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the service access method as described in claim 7 or 8.
Citation Information
Patent Citations
Domain name resolution method and device, electronic equipment and storage medium
CN111245944A
Setting up a name resolution system for home-to-home communications
US20050066041A1