Service access method and device, electronic equipment and storage medium

By deploying the domain name system center and the domain name system sentinel in the K8S cluster, the problem of cross-K8S cluster access services is solved, and unaware cross-cluster access is achieved and operation and maintenance complexity is reduced.

CN119835316AActive Publication Date: 2025-04-15CHINA TELECOM CLOUD TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411744408.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-30
Publication Date
2025-04-15
Estimated Expiration
2044-11-30

AI Technical Summary

Technical Problem

The existing K8S cluster service access methods cannot meet the needs of cross-cluster access services, especially in business deployment scenarios across K8S clusters.

Method used

By deploying the domain name system center and domain name system sentinel in the central cluster and dedicated cluster, the domain name system sentinel is used to establish communication connections between the central cluster and dedicated cluster, and service access across the K8S cluster is achieved.

Benefits of technology

It realizes cross-cluster access services without perception in business deployment scenarios across K8S clusters, reducing operation and maintenance complexity and improving system maintainability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119835316A_ABST
    Figure CN119835316A_ABST
Patent Text Reader

Abstract

The invention provides a service access method and device, electronic equipment and a storage medium, and the method comprises the steps: deploying a domain name system center in a center cluster, and deploying domain name system sentries in a special cluster and the center cluster, the method comprises the following steps: establishing communication connection between a central cluster and a special cluster through a domain name system sentry, judging whether a service container accesses a service container in the central cluster through a cluster domain name system, and obtaining a target service address through a domain name system center under the condition that the service container accesses the service container in the central cluster, and accessing a service corresponding to the target service address in the service container according to the target service address. The domain name system center and the domain name system sentinel are deployed in the center cluster and the special cluster, the link between the center cluster and the special cluster is opened through the domain name system sentinel, and service access across the K8S cluster is achieved in a service deployment scene across the K8S cluster.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of K8S cluster technology, and in particular to a service access method, device, electronic device and storage medium. Background Art

[0002] With the rapid development of cloud computing technology, containerization technology has become the mainstream way of modern application deployment. As a container orchestration system, Kubernetes (K8S for short) has become the de facto standard for container orchestration in cloud computing due to its powerful functions and flexibility. K8S not only supports the rapid deployment and scaling of applications, but also provides key functions such as service discovery and load balancing, making it widely adopted by major cloud vendors.

[0003] However, with the continuous expansion and complexity of enterprise business, the demand for cross-K8S cluster business deployment is gradually increasing. In the scenario of cross-cluster business deployment, the existing K8S cluster service access method cannot meet the demand for cross-cluster service access. Therefore, how to achieve cross-K8S cluster service access in the cross-K8S cluster business deployment scenario has become an urgent problem to be solved. Summary of the invention

[0004] In view of the above problems, a service access method, device, electronic device and storage medium are proposed to overcome the above problems or at least partially solve the above problems, including:

[0005] In a first aspect, an embodiment of the present application provides a service access method, the method comprising:

[0006] Taking any one of the clusters as a central cluster, and deploying a domain name system center in the central cluster;

[0007] At least one of the clusters other than the central cluster is used as a dedicated cluster, and a domain name system sentinel, a business container and a cluster domain name system are deployed in the dedicated cluster and the central cluster respectively;

[0008] Establishing a communication connection between the central cluster and the dedicated cluster through the domain name system sentinel;

[0009] When the communication connection between the central cluster and the dedicated cluster is established, determining, by the cluster domain name system, whether the business container accesses the service container in the central cluster;

[0010] When the business container accesses the service container in the central cluster, obtaining a target service address through the domain name system center;

[0011] The service corresponding to the target service address in the service container is accessed according to the target service address.

[0012] Optionally, establishing a communication connection between the central cluster and the dedicated cluster through the domain name system sentinel includes:

[0013] Obtaining a configuration file of the domain name system sentinel, wherein the configuration file includes a service name;

[0014] Sending a query request to the cluster domain name system through the domain name system sentinel, wherein the query request includes a service name;

[0015] When the cluster domain name system receives the query request, the service name is parsed to obtain a service address;

[0016] Sending the service address to the DNS Sentinel;

[0017] When the DNS sentinel receives the service address, sending a registration request to the DNS center, wherein the registration request includes the service name and the service address;

[0018] When the domain name system center receives the registration request, registering the service name and the service address to obtain a registration result;

[0019] The registration result is sent to the domain name system sentinel.

[0020] Optionally, the cluster includes nodes;

[0021] The establishing of a communication connection between the central cluster and the dedicated cluster through the domain name system sentinel comprises:

[0022] In the case where the node where the domain name system sentinel is located is a network element node, sending the service address and the cluster corresponding to the service address to a pre-deployed switch through the domain name system sentinel;

[0023] When the switch receives the service address and the cluster corresponding to the service address, a corresponding relationship between the service address and the cluster is established, and the corresponding relationship between the service address and the cluster is stored.

[0024] Optionally, establishing a communication connection between the central cluster and the dedicated cluster through the domain name system sentinel includes:

[0025] Obtaining a configuration file of the cluster domain name system through the domain name system sentinel;

[0026] Configuring an upstream domain name system server of the cluster domain name system in the configuration file as the domain name system center;

[0027] When the configuration is completed, obtaining the service address from the domain name system center through the domain name system sentinel;

[0028] When the domain name system sentinel receives the service address, the next hop of the service address is configured as the switch.

[0029] Optionally, the determining, by the cluster domain name system, whether the business container accesses a service container in the central cluster includes:

[0030] Sending a query request to the cluster domain name system in the dedicated cluster through the business container, wherein the query request includes a target service name;

[0031] When the cluster domain name system receives the query request, determining whether there is a target service address corresponding to the target service name in the local cache of the cluster domain name system;

[0032] If the target service address corresponding to the target service name exists in the local cache, determining that the business container stops accessing the service container in the central cluster;

[0033] When the target service address corresponding to the target service name does not exist in the local cache, it is determined that the business container accesses the service container in the central cluster.

[0034] Optionally, obtaining the target service address through the domain name system center includes:

[0035] Sending the query request to the domain name system center through the cluster domain name system;

[0036] When the domain name system center receives the query request, obtaining a target service address corresponding to the target service name;

[0037] Sending the target service address corresponding to the target service name to the cluster domain name system;

[0038] When the cluster domain name system receives the target service address, the target service address is sent to the business container.

[0039] Optionally, the central cluster includes a domain name system sentinel container and a service container;

[0040] The accessing, according to the target service address, the service in the service container corresponding to the target service address comprises:

[0041] When the service container receives the target service address, generating a target message including the target service address;

[0042] Sending the target message to the switch;

[0043] When the switch receives the target message, judging whether the cluster corresponding to the target service address is the central cluster according to the target service address and the correspondence between the service address and the cluster;

[0044] When the cluster corresponding to the target service address is the central cluster, sending the target message to the domain name system sentinel container;

[0045] When the domain name system sentinel container receives the target message, the target message is sent to the service container, so that the service in the service container accesses the service in the service container.

[0046] In a second aspect, an embodiment of the present application provides a service access device, the device comprising:

[0047] A domain name system center deployment module, used to take any cluster as a center cluster and deploy a domain name system center in the center cluster;

[0048] A domain name system sentinel deployment module, used to use at least one of the clusters outside the central cluster as a dedicated cluster, and deploy a domain name system sentinel, a business container and a cluster domain name system in the dedicated cluster and the central cluster respectively;

[0049] A domain name system sentinel configuration module, used to establish a communication connection between the central cluster and the dedicated cluster through the domain name system sentinel;

[0050] A cross-cluster access judgment module, used to judge whether the business container accesses the service container in the central cluster through the cluster domain name system when the communication connection between the central cluster and the dedicated cluster is established;

[0051] A service address determination module, configured to obtain a target service address through the domain name system center when the business container accesses a service container in the central cluster;

[0052] The target service access module is used to access the service corresponding to the target service address in the service container according to the target service address.

[0053] In a third aspect, an embodiment of the present application further provides an electronic device, comprising: a processor; and a memory for storing instructions executable by the processor, wherein the processor is configured to execute the instructions to implement any of the service access methods described above.

[0054] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which, when instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to execute any of the service access methods described above.

[0055] In an embodiment of the present application, any cluster is used as a central cluster, a domain name system center is deployed in the central cluster, at least one cluster other than the central cluster is used as a dedicated cluster, and domain name system sentinels are deployed in the dedicated cluster and the central cluster, respectively, wherein the dedicated cluster includes a business container and a cluster domain name system, and a communication connection between the central cluster and the dedicated cluster is established through the domain name system sentinel. When the communication connection between the central cluster and the dedicated cluster is established, the cluster domain name system is used to determine whether the business container accesses the service container in the central cluster. When the business container accesses the service container in the central cluster, the target service address is obtained through the domain name system center, and the service corresponding to the target service address in the service container is accessed according to the target service address. The present application deploys a domain name system center and a domain name system sentinel in the central cluster and the dedicated cluster, and uses the domain name system sentinel to open up the link between the central cluster and the dedicated cluster. In the cross-K8S cluster business deployment scenario, cross-K8S cluster service access is realized, and the service can be accessed across clusters only through the service address, so that users can access services across clusters without changing the code at the business level and the configuration at the operation and maintenance deployment level, that is, they can access services across clusters without perception. In addition, the communication connection between the central cluster and the dedicated cluster is established through the domain name system sentinel, so that the operation and maintenance personnel do not need to manually specify the IP (Internet Protocol) and port, which reduces the complexity of operation and maintenance and improves the maintainability of the system.

[0056] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] 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 present application. Also, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:

[0058] Figure 1 This is one of the step flow charts of a service access method provided in an embodiment of the present application;

[0059] Figure 2 This is a schematic diagram of a scenario in which some services in a central cluster are deployed in a dedicated cluster provided by the implementation of this application;

[0060] Figure 3 This is a schematic diagram of a workflow of a domain name system center provided in an embodiment of the present application;

[0061] Figure 4 It is a schematic diagram of a service registration provided by the implementation of this application;

[0062] Figure 5 It is a workflow diagram of a domain name system sentinel provided by the implementation of this application;

[0063] Figure 6 It is a schematic diagram of a service address routing announcement provided by the implementation of this application;

[0064] Figure 7 It is a schematic diagram of a service address query provided by the implementation of this application;

[0065] Figure 8 This is a workflow diagram of a service address query provided by the implementation of this application;

[0066] Fig. 9 This is a schematic diagram of a business container accessing a service container across clusters provided by the implementation of this application;

[0067] Fig.10 is a device block diagram of a service access device provided in an embodiment of the present application;

[0068] Fig.11 It is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0069] The exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application 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 application and to fully convey the scope of the present application to those skilled in the art.

[0070] To facilitate understanding, the terms involved in the embodiments of the present application are first briefly introduced.

[0071] 1. K8S (Kubernetes) cluster

[0072] K8S cluster is a container orchestration tool and an open source system for automatically deploying, scaling, and managing containerized applications.

[0073] 2. DNS (Domain Name System)

[0074] DNS is a distributed database on the Internet that maps domain names to IP addresses. It allows users to access the Internet more conveniently without having to remember IP numbers that can be directly read by machines. The process of obtaining the IP address corresponding to a host through a host name is called domain name resolution (or host name resolution). The DNS protocol runs on top of the UDP protocol and uses port number 53.

[0075] 3. BGP (Border Gateway Protocol)

[0076] BGP is a core decentralized autonomous routing protocol on the Internet.

[0077] 4. CIDR (Classless Inter-Domain Routing)

[0078] CIDR eliminates the traditional Class A, Class B, and Class C addresses and the concept of subnetting, thus allocating IPv4 address space more efficiently. It can combine several IP networks together, using a classless inter-domain routing algorithm to merge them into one route, thereby reducing the number of routing entries in the routing table and alleviating the burden on Internet routers.

[0079] 5. Service Name

[0080] The service name is a concept in the K8S cluster, which is equivalent to the domain name in DNS.

[0081] 6. Service address

[0082] The service address is a concept in the K8S cluster, which is equivalent to the IP address in DNS.

[0083] In conjunction with the accompanying drawings, a service access method, device, storage medium and vehicle provided in an embodiment of the present application are described in detail below through specific embodiments and their application scenarios.

[0084] Figure 1is a flow chart of the steps of a service access method provided by an embodiment of the present application, such as Figure 1 As shown, the method includes:

[0085] Step 101: Take any cluster as a central cluster and deploy a domain name system center in the central cluster.

[0086] Step 102: Use at least one cluster other than the central cluster as a dedicated cluster, and deploy a domain name system sentinel, a business container, and a cluster domain name system in the dedicated cluster and the central cluster, respectively.

[0087] It should be noted that in the embodiment of the present application, the cluster may be a kubernetes (K8S for short) cluster.

[0088] The application scenario of this application is that some services in a K8S cluster are deployed in other K8S clusters other than the K8S cluster, such as Figure 2 As shown, the management platform in a K8S cluster can be deployed in other K8S clusters except the K8S cluster, and the K8S cluster deploying the management platform can be a general computing K8S cluster; the computing business in a K8S cluster can be deployed in other K8S clusters except the K8S cluster, and the K8S cluster deploying the computing business can be a computing K8S cluster; the high IO (Input / Output) business in a K8S cluster can be deployed in other K8S clusters except the K8S cluster, and the K8S cluster deploying the high IO business can be a high IO K8S cluster; the heterogeneous computing business in a K8S cluster can be deployed in other K8S clusters except the K8S cluster, and the K8S cluster deploying the heterogeneous computing business can be a heterogeneous K8S cluster.

[0089] Among them, in this application scenario, that is, some businesses in a K8S cluster are deployed in other K8S clusters except this K8S cluster. This K8S cluster can be used as the central cluster, and other K8S clusters except this K8S cluster can be used as dedicated clusters.

[0090] To ensure that the business container in the dedicated cluster can access the service container in the central cluster, after setting up the central cluster and the dedicated cluster, you can deploy the Domain Name System Center (DNS-central) in the central cluster, and deploy the Domain Name System Sentinel (DNS-sentinel), business container, and cluster Domain Name System (coredns) in the dedicated cluster and the central cluster respectively.

[0091] After you have deployed the DNS center, Figure 3As shown, when the domain name system center is started, the domain name system center will send a query request to the cluster domain name system in the K8S cluster, where the query request includes the service name of the domain name system center. When the cluster domain name system receives the query request, the cluster domain name system resolves the service name of the domain name system center, obtains the service address of the domain name system center, and sends the service address of the domain name system center to the domain name system center; when the domain name system center receives the service address, the service name and service address of the domain name system center are stored as the first record in the domain name system center and managed.

[0092] In addition, the domain name system center will regularly organize the stored service names and service addresses, and summarize the service addresses using CIDR (Classless InterDomain Routing).

[0093] In addition, if a new cluster needs to be added, you only need to deploy a domain name system sentinel in the new cluster to complete the work related to service name, service address registration and service address routing announcement, and then migrate or expand the business without any perception.

[0094] Step 103: Establish a communication connection between the central cluster and the dedicated cluster through the domain name system sentinel.

[0095] Step 104: After the communication connection between the central cluster and the dedicated cluster is established, it is determined through the cluster domain name system whether the business container accesses the service container in the central cluster.

[0096] Step 105: When the business container accesses the service container in the central cluster, the target service address is obtained through the domain name system center.

[0097] Step 106: Access the service corresponding to the target service address in the service container according to the target service address.

[0098] It should be noted that in an embodiment of the present application, after the deployment of the domain name system sentinel is completed, the link between the central cluster and the dedicated cluster is opened through the domain name system sentinel, that is, a communication connection is established between the central cluster and the dedicated cluster. When a communication connection is established between the central cluster and the dedicated cluster, the cluster domain name system is used to determine whether the business container in the dedicated cluster needs to cross the K8S cluster to access the service container in the central cluster. If the judgment result is that the business container in the dedicated cluster needs to cross the K8S cluster to access the service container in the central cluster, the business container will query the domain name system center for the target service address. When the business container obtains the target service address, the business container will access the service corresponding to the target service address in the service container according to the target service address.

[0099] This application deploys a domain name system center and a domain name system sentinel in a central cluster and a dedicated cluster, and uses the domain name system sentinel to open up the link between the central cluster and the dedicated cluster. In a cross-K8S cluster business deployment scenario, service access across K8S clusters is achieved, and services can be accessed across clusters simply by using the service address, enabling users to access services across clusters without having to make code changes at the business level and configuration changes at the operation and maintenance deployment level, that is, achieving imperceptible cross-cluster access to services. In addition, by establishing a communication connection between the central cluster and the dedicated cluster through the domain name system sentinel, the operation and maintenance personnel do not need to manually specify the IP (Internet Protocol) and port, which reduces the complexity of operation and maintenance and improves the maintainability of the system.

[0100] Furthermore, in the embodiment of the present application, step 103 may also include the following steps:

[0101] Sub-step 11, obtaining a configuration file of the domain name system sentinel, wherein the configuration file includes a service name.

[0102] Sub-step 12: Send a query request to the cluster domain name system through the domain name system sentinel, wherein the query request includes the service name.

[0103] Sub-step 13, when the cluster domain name system receives the query request, the service name is resolved to obtain the service address.

[0104] Sub-step 14, sending the service address to the domain name system sentinel.

[0105] Sub-step 15, when the DNS sentinel receives the service address, it sends a registration request to the DNS center, wherein the registration request includes the service name and the service address.

[0106] Sub-step 16, when the domain name system center receives the registration request, the service name and service address are registered to obtain a registration result.

[0107] Sub-step 17, sending the registration result to the domain name system sentinel.

[0108] It should be noted that in the embodiments of the present application, Figure 4 As shown, after the deployment of the domain name system sentinel is completed, the domain name system sentinel will register the information of the services that need to be exposed with the domain name system center, where the information includes the service name and service address.

[0109] The specific implementation process of the DNS Sentinel registering the information of the services to be exposed with the DNS center is as follows: Figure 5As shown in the figure, the DNS Sentinel will first send a configuration file acquisition request to the backend component kube-apiserver in the K8S cluster. When kube-apiserver receives the configuration file acquisition request sent by the DNS Sentinel, it sends the DNS Sentinel configuration file (configmap) to the DNS Sentinel, where the DNS Sentinel configuration file includes the information of the services that need to be exposed (service name and service address).

[0110] When the DNS Sentinel receives the configuration file sent by the kube-apiserver, the DNS Sentinel sends a query request to the cluster DNS, where the query request includes the service name in the configuration file. When the cluster DNS receives the query request sent by the DNS Sentinel, it parses the service name included in the query request, obtains the service address corresponding to the service name, and sends the service address to the DNS Sentinel. When the DNS Sentinel receives the service address, the DNS Sentinel sends a registration request to the DNS Center, where the registration request includes the service name and the service address. When the DNS Center receives the registration request, it registers the service name and the service address included in the registration request, generates a registration result, and sends the registration result to the DNS Sentinel.

[0111] This application registers the information of the services to be exposed to the cluster domain name system through the domain name system sentinel, where the information includes the service name and service address, so that the services in the K8S cluster will only be exposed to the outside through the node where the domain name system sentinel is located, and the data link is clear and controllable. At the same time, it will not cause competition for the host port number, avoiding additional security maintenance caused by the exposure of the host port and host port conflicts.

[0112] Furthermore, in the embodiment of the present application, step 103 may also include the following steps:

[0113] Sub-step 21, when the node where the domain name system sentinel is located is a network element node, the service address and the cluster corresponding to the service address are sent to the pre-deployed switch through the domain name system sentinel.

[0114] Sub-step 22: when the switch receives the service address and the cluster corresponding to the service address, establish a corresponding relationship between the service address and the cluster, and store the corresponding relationship between the service address and the cluster.

[0115] It should be noted that, in the embodiment of the present application, after the deployment of the domain name system sentinel is completed, such as Figure 6As shown, the DNS sentinel announces the routing information of the service address to be exposed to the switch through BGP (Border Gateway ProtocolBorder Gateway Protocol), that is, announces the service address route to the switch.

[0116] Specifically, the K8S cluster includes several nodes, on which a DNS sentinel container is deployed, and the DNS sentinel container includes a DNS sentinel. If the node where the DNS sentinel is located is a network element node, the DNS sentinel sends the routing information of the service address to be exposed, that is, the service address and the cluster corresponding to the service address, to the pre-deployed switch. When the switch receives the service address and the cluster corresponding to the service address, a corresponding relationship between the service address and the cluster is established, and the corresponding relationship between the service address and the cluster is recorded and stored.

[0117] This application realizes the automatic configuration of cross-cluster routing through the collaboration of DNS Sentinel and switch, so that the business can continue to use the service name in the cross-cluster scenario and transparently access the service through the service address. This method not only improves the flexibility of the business, but also provides strong support for the expansion of the business, allowing enterprises to achieve cross-K8S cluster business migration and service access without modifying the business code and operation and maintenance configuration.

[0118] Furthermore, in the embodiment of the present application, step 103 may also include the following steps:

[0119] Sub-step 31, obtaining the configuration file of the cluster domain name system through the domain name system sentinel.

[0120] Sub-step 32, configuring the upstream domain name system server of the cluster domain name system in the configuration file as the domain name system center.

[0121] Sub-step 33, when the configuration is completed, obtain the service address from the domain name system center through the domain name system sentinel.

[0122] Sub-step 34, when the domain name system sentinel receives the service address, configure the next hop of the service address as a switch.

[0123] It should be noted that, in the embodiment of the present application, after the deployment of the domain name system sentinel is completed, such as Figure 5As shown in the figure, the DNS Sentinel sends a configuration file acquisition request to the backend component kube-apiserver in the K8S cluster. When the kube-apiserver receives the configuration file acquisition request sent by the DNS Sentinel, it sends the cluster DNS configuration file to the DNS Sentinel. When the DNS Sentinel receives the cluster DNS configuration file, it sets the upstream DNS server of the cluster DNS in the configuration file to the DNS center.

[0124] In addition, the domain name system center will regularly summarize the service addresses and obtain CIDR information, such as Figure 5 As shown in Figure 1, the DNS Sentinel also periodically obtains CIDR information, that is, the service address, from the DNS center. When the DNS Sentinel receives the service address, it configures the next hop of the service address as a switch to ensure that the service address is sent to the switch instead of the local end.

[0125] This application configures the upstream DNS server of the cluster DNS as the DNS center, ensuring that when the service address cannot be obtained in the cluster DNS, the cluster DNS can be queried to establish a communication connection between the dedicated cluster and the central cluster. In addition, this application configures the next hop of the service address as a switch to ensure that the service address will be sent to the switch instead of the local end, thereby enabling cross-cluster service access through the switch.

[0126] Furthermore, in the embodiment of the present application, step 104 may also include the following steps:

[0127] Sub-step 41, sending a query request to a cluster domain name system in the dedicated cluster through the business container, wherein the query request includes a target service name;

[0128] Sub-step 42: when the cluster domain name system receives the query request, it is determined whether there is a target service address corresponding to the target service name in the local cache of the cluster domain name system.

[0129] Sub-step 43: when the target service address corresponding to the target service name exists in the local cache, determine that the business container stops accessing the service container in the central cluster.

[0130] Sub-step 44 , when the target service address corresponding to the target service name does not exist in the local cache, determining that the business container accesses the service container in the central cluster.

[0131] It should be noted that in the embodiments of the present application, Figure 7As shown, in order to determine whether the business container in the dedicated cluster needs to access the service container in the central cluster across the K8S cluster, the business container in the dedicated cluster will query the cluster domain name system in the dedicated cluster for the service address.

[0132] Specifically, Figure 8 As shown, the business container sends a query request to the cluster domain name system, wherein the query request includes the target service name. When the cluster domain name system receives the query request, it determines whether there is a target service address corresponding to the target service name in the local cache of the cluster domain name system.

[0133] If the target service address corresponding to the target service name exists in the local cache of the cluster domain name system, it is determined that the business container in the dedicated cluster does not access the service container in the central cluster across the K8S cluster. If the target service address corresponding to the target service name does not exist in the local cache of the cluster domain name system, it is determined that the business container in the dedicated cluster needs to access the service container in the central cluster across the K8S cluster.

[0134] This application determines whether the business container in the dedicated cluster needs to access the service container in the central cluster across the K8S cluster by querying whether the target service name corresponds to the target service address in the local cache of the cluster domain name system. This not only reduces unnecessary cross-cluster access, thereby reducing network latency and improving service response speed, but also enables rapid decision-making on service access, allowing the business to continue to use the service name in cross-cluster scenarios and transparently access the service through the service address. This approach not only simplifies the complexity of business migration, but also avoids code changes at the business level and configuration changes at the operation and maintenance deployment level, achieving imperceptible migration of the business.

[0135] Furthermore, in the embodiment of the present application, step 105 may also include the following steps:

[0136] Sub-step 51, sending the query request to the domain name system center through the cluster domain name system.

[0137] Sub-step 52, when the domain name system center receives the query request, obtain the target service address corresponding to the target service name.

[0138] Sub-step 53, sending the target service address corresponding to the target service name to the cluster domain name system.

[0139] Sub-step 54: When the cluster domain name system receives the target service address, the target service address is sent to the business container.

[0140] It should be noted that in the embodiments of the present application, Figure 8As shown, when the target service address corresponding to the target service name does not exist in the local cache of the cluster domain name system, it means that the business container in the dedicated cluster needs to access the service container in the central cluster across the K8S cluster. The cluster domain name system will further send the query request to the domain name system center, and query the service address through the domain name system center. When the domain name system center receives the query request sent by the cluster domain name system, the domain name system center will query the target service address corresponding to the target service name according to the target service name included in the query request, and send the target service address corresponding to the queried target service name to the cluster domain name system. When the cluster domain name system receives the target service address sent by the domain name system center, it returns the received target service address to the business container.

[0141] This application, when the target service address corresponding to the target service name does not exist in the local cache of the cluster domain name system, further queries the service address through the domain name system center, and sends the target service address to the business container. The service address is centrally managed by the domain name system center, thereby achieving rapid query of the service address. This not only improves the efficiency of service address query, improves the reliability and stability of the system, realizes imperceptible migration of the business, but also improves the flexibility and scalability of the business.

[0142] Furthermore, in the embodiment of the present application, step 106 may also include the following steps:

[0143] Sub-step 61: When the service container receives the target service address, a target message including the target service address is generated.

[0144] Sub-step 62, sending the target message to the switch.

[0145] Sub-step 63, when the switch receives the target message, it is determined whether the cluster corresponding to the target service address is the central cluster according to the target service address and the correspondence between the service address and the cluster.

[0146] Sub-step 64, when the cluster corresponding to the target service address is a central cluster, sending the target message to the domain name system sentinel container.

[0147] Sub-step 65: When the DNS sentinel container receives the target message, the target message is sent to the service container, so that the service in the service container accesses the service in the service container.

[0148] It should be noted that in the embodiments of the present application, Fig. 9As shown, when the business container in the dedicated cluster receives the target service address sent by the domain name system center, it will generate a target message containing the target service address and send the target message to the physical machine where the business container is located. When the physical machine where the business container is located receives the target message, it will send the target message to the switch through the physical network, where the switch can be a three-layer switch.

[0149] Since the switch records and stores the correspondence between the service address and the cluster, when the switch receives the target message sent by the physical machine where the business container is located, the switch will query the corresponding cluster according to the target service address in the target message and the correspondence between the service address and the cluster. According to the queried cluster, it is determined whether the queried cluster is the central cluster. If the queried cluster is the central cluster, the switch will send the target message to the physical machine in the central cluster.

[0150] When the physical machine in the central cluster receives the target message, it sends the target message to the domain name system sentinel container deployed on the physical machine, wherein the domain name system sentinel container includes the domain name system sentinel. When the domain name system sentinel container receives the target message, it sends the target message to the physical machine where the service container is located through the container network. When the physical machine receives the target message, it sends the target message to the service container, which includes the service, so that the business in the business container accesses the service in the service container.

[0151] This application implements cross-cluster service access by sending the target message containing the target service address to the switch when the business container receives the target service address, and then the switch sends the target to the service container in the central cluster, so that the business can continue to use the service name in the cross-cluster scenario and transparently access the service through the service address. This method not only simplifies the complexity of business migration, but also avoids code changes at the business level and configuration changes at the operation and maintenance deployment level, and realizes imperceptible migration of the business.

[0152] Corresponding to the method provided in the service access method embodiment of the present application, see Fig.10 The present application also provides a device block diagram of a service access device. In this embodiment, the device includes:

[0153] A domain name system center deployment module 1001 is used to take any cluster as a center cluster and deploy a domain name system center in the center cluster;

[0154] A domain name system sentinel deployment module 1002 is used to use at least one of the clusters outside the central cluster as a dedicated cluster, and deploy a domain name system sentinel, a business container and a cluster domain name system in the dedicated cluster and the central cluster respectively;

[0155] A DNS sentinel configuration module 1003, configured to establish a communication connection between the central cluster and the dedicated cluster via the DNS sentinel;

[0156] The cross-cluster access judgment module 1004 is used to judge whether the business container accesses the service container in the central cluster through the cluster domain name system when the communication connection between the central cluster and the dedicated cluster is established;

[0157] A service address determination module 1005, configured to obtain a target service address through the domain name system center when the business container accesses a service container in the central cluster;

[0158] The target service access module 1006 is configured to access the service corresponding to the target service address in the service container according to the target service address.

[0159] Optionally, the domain name system sentinel configuration module 1003 includes:

[0160] A first configuration file acquisition submodule is used to acquire a configuration file of a domain name system sentinel, wherein the configuration file includes a service name;

[0161] A first query request sending submodule, configured to send a query request to a cluster domain name system through a domain name system sentinel, wherein the query request includes a service name;

[0162] A first service name resolution submodule is used to resolve the service name to obtain the service address when the cluster domain name system receives a query request;

[0163] The service address sending submodule is used to send the service address to the domain name system sentinel;

[0164] A registration request sending submodule, used for sending a registration request to a domain name system center when a domain name system sentinel receives a service address, wherein the registration request includes a service name and a service address;

[0165] The registration submodule is used to register the service name and service address when the domain name system center receives the registration request and obtain the registration result;

[0166] The registration result sending submodule is used to send the registration result to the domain name system sentinel.

[0167] Optionally, the cluster includes nodes;

[0168] The DNS Sentinel configuration module 1003 includes:

[0169] The service address routing announcement submodule is used to send the service address and the cluster corresponding to the service address to the pre-deployed switch through the domain name system sentinel when the node where the domain name system sentinel is located is a network element node;

[0170] The service address routing storage submodule is used to establish a corresponding relationship between the service address and the cluster when the switch receives the service address and the cluster corresponding to the service address, and store the corresponding relationship between the service address and the cluster.

[0171] Optionally, the domain name system sentinel configuration module 1003 includes:

[0172] The second configuration file acquisition submodule is used to obtain the configuration file of the cluster domain name system through the domain name system sentinel;

[0173] An upstream DNS server configuration submodule is used to configure the upstream DNS server of the cluster DNS in the configuration file as a DNS center;

[0174] The service address acquisition submodule is used to obtain the service address from the domain name system center through the domain name system sentinel when the configuration is completed;

[0175] The service address configuration submodule is used to configure the next hop of the service address as a switch when the domain name system sentinel receives the service address.

[0176] Optionally, the cross-cluster access determination module 1004 includes:

[0177] A second query request sending submodule, used to send a query request to a cluster domain name system in the dedicated cluster through a business container, wherein the query request includes a target service name;

[0178] The data judgment submodule is used to judge whether there is a target service address corresponding to the target service name in the local cache of the cluster domain name system when the cluster domain name system receives the query request;

[0179] A first data judgment result submodule is used to determine that the business container stops accessing the service container in the central cluster when the target service address corresponding to the target service name exists in the local cache;

[0180] The second data judgment result submodule is used to determine that the business container accesses the service container in the central cluster when the target service address corresponding to the target service name does not exist in the local cache.

[0181] Optionally, the service address determination module 1005 includes:

[0182] A third query request sending submodule is used to send the query request to the domain name system center through the cluster domain name system;

[0183] The target service address acquisition submodule is used to obtain the target service address corresponding to the target service name when the domain name system center receives the query request;

[0184] A first target service address sending submodule, used to send a target service address corresponding to a target service name to a cluster domain name system;

[0185] The second target service address sending submodule is used to send the target service address to the business container when the cluster domain name system receives the target service address.

[0186] Optionally, the central cluster includes a domain name system sentinel container and a service container;

[0187] The target service access module 1006 includes:

[0188] A target message generation submodule, used to generate a target message including the target service address when the business container receives the target service address;

[0189] A first target message sending submodule, used to send the target message to the switch;

[0190] The cluster judgment submodule is used to judge whether the cluster corresponding to the target service address is the central cluster according to the correspondence between the target service address and the cluster when the switch receives the target message;

[0191] A second target message sending submodule is used to send the target message to the domain name system sentinel container when the cluster corresponding to the target service address is a central cluster;

[0192] The cross-cluster access service submodule is used to send the target message to the service container when the domain name system sentinel container receives the target message, so that the business in the business container accesses the service in the service container.

[0193] Fig.11 This is a structural diagram of an electronic device M00 provided in an embodiment of the present application. In the figure, the electronic device M00 includes a processor M01 and a memory M02. The memory M02 stores programs or instructions that can be run on the processor M01. When the program or instructions are executed by the processor M01, the various steps of the above-mentioned service access method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, they are not repeated here.

[0194] In an embodiment of the present application, the memory M02 may be used to store software programs and various data. The memory M02 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory M02 may include a volatile memory or a non-volatile memory, or the memory M02 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory M02 in the embodiment of the present application includes but is not limited to these and any other suitable types of memories.

[0195] The processor M01 may include one or more processing units; optionally, the processor M01 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor M01.

[0196] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned service access method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0197] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.

[0198] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned service access method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0199] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the relevant technology, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0200] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A service access method, characterized in that: The method comprises: Taking any one of the clusters as a central cluster, and deploying a domain name system center in the central cluster; At least one of the clusters other than the central cluster is used as a dedicated cluster, and a domain name system sentinel, a business container and a cluster domain name system are deployed in the dedicated cluster and the central cluster respectively; Establishing a communication connection between the central cluster and the dedicated cluster through the domain name system sentinel; When the communication connection between the central cluster and the dedicated cluster is established, determining, by the cluster domain name system, whether the business container accesses the service container in the central cluster; When the business container accesses the service container in the central cluster, obtaining a target service address through the domain name system center; The service corresponding to the target service address in the service container is accessed according to the target service address.

2. The method according to claim 1, characterized in that: The establishing of a communication connection between the central cluster and the dedicated cluster through the domain name system sentinel comprises: Obtaining a configuration file of the domain name system sentinel, wherein the configuration file includes a service name; Sending a query request to the cluster domain name system through the domain name system sentinel, wherein the query request includes a service name; When the cluster domain name system receives the query request, the service name is parsed to obtain a service address; Sending the service address to the DNS Sentinel; When the DNS sentinel receives the service address, sending a registration request to the DNS center, wherein the registration request includes the service name and the service address; When the domain name system center receives the registration request, registering the service name and the service address to obtain a registration result; The registration result is sent to the domain name system sentinel.

3. The method according to claim 2, characterized in that The cluster includes nodes; The establishing of a communication connection between the central cluster and the dedicated cluster through the domain name system sentinel comprises: In the case where the node where the domain name system sentinel is located is a network element node, sending the service address and the cluster corresponding to the service address to a pre-deployed switch through the domain name system sentinel; When the switch receives the service address and the cluster corresponding to the service address, a corresponding relationship between the service address and the cluster is established, and the corresponding relationship between the service address and the cluster is stored.

4. The method according to claim 3, characterized in that The establishing of a communication connection between the central cluster and the dedicated cluster through the domain name system sentinel comprises: Obtaining a configuration file of the cluster domain name system through the domain name system sentinel; Configuring an upstream domain name system server of the cluster domain name system in the configuration file as the domain name system center; When the configuration is completed, obtaining the service address from the domain name system center through the domain name system sentinel; When the domain name system sentinel receives the service address, the next hop of the service address is configured as the switch.

5. The method according to claim 1, characterized in that The determining, by the cluster domain name system, whether the business container accesses the service container in the central cluster comprises: Sending a query request to the cluster domain name system in the dedicated cluster through the business container, wherein the query request includes a target service name; When the cluster domain name system receives the query request, determining whether there is a target service address corresponding to the target service name in the local cache of the cluster domain name system; If the target service address corresponding to the target service name exists in the local cache, determining that the business container stops accessing the service container in the central cluster; When the target service address corresponding to the target service name does not exist in the local cache, it is determined that the business container accesses the service container in the central cluster.

6. The method according to claim 5, characterized in that The obtaining of the target service address through the domain name system center includes: Sending the query request to the domain name system center through the cluster domain name system; When the domain name system center receives the query request, obtaining a target service address corresponding to the target service name; Sending the target service address corresponding to the target service name to the cluster domain name system; When the cluster domain name system receives the target service address, the target service address is sent to the business container.

7. The method according to claim 3, characterized in that The central cluster includes a domain name system sentinel container and a service container; The accessing the service corresponding to the target service address in the service container according to the target service address includes: When the service container receives the target service address, generating a target message including the target service address; Sending the target message to the switch; When the switch receives the target message, judging whether the cluster corresponding to the target service address is the central cluster according to the target service address and the correspondence between the service address and the cluster; When the cluster corresponding to the target service address is the central cluster, sending the target message to the domain name system sentinel container; When the domain name system sentinel container receives the target message, the target message is sent to the service container, so that the service in the service container accesses the service in the service container.

8. A service access device, characterized in that: The device comprises: A domain name system center deployment module, used to take any cluster as a center cluster and deploy a domain name system center in the center cluster; A domain name system sentinel deployment module, used to use at least one of the clusters outside the central cluster as a dedicated cluster, and deploy a domain name system sentinel, a business container and a cluster domain name system in the dedicated cluster and the central cluster respectively; A domain name system sentinel configuration module, used to establish a communication connection between the central cluster and the dedicated cluster through the domain name system sentinel; A cross-cluster access judgment module, used to judge whether the business container accesses the service container in the central cluster through the cluster domain name system when the communication connection between the central cluster and the dedicated cluster is established; A service address determination module, configured to obtain a target service address through the domain name system center when the business container accesses a service container in the central cluster; The target service access module is used to access the service corresponding to the target service address in the service container according to the target service address.

9. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the service access method according to any one of claims 1 to 7.

10. A storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the service access method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Construction method and device of cross-K8s target service access channel

    CN111885123A

  • Cross-domain data distribution method and device, electronic equipment and storage medium

    CN117573637A

  • System and method for managing a cluster of cache servers (TRASK)

    US20180121304A1