CN111124589A - Service discovery system, method, device and equipment - Google Patents

Service discovery system, method, device and equipment Download PDF

Info

Publication number
CN111124589A
CN111124589A CN201811278717.7A CN201811278717A CN111124589A CN 111124589 A CN111124589 A CN 111124589A CN 201811278717 A CN201811278717 A CN 201811278717A CN 111124589 A CN111124589 A CN 111124589A
Authority
CN
China
Prior art keywords
service
application
corresponding relation
micro
name
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201811278717.7A
Other languages
Chinese (zh)
Other versions
CN111124589B (en
Inventor
戴正元
王尧
吴云飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Mobile Communications Group Co Ltd
China Mobile Suzhou Software Technology Co Ltd
Original Assignee
China Mobile Communications Group Co Ltd
China Mobile Suzhou Software Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Mobile Communications Group Co Ltd, China Mobile Suzhou Software Technology Co Ltd filed Critical China Mobile Communications Group Co Ltd
Priority to CN201811278717.7A priority Critical patent/CN111124589B/en
Publication of CN111124589A publication Critical patent/CN111124589A/en
Application granted granted Critical
Publication of CN111124589B publication Critical patent/CN111124589B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/45Network directories; Name-to-address mapping
    • H04L61/4505Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols
    • H04L61/4511Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols using domain name system [DNS]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/51Discovery or management thereof, e.g. service location protocol [SLP] or web services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45595Network integration; Enabling network access in virtual machine instances

Abstract

The embodiment of the application provides a service discovery system, method, device and equipment, which are used for realizing mutual access between two services with the same name in the same Namespace. The system comprises: the system comprises: the domain name synchronization analysis system comprises an application creation module, a domain name synchronization analysis module and a key value database; the application creation module is used for acquiring a first corresponding relation between the application and the micro service according to an application name of the application needing to be created and a service name of the micro service included in the application, which are input by a user, and creating the application; the domain name synchronization module is used for acquiring the first corresponding relation from the application creation module, acquiring a network protocol IP address of the micro service, establishing a second corresponding relation between the first corresponding relation and the IP address of the micro service, and writing the second corresponding relation into the key value database; and the key value database is used for storing the second corresponding relation.

Description

Service discovery system, method, device and equipment
Technical Field
The present application relates to the field of computer technologies, and in particular, to a service discovery system, method, apparatus, and device.
Background
Kubernets, abbreviated as k8s, is a Google open source system for managing container (docker) clusters, and provides automated deployment, scheduling, maintenance, and cluster management functions for microservices. k8s supports the creation of multiple virtual clusters on one physical cluster, referred to as namespaces (namespaces). k8s manages dockers by taking Pod as a unit, most of the Pod and Pod running micro-services of k8s are located in Namespace, and the Namespace realizes multi-tenant resource isolation in many cases and is used for isolating the Pod and Pod running micro-services of different tenants. The process of running the application is actually the process of coordinating and running a plurality of micro services. Multiple services may need to communicate with each other, and one service needs to obtain the IP address of another service before communicating with another service before accessing the service through the IP address of another service. The process of obtaining the IP address of another microservice is service discovery.
At present, k8s implements service discovery by domain name resolution. Specifically, each micro service and the corresponding service name, and the virtual Cluster IP corresponding to the service name are synchronized in real time to the database of k8s through the domain name synchronization module. When the micro service needs to access other micro services, the micro service can initiate a request for analyzing the Cluster IP of other micro services to the domain name analyzing module, the domain name analyzing module accesses the database according to the names of other micro services in the domain name analyzing request to obtain the Cluster IP of other micro services, and then the domain name analyzing module returns the Cluster IP of other micro services to the micro service, so that the micro service can find other micro services. The service discovery mode is a service discovery request initiated to the domain name resolution module based on the service name, so that the condition that one Namespace has two duplicate name micro-services is not applicable.
Disclosure of Invention
The embodiment of the application provides a service discovery system, method, device and equipment, which are used for realizing mutual access between two services with the same name in the same Namespace.
The technical scheme adopted by the embodiment of the application is as follows:
in a first aspect, a service discovery system is provided, the system comprising: the domain name synchronization analysis system comprises an application creation module, a domain name synchronization analysis module and a key value database;
the application creation module is used for acquiring a first corresponding relation between the application and the micro service according to an application name of the application needing to be created and a service name of the micro service included in the application, which are input by a user, and creating the application;
the domain name synchronization module is used for acquiring the first corresponding relation from the application creation module, acquiring a network protocol IP address of the micro service, establishing a second corresponding relation between the first corresponding relation and the IP address of the micro service, and writing the second corresponding relation into the key value database;
and the key value database is used for storing the second corresponding relation.
In the embodiment of the application, the application creation module obtains a first corresponding relation between micro services of the micro services and the application, the application is created according to the first corresponding relation, the micro services always correspond to the application, the first corresponding relation and the IP addresses of the micro services are stored in the key value database, even under the same namespace, the two micro services with two duplicate names can be distinguished through the application names included in the first corresponding relation, and therefore the problem that discovery of the micro services with two duplicate names cannot be achieved under the same namespace in the prior art is solved.
Optionally, the application creation module includes an application agent unit and a programmatic application interface service unit, where:
the application proxy unit is used for detecting input operation of a user, acquiring the application name and the micro-service name according to the input operation, converting the service name into a name taking the application name as a suffix so as to obtain the first corresponding relation, and sending the first corresponding relation to the programming application interface service unit;
the programming application interface service unit is used for creating the application according to the first corresponding relation.
According to the embodiment of the application, the application proxy unit is additionally arranged, the application proxy unit analyzes the information input by the user, and the application name is added behind the name of the micro-service to be used as a suffix, so that the corresponding relation between the application and the micro-service is obtained, and the problem of duplicate name conflict of two micro-services under the same namespace can be solved. And the application proxy unit is simple to realize, and the cost of the service discovery system is reduced.
Optionally, the api service unit is further configured to:
and writing the first corresponding relation into the key value database.
The programming application interface service unit writes the first corresponding relation into the key value database in advance, so that the domain name synchronization module can acquire the message generated by the new application earlier, and the efficiency of the domain name synchronization module for synchronizing the data of the microservice of the new application is improved.
Optionally, the application creation module is further configured to:
after the application is created, a third corresponding relation between the micro service and at least one Pod included in the micro service is obtained.
The application creation module also obtains the corresponding relation between the micro-services and the Pod, so that the later service discovery system can manage the corresponding micro-services, the Pod and the like conveniently.
Optionally, the system further includes:
and the domain name resolution module is used for calling the second corresponding relation in the key value database to obtain the IP address of the first micro service after receiving a domain name resolution request of the Pod for the first micro service, wherein the domain name resolution request comprises the service name of the first micro service and the application name of the application to which the first micro service belongs.
In the embodiment of the application, the service discovery system is further additionally provided with a domain name resolution module, the domain name resolution module calls data in the key value database according to the domain name resolution request so as to obtain the corresponding IP address of the micro service, and the key value database is called so as to obtain the IP address of the micro service, so that the service discovery process is more efficient. And even if the two duplicate micro-services exist, the service discovery system can analyze the two duplicate micro-services according to the corresponding relation between the service in the key value database and the application, so that the service discovery of the two duplicate micro-services is realized.
In a second aspect, a service discovery method is provided, which is applied in the service discovery system according to the first aspect, and includes:
receiving a domain name resolution request sent by a Pod, wherein the domain name resolution request comprises a service name of a first micro service and an application name of an application to which the first micro service belongs, the Pod belongs to a second micro service, and the second micro service is different from the first micro service;
acquiring a network protocol (IP) address of the first micro service according to the first request, wherein a second corresponding relation between a first corresponding relation and the IP address of the micro service is stored in the service discovery system, and the first corresponding relation is the corresponding relation between an application and the micro service included by the application;
sending the IP address of the first micro-service to the Pod.
Optionally, before acquiring the network protocol IP address of the first micro service according to the first request, the method further includes:
acquiring the first corresponding relation according to an application name which needs to be created and a service name of a first micro service included in the application, and creating the application;
and acquiring the IP address of the first micro service, acquiring the second corresponding relation according to the first corresponding relation and the IP address, and writing the second corresponding relation into the service discovery system.
Optionally, obtaining the first corresponding relationship between the application and the first microservice includes:
detecting input operation of a user, acquiring the application name and the service name of the first micro service according to the input operation, and converting the first micro service name into a name taking the application name as a suffix, thereby acquiring the first corresponding relation.
Optionally, after creating the application, the method further includes:
and acquiring a third corresponding relation between the micro service and at least one Pod included in the micro service.
In a third aspect, a service discovery apparatus is provided, including:
the domain name resolution system comprises a receiving and sending module, a processing module and a processing module, wherein the receiving and sending module is used for receiving a domain name resolution request sent by a Pod, the domain name resolution request comprises a service name of a first micro service and an application name of an application to which the first micro service belongs, the Pod belongs to a second micro service, and the second micro service is different from the first micro service;
a processing module, configured to obtain a network protocol IP address of the first micro service according to the first request, where a second corresponding relationship between a first corresponding relationship and the IP address of the micro service is stored in the service discovery system, and the first corresponding relationship is a corresponding relationship between an application and the micro service included in the application;
the transceiver module is further configured to send the IP address of the first micro service to the Pod.
Optionally, the processing module is further configured to:
before acquiring the network protocol IP address of the first micro service according to the first request, acquiring the first corresponding relation according to an application name which is input by a user and needs to be created and a service name of the first micro service included in the application, and creating the application;
and acquiring the IP address of the first micro service, acquiring the second corresponding relation according to the first corresponding relation and the IP address, and writing the second corresponding relation into the service discovery system.
Optionally, the processing module is specifically configured to:
detecting input operation of a user, acquiring the application name and the service name of the first micro service according to the input operation, and converting the service name of the first micro service into a name taking the application name as a suffix, so as to obtain the first corresponding relation.
Optionally, the processing module is further configured to:
after the application is created, a third corresponding relation between the micro service and at least one Pod included in the micro service is obtained.
In a fourth aspect, a service discovery apparatus is provided, including:
a memory communicatively coupled to the at least one processor;
wherein the memory stores instructions executable by the at least one processor, the at least one processor implementing the method of any one of the second aspects by executing the instructions stored by the memory.
In a fifth aspect, there is provided a computer readable storage medium having stored thereon computer instructions which, when run on a computer, cause the computer to perform the method of any of the second aspects.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the embodiments of the present application will be briefly described below, and it is obvious that the drawings described below are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a schematic diagram of access between microservices provided by an embodiment of the present application;
fig. 2 is a block diagram of a service discovery system according to an embodiment of the present application;
fig. 3 is a block diagram of a service discovery system according to an embodiment of the present application;
fig. 4 is a block diagram of a service discovery system including a domain name resolution module according to an embodiment of the present application;
fig. 5 is a schematic diagram of an application of a service discovery system provided in an embodiment of the present application;
fig. 6 is a schematic flowchart of a service discovery method according to an embodiment of the present application;
fig. 7 is a block diagram of a service discovery apparatus according to an embodiment of the present application;
fig. 8 is a structural diagram of a service discovery device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application.
Hereinafter, some terms in the embodiments of the present application are explained to facilitate better understanding of the embodiments of the present application by those skilled in the art.
1) The container docker is an open-source application container engine, can realize lightweight virtual operation of applications, is similar to a virtual machine, and enables developers to package their applications and dependence packages into a portable docker and then release the portable docker to a computer device for operation. The containers are fully sandboxed without any interface between each other.
2) A cluster is a loosely coupled set of computing nodes formed by a group of computer devices, and each computing node in the cluster can independently run its own process. The cluster provides a uniform service platform for the outside, and the cluster looks like a server to the client. When a client accesses a cluster system, a cluster usually distributes a service request of the client to a certain service node in the cluster system for processing according to the load or service division of each service node (i.e., a computing node). To distinguish between different clusters, each cluster has its own name.
3) Kubernets, k8s for short, is a Google open source system for managing container (docker) clusters, providing automated deployment, scheduling, maintenance, and cluster management functions for services. k8s to manage the different resources, k8s supports the creation of multiple virtual clusters on one physical cluster, referred to as namespaces (namespaces). Most of the services operated by the multiple Pod and Pod of k8s are located in Namespace, which in many cases implements multi-tenant resource isolation for isolating multiple pods and Pod operated services of different tenants. To distinguish between different namespaces, each namespace has a corresponding name.
4) And the Pods are basic management units in the k8s, one Pod consists of a group of dockers, one Pod shares a storage volume and a network stack, and has an independent Pod IP.
5) And the micro-service comprises a plurality of micro-services or one micro-service to form an application, each micro-service refers to a process distributed on the docker, and the processes are packaged into a Pod, so that the k8s is convenient to manage each micro-service. To reduce the load of a Pod in a microservice, k8s establishes a corresponding Pod copy for the microservice, which is consistent with the contents of the Pod and assists the Pod, so that a microservice typically includes multiple pods.
6) The network protocol Cluster IP, hereinafter referred to for ease of description, is simply the IP of the microservice. In order to make the different services accessible to each other, k8s will bind a fixed IP for each micro service, which is the Cluster IP, and the life cycle of the Cluster IP is the same as that of the micro service, that is, as long as the micro service exists, the Cluster IP of the micro service exists. The Cluster IP of the micro service does not change even if the number of Pod in the micro service increases or decreases.
In a cluster, a business system may need to be implemented by multiple microservices with different functions. Multiple microservices may need to communicate with each other while the business system is running. For example, referring to fig. 1, a group includes a telephone charge management system to implement a telephone charge for managing users, the telephone charge management system may need to be implemented by three micro services, namely, a front-end micro service, a telephone charge calculation micro service and a database micro service, the front-end micro service includes Pod1 (corresponding to P1 in fig. 1) and Pod2 (corresponding to P2 in fig. 1), the telephone charge calculation micro service includes Pod3 (corresponding to P3 in fig. 1), and the database micro service includes Pod4 (corresponding to P4 in fig. 1). The Pod1 in the front-end micro service detects and acquires the call minutes of the user, then the call minutes need to be sent to the Pod3 of the call charge calculation micro service and the Pod4 in the database micro service, the call charge calculation micro service calculates the consumption of the user according to the call minutes of the user, then the call charge calculation micro service sends the consumption of the user to the Pod4 in the database micro service, and the database micro service stores the call minutes, the consumption and other data of the user. Therefore, the front-end micro service, the calculation micro service and the database micro service need to be communicated with each other to complete the function of the telephone charge management system.
k8s is based on network protocol to realize intercommunication between clusters, so two micro services need to communicate with each other, and the micro service needs to obtain the IP address of the other micro service before establishing communication with the other micro service. Continuing with fig. 1, that is, the front-end micro service needs to send Pod3 of the call charge calculation micro service and Pod4 of the database micro service, the front-end micro service needs to obtain the IP address of the call charge calculation micro service and the IP address of the database micro service, and similarly, the call charge calculation micro service needs to send the consumption of the user to Pod4 of the database micro service, and the call charge calculation micro service needs to obtain the IP address of the database micro service to realize the function of the call charge management system. The process of obtaining the IP address of another microservice may be understood as service discovery. The service discovery method of k8s in the prior art is described below.
Currently, k8s implements service discovery by means of domain name resolution. Specifically, the domain name synchronization module of k8s synchronizes the mapping between each micro-service name and the IP address of the micro-service into the key-value store (ectd). When a micro service needs to obtain an IP address of another micro service, a domain name resolution request may be directly initiated to the domain name resolution module in k8s, and the domain name resolution module invokes the IP address of the corresponding micro service from the key value database according to the domain name resolution request, thereby obtaining the IP address of the corresponding micro service. Because the domain name format in the domain name resolution request comprises the cluster name, the namespace name and the service name of the micro-service, the service discovery method requires that two micro-services below the same namespace cannot have the same name, otherwise, the domain name resolution module cannot determine which micro-service corresponds to the micro-service requested to be resolved, and further the service discovery fails. It can be seen that the service discovery approach in the prior art has limitations.
In view of this, embodiments of the present application provide a service discovery system, where the service discovery system may be implemented by software modules in a cluster, where the cluster may be implemented by one or more entity servers, and the cluster may also be implemented by a virtual server. Referring to fig. 2, the service discovery system includes an application creation module, a domain name synchronization module, and a key-value store. The application creation module and the domain name synchronization module can communicate with each other, and the domain name synchronization module and the key value database can communicate with each other.
The application creation module is used for acquiring a first corresponding relation between the application and the micro service according to the application name of the application needing to be created and the service name of the micro service included in the application, which are input by a user, and creating the application;
the domain name synchronization module is used for acquiring a first corresponding relation from the application creation module, acquiring a network protocol IP address of the micro service, establishing a second corresponding relation of the first corresponding relation and the IP address of the micro service, and writing the second corresponding relation into the key value database;
and the key value database is used for storing the second corresponding relation.
In the embodiment of the application, the application creation module obtains a first corresponding relation between micro services of the micro services and the application, the application is created according to the first corresponding relation, the micro services always correspond to the application, the first corresponding relation and the IP addresses of the micro services are stored in the key value database, even under the same namespace, the two micro services with two duplicate names can be distinguished through the application names included in the first corresponding relation, and therefore the problem that discovery of the micro services with two duplicate names cannot be achieved under the same namespace in the prior art is solved.
These three modules are described separately below. First, an Application creation module is described in detail, referring to fig. 3, where the Application creation module includes an Application proxy unit and a programming Application interface service (API server).
In this embodiment of the present application, the application proxy unit is configured to detect an input operation of a user, obtain the application name and the micro-service name according to the input operation, convert the service name into a name with the application name as a suffix, thereby obtaining the first corresponding relationship, and send the first corresponding relationship to the api service unit;
the programming application interface service unit is used for creating the application according to the first corresponding relation.
For convenience of description, in the following description, information obtained according to a user input operation is referred to as first information. The number of applications including the micro service may be one or more, and the number of micro services is not particularly limited herein. The first information may include, in addition to the application name and the service name of the micro service included in the application, a port of each micro service, the number of Pod of each micro service and the number of copies corresponding to each Pod, a cluster in which the application is located, and namespace in which the application is located. The first information may be in the form of yaml or JSON.
When a user needs to create an application, the user may input a creation instruction first, and after receiving the creation instruction, the application agent unit displays a corresponding creation template, and the user directly inputs first information in the creation template, which is equivalent to that the application agent unit obtains the first information input by the user. Or in order to reduce the step of inputting the creation instruction by the user, once the application agent unit detects that the user has an input operation, the application agent unit directly determines that the user needs to create the application, then detects the input operation of the user, and acquires the first information of the application needing to be created, which is input by the user, according to the input operation of the user, that is, the user does not need to separately input the creation instruction. Or for the convenience of user operation, the user may input the first information in the terminal device, and the terminal device sends the first information to the application creation module. The specific manner of obtaining the first information is not limited herein. The application proxy unit obtains the first corresponding relation according to the first information after the first information input by the user.
When the first information input by the user includes only the application name and the service name, the first correspondence relationship is obtained in such a manner that the application proxy unit parses the application name and the service name in the first information, and adds a suffix, which is the application name, to the micro-service name, thereby obtaining the first correspondence relationship. The first correspondence may be understood as a correspondence between the microservice and the application.
For example, the application a input by the user includes a micro service a and a micro service b, and after receiving the information, the application agent unit parses the relationship between the application a, the micro service a, and the micro service b, modifies the name of the micro service a into the micro service a.
When the first information input by the user comprises a cluster name, a namespace name, an application name and a service name, the first corresponding relation is obtained by analyzing the cluster name, the namespace name, the application name and the service name in the first information by the application agent unit, and the corresponding relation between the micro-service and the application, the namespace and the cluster is established, so that the first corresponding relation is obtained.
For example, the user inputs namespace1 in cluster 1, the namespace1 includes application a including microservice a, and the application proxy unit parses the cluster name, the namespace name, the application name and the service name, and expresses the correspondence between the four as the cluster name.
After obtaining the first corresponding relationship, the application proxy unit may send the first corresponding relationship to the api service unit, where the application proxy unit may send the first corresponding relationship to the api service unit through a network component in k8s, where the network component is, for example, a Flannel that uses a User Datagram Protocol (UDP) as an underlying transport Protocol by default.
After the application proxy unit sends the first correspondence to the api service unit, the api service unit receives the correspondence. In order to obtain more detailed information by the application program interface service unit, the application proxy unit may send the first corresponding relationship to the application program interface service unit, and may also send information, other than the first corresponding relationship, of the first information input by the user to the application program interface service unit.
The programming application interface service unit creates an application according to the first corresponding relationship after receiving the first corresponding relationship. Specifically, the api service unit determines, according to the first correspondence, the number of micro services that need to be created, and then determines, according to the information other than the first correspondence in the first information, the number of pods required by the micro services, or the api service unit determines to create a default number of pods for each micro service, and then the api service unit creates processes included in the micro services, and then encapsulates all the processes into a corresponding number of pods, and the api service unit attempts to allocate resources to the pods, which are created successfully until all the pods of the micro services are created successfully, which is equivalent to creating an application by the micro service, and when all the micro services are created, the corresponding application is created completely. Resources such as processor resources or, for example, processor resources and memory. The specific process of creating the corresponding Pod by the api servlet may refer to the existing process of creating Pod of k8s, which is not described in detail herein.
In order to facilitate other modules in the service discovery system to know that a new microservice is generated as soon as possible, the api servlet may write the first mapping relationship to the key-value store. The application agent unit may receive the first corresponding relationship sent by the application agent unit, and then write the first corresponding relationship into the key-value database, or the application agent unit may create a corresponding application, and then write the first corresponding relationship into the key-value database, where the specific time for writing the first corresponding relationship into the application agent unit is not limited herein. In order to facilitate other modules in the service system to know more detailed information of the new microservice, the api service unit may write information other than the first mapping relationship in the first information into the key-value database at the same time when sending the first mapping relationship.
To enable mutual access between the Pod, after the application is created by the programming application interface service, k8s may assign each Pod a non-repeating IP address, and each Pod will own the corresponding Pod IP. In order that other Pod can access the Pod corresponding to the micro service by accessing the micro service, after the application is created by the application interface service unit, k8s will assign a corresponding cluster IP to each micro service, so that each micro service can possess its own IP address. The specific process of assigning the Pod IP or the cluster IP by the specific k8s can refer to the content of the prior art, and is not described in detail herein. After k8s allocates the corresponding cluster IP for the micro service, the api servlet may obtain the IP address of the micro service.
In order to facilitate the later management of the micro services, after the application interface service unit creates the application, the api service unit may further obtain a third correspondence between each micro service and at least one Pod included in the micro service, that is, the third correspondence indicates which pods belong to which micro services. Meanwhile, in order to enable other modules of the service discovery system to obtain the third corresponding relationship, the programming application interface may further store the third corresponding relationship in the key-value database.
After the api service unit creates an application, the api service unit sends a notification to the domain name synchronization module, which may also be informed that a new application is generated according to the notification received from the api service unit. Or after the programming application interface service unit writes the first corresponding relation into the key value database, the key value database informs the domain name synchronization module that new micro-services are generated. Or after the programming application interface service unit writes the first corresponding relation into the key value database, the domain name synchronization module periodically accesses the data in the key value database to know that new micro-services are generated. In summary, the domain name synchronization module is aware that a new application is generated.
After the domain name synchronization module obtains new application generation, the domain name synchronization module obtains a first corresponding relation from the application creation module, obtains the IP address of the micro service, establishes a second corresponding relation between the first corresponding relation and the IP address of the micro service, and writes the second corresponding relation into the key value database. The first corresponding relation can refer to the content discussed in the foregoing, and is not described in detail here. And establishing a one-to-one correspondence between the first correspondence and the IP addresses of the micro-services to obtain a second correspondence.
For example, the domain name synchronization module obtains that the first correspondence is a cluster name, namespace1, application a, service a, and the IP address of service a is 10.0.1.1, then the domain name synchronization module establishes that the cluster name, namespace1, application a, service a, and the IP address of service a are 10.0.1.1 one-to-one correspondence, and the domain name synchronization module writes the second correspondence into the key value database. Or for example, the domain name synchronization module obtains the first corresponding relationship as the IP address of the micro service a. application a and the IP address of the micro service a is 10.0.0.1, then the domain name synchronization module establishes the one-to-one corresponding relationship between the IP address of the micro service a. application a and the IP address of the micro service a is 10.0.0.1, obtains the second corresponding relationship of the micro service a, and the domain name synchronization module writes the second corresponding relationship into the key value database.
The way for the domain name synchronization module to write in the second corresponding relationship may be to write the first corresponding relationship as a key (key) into the key-value database, and write the IP address of the micro service as a value (value) into the key-value database. The key-value store stores a second corresponding relationship, which is an example of the second corresponding relationship stored in the key-value store with reference to table 1 below.
TABLE 1
Key Value
Microservice a. application A 10.0.0.1
Microservice b. application A 10.0.0.2
Microservice B. application B 10.0.0.3
When other modules input the Key, the Value corresponding to the Key can be accessed. In order to reduce the storage amount of the key-value database, after the domain name synchronization module writes the second corresponding relationship into the key-value database, the key-value database may directly delete the data such as the first corresponding relationship and the third corresponding relationship written before the application interface service unit is programmed. Alternatively, in order to simplify the operation of the key-value store, data such as the first correspondence and the third correspondence stored in the key-value store may be retained. Or in order to improve efficiency of searching the key-value database by other modules in the service discovery system, the key-value database may further add a corresponding index, for example, an application name is referred to as an index, specifically referring to table 2.
TABLE 2
index Key Value
Applications A Micro-service aWith A 10.0.0.1
Applications A Microservice b. application A 10.0.0.2
Applications A Microservice c. application A 10.0.0.3
Application B Microservice d. application B 10.0.0.4
In the process of generating the new micro service in the cluster and writing the new micro service into the second corresponding relation, the corresponding modules of the service discovery system can repeat the steps, so that the second corresponding relation of the newly created micro service in the cluster is synchronized into the key value database in real time.
Referring to fig. 4, the service discovery system further includes a domain name resolution module. The specific functions of the domain name resolution module and the like will be described in detail below. The domain name resolution module can also be understood as a micro-service, and the corresponding domain name resolution module also has an IP address of the domain name resolution module.
When the Pod corresponding to the micro-service is started for the first time, the management component of k8s maps the IP address of the domain name resolution module to the Pod included in the micro-service, so that the Pod can communicate with the domain name resolution module through the IP address of the domain name resolution module. The management component, such as a Kubelet component, which generally runs on the Pod, maintains the running environment of the running Pods, that is, the Kubelet component writes the IP address of the domain name resolution module into the domain name resolution configuration file of each Pod.
When a Pod in a microservice needs to access a first microservice, the microservice is a different microservice than the first microservice. The Pod may obtain the IP address of the domain name resolution module according to the resolution configuration file, and then initiate a domain name resolution request to the domain name resolution module. The specific format of the domain name resolution request is not limited, but the domain name resolution request includes at least a service name and an application name of the first microservice. For example, the domain name resolution request may be a domain name of the first micro-service, which may be in the format of a service name.
After the domain name resolution module receives the domain name resolution request, the domain name resolution module matches a second corresponding relation corresponding to the domain name resolution request in the key value database according to the service name and the application name of the first micro service included in the domain name resolution request, the domain name resolution module can obtain the IP address of the first micro service according to the second corresponding relation, then the domain name resolution module returns the IP address of the first micro service to the requested Pod, and the Pod can communicate with the first micro service according to the IP address of the first micro service.
When the Pod sends a message to the first microservice, the message may be forwarded to the first Pod of the first microservice via a kube-proxy within k8 s. Because the first microservice may include multiple Pod, the kube-proxy needs to determine which Pod is the first Pod. The kube-proxy may randomly select a Pod of the first micro service to determine as the first Pod, or the kube-proxy may determine the first Pod by polling. The polling refers to that the kube-proxy queries the load of each Pod in the first micro service, determines the Pod with the minimum load as the first Pod, and the polling mode can realize the load balance of each Pod of the first micro service.
For example, referring to fig. 5, the Pod requested to access the first micro service is Pod1 in fig. 5, and the first micro service includes, for example, 4 pods, namely Pod2 (corresponding to P2 in fig. 5), Pod3 (corresponding to P3 in fig. 5), Pod4 (corresponding to P4 in fig. 5), and Pod5 (corresponding to P5 in fig. 5). The Pod1 needs to send the call minutes of the user to the first micro service calculation, the Pod1 initiates a domain name resolution request for requesting the IP address of the first micro service to the domain name resolution module, the domain name resolution module calls the data in the key value database after receiving the domain name resolution request to obtain the IP address of the first micro service, and then the domain name resolution module sends the IP address of the first micro service to the Pod 1.
The Pod1, after receiving the IP address of the first micro-service, sends the user's minutes of the call to the first micro-service through the IP address. The kube-proxy (corresponding to kb in fig. 5) receives the number of minutes of the call of the user sent by the Pod1, then queries the loads of the Pod2, the Pod3, the Pod4 and the Pod5 respectively, after the kube-proxy queries, the load of the Pod2 is 5%, the load of the Pod3 is 7%, the load of the Pod4 is 9%, the load of the Pod5 is 13%, and the kube-proxy determines that the load of the Pod2 is the minimum, then the kube-proxy directly sends the number of minutes of the call of the user sent by the Pod1 to the Pod2, and the number of minutes of the call of the user sent by the Pod1 is processed by the Pod 2.
On the basis of the service discovery system, the embodiment of the present application further provides a service discovery method, which is performed by the service discovery system. Referring to fig. 6, the flow of the method is described as follows.
601, receiving a domain name resolution request sent by a Pod, wherein the domain name resolution request comprises a service name of a first micro service and an application name of an application to which the first micro service belongs, the Pod belongs to a second micro service, and the second micro service is different from the first micro service;
step 602, acquiring a network protocol IP address of a first micro service, wherein a second corresponding relationship between a first corresponding relationship and the IP address of the micro service is stored in the service discovery system, and the first corresponding relationship is a corresponding relationship between an application and the micro service included in the application;
step 603, sending the IP address of the first micro-service to the Pod.
Optionally, before acquiring the network protocol IP address of the first micro service according to the first request, the method further includes:
acquiring a first corresponding relation according to an application name required to be created and a first micro-service name included in the application, which are input by a user, and creating the application;
and acquiring the IP address of the first micro service, acquiring a second corresponding relation according to the first corresponding relation and the IP address, and writing the second corresponding relation into the service discovery system.
Optionally, obtaining the first corresponding relationship between the application and the first microservice includes:
the method comprises the steps of detecting input operation of a user, obtaining an application name and a first micro-service name according to the input operation, and converting the first micro-service name into a name with the application name as a suffix, so that a first corresponding relation is obtained.
Optionally, after the creating of the application, the method further includes obtaining a third corresponding relationship between the micro service and at least one Pod included in the micro service.
Optionally, before the service discovery system acquires the network protocol IP address of the first micro service, the first corresponding relationship may be stored.
The content in the service discovery method may refer to the content in the service discovery system, and is not described herein again.
On the basis of the service discovery method, an embodiment of the present application further provides a service discovery apparatus, please refer to fig. 7, where the apparatus includes a transceiver module 701 and a processing module 702.
Specifically, the transceiver module 701 is configured to receive a domain name resolution request sent by a Pod, where the domain name resolution request includes a service name of a first micro service and an application name of an application to which the first micro service belongs, the Pod belongs to a second micro service, and the second micro service is different from the first micro service;
the processing module 702 is configured to obtain a network protocol IP address of a first micro service according to the first request, where a second corresponding relationship between a first corresponding relationship and the IP address of the micro service is stored in the service discovery system, and the first corresponding relationship is a corresponding relationship between an application and the micro service included in the application.
The transceiver module 701 is further configured to send the IP address of the first micro service to the Pod.
Optionally, the processing module 702 is further configured to: before acquiring a network protocol IP address of a first micro service according to a first request, acquiring a first corresponding relation according to an application name required to be created and a first micro service name included by the application, which are input by a user, and creating the application;
and acquiring the IP address of the first micro service, acquiring a second corresponding relation according to the first corresponding relation and the IP address, and writing the second corresponding relation into the service discovery system.
Optionally, the processing module 702 is specifically configured to detect an input operation of a user, obtain an application name and a first micro-service name according to the input operation, and convert the first micro-service name into a name with the application name as a suffix, so as to obtain the first corresponding relationship.
The processing module 702 is further configured to, after creating the application, obtain a third correspondence between the micro service and at least one Pod included in the micro service.
On the basis of the service discovery method, an embodiment of the present application further provides a service discovery apparatus, please refer to fig. 8, where the apparatus includes:
at least one processor 801, and
a memory 802 communicatively coupled to the at least one processor 801;
wherein the memory 802 stores instructions executable by the at least one processor 801, the at least one processor 801 implementing the method of any of fig. 6 by executing the instructions stored by the memory 802.
As an embodiment, the number of the processors 801 in the embodiment of the present application may be one or more, and fig. 8 illustrates one processor 801, but the number of the processors 801 is not limited in practice.
The processing module in fig. 7 may be implemented by the processor 801 in fig. 8 as an embodiment.
On the basis of the service discovery method, an embodiment of the present application further provides a computer-readable storage medium, which stores computer instructions that, when executed on a computer, cause the computer to perform the method as in any one of fig. 6.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While the preferred embodiments of the present application have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all alterations and modifications as fall within the scope of the application.
It will be apparent to those skilled in the art that various changes and modifications may be made in the embodiments of the present application without departing from the spirit and scope of the embodiments of the present application. Thus, if such modifications and variations of the embodiments of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to encompass such modifications and variations.

Claims (15)

1. A service discovery system, the system comprising: the domain name synchronization analysis system comprises an application creation module, a domain name synchronization analysis module and a key value database;
the application creation module is used for acquiring a first corresponding relation between the application and the micro service according to an application name of the application needing to be created and a service name of the micro service included in the application, which are input by a user, and creating the application;
the domain name synchronization module is used for acquiring the first corresponding relation from the application creation module, acquiring a network protocol IP address of the micro service, establishing a second corresponding relation between the first corresponding relation and the IP address of the micro service, and writing the second corresponding relation into the key value database;
and the key value database is used for storing the second corresponding relation.
2. The system of claim 1, wherein the application creation module comprises an application agent unit and a programmatic application interface service unit, wherein:
the application proxy unit is used for detecting input operation of a user, acquiring the application name and the service name according to the input operation, converting the service name into a name taking the application name as a suffix so as to acquire the first corresponding relation, and sending the first corresponding relation to the programming application interface service unit;
the programming application interface service unit is used for creating the application according to the first corresponding relation.
3. The system of claim 2, wherein the programmatic application interface service unit is further to:
and writing the first corresponding relation into the key value database.
4. The system of any of claims 1-3, wherein the application creation module is further to:
after the application is created, a third corresponding relation between the micro service and at least one Pod included in the micro service is obtained.
5. The system of claim 4, wherein the system further comprises:
and the domain name resolution module is used for calling the second corresponding relation in the key value database to obtain the IP address of the first micro service after receiving a domain name resolution request of the Pod for the first micro service, wherein the domain name resolution request comprises the service name of the first micro service and the application name of the application to which the first micro service belongs.
6. A service discovery method applied to the service discovery system according to claims 1 to 5, comprising:
receiving a domain name resolution request sent by a Pod, wherein the domain name resolution request comprises a service name of a first micro service and an application name of an application to which the first micro service belongs, the Pod belongs to a second micro service, and the second micro service is different from the first micro service;
acquiring a network protocol (IP) address of the first micro service according to the first request, wherein a second corresponding relation between a first corresponding relation and the IP address of the micro service is stored in the service discovery system, and the first corresponding relation is the corresponding relation between an application and the micro service included by the application;
sending the IP address of the first micro-service to the Pod.
7. The method of claim 6, prior to obtaining a network protocol, IP, address of the first microservice in accordance with the first request, further comprising:
acquiring the first corresponding relation according to an application name which needs to be created and a service name of a first micro service included in the application, and creating the application;
and acquiring the IP address of the first micro service, acquiring the second corresponding relation according to the first corresponding relation and the IP address, and writing the second corresponding relation into the service discovery system.
8. The method of claim 7, wherein obtaining a first correspondence of the application with the first microservice comprises:
detecting input operation of a user, acquiring the application name and the service name of the first micro service according to the input operation, and converting the service name of the first micro service into a name taking the application name as a suffix, so as to obtain the first corresponding relation.
9. The method of any of claims 6-7, after creating the application, further comprising:
and acquiring a third corresponding relation between the micro service and at least one Pod included in the micro service.
10. A service discovery apparatus, comprising:
the domain name resolution system comprises a receiving and sending module, a processing module and a processing module, wherein the receiving and sending module is used for receiving a domain name resolution request sent by a Pod, the domain name resolution request comprises a service name of a first micro service and an application name of an application to which the first micro service belongs, the Pod belongs to a second micro service, and the second micro service is different from the first micro service;
a processing module: the service discovery system is used for acquiring a network protocol (IP) address of the first micro service according to the first request, wherein a second corresponding relation between a first corresponding relation and the IP address of the micro service is stored in the service discovery system, and the first corresponding relation is a corresponding relation between an application and the micro service included by the application;
the transceiver module is further configured to send the IP address of the first micro service to the Pod.
11. The apparatus of claim 10, wherein the processing module is further to:
before acquiring the network protocol IP address of the first micro service according to the first request, acquiring the first corresponding relation according to an application name required to be created and a micro service name of the first micro service included in the application, which are input by a user, and creating the application;
and acquiring the IP address of the first micro service, acquiring the second corresponding relation according to the first corresponding relation and the IP address, and writing the second corresponding relation into the service discovery system.
12. The apparatus of claim 10, wherein the processing module is specifically configured to:
detecting input operation of a user, acquiring the application name and the service name of the first micro service according to the input operation, and converting the micro service name of the first micro service into a name taking the application name as a suffix, so as to obtain the first corresponding relation.
13. The apparatus of any of claims 10-12, wherein the processing module is further to:
after the application is created, a third corresponding relation between the micro service and at least one Pod included in the micro service is obtained.
14. A service discovery device, comprising:
at least one processor, and
a memory communicatively coupled to the at least one processor;
wherein the memory stores instructions executable by the at least one processor, the at least one processor implementing the method of any one of claims 6-9 by executing the instructions stored by the memory.
15. A computer-readable storage medium having stored thereon computer instructions which, when executed on a computer, cause the computer to perform the method of any one of claims 6-9.
CN201811278717.7A 2018-10-30 2018-10-30 Service discovery system, method, device and equipment Active CN111124589B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811278717.7A CN111124589B (en) 2018-10-30 2018-10-30 Service discovery system, method, device and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811278717.7A CN111124589B (en) 2018-10-30 2018-10-30 Service discovery system, method, device and equipment

Publications (2)

Publication Number Publication Date
CN111124589A true CN111124589A (en) 2020-05-08
CN111124589B CN111124589B (en) 2022-12-13

Family

ID=70484473

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811278717.7A Active CN111124589B (en) 2018-10-30 2018-10-30 Service discovery system, method, device and equipment

Country Status (1)

Country Link
CN (1) CN111124589B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111770159A (en) * 2020-06-26 2020-10-13 中信银行股份有限公司 Service discovery system, method, first server and storage medium
CN112181438A (en) * 2020-09-18 2021-01-05 杭州卓健信息科技有限公司 Micro-service independent deployment system and method in 2B SAAS platform
CN112632527A (en) * 2020-12-18 2021-04-09 航天信息股份有限公司 API (application programming interface) testing method and system for service open platform
CN112910991A (en) * 2021-01-29 2021-06-04 杭州涂鸦信息技术有限公司 Back-end application calling method and device, computer equipment and readable storage medium
CN116662267A (en) * 2023-08-02 2023-08-29 中国电子投资控股有限公司 Distributed application snapshot system based on cloud protogenesis and snapshot creation method

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108040079A (en) * 2017-10-26 2018-05-15 山东浪潮云服务信息科技有限公司 Distributed container cluster service discovery method based on domestic CPU and operating system
CN108512935A (en) * 2018-04-16 2018-09-07 腾讯科技(深圳)有限公司 data service system, method, server and computer readable storage medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108040079A (en) * 2017-10-26 2018-05-15 山东浪潮云服务信息科技有限公司 Distributed container cluster service discovery method based on domestic CPU and operating system
CN108512935A (en) * 2018-04-16 2018-09-07 腾讯科技(深圳)有限公司 data service system, method, server and computer readable storage medium

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111770159A (en) * 2020-06-26 2020-10-13 中信银行股份有限公司 Service discovery system, method, first server and storage medium
CN111770159B (en) * 2020-06-26 2023-08-22 中信银行股份有限公司 Service discovery system, method, first server and storage medium
CN112181438A (en) * 2020-09-18 2021-01-05 杭州卓健信息科技有限公司 Micro-service independent deployment system and method in 2B SAAS platform
CN112632527A (en) * 2020-12-18 2021-04-09 航天信息股份有限公司 API (application programming interface) testing method and system for service open platform
CN112632527B (en) * 2020-12-18 2024-03-08 航天信息股份有限公司 API test method and system for service open platform
CN112910991A (en) * 2021-01-29 2021-06-04 杭州涂鸦信息技术有限公司 Back-end application calling method and device, computer equipment and readable storage medium
CN116662267A (en) * 2023-08-02 2023-08-29 中国电子投资控股有限公司 Distributed application snapshot system based on cloud protogenesis and snapshot creation method
CN116662267B (en) * 2023-08-02 2024-04-05 中国电子投资控股有限公司 Distributed application snapshot system based on cloud protogenesis and snapshot creation method

Also Published As

Publication number Publication date
CN111124589B (en) 2022-12-13

Similar Documents

Publication Publication Date Title
CN111124589B (en) Service discovery system, method, device and equipment
US9003006B2 (en) Intercloud application virtualization
US20210026692A1 (en) Systems and methods providing serverless dns integration
CN110703980B (en) File transmission method and device
CN114281263B (en) Storage resource processing method, system and equipment of container cluster management system
WO2024016624A1 (en) Multi-cluster access method and system
CN109104368B (en) Connection request method, device, server and computer readable storage medium
US20110153826A1 (en) Fault tolerant and scalable load distribution of resources
US8978041B2 (en) Service virtualization container
CN114996750A (en) Data sharing method and device
CN110798358B (en) Distributed service identification method and device, computer readable medium and electronic equipment
CN112698930A (en) Method, device, equipment and medium for obtaining server identification
US10791088B1 (en) Methods for disaggregating subscribers via DHCP address translation and devices thereof
CN115277707A (en) Service processing method, device, electronic equipment and storage medium
CN111294383B (en) Internet of things service management system
US11042665B2 (en) Data connectors in large scale processing clusters
CN113810472A (en) Request processing method and device, electronic equipment and storage medium
CN112532666A (en) Reverse proxy method, apparatus, storage medium, and device
CN112217852A (en) Platform-as-a-service system and method based on workflow engine
CA3057458A1 (en) System and method for self-deploying and self-adapting contact center components
US20230385121A1 (en) Techniques for cloud agnostic discovery of clusters of a containerized application orchestration infrastructure
CN112073449B (en) Kubernetes-based environment switching processing method and equipment
US20230315541A1 (en) Tightly coupled parallel applications on a serverless computing system
US20230315543A1 (en) Tightly coupled parallel applications on a serverless computing system
US20230161603A1 (en) Handling the running of software

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant