Container-based service access method, device, equipment, and medium

By leveraging the existing architecture of the cluster DNS service and the container platform to build a DNS request transmission path, the high development cost of the container platform service discovery module is solved, and low-cost DNS resolution and efficient container service communication are achieved.

CN119728545BActive Publication Date: 2025-09-30CHINA TELECOM CLOUD TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411754503.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-02
Publication Date
2025-09-30
Estimated Expiration
2044-12-02

AI Technical Summary

Technical Problem

The development cost of existing container platform service discovery modules is high, mainly due to the need to build efficient storage structures and design complex communication mechanisms to cope with dynamic changes in services and interactions with other modules.

Method used

Leveraging the existing architecture of the cluster DNS service and container platform, the auxiliary container captures the DNS request of the main container, forwards it to the container DNS service, and then delivers it to the cluster DNS service to determine the target IP address. It then returns along the original route to build a transmission path for DNS requests, reducing development costs.

Benefits of technology

It reduces the development cost of service information processing, implements low-cost and efficient DNS resolution, and meets the communication needs between container services.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119728545B_ABST
    Figure CN119728545B_ABST
Patent Text Reader

Abstract

The present invention provides a container-based service access method, apparatus, device, and medium. The method specifically includes: a first auxiliary container captures a DNS request sent by a first primary container; the DNS request includes the domain name of a second business service; the first auxiliary container forwards the DNS request to a container DNS service; the container DNS service forwards the DNS request to a cluster DNS service; the cluster DNS service determines the target IP address corresponding to the domain name based on service information of the business service deployed on the container platform, and the target IP address is returned to the first primary container via a transmission path; the transmission path sequentially includes the cluster DNS service, the container DNS service, the first auxiliary container, and the first primary container. The present invention can achieve DNS resolution while reducing development costs.
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 computer technology, and in particular to a container-based service access method, apparatus, device, and medium. Background Art

[0002] To meet diverse business requirements, enterprises offer a wide variety of services. With the widespread adoption of cloud computing and microservices architectures, the deployment and management of internal enterprise services has become increasingly difficult, making the integration and coordination of services increasingly critical. Container platforms (such as Nomad clusters), as an infrastructure, provide isolated operating environments, resource allocation, and deployment management for services, making them a key enabler for the efficient operation of internal enterprise services.

[0003] To enable interoperability between services, current container platforms have a service discovery module. This module stores service information submitted by services, such as the service name and IP (Internet Protocol) address, in a service information repository. Furthermore, upon receiving an access request from a first service, the module searches the service information repository for the second service's service name in the access request, obtains the second service's IP address, and returns the second service's IP address to the first service.

[0004] However, developing a service discovery module presents numerous complexities, resulting in high development costs. On one hand, to cope with dynamic service changes, an efficient storage structure must be built to properly handle service information. On the other hand, to enable interaction between the service discovery module and other modules within the container platform, an adaptive communication mechanism must be designed based on the container platform's interface specifications. This process involves numerous complex technical details and custom development work, requiring a significant investment of time and effort, thus driving up development costs. Summary of the Invention

[0005] The embodiments of the present application provide a container-based service access method that can implement DNS resolution while reducing development costs.

[0006] Accordingly, an embodiment of the present application also provides a container-based service access device, an electronic device, and a machine-readable medium to ensure the implementation and application of the above method.

[0007] To solve the above problems, an embodiment of the present application discloses a container-based service access method, which is applied to a first host machine. The first host machine includes: a container platform, a cluster DNS service, and a container service. The container service includes: a container task and a container DNS service. The container task includes: a first primary container and a first auxiliary container of a first business service. Service information of the container service deployed by the container platform is provided to the cluster DNS service. The method includes:

[0008] The first auxiliary container captures a DNS request sent by the first main container; the DNS request includes: a domain name of a second business service;

[0009] The first auxiliary container forwards the DNS request to the container DNS service;

[0010] The container DNS service forwards the DNS request to the cluster DNS service;

[0011] The cluster DNS service determines the target IP address corresponding to the domain name based on the service information of the business service deployed on the container platform, and returns the target IP address to the first primary container via a transmission path; the transmission path sequentially includes: the cluster DNS service, the container DNS service, the first auxiliary container, and the first primary container.

[0012] To solve the above problems, an embodiment of the present application discloses a container-based service access device, which is applied to a first host machine. The first host machine includes: a container platform, a cluster DNS service, and a container service. The container service includes: a container task and a container DNS service. The container task includes: a first primary container and a first auxiliary container of a first business service. Service information of the container service deployed by the container platform is provided to the cluster DNS service. The device includes:

[0013] A capture module is configured to capture, on the first auxiliary container side, a DNS request sent by the first main container; the DNS request includes: a domain name of a second business service;

[0014] A first forwarding module, configured to forward the DNS request to a container DNS service on the first auxiliary container side;

[0015] A second forwarding module is used to forward the DNS request to the cluster DNS service on the container DNS service side;

[0016] The target IP determination module is used to determine the target IP corresponding to the domain name based on the service information of the business service deployed on the container platform on the cluster DNS service side, and return the target IP to the first primary container via a transmission path; the transmission path includes: cluster DNS service, container DNS service, first auxiliary container and first primary container.

[0017] Optionally, the first forwarding module is specifically configured to forward the DNS request to the container DNS service using a port forwarding tool;

[0018] The port forwarding tool forwards the DNS request to the container DNS service according to the access address of the container DNS service in the first configuration file.

[0019] Optionally, the device further comprises:

[0020] The change processing module is used to detect the access address change of the container DNS service on the cluster DNS service side and send corresponding change information to the first auxiliary container; the first auxiliary container updates the access address in the first configuration file according to the change information.

[0021] Optionally, the container DNS service determines the upstream domain name resolution address according to the IP address of the first host machine and the port of the cluster DNS service; the port of the cluster DNS service is different from the port of the system DNS service.

[0022] Optionally, the container service further includes: a load balancing service;

[0023] The device further comprises:

[0024] An access request sending module, configured to send an access request for the second business service to the load balancing service based on the target IP address on the first main container side;

[0025] The access request forwarding module is used to forward the access request on the load balancing service side.

[0026] Optionally, the access request forwarding module includes:

[0027] a forwarding module within the host machine, configured to forward the access request between different container tasks on the first host machine; or

[0028] The external host forwarding module is used to forward the access request of the first host to the second host.

[0029] Optionally, the first auxiliary container includes: a forwarding module and a port forwarding tool; the device further includes:

[0030] An image processing module is configured to use the system image of the operating system as the base image of the first auxiliary container; install the executable file of the forwarding module, the first configuration file, and the port forwarding tool into the auxiliary image, and push the base image and the auxiliary image to the image repository; the executable file is configured to capture the DNS request sent by the first main container and send a call request to the port forwarding tool so that the port forwarding tool forwards the DNS request to the container DNS service; the first configuration file is configured to configure the access address of the container DNS service included in the call request;

[0031] The publishing processing module is used to add the name of the auxiliary image to the second configuration file of the first business service during the process of publishing the first business service.

[0032] An embodiment of the present application further discloses an electronic device, comprising: a processor; and a memory on which executable code is stored. When the executable code is executed, the processor executes the method described in the embodiment of the present application.

[0033] The embodiment of the present application further discloses a machine-readable medium having executable code stored thereon. When the executable code is executed, the processor executes the method described in the embodiment of the present application.

[0034] The embodiments of the present application include the following advantages:

[0035] In the technical solution of the embodiment of this application, the existing cluster DNS service is used to obtain service information for the container service. Since the cluster DNS service, as an existing infrastructure, has its own service information processing capabilities, the embodiment of this application utilizes this feature to eliminate the tedious development work of service information processing and can reduce the corresponding development costs of service information processing.

[0036] Furthermore, this embodiment of the application establishes a DNS request transmission path based on the internal architecture of the first host: a DNS request sent from the first primary container is captured by the first auxiliary container, forwarded to the container DNS service, then delivered to the cluster DNS service to determine the target IP address, and then returned along the original path. Because the nodes included in this transmission path are all existing container architectures, this embodiment of the application can reduce the development cost of the DNS request routing mechanism.

[0037] In summary, the embodiments of the present application utilize cluster DNS services and the existing container architecture to build a transmission path, which can achieve DNS resolution while reducing development costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 This is a flowchart of the steps of a container-based service access method according to an embodiment of the present application;

[0039] Figure 2 This is a schematic structural diagram of a first host machine according to an embodiment of the present application;

[0040] Figure 3 This is a flowchart of the steps of a container-based service access method according to an embodiment of the present application;

[0041] Figure 4 This is a schematic diagram of the structure of a container-based service access device according to an embodiment of the present application;

[0042] Figure 5 It is a structural diagram of a device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0043] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.

[0044] In the embodiments of the present application, a service is a software unit that provides a certain function. Whether it is a simple tool service (such as providing a time query service) or a complex enterprise-level service (such as a transaction service in a financial system), its core is to provide specific functions for users or other systems. Microservices are also software units that focus on providing fine-grained business functions. In essence, it is a special form of service. It is different from the traditional service concept in that it focuses on fine-grained business, can be independently developed and deployed, and can work collaboratively with the help of lightweight communication. The functional granularity is more refined, the architecture is more distributed, and the development and deployment are more flexible.

[0045] In a microservices architecture, numerous microservices are deployed as containers. Container-based service access methods can be used to enable communication between different microservices. For example, an e-commerce system consists of multiple microservices, such as a console service, an order service, and a database service. Upon receiving order information from the order service, the console service needs to initiate a call to the database service to store the order information in the database service's corresponding database.

[0046] To enable mutual access between services, current container platforms have a service discovery module. This module saves service information submitted by services, such as the service name and IP address, to a service information repository. Furthermore, upon receiving an access request from a first service, it searches the service information repository for the second service's service name in the access request, obtains the second service's IP address, and returns the second service's IP address to the first service. However, developing a service discovery module presents numerous complexities, resulting in high development costs.

[0047] To address the technical problem of high development costs of service discovery modules in related technologies, an embodiment of the present application provides a container-based service access method, which is applied to a first host machine. The first host machine includes: a container platform, a cluster DNS (Domain System) service, and a container service. The container service includes: a container task and a container DNS service. The container task includes: a first primary container and a first auxiliary container of a first business service. Service information of the container service deployed by the container platform is provided to the cluster DNS service. The above method specifically includes the following steps:

[0048] The first auxiliary container captures a DNS request sent by the first main container; the DNS request includes: a domain name of a second business service;

[0049] The first auxiliary container forwards the DNS request to the container DNS service;

[0050] The container DNS service forwards the DNS request to the cluster DNS service;

[0051] The cluster DNS service determines the target IP address corresponding to the domain name based on the service information of the business service deployed on the container platform, and returns the target IP address to the first primary container via a transmission path; the transmission path sequentially includes: the cluster DNS service, the container DNS service, the first auxiliary container, and the first primary container.

[0052] In the embodiments of this application, the container platform is a software system for managing and orchestrating containerized services. It packages services and their dependencies into independent containers, enabling them to run consistently across different computing environments. This approach allows for efficient use of system resources because containers share the operating system kernel. Compared to traditional virtual machines, containers consume fewer resources and start up faster.

[0053] The container platform provides powerful container orchestration capabilities, including service deployment, scheduling, scaling, monitoring, and management. It automatically allocates resources and dynamically adjusts the number of containers based on service load, ensuring high performance and availability. It also manages network communication between containers, enabling them to collaborate and form a complete service system.

[0054] The container platform also supports the lifecycle management of containers (i.e., container services), including operations such as creating, starting, stopping, and deleting containers, and can ensure the consistency of services in different environments (such as development environment, test environment, and production environment).

[0055] In the existing container service architecture, the cluster DNS service implements container service management and control based on the service discovery mechanism. Upon startup, the container service sends service information, such as the domain name, IP address, and port number, to the cluster DNS service. Based on this service information, the cluster DNS service establishes and stores a mapping between the domain name and IP address, and then provides DNS services for the container service based on this mapping. If the container service's IP address and other information change due to load balancing, network architecture changes, or other factors, the cluster DNS service promptly detects the change and updates its stored information, ensuring continuous and effective DNS service.

[0056] In traditional technologies, the development cost of service discovery modules is high because it requires building a system from scratch that can accurately collect and properly store diverse service information, and it also requires developing an efficient and robust DNS request routing mechanism. These complex tasks result in huge investments.

[0057] This embodiment of the application utilizes the existing cluster DNS service to obtain service information for the container service. Since the cluster DNS service, as an existing infrastructure, has its own service information processing capabilities, this embodiment of the application utilizes this feature to eliminate the tedious development work of service information processing and can reduce the corresponding development costs of service information processing.

[0058] Furthermore, this embodiment of the application establishes a DNS request transmission path based on the internal architecture of the first host: a DNS request sent from the first primary container is captured by the first auxiliary container, forwarded to the container DNS service, then delivered to the cluster DNS service to determine the target IP address, and then returned along the original path. Because the nodes included in this transmission path are all existing container architectures, this embodiment of the application can reduce the development cost of the DNS request routing mechanism.

[0059] In summary, the embodiments of the present application utilize cluster DNS services and the existing container architecture to build a transmission path, which can achieve DNS resolution while reducing development costs.

[0060] The nodes included in the above transmission path are all existing container architectures, specifically:

[0061] The first primary container and the first auxiliary container are container tasks deployed by the container platform for the first business service. The first primary container and the first auxiliary container share a network namespace. When the first primary container requests a local DNS request, the corresponding DNS request will be captured by the first auxiliary container.

[0062] The first main container is used to execute the core business functions of the first business service. For example, in an e-commerce system, the first main container of the order service is used to process logic such as order creation.

[0063] The first auxiliary container works closely with the first primary container, and the two share a network namespace. This shared network namespace design is a feature of the container architecture, which enables easy communication and interaction between containers in the same network namespace.

[0064] When the first main container initiates a DNS request to the local area (here "local" specifically refers to the network namespace shared by the two), based on the established network architecture settings of the container platform and the existing communication rules and mechanisms between containers, the DNS request will be captured by the first auxiliary container in the same network namespace and operating in collaboration.

[0065] The container DNS service is a global service on the container platform. It is deployed on each host before generating business services. The container DNS service can be named DNSMASQ (Domain Name System Masquerading).

[0066] The cluster DNS service is a DNS-enabled service within the existing container service architecture. It is primarily responsible for translating domain name requests within container services into corresponding IP addresses, thereby establishing network connections between containers. Furthermore, it centrally manages service domain name information within the container platform, providing unified domain name resolution support for efficient communication within container services.

[0067] In the embodiments of the present application, examples of container platforms may include: Nomad and Kubernetes. Nomad is a container orchestration tool launched by HashiCorp. It is lightweight and flexible in design, and has good practicality in container management and scheduling. It can adapt to various infrastructure types, cope with different workload scenarios, and facilitate the orderly deployment and operation of containers in distributed applications. Kubernetes is an open source container orchestration system with a mature and stable architecture and built-in comprehensive container lifecycle management, automatic scaling, and self-healing mechanisms.

[0068] Examples of cluster DNS services include Consul and CoreDNS. Consul is widely used in the field of distributed systems, with core functions focusing on service discovery, configuration management, and health checks. Its DNS resolution capabilities can effectively convert the domain name of the container service into the corresponding IP address. With its own reliable data consistency guarantee, it allows domain name-based communication between containers to proceed smoothly. CoreDNS is characterized by its flexible and diverse plug-in architecture. Based on this feature, it can customize domain name resolution rules according to the needs of specific container cluster scenarios, finely handle domain name requests, and adapt to complex and changing DNS resolution conditions.

[0069] One purpose of the embodiments of the present application is to utilize the container platform and cluster DNS service to achieve low-cost, efficient and accurate domain name resolution, thereby meeting the communication needs between container services, without limiting the specific container platform and cluster DNS service.

[0070] Method Example 1

[0071] Reference Figure 1 , shows a schematic diagram of the steps of the container-based service access method according to an embodiment of the present application, referring to Figure 2 , which shows a schematic diagram of the structure of a first host machine according to an embodiment of the present application. The method can be applied to the first host machine, which includes: a container platform 201, a cluster DNS service 202, and a container service 203. The container service 203 includes: a container task 231 and a container DNS service 232. The container task 231 specifically includes: a first main container 2311 and a first auxiliary container 2322 for a first business service. The service information of the container service 203 deployed by the container platform 201 is provided to the cluster DNS service 202. The method may specifically include the following steps:

[0072] Step 101: A first auxiliary container captures a DNS request sent by a first main container; the DNS request specifically includes: a domain name of a second business service;

[0073] Step 102: The first auxiliary container forwards the DNS request to the container DNS service.

[0074] Step 103: The container DNS service forwards the DNS request to the cluster DNS service.

[0075] Step 104: The cluster DNS service determines the target IP address corresponding to the domain name based on the service information of the business service deployed on the container platform. The target IP address is returned to the first primary container via a transmission path. The transmission path sequentially includes: the cluster DNS service, the container DNS service, the first auxiliary container, and the first primary container.

[0076] In the embodiments of this application, the host machine refers to the physical computer on which the container platform is installed. It is the foundation for the operation of the container platform and is responsible for managing the creation, operation, and monitoring of containers. The host machine has its own operating system and hardware resources, and provides support for containers through the container platform.

[0077] A container is a lightweight, portable, standalone software package that runs on a host machine. It encapsulates services and their dependencies, a runtime environment, and a file system, sharing the kernel with the host's operating system. Each container is isolated and has its own file system, network space, and process space, but shares the kernel with the host.

[0078] The first host machine in the embodiment of the present application can be any host machine. The embodiment of the present application can deploy the container platform and cluster DNS service on any host machine.

[0079] The container platform schedules container services on its own host. This scheduling allocates the host resources required by the container service. Based on the actual needs of the container service, the container platform allocates host resources such as CPU, memory, and disk I / O (Input / Output) to the corresponding container service. For example, the container platform monitors the load of each container service. If a container service's load increases and requires more computing resources to maintain performance, it will allocate more CPU time or memory space to that container service.

[0080] The cluster DNS service is used to provide DNS services for container services, helping containers accurately resolve corresponding IP addresses through domain names and achieve normal communication.

[0081] In addition, the cluster DNS service also provides metadata services. The metadata mentioned here specifically includes service configuration information, that is, the specific parameter settings required for each container service at different operation stages (development, testing, production, etc.); service health status information, which determines whether the container service is running normally or experiencing failures through regular checks; and node location information, which clearly identifies the specific node location of each container service.

[0082] For example, the Consul service in the Nomad platform acts as a metadata management solution, responsible for centrally managing and processing these metadata, such as collecting, storing, and updating the above metadata of various container services, so that other container services in the container platform can easily obtain the required service configuration, health status, node location and other key information.

[0083] To achieve scheduling consistency across the entire container service and avoid scheduling conflicts, the cluster DNS service needs to synchronize data with the container platform. This data synchronization process is implemented within the cluster DNS service. Specifically, it may use specific communication protocols and data interfaces to periodically or in real time exchange information with the container platform regarding the creation, deletion, migration, and resource allocation of container services. This ensures that the domain name resolution and other related data held by the cluster DNS service are consistent with the container platform's scheduling.

[0084] The embodiments of the present application can perform distributed deployment of cluster DNS services on multiple nodes (multiple hosts) and utilize technologies such as data redundancy to address issues such as node failures. Specifically, the relevant data of the container service is backed up and stored on multiple nodes. In this way, when a node experiences a failure such as downtime or disk damage, other normal nodes can continue to provide complete services for the entire system based on the stored redundant data.

[0085] In step 101, the first auxiliary container and the first main container are deployed on the first host. The first main container performs the core business functions of the first business service, while the first auxiliary container provides auxiliary functions such as log collection, monitoring, and security authentication. This decouples auxiliary functions from core business functions, making the management and maintenance of the first business service more convenient.

[0086] When there is an access request for the second business service, the first business service can initiate a DNS request with the help of the first main container to which it belongs. The content of the DNS request includes information such as the domain name of the second business service, and is intended to obtain the IP address corresponding to the second business service with the help of the DNS resolution mechanism to achieve access to the second business service. It is worth noting that the embodiment of the present application does not specifically limit the specific types, business scopes, etc. of the first business service and the second business service involved, and has wide applicability and can adapt to cross-service access requirements in a variety of different business scenarios.

[0087] In the container environment, the first main container and the first auxiliary container share a network namespace, which puts them in the same shared network environment. The first main container initiates a DNS request, which needs to be transmitted outward through the network interface and port in the shared network environment. This shared network namespace is determined by the network configuration and scheduling rules of the container platform. Based on this, the first auxiliary container can listen to the host IP address and local request port of the first main container in the shared network environment, and then capture the DNS request issued by the first main container. For example, the host IP address of the first main container is: 127.0.0.1, and the local request port number is 53. The first auxiliary container can listen to 127.0.0.1:53 to capture the DNS request.

[0088] In step 102, the process of the first auxiliary container forwarding the above-mentioned DNS request to the container DNS service specifically includes: the first auxiliary container uses a port forwarding tool to forward the DNS request to the container DNS service; wherein the port forwarding tool forwards the DNS request to the container DNS service according to the access address of the container DNS service in the first configuration file.

[0089] The container DNS service's access address is used to locate the network location of the container DNS service. It specifically includes the container DNS service's host IP address and port. For example, if the container DNS service's host IP address is 172.16.10.5, which uses the UDP protocol and has a local port number of 53, the port forwarding tool can accurately forward DNS requests to the address 172.16.10.5:53. In other words, the port forwarding tool can use "172.16.10.5:53" as the forwarding address or next-hop address for DNS requests.

[0090] The access address of the container DNS service is used to locate the network location identifier of the container DNS service, which specifically includes: the host IP address and port of the container DNS service. For example, if the host IP of the container DNS service is 172.16.10.5 and the port number is 53, the port forwarding tool can forward the DNS request according to the address format of 172.16.10.5:53. It should be noted that in the embodiment of the present application, UDP (User Datagram Protocol) can be used to transmit the DNS request. Of course, the embodiment of the present application does not limit the specific transmission protocol of the DNS request.

[0091] According to IANA (Internet Assigned Numbers Authority), the standard port number for DNS services is 53. However, in actual application scenarios, the port number of the DNS service is not fixed and can be flexibly set due to considerations such as special network architecture planning, security control policy adjustments, or internal operation and maintenance management convenience. For example, the embodiments of the present application can flexibly set the port number of the container DNS service or the cluster DNS service according to actual application requirements.

[0092] In one implementation of the present application, the cluster DNS service detects a change in the access address of the container DNS service and sends corresponding change information to the first auxiliary container; the first auxiliary container updates the access address in the first configuration file based on the change information.

[0093] The cluster DNS service uses a detection mechanism to capture changes in the access address of the container DNS service, and then sends the change information to the first auxiliary container. After receiving the change information, the first auxiliary container modifies the access address in the first configuration file according to the information content.

[0094] The mechanism for synchronously updating the access address among the container DNS service, cluster DNS service, and the first auxiliary container enables the access address in the first configuration file to adapt in real time to the dynamic changes in the access address of the container DNS service. This enables the first auxiliary container to continuously and accurately forward DNS requests to the correct address, thereby improving the stability and adaptability of domain name resolution in scenarios where network configuration changes occur.

[0095] In practice, the cluster DNS service uses service discovery to detect changes to the container DNS service's access address. After startup, the container DNS service sends service information containing the access address to the cluster DNS service. If the access address changes, the container DNS service resends the updated access address to the cluster DNS service.

[0096] In a specific implementation, the first auxiliary container specifically includes: a forwarding module and a port forwarding tool; the method further includes:

[0097] Using the system image of the operating system as the base image of the first auxiliary container; installing the executable file of the forwarding module, the first configuration file, and the port forwarding tool into the auxiliary image, and pushing the base image and the auxiliary image to the image repository; the executable file is used to capture the DNS request sent by the first main container and send a call request to the port forwarding tool, so that the port forwarding tool forwards the DNS request to the container DNS service; the first configuration file is used to configure the access address of the container DNS service included in the call request;

[0098] During the process of publishing the first business service, the name of the auxiliary image is added to the second configuration file of the first business service.

[0099] The first auxiliary container in this embodiment of the present application specifically includes a forwarding module and a port forwarding tool. This embodiment of the present application uses the operating system's system image as the base image, primarily providing a basic operating framework for the first auxiliary container. This operating framework encompasses fundamental components such as the operating system's kernel functionality, file system structure, and system libraries. The base image provides a standardized system environment for the first auxiliary container.

[0100] The role of the auxiliary image is to integrate the forwarding module and port forwarding tool, so that the first auxiliary container can process the DNS request of the first main container in a predetermined manner and provide support for the network communication of the first business service.

[0101] Adding the auxiliary image name to the second configuration file of the first business service allows the operating system to accurately locate and deploy the corresponding auxiliary image from the image repository based on the auxiliary image name, ensuring the first auxiliary container is ready to provide the necessary network communication support for the first business service. Adding the auxiliary image name to the second configuration file of the first business service establishes a close connection between the first business service and the first auxiliary container.

[0102] In step 103, the container DNS service is a global service of the container platform, which can have one or more roles.

[0103] On the one hand, the container DNS service can act as a relay, setting the upstream domain name resolution address with the help of the second configuration file, thereby building a communication link with the upstream DNS server and efficiently forwarding the received DNS requests to the corresponding upstream DNS server.

[0104] On the other hand, the container DNS service can also act as a local static resolution service, recording the correspondence between preset domain names and IP addresses in a second configuration file. This way, when a DNS request for these preset domain names is encountered, it can bypass the external query process and directly complete the resolution work locally quickly and precisely.

[0105] Specifically in this embodiment of the present application, the upstream DNS server may be a cluster DNS service. In this embodiment of the present application, the cluster DNS service may be set as the upstream DNS server in the following manner: the container DNS service determines the upstream domain name resolution address based on the IP address of the first host machine and the port of the cluster DNS service; the port of the cluster DNS service is different from the port of the system DNS service.

[0106] It's important to note that there are multiple implementations of the system DNS service, one of which is commonly known as Systemd-Resolved. Systemd-Resolved is a DNS resolution service provided by systemd (the system daemon). In many modern Linux environments, it manages the domain name resolution process for the entire operating system.

[0107] According to standard DNS service settings, Systemd-Resolved typically uses standard port 53 to perform domain name resolution-related communication operations. However, in the application scenario of container platforms, due to its inherent architecture and design mechanisms, Systemd-Resolved cannot obtain detailed service information of container services deployed by the container platform. This leads to a key problem: when it receives domain name resolution requests related to container services, it lacks sufficient information to accurately complete the resolution work, thus failing to complete the domain name resolution task for container services.

[0108] In this embodiment of the application, the port used by the cluster DNS service is different from the port used by the system DNS service. This distinction is very important because it can effectively avoid port conflicts and allow container services to independently and smoothly perform their own DNS operations in the network environment, without problems such as data confusion and incorrect request processing caused by the same port.

[0109] The port number of the system DNS service is usually 53, so the port number used by the cluster DNS service can be a value other than 53. For example, the port number used by the cluster DNS service can be 8600 or other values.

[0110] In step 104, the cluster DNS service determines the target IP address corresponding to the domain name based on the service information of the business service deployed on the container platform. Specifically, the cluster DNS service establishes and stores a mapping between domain names and IP addresses based on the service information, and searches the domain name-to-IP address mapping for the domain name of the second business service to obtain the target IP address corresponding to the domain name of the second business service.

[0111] After the cluster DNS service determines the target IP, it can start the transmission process of the target IP.

[0112] First, the cluster DNS service sends the target IP address to the container DNS service based on the access address of the container DNS service in the first host.

[0113] After receiving the target IP, the container DNS service passes the target IP to the first auxiliary container based on the address information of the container task where the first auxiliary container is located.

[0114] After receiving the target IP address, the first auxiliary container forwards it to the first primary container according to the address of the first primary container. In a container environment, since the first primary container and the first auxiliary container share a network namespace, after receiving the target IP address, the first auxiliary container can use the network interface in the shared network namespace to send the target IP address to the response port corresponding to the first primary container, completing the transfer of the target IP address. The request port is the source port of the data sender in network communication (e.g., the DNS request initiated by the first primary container). The response port is the port used by the receiver (e.g., the first primary container) to receive the response data (e.g., the target IP address).

[0115] The container-based service access method of the present embodiment utilizes the existing cluster DNS service to obtain service information for the container service. Since the cluster DNS service, as an existing infrastructure, has its own service information processing capabilities, the present embodiment utilizes this feature to eliminate the tedious development work of service information processing and reduce the development costs associated with service information processing.

[0116] Furthermore, this embodiment of the application establishes a DNS request transmission path based on the internal architecture of the first host: a DNS request sent from the first primary container is captured by the first auxiliary container, forwarded to the container DNS service, then delivered to the cluster DNS service to determine the target IP address, and then returned along the original path. Because the nodes included in this transmission path are all existing container architectures, this embodiment of the application can reduce the development cost of the DNS request routing mechanism.

[0117] In summary, the embodiments of the present application utilize cluster DNS services and the existing container architecture to build a transmission path, which can achieve DNS resolution while reducing development costs.

[0118] Method Example 2

[0119] Reference Figure 3 , shows a schematic flow chart of the steps of a container-based service access method according to an embodiment of the present application. The method can be applied to a first host machine, wherein the first host machine includes: a container platform, a cluster DNS service, and a container service. The container service includes: a container task, a container DNS service, and a load balancing service. The container task specifically includes: a first primary container and a first auxiliary container of a first business service. Service information of the container service deployed by the container platform is provided to the cluster DNS service. The method may specifically include the following steps:

[0120] Step 301: The first auxiliary container captures a DNS request sent by the first main container; the DNS request specifically includes: a domain name of a second business service;

[0121] Step 302: The first auxiliary container forwards the DNS request to the container DNS service.

[0122] Step 303: The container DNS service forwards the DNS request to the cluster DNS service.

[0123] Step 304: The cluster DNS service determines the target IP address corresponding to the domain name based on the service information of the business service deployed on the container platform. The target IP address is returned to the first primary container via a transmission path. The transmission path sequentially includes: the cluster DNS service, the container DNS service, the first auxiliary container, and the first primary container.

[0124] Relative to Figure 1 The method of embodiment 1 shown in the figure may further include:

[0125] Step 305: The first main container sends an access request for the second business service to the load balancing service based on the target IP address.

[0126] Step 306: The load balancing service forwards the access request.

[0127] The load balancing service of the embodiment of the present application is used to forward access requests. The load balancing service can use a load balancer to forward access requests.

[0128] Assume that the cluster DNS service maintains a service registry that contains service information for container services on at least one host in the application system. The load balancing service can read the service information in the service registry to understand which cluster services are available in the entire application system, as well as their location and status.

[0129] For example, in a microservices-based application system, multiple microservices register themselves with the cluster DNS service. The load balancing service reads the service information of these microservices to determine the access address of each microservice. The access address can be a combination of the container service's IP address and port number.

[0130] After receiving an access request with a target IP address from the first primary container, the load balancing service analyzes the target IP address. If the target IP address corresponds to a single, healthy target container service, the access request is forwarded directly to that target container service. If the target IP address corresponds to multiple healthy candidate container services, a load balancing algorithm (such as round-robin or least connections) is used to select a target container service from among the candidate services and forward the access request to that service.

[0131] It should be noted that in a container cluster environment, to achieve high availability, high performance, and load balancing, multiple container services with the same functionality are usually deployed to provide services. For example, a service may have multiple container replicas running on different hosts.

[0132] When the target IP is a virtual IP or a public access point for load balancing, it will be associated with multiple container services. These container services share the task of processing requests, avoiding single points of failure and improving processing efficiency. From the perspective of the service registry, these container services are associated with the target IP during registration, indicating that they are all capable of processing requests sent to this target IP.

[0133] In a specific implementation, the load balancing service forwards the access request, which may specifically include:

[0134] The load balancing service forwards the access request between different container tasks of the first host; or

[0135] The load balancing service forwards the access request of the first host machine to the second host machine.

[0136] The load balancing service has two load balancing results for access requests:

[0137] If the container task corresponding to the target IP is logically located on the first host, the load balancing service can select a suitable second container task from the container tasks corresponding to the target IP that are located on the first host and can provide the second business service based on a load balancing algorithm (such as polling, least connections, etc.), and forward the access request to the second container task. It is understood that multiple container tasks can be deployed on the first host, and the multiple container tasks are respectively: a first container task and a second container task, etc., where the first container task corresponds to the first business service and the second container task corresponds to the second business service.

[0138] If the container task corresponding to the target IP address is logically located on the second host, the load balancing service can select a suitable third container task from the container tasks corresponding to the target IP address and located on the second host that can provide the second service based on a load balancing algorithm (such as round-robin or least connections), and forward the access request to the third container task. The second host can be any host different from the first host. The third container task runs on the second host and corresponds to the second service.

[0139] Method Example 3

[0140] In the embodiment of the present application, the container platform is specifically the Nomad platform, and the cluster DNS service is specifically the Consul service.

[0141] In an embodiment of the present application, the deployment method of the container platform, cluster DNS service, and container service in the host machine specifically includes:

[0142] Step S1: Deploy the Nomad platform and Consul service.

[0143] Place the Nomad platform and Consul service binaries in the / usr / local / bin directory on all hosts in your application system. This directory is typically where operating systems store executable binaries. Placing the relevant files here makes it easier for the system to find and call them when needed.

[0144] Set up the Nomad platform and Consul services to auto-start based on Systemd. Systemd is a commonly used initialization system and service manager in Linux systems. By using it to auto-start, you can enable the Nomad platform and Consul services to automatically run after the host machine boots or reboots, eliminating the need for manual restarts and improving the automation and operational efficiency of the application system.

[0145] Create the file / etc / consul.d / consul.hcl as the third configuration file for the Consul service. Create the file / etc / nomad.d / nomad.hcl as the fourth configuration file for the Nomad platform. In the third and fourth configuration files, set the service discovery IP addresses of all hosts. These IP addresses will serve as the host IP addresses, enabling connectivity between different hosts in the application system. Assuming the host IP addresses in the application system are 10.0.10.50, 10.0.10.52, and 10.0.10.53, these IP addresses will be able to connect to each other.

[0146] Step S2: Use the system image of the operating system as the base image of the first auxiliary container, install the executable file of the forwarding module, the first configuration file, and the port forwarding tool into the auxiliary image, and push the base image and the auxiliary image to the image warehouse.

[0147] Step S3: Deploy the load balancing service according to the fifth configuration file in the HCL (Hashicorp Configuration Language) format.

[0148] Among them, HCL is a domain-specific language developed by Hash for configuring infrastructure and applications. It is used to simplify and optimize the writing of configuration files.

[0149] In the fifth configuration file, the load balancing service's listening mode is set to dynamic listening. Dynamic listening is a very flexible listening mechanism. Typically, if a service needs to listen on a new port during operation, conventional methods often require a series of tedious reconfiguration operations. However, with dynamic listening, services can autonomously and flexibly customize the listening port based on their own configuration, eliminating the need for reconfiguration each time a new port is listened on.

[0150] Step S4: Deploy the container DNS service according to the sixth configuration file in the HCL format.

[0151] In the sixth configuration file, the upstream domain name resolution address of the container DNS service is set to: the host machine's IP address + the port 8600 of the Consul service. Executing the sixth configuration file can implement the deployment of the container DNS service.

[0152] Step S5: In the process of publishing the business service, add the name of the auxiliary image to the second configuration file of the business service.

[0153] Using the above auxiliary image for the first auxiliary container can implement a forwarding mechanism from the first auxiliary container to the DNS service and then to the CONSUL service, thus achieving low-cost domain name resolution in the container platform environment.

[0154] To summarize, first configure the Nomad platform and Consul service on the host. The Nomad platform reads HCL-formatted configuration files and deploys container services, such as business services and container DNS services, based on resource allocation and service dependencies, thus achieving service containerization.

[0155] The Consul service is an existing infrastructure with service information processing capabilities, including service registration, monitoring, and discovery. It records and updates service information through built-in algorithms and mechanisms. This application leverages this feature to reduce the development work and cost of service information processing.

[0156] This application also establishes a DNS request transmission path based on the host's internal architecture. The first primary container issues a DNS request, which is captured by the first auxiliary container and forwarded to the container DNS service. This request is then sent to the cluster DNS service to determine the target IP address, and finally returned along the original path. Because the transmission path is based on the existing container architecture, the development cost of the DNS request routing mechanism is reduced.

[0157] Based on the above, the embodiments of the present application enable domain-name-based service discovery in the Nomad platform's host network environment. For example, in an e-commerce system with microservices such as a console service, an order service, and a database service, the console service can discover and call the order service via the domain name, and the order service can also discover and call the database service, thereby enabling dynamic mutual calls between business services.

[0158] It should be noted that for the method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present application are not limited by the order of the actions described, because according to the embodiments of the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present application.

[0159] Based on the above embodiment, this embodiment also provides a container-based service access device, referring to Figure 4 In the structural diagram shown, the apparatus is applied to a first host machine, the first host machine includes: a container platform, a cluster DNS service, and a container service, the container service includes: a container task and a container DNS service, the container task includes: a first primary container and a first auxiliary container of a first business service; service information of the container service deployed by the container platform is provided to the cluster DNS service; the apparatus specifically includes the following modules:

[0160] The capture module 401 is configured to capture, on the first auxiliary container side, a DNS request sent by the first main container; the DNS request includes: a domain name of a second business service;

[0161] A first forwarding module 402 is configured to forward the DNS request to a container DNS service on the first auxiliary container side;

[0162] The second forwarding module 403 is used to forward the DNS request to the cluster DNS service on the container DNS service side;

[0163] The target IP determination module 404 is used to determine the target IP corresponding to the domain name based on the service information of the business service deployed on the container platform on the cluster DNS service side, and return the target IP to the first primary container via a transmission path; the transmission path includes: cluster DNS service, container DNS service, first auxiliary container and first primary container.

[0164] Optionally, the first forwarding module 402 is specifically configured to forward the DNS request to the container DNS service using a port forwarding tool;

[0165] The port forwarding tool forwards the DNS request to the container DNS service according to the access address of the container DNS service in the first configuration file.

[0166] Optionally, the device may further include:

[0167] The change processing module is used to detect the access address change of the container DNS service on the cluster DNS service side and send corresponding change information to the first auxiliary container; the first auxiliary container updates the access address in the first configuration file according to the change information.

[0168] Optionally, the container DNS service determines the upstream domain name resolution address according to the IP address of the first host machine and the port of the cluster DNS service; the port of the cluster DNS service is different from the port of the system DNS service.

[0169] Optionally, the container service may further include: a load balancing service;

[0170] The apparatus may further comprise:

[0171] An access request sending module, configured to send an access request for the second business service to the load balancing service based on the target IP address on the first main container side;

[0172] The access request forwarding module is used to forward the access request on the load balancing service side.

[0173] Optionally, the access request forwarding module may include:

[0174] a forwarding module within the host machine, configured to forward the access request between different container tasks on the first host machine; or

[0175] The external host forwarding module is used to forward the access request of the first host to the second host.

[0176] Optionally, the first auxiliary container may include: a forwarding module and a port forwarding tool; the device further includes:

[0177] An image processing module is configured to use the system image of the operating system as the base image of the first auxiliary container; install the executable file of the forwarding module, the first configuration file, and the port forwarding tool into the auxiliary image, and push the base image and the auxiliary image to the image repository; the executable file is configured to capture the DNS request sent by the first main container and send a call request to the port forwarding tool so that the port forwarding tool forwards the DNS request to the container DNS service; the first configuration file is configured to configure the access address of the container DNS service included in the call request;

[0178] The publishing processing module is used to add the name of the auxiliary image to the second configuration file of the first business service during the process of publishing the first business service.

[0179] An embodiment of the present application further provides a non-volatile readable storage medium, which stores one or more modules (programs). When the one or more modules are applied to a device, the device can execute instructions (instructions) of each method step in the embodiment of the present application.

[0180] The present application provides one or more machine-readable media having instructions stored thereon, which, when executed by one or more processors, cause an electronic device to perform one or more of the methods described in the above embodiments. In the present application, the electronic device includes various types of devices such as terminal devices and servers (clusters).

[0181] The embodiments of the present disclosure may be implemented as a device configured as desired using any appropriate hardware, firmware, software, or any combination thereof, and the device may include: a terminal device, a server (cluster), and other electronic devices. Figure 5 An exemplary apparatus 1100 that can be used to implement various embodiments described in this application is schematically illustrated.

[0182] For one embodiment, Figure 5 An exemplary apparatus 1100 is shown having one or more processors 1102, a control module (chip set) 1104 coupled to at least one of the processor(s) 1102, a memory 1106 coupled to the control module 1104, a non-volatile memory / storage device 1108 coupled to the control module 1104, one or more input / output devices 1110 coupled to the control module 1104, and a network interface 1112 coupled to the control module 1104.

[0183] The processor 1102 may include one or more single-core or multi-core processors, and the processor 1102 may include any combination of general-purpose processors or dedicated processors (e.g., graphics processors, application processors, baseband processors, etc.). In some embodiments, the apparatus 1100 can serve as a terminal device, server (cluster), or other device described in the embodiments of the present application.

[0184] In some embodiments, the apparatus 1100 may include one or more computer-readable media (e.g., memory 1106 or non-volatile memory / storage 1108) having instructions 1114 and one or more processors 1102 configured, in combination with the one or more computer-readable media, to execute the instructions 1114 to implement a module to perform the actions described in the present disclosure.

[0185] For one embodiment, the control module 1104 may include any suitable interface controller to provide any suitable interface to at least one of the processor(s) 1102 and / or any suitable device or component in communication with the control module 1104 .

[0186] The control module 1104 may include a memory controller module to provide an interface to the memory 1106. The memory controller module may be a hardware module, a software module, and / or a firmware module.

[0187] The memory 1106 may be used, for example, to load and store data and / or instructions 1114 for the device 1100. For one embodiment, the memory 1106 may include any suitable volatile memory, such as a suitable DRAM (Dynamic Random Access Memory). In some embodiments, the memory 1106 may include a double data rate type four synchronous dynamic random access memory.

[0188] For one embodiment, the control module 1104 may include one or more input / output controllers to provide an interface to the non-volatile memory / storage device 1108 and the input / output device(s) 1110 .

[0189] For example, the non-volatile memory / storage device 1108 may be used to store data and / or instructions 1114. The non-volatile memory / storage device 1108 may include any suitable non-volatile memory (e.g., flash memory) and / or may include any suitable non-volatile storage device(s) (e.g., one or more hard disk drives, one or more optical disk drives, and / or one or more digital versatile optical disk drives).

[0190] The non-volatile memory / storage device 1108 may include storage resources that are physically part of the device on which the apparatus 1100 is installed, or it may be accessible to the device without being part of the device. For example, the non-volatile memory / storage device 1108 may be accessed via one or more input / output devices 1110 over a network.

[0191] (One or more) input / output devices 1110 may provide an interface for apparatus 1100 to communicate with any other appropriate devices. Input / output devices 1110 may include communication components, audio components, sensor components, etc. Network interface 1112 may provide an interface for apparatus 1100 to communicate via one or more networks. Apparatus 1100 may wirelessly communicate with one or more components of a wireless network according to any of one or more wireless network standards and / or protocols, for example, accessing a wireless network based on a communication standard such as WiFi (Wireless Fidelity), 2G (2nd Generation Wireless Telephone Technology), 3G (3rd Generation Wireless Telephone Technology), 4G (4th Generation Wireless Telephone Technology), 5G (5th Generation Wireless Telephone Technology), etc., or a combination thereof for wireless communication.

[0192] For one embodiment, at least one of the processor(s) 1102 may be packaged together with the logic of one or more controllers (e.g., a memory controller module) of the control module 1104. For one embodiment, at least one of the processor(s) 1102 may be packaged together with the logic of one or more controllers of the control module 1104 to form a system-in-package. For one embodiment, at least one of the processor(s) 1102 may be integrated on the same die with the logic of one or more controllers of the control module 1104. For one embodiment, at least one of the processor(s) 1102 may be integrated on the same die with the logic of one or more controllers of the control module 1104 to form a system-on-chip.

[0193] In various embodiments, apparatus 1100 may be, but is not limited to, a terminal device such as a server, a desktop computing device, or a mobile computing device (e.g., a laptop computing device, a handheld computing device, a touchscreen device, a netbook, etc.). In various embodiments, apparatus 1100 may have more or fewer components and / or a different architecture. For example, in some embodiments, apparatus 1100 includes one or more cameras, a keyboard, an LCD screen (including a touchscreen display), a non-volatile memory port, multiple antennas, a graphics chip, an application-specific integrated circuit, and a speaker.

[0194] Among them, the main control chip can be used as a processor or control module in the detection device, sensor data, location information, etc. are stored in a memory or non-volatile memory / storage device, the sensor group can be used as an input / output device, and the communication interface can include a network interface.

[0195] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0196] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0197] The present application embodiment is described with reference to the flow chart and / or block diagram of the method, terminal device (system), and computer program product according to the embodiment of the present application. It should be understood that each process and / or box in the flow chart and / or block diagram, and the combination of the process and / or box in the flow chart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device produce a device for implementing the function specified in one process or multiple processes in the flow chart and / or one box or multiple boxes in the block diagram.

[0198] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.

[0199] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce computer-implemented processing, so that the instructions executed on the computer or other programmable terminal device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.

[0200] Although preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic inventive concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.

[0201] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.

[0202] The above is a detailed introduction to a container-based service access method and device, an electronic device and a machine-readable medium provided by the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core ideas. At the same time, for those skilled in the art, according to the ideas of the present application, there may be changes in the specific implementation methods and application sets. In summary, the content of this specification should not be understood as limiting the present application.

Claims

1. A container-based service access method, characterized in that: The method is applied to a first host machine, the first host machine including: a container platform, a cluster DNS service, and a container service, the container service including: a container task and a container DNS service, the container task including: a first primary container and a first auxiliary container of a first business service; service information of the container service deployed by the container platform is provided to the cluster DNS service; the method includes: The first auxiliary container captures a DNS request sent by the first main container; the DNS request includes: a domain name of a second business service; The first auxiliary container forwards the DNS request to the container DNS service; The container DNS service forwards the DNS request to the cluster DNS service; The cluster DNS service determines the target IP address corresponding to the domain name based on the service information of the business service deployed on the container platform, and returns the target IP address to the first primary container via a transmission path; the transmission path sequentially includes: the cluster DNS service, the container DNS service, the first auxiliary container, and the first primary container.

2. The method according to claim 1, characterized in that The first auxiliary container forwarding the DNS request to the container DNS service includes: The first auxiliary container forwards the DNS request to the container DNS service using a port forwarding tool; The port forwarding tool forwards the DNS request to the container DNS service according to the access address of the container DNS service in the first configuration file.

3. The method according to claim 2, characterized in that The method further comprises: The cluster DNS service detects a change in the access address of the container DNS service and sends corresponding change information to the first auxiliary container; the first auxiliary container updates the access address in the first configuration file according to the change information.

4. The method according to claim 1, wherein The container DNS service determines the upstream domain name resolution address based on the IP address of the first host machine and the port of the cluster DNS service; the port of the cluster DNS service is different from the port of the system DNS service.

5. The method according to claim 1, wherein The container service also includes: load balancing service; The method further comprises: The first main container sends an access request for the second business service to the load balancing service based on the target IP address. The load balancing service forwards the access request.

6. The method according to claim 5, characterized in that The load balancing service forwards the access request, including: The load balancing service forwards the access request between different container tasks of the first host; or The load balancing service forwards the access request of the first host machine to the second host machine.

7. The method according to claim 1, characterized in that The first auxiliary container includes: a forwarding module and a port forwarding tool; the method further includes: Using the system image of the operating system as the base image of the first auxiliary container; installing the executable file of the forwarding module, the first configuration file, and the port forwarding tool into the auxiliary image, and pushing the base image and the auxiliary image to the image repository; the executable file is used to capture the DNS request sent by the first main container and send a call request to the port forwarding tool, so that the port forwarding tool forwards the DNS request to the container DNS service; the first configuration file is used to configure the access address of the container DNS service included in the call request; During the process of publishing the first business service, the name of the auxiliary image is added to the second configuration file of the first business service.

8. A container-based service access device, characterized in that: The apparatus is applied to a first host machine, the first host machine including: a container platform, a cluster DNS service, and a container service, the container service including: a container task and a container DNS service, the container task including: a first primary container and a first auxiliary container of a first business service; service information of the container service deployed by the container platform is provided to the cluster DNS service; the apparatus includes: A capture module is configured to capture, on the first auxiliary container side, a DNS request sent by the first main container; the DNS request includes: a domain name of a second business service; A first forwarding module, configured to forward the DNS request to a container DNS service on the first auxiliary container side; A second forwarding module is used to forward the DNS request to the cluster DNS service on the container DNS service side; The target IP determination module is used to determine the target IP corresponding to the domain name based on the service information of the business service deployed on the container platform on the cluster DNS service side, and return the target IP to the first primary container via a transmission path; the transmission path includes: cluster DNS service, container DNS service, first auxiliary container and first primary container.

9. An electronic device, characterized in that: include: processor; and A memory having executable codes stored thereon, which, when executed, causes the processor to perform the method according to any one of claims 1 to 7.

10. A machine-readable medium having executable codes stored thereon, which, when executed, cause a processor to perform the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Container service access method, and network address parsing method, device and system

    CN108737584A

  • DNS service deployment method and related device

    CN116192800A