CN114422602A - Method and device for calling micro-service based on K8S cluster, electronic equipment and storage medium - Google Patents

Method and device for calling micro-service based on K8S cluster, electronic equipment and storage medium Download PDF

Info

Publication number
CN114422602A
CN114422602A CN202111642074.1A CN202111642074A CN114422602A CN 114422602 A CN114422602 A CN 114422602A CN 202111642074 A CN202111642074 A CN 202111642074A CN 114422602 A CN114422602 A CN 114422602A
Authority
CN
China
Prior art keywords
target
service
micro
micro service
calling
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.)
Pending
Application number
CN202111642074.1A
Other languages
Chinese (zh)
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 Telecom Corp Ltd
Original Assignee
China Telecom Corp 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 Telecom Corp Ltd filed Critical China Telecom Corp Ltd
Priority to CN202111642074.1A priority Critical patent/CN114422602A/en
Publication of CN114422602A publication Critical patent/CN114422602A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Stored Programmes (AREA)

Abstract

The application provides a method and a device for calling a micro-service based on a K8S cluster, electronic equipment and a storage medium, wherein the method comprises the following steps: acquiring a target service code and a target port number of a target micro service to be called; determining a target domain name address of the target micro service according to the target service code and the target port number; and calling the target micro service according to the target domain name address. In the embodiment of the application, the calling party calls the target micro service according to the target domain name address corresponding to the target micro service, and when the target micro service and the calling party are in the same cluster, the calling party can directly call the target micro service without passing through a hard load device, so that the flow pressure of the hard load device can be reduced; because the calling party calls the target micro service through the target domain name address corresponding to the target micro service, when the target micro service is migrated, the target micro service is not sensible to the calling party, and the system upgrading risk and the workload of related personnel can be greatly reduced.

Description

Method and device for calling micro-service based on K8S cluster, electronic equipment and storage medium
Technical Field
The present application relates to the field of communications technologies, and in particular, to a method and an apparatus for invoking a microservice based on a K8S cluster, an electronic device, and a storage medium.
Background
In the related art, the micro-service calling mode based on the K8S cluster is as follows: the called micro-services are uniformly registered on a hard load outside the cluster, and the caller calls other micro-services by using a hard load address. The longer the call link of the call mode is, and the more the traffic is amplified by the hard load in the call process, the greater the traffic is amplified by the hard load, and the greater the risk of failure is for one service processing.
In addition, in the related art, when the microservice migrates in the system, the caller also needs to synchronously upgrade the calling address, and the coupling degree and the risk are high.
Disclosure of Invention
In view of the foregoing, the present application is proposed to provide a method and apparatus, an electronic device, and a storage medium for invoking a micro-service based on a K8S cluster, which overcome or at least partially solve the above problems, and include:
a K8S-based cluster microservice invocation method, the method comprising:
acquiring a target service code and a target port number of a target micro service to be called;
determining a target domain name address of the target micro service according to the target service code and the target port number;
and calling the target micro service according to the target domain name address.
Optionally, the obtaining a target service code and a target port number of a target micro service to be invoked includes:
acquiring a preset index table, wherein the preset index table records service codes and port numbers of each micro service;
and inquiring the target service code and the target port number of the target micro service from the preset index table.
Optionally, the obtaining a target service code and a target port number of a target micro service to be invoked includes:
sending a calling request to a micro-service resource management platform, wherein the calling request comprises identification information of a target micro-service, and the micro-service resource management platform comprises a preset index table, and the preset index table records service codes and port numbers of each micro-service; the micro service resource management platform inquires corresponding target service codes and target port numbers from the preset index table according to the identification information of the target micro services;
and receiving the target service code and the target port number returned by the micro service resource management platform.
Optionally, the determining a target domain name address of the target micro service according to the target service code and the target port number includes:
and sending the target service code and the target port number to a domain name resolution (DNS), and returning a target domain name address of the target micro service to a caller calling the target micro service by the DNS.
Optionally, the method comprises:
in the K8S cluster, when a micro service is released, a name space is created by taking a platform code corresponding to the micro service as a name space name;
and creating a service by taking the service code corresponding to the micro service as a service name under the name space.
Optionally, the invoking the target micro service according to the target domain name address includes:
and when the target micro service and the calling position for calling the target micro service are positioned in the same cluster, calling the target micro service in the cluster according to the target domain name address.
Optionally, the invoking the target micro service according to the target domain name address includes:
and when the target micro service and a calling party calling the target micro service are positioned in different clusters, sending the target domain name address to corresponding hard load equipment so as to call the target micro service through the hard load equipment.
A K8S-based cluster microservice invocation apparatus, the apparatus comprising:
the first acquisition module is used for acquiring a target service code and a target port number of a target micro service to be called;
a first determining module, configured to determine a target domain name address of the target micro service according to the target service code and a target port number;
and the first calling module is used for calling the target micro service according to the target domain name address.
Optionally, the first obtaining module includes:
the device comprises a preset index table acquisition module, a preset index table acquisition module and a control module, wherein the preset index table is used for acquiring a preset index table, and the preset index table records service codes and port numbers of various micro services;
and the target service code and target port number determining module is used for inquiring the target service code and the target port number of the target micro service from the preset index table.
Optionally, the first obtaining module includes:
the system comprises a sending module, a receiving module and a processing module, wherein the sending module is used for sending a calling request to a micro service resource management platform, the calling request comprises identification information of a target micro service, the micro service resource management platform comprises a preset index table, and the preset index table records service codes and port numbers of each micro service; the micro service resource management platform inquires corresponding target service codes and target port numbers from the preset index table according to the identification information of the target micro services;
and the receiving module is used for receiving the target service codes and the target port numbers returned by the micro service resource management platform.
Optionally, the first determining module is configured to send the target service code and the target port number to a domain name resolution DNS, and return, by the DNS, the target domain name address of the target micro service to a caller who calls the target micro service.
Optionally, the apparatus comprises:
the system comprises a namespace creating module, a namespace creating module and a namespace creating module, wherein the namespace creating module is used for creating a namespace by taking a platform code corresponding to the micro-service as a namespace name when the micro-service is released in a K8S cluster;
and the service name creating module is used for creating service by taking the service code corresponding to the micro service as the service name under the name space.
Optionally, the first calling module includes:
and the calling module in the cluster is used for calling the target micro service in the cluster according to the target domain name address when the target micro service and the calling position for calling the target micro service are positioned in the same cluster.
Optionally, the first calling module includes:
and the cross-cluster calling module is used for sending the target domain name address to corresponding hard load equipment when the target micro service and a calling party calling the target micro service are positioned in different clusters so as to call the target micro service through the hard load equipment.
An electronic device comprising a processor, a memory and a computer program stored on the memory and capable of running on the processor, the computer program, when executed by the processor, implementing the steps of the K8S-based cluster microservice calling method as described above.
A computer readable storage medium having stored thereon a computer program which, when executed by a processor, carries out the steps of the K8S-based cluster microservice calling method as described above.
The application has the following advantages:
in the embodiment of the application, a target service code and a target port number of a target micro service to be called are obtained based on a calling party in a K8S cluster; determining a target domain name address of the target micro service according to the target service code and the target port number; and calling the target micro service according to the target domain name address. In the embodiment of the application, when a calling party calls a target micro service, the target micro service is called according to a target domain name address corresponding to the target micro service, but not according to a hard load device address, when the target micro service and the calling party are in the same cluster, the calling party can directly call the target micro service without passing through the hard load device, and therefore, the flow pressure of the hard load device can be reduced; moreover, the target micro service is called by the calling party through the target domain name address corresponding to the target micro service, so that the calling party is insensitive when the target micro service is migrated, and the risk of system upgrade and the workload of related personnel can be greatly reduced.
Drawings
In order to more clearly illustrate the technical solutions of the present application, the drawings needed to be used in the description of the present application will be briefly introduced below, and it is apparent that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive labor.
Fig. 1 is a flowchart illustrating steps of a method for invoking micro-services based on a K8S cluster according to an embodiment of the present disclosure;
FIG. 2 is a system architecture diagram for implementing a K8S-based cluster microservice calling method according to an embodiment of the present application;
fig. 3 is a block diagram illustrating a configuration of a K8S-based cluster microservice calling device according to an embodiment of the present disclosure.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present application more comprehensible, the present application is described in further detail with reference to the accompanying drawings and the detailed description. It is to be understood that the embodiments described are only a few embodiments of the present application and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The K8S cluster is short for kubernets and is an open source system for automatically deploying, extending and managing containerized applications. In the related art, the micro-service calling mode based on the K8S cluster is as follows: the called micro-services are uniformly registered on a hard load outside the cluster, and the caller calls other micro-services by using a hard load address. The longer the call link of the call mode is, and the more the traffic is amplified by the hard load in the call process, the greater the traffic is amplified by the hard load, and the greater the risk of failure is for one service processing. In addition, in the related art, when the microservice migrates in the system, the caller also needs to synchronously upgrade the calling address, and the coupling degree and the risk are high.
In view of this, the embodiment of the present application provides a method for invoking micro-services based on a K8S cluster, so as to overcome the defects in the prior art.
Referring to fig. 1, a flowchart illustrating steps of a method for calling a microservice based on a K8S cluster according to an embodiment of the present application is shown, where in an embodiment of the present application, the method may include the following steps:
step 101, acquiring a target service code and a target port number of a target micro service to be called;
step 102, determining a target domain name address of the target micro service according to the target service code and the target port number;
step 103, calling the target micro service according to the target domain name address.
In the embodiment of the application, a target service code and a target port number of a target micro service to be called are obtained based on a calling party in a K8S cluster; determining a target domain name address of the target micro service according to the target service code and the target port number; and calling the target micro service according to the target domain name address. In the embodiment of the application, when a calling party calls a target micro service, the target micro service is called according to a target domain name address corresponding to the target micro service, but not according to a hard load device address, when the target micro service and the calling party are in the same cluster, the calling party can directly call the target micro service without passing through the hard load device, and therefore, the flow pressure of the hard load device can be reduced; moreover, the target micro service is called by the calling party through the target domain name address corresponding to the target micro service, so that the calling party is insensitive when the target micro service is migrated, and the risk of system upgrade and the workload of related personnel can be greatly reduced.
Next, the K8S-based cluster microservice calling method in the present exemplary embodiment will be further described.
In the embodiment of the application, when a micro service is released in the K8S cluster, a namespace is created for a space name by using a platform code of the micro service, and a service is created for a service name by using a service code of the micro service under the namespace. Since the name letters of the named controls of the K8S cluster need to be lower case, when the platform code of the microservice contains upper case letters, conversion to corresponding lower case letters is needed.
In step 101, a target service code and a target port number of a target micro-service to be invoked are obtained.
In this embodiment, the caller may be any one of the K8S clusters that has a microservice that calls the requirements of other microservices; for the convenience of differentiation, the micro-service that calls other micro-services is defined as the caller, and the micro-service called by the caller is defined as the target micro-service.
In this embodiment, when the caller needs to call another micro service, the service code and the port number of the target micro service (i.e., the callee) need to be obtained, and for convenience of distinction, the service code of the target micro service is recorded as the target service code, and the port number of the target micro service is recorded as the target port number.
In an optional embodiment, the process of the caller acquiring the target service code and the target port number of the target micro service to be called may include:
the calling party acquires a preset index table, and the preset index table records service codes and port numbers of each micro service;
and the caller inquires a target service code and a target port number of the target micro service from the preset index table.
In this embodiment, the identification information of each micro service, and the service code and the port number of each micro service may be filled into a preset index table by a worker, that is, the preset index table records the association relationship between the identification information of the micro service and the service code and the port number thereof; the identification information of the micro service can be a service name corresponding to the micro service; the port number of each micro service corresponds to the service code one by one and is not repeatedly distributed.
The calling party can obtain a preset index table recorded with service codes and port numbers of each micro service in advance, for example, a worker can maintain the preset index table in the micro service resource management platform, the calling party can communicate with the micro service resource management platform to obtain the preset index table maintained in the micro service resource management platform, and then the target service codes and the target port numbers of the target micro services are searched and obtained from the preset index table according to identification information of the target micro services required to be called by the calling party.
In another optional embodiment, the process of the caller acquiring the target service code and the target port number of the target micro service to be called may include:
the calling direction micro service resource management platform sends a calling request, wherein the calling request comprises identification information of a target micro service, the micro service resource management platform comprises a preset index table, and the preset index table records service codes and port numbers of each micro service;
and the micro-service resource management platform inquires a corresponding target service code and a target port number from the preset index table according to the identification information of the target micro-service, and returns the target service code and the target port number to the caller.
In this embodiment, the caller may communicate with the micro service resource management platform to request the micro service resource management platform to search the target service code and the target port number corresponding to the target micro service according to the preset index table maintained by the micro service resource management platform, and return the target service code and the target port number obtained by the search to the caller.
In step 102, a target domain name address of the target micro-service is determined according to the target service code and a target port number.
In the present embodiment, in domain name resolution DNS management, the format of the domain name address of the microservice is [ service code ] - [ platform code ]: a port number; in the present embodiment, the service code of the microservice has a uniform code format, and specifically, the service code of the microservice is generated by arranging the platform code, the category code, the service number, and the cluster number in a specific order. Illustratively, the service code may be 4-bit non-platform code, 2-bit class code, 2-bit service serial number, and 2-bit cluster serial number in order from high to low. For example, when the platform code of the corresponding platform of the micro service is P101, the class code is 01, the service serial number is 01, and the cluster serial number is 01, the service code of the micro service is P101010101.
It should be noted that the number of bits and the sequence of the platform code, the category code, the service serial number, and the cluster serial number are not limited to the above example, but it should be emphasized that although the format of the service code is not limited, the service codes of all the micro services in the K8S cluster need to adopt a uniform coding format.
Therefore, after the calling party acquires the target service code and the target port number of the target micro service, the target domain name address of the target micro service can be determined.
Specifically, the step of determining, by the caller, the target domain name address of the target micro service according to the target service code and the target port number includes:
and the caller sends the target service code and the target port number to a domain name resolution (DNS), and the DNS returns the target domain name address of the target micro service to the caller.
In this example, the caller may also send the target service code and the target port number to the DNS, and the DNS determines the target platform code, the target service code, and the target port number of the target micro service according to the target service code and the target port number, and further determines the target domain name address of the target micro service, and then returns to the caller.
In step 103, the target microservice is invoked according to the target domain name address.
In this embodiment, after the caller determines the target domain name address of the target micro-service, the caller may call the target micro-service using the target domain name address. When the target micro service and the calling party are in the same cluster, the calling party can directly call the target micro service according to the target domain name address of the target micro service. When the target micro-service is in a different cluster from the caller, the caller needs to call the target micro-service through the hard load device. In this embodiment, regardless of whether the target microservice is in the same cluster as the caller, the caller may call the target microservice directly or indirectly according to the target domain name address of the target microservice.
Specifically, as shown in FIG. 2, the caller is microservice A and the target microservices are B and B', respectively. The calling party inquires the target domain name address of the target micro-service by the DNS, and the DNS also returns the cluster IP of the target micro-service when returning the target domain name address to the calling party. When the cluster IP corresponding to the target micro-service is the same as the cluster IP corresponding to the caller, it indicates that the target micro-service and the caller are in the same cluster, and the caller can directly call the target micro-service without calling through a hard load device by directly using the basis that the micro-services in the K8S and the same cluster can be directly and mutually called. The mutual calling among the micro services in the cluster is realized to be digested in the cluster, external hard load equipment is not needed, and the flow pressure of the hard load equipment can be reduced to a great extent for a large-scale micro service system with frequent mutual calling of the micro services in the cluster.
When the cluster IP corresponding to the target micro-service is different from the cluster IP corresponding to the caller, it indicates that the target micro-service and the caller are in different clusters, that is, the target micro-service needs to be called across the clusters, and the caller needs to call the target micro-service through the hard load device. Specifically, when the target micro service and the caller are located in different clusters, the caller sends the target domain name address to corresponding hard load equipment, and the target micro service is called through the hard load equipment; the process of invoking the target microservice by the hard load device may include: the hard load device can determine a target cluster where the target micro service is located according to a cluster IP corresponding to the target micro service, and call the target micro service from the target cluster according to a target domain name address. Therefore, in this embodiment, when the target micro service is migrated from the original cluster to the new cluster, the target domain name address corresponding to the target micro service is correspondingly maintained to the new cluster IP, so that it is possible to make the caller who calls the target micro service insensitive when the target micro service is migrated; that is, in this embodiment, no matter which cluster the target micro service is located in, the caller only needs to use the target domain name address of the target micro service, and the call of the target micro service can be realized.
In the embodiment of the application, micro services in a K8S cluster are uniformly coded, and the service coding format of the micro services is that platform codes, category codes, service serial numbers and cluster serial numbers of the micro services are arranged according to a specified sequence; in the K8S cluster, a namespace is created by using the platform code of the service as the name of the namespace, the service is created by using the service code as the name of the service under the namespace, and the service code of the micro service has a clear corresponding relation with the name control and the name of the service. The caller only needs to inquire out the service code and port number of the called target micro service in the micro service resource management platform, and the domain name address of the target micro service can be calculated by himself; and then the target micro service is called according to the target domain name address. In the embodiment of the application, when a calling party calls a target micro service, the target micro service is called according to a target domain name address corresponding to the target micro service, and when the target micro service and the calling party are in the same cluster, the calling party can directly call the target micro service without passing through a hard load device, so that the flow pressure of the hard load device can be reduced; moreover, the target micro service is called by the calling party through the target domain name address corresponding to the target micro service, so that the calling party is insensitive when the target micro service is migrated, and the risk of system upgrade and the workload of related personnel can be greatly reduced.
It should be noted that, for simplicity of description, the method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the embodiments are not limited by the order of acts described, as some steps may occur in other orders or concurrently depending on the embodiments. Further, those skilled in the art will also appreciate that the embodiments described in the specification are presently preferred and that no particular act is required of the embodiments of the application.
Referring to fig. 3, a block diagram illustrating a structure of an embodiment of a K8S-based cluster microservice calling apparatus according to the present application is shown, where the apparatus in this embodiment of the present application may include the following modules:
a first obtaining module 301, configured to obtain a target service code and a target port number of a target micro service to be called;
a first determining module 302, configured to determine a target domain name address of the target micro service according to the target service code and a target port number;
a first calling module 303, configured to call the target micro service according to the target domain name address.
Optionally, the first obtaining module 301 includes:
the device comprises a preset index table acquisition module, a preset index table acquisition module and a control module, wherein the preset index table is used for acquiring a preset index table, and the preset index table records service codes and port numbers of various micro services;
and the target service code and target port number determining module is used for inquiring the target service code and the target port number of the target micro service from the preset index table.
Optionally, the first obtaining module 301 includes:
the system comprises a sending module, a receiving module and a processing module, wherein the sending module is used for sending a calling request to a micro service resource management platform, the calling request comprises identification information of a target micro service, the micro service resource management platform comprises a preset index table, and the preset index table records service codes and port numbers of each micro service; the micro service resource management platform inquires corresponding target service codes and target port numbers from the preset index table according to the identification information of the target micro services;
and the receiving module is used for receiving the target service codes and the target port numbers returned by the micro service resource management platform.
Optionally, the first determining module 302 is configured to send the target service code and the target port number to a domain name resolution DNS, and the DNS returns the target domain name address of the target micro service to a caller who calls the target micro service.
Optionally, the apparatus comprises:
the system comprises a namespace creating module, a namespace creating module and a namespace creating module, wherein the namespace creating module is used for creating a namespace by taking a platform code corresponding to the micro-service as a namespace name when the micro-service is released in a K8S cluster;
and the service name creating module is used for creating service by taking the service code corresponding to the micro service as the service name under the name space.
Optionally, the first invoking module 303 includes:
and the calling module in the cluster is used for calling the target micro service in the cluster according to the target domain name address when the target micro service and the calling position for calling the target micro service are positioned in the same cluster.
Optionally, the first invoking module 303 includes:
and the cross-cluster calling module is used for sending the target domain name address to corresponding hard load equipment when the target micro service and a calling party calling the target micro service are positioned in different clusters so as to call the target micro service through the hard load equipment.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
The embodiment of the application also discloses an electronic device, which comprises a processor, a memory and a computer program stored on the memory and capable of running on the processor, wherein when the computer program is executed by the processor, the steps of the method for calling the microservice based on the K8S cluster are realized.
The embodiment of the application also discloses a computer readable storage medium, wherein a computer program is stored on the computer readable storage medium, and when the computer program is executed by a processor, the steps of the method for calling the micro-service based on the K8S cluster are realized.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
As will be appreciated by one of skill in the art, embodiments of the present application may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of 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, embodiments of 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.
Embodiments of the present application are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (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 terminal to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal, 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 terminal 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 terminal to cause a series of operational steps to be performed on the computer or other programmable terminal to produce a computer implemented process such that the instructions which execute on the computer or other programmable terminal provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present application have been described, additional variations and modifications of these 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 the preferred embodiment and all such alterations and modifications as fall within the true scope of the embodiments of the application.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or terminal that comprises the element.
The method and the device for calling the micro-service based on the K8S cluster, the electronic device and the storage medium provided by the present application are introduced in detail, and a specific example is applied to illustrate the principle and the implementation of the present application, and the description of the above embodiment is only used to help understand the method and the core idea of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (10)

1. A K8S-based cluster microservice calling method, the method comprising:
acquiring a target service code and a target port number of a target micro service to be called;
determining a target domain name address of the target micro service according to the target service code and the target port number;
and calling the target micro service according to the target domain name address.
2. The method of claim 1, wherein the obtaining a target service code and a target port number of a target micro service to be invoked comprises:
acquiring a preset index table, wherein the preset index table records service codes and port numbers of each micro service;
and inquiring the target service code and the target port number of the target micro service from the preset index table.
3. The method of claim 1, wherein the obtaining a target service code and a target port number of a target micro service to be invoked comprises:
sending a calling request to a micro-service resource management platform, wherein the calling request comprises identification information of a target micro-service, and the micro-service resource management platform comprises a preset index table, and the preset index table records service codes and port numbers of each micro-service; the micro service resource management platform inquires corresponding target service codes and target port numbers from the preset index table according to the identification information of the target micro services;
and receiving the target service code and the target port number returned by the micro service resource management platform.
4. The method of claim 1, wherein the determining a target domain name address of the target micro-service according to the target service code and a target port number comprises:
and sending the target service code and the target port number to a domain name resolution (DNS), and returning a target domain name address of the target micro service to a caller calling the target micro service by the DNS.
5. The method according to claim 1, characterized in that it comprises:
in the K8S cluster, when a micro service is released, a name space is created by taking a platform code corresponding to the micro service as a name space name;
and creating a service by taking the service code corresponding to the micro service as a service name under the name space.
6. The method of claim 1, wherein said invoking the target microservice according to the target domain name address comprises:
and when the target micro service and the calling position for calling the target micro service are positioned in the same cluster, calling the target micro service in the cluster according to the target domain name address.
7. The method of claim 1, wherein said invoking the target microservice according to the target domain name address comprises:
and when the target micro service and a calling party calling the target micro service are positioned in different clusters, sending the target domain name address to corresponding hard load equipment so as to call the target micro service through the hard load equipment.
8. A K8S-based cluster microservice invoking device, the device comprising:
the first acquisition module is used for acquiring a target service code and a target port number of a target micro service to be called;
a first determining module, configured to determine a target domain name address of the target micro service according to the target service code and a target port number;
and the first calling module is used for calling the target micro service according to the target domain name address.
9. An electronic device comprising a processor, a memory, and a computer program stored on the memory and capable of running on the processor, the computer program when executed by the processor implementing the steps of the K8S-based cluster microservice invocation method of any of claims 1-7.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the K8S-based cluster microservice calling method according to any one of claims 1 to 7.
CN202111642074.1A 2021-12-29 2021-12-29 Method and device for calling micro-service based on K8S cluster, electronic equipment and storage medium Pending CN114422602A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111642074.1A CN114422602A (en) 2021-12-29 2021-12-29 Method and device for calling micro-service based on K8S cluster, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111642074.1A CN114422602A (en) 2021-12-29 2021-12-29 Method and device for calling micro-service based on K8S cluster, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114422602A true CN114422602A (en) 2022-04-29

Family

ID=81269974

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111642074.1A Pending CN114422602A (en) 2021-12-29 2021-12-29 Method and device for calling micro-service based on K8S cluster, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114422602A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115242866A (en) * 2022-07-28 2022-10-25 度小满科技(北京)有限公司 Micro-service calling method and device, electronic equipment and storage medium
CN116939032A (en) * 2023-07-26 2023-10-24 中航信移动科技有限公司 Micro-service calling method, electronic equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108418862A (en) * 2018-01-31 2018-08-17 金蝶软件(中国)有限公司 Micro services management method and system based on artificial intelligence service cloud platform
CN110225131A (en) * 2019-06-19 2019-09-10 广州小鹏汽车科技有限公司 A kind of service calling method and device
CN110928709A (en) * 2019-11-21 2020-03-27 中国民航信息网络股份有限公司 Service calling method and device under micro-service framework and server
US20200401457A1 (en) * 2019-06-18 2020-12-24 Nutanix, Inc. Deploying microservices into virtualized computing systems
CN112433863A (en) * 2020-11-18 2021-03-02 平安消费金融有限公司 Micro-service calling method and device, terminal equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108418862A (en) * 2018-01-31 2018-08-17 金蝶软件(中国)有限公司 Micro services management method and system based on artificial intelligence service cloud platform
US20200401457A1 (en) * 2019-06-18 2020-12-24 Nutanix, Inc. Deploying microservices into virtualized computing systems
CN110225131A (en) * 2019-06-19 2019-09-10 广州小鹏汽车科技有限公司 A kind of service calling method and device
CN110928709A (en) * 2019-11-21 2020-03-27 中国民航信息网络股份有限公司 Service calling method and device under micro-service framework and server
CN112433863A (en) * 2020-11-18 2021-03-02 平安消费金融有限公司 Micro-service calling method and device, terminal equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115242866A (en) * 2022-07-28 2022-10-25 度小满科技(北京)有限公司 Micro-service calling method and device, electronic equipment and storage medium
CN116939032A (en) * 2023-07-26 2023-10-24 中航信移动科技有限公司 Micro-service calling method, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN114422602A (en) Method and device for calling micro-service based on K8S cluster, electronic equipment and storage medium
US7493377B2 (en) Method and apparatus to manage a configuration of clustered computers according to deployment date structures
CN110109766B (en) Data interaction method and device based on cross-department and cross-platform data sharing exchange
CN110063042B (en) Database fault response method and terminal thereof
CN114726632B (en) Login method, login equipment and storage medium
CN104135378A (en) Method of management control of Internet of Things gateways and management control entity for Internet of Things gateways
CN116257438A (en) Updating method of interface test case and related equipment
CN103425684A (en) Method and device for database operation
CN116070294B (en) Authority management method, system, device, server and storage medium
CN109614442B (en) Data table maintenance method and device for data synchronization, storage medium and electronic equipment
CN109683942B (en) Script management method, script management device, script management medium and electronic equipment
CN116737662A (en) Method, device, electronic equipment and storage medium for processing business data
CN113608831B (en) Plug-in instance management method, system, storage medium and equipment
CN112910675A (en) Equipment management method, device and system
CN114493185A (en) Approval processing method, device, system, electronic equipment, storage medium and product
JP2002366381A (en) Dynamic exchange processing method for object
CN112463208A (en) Version management method and device, electronic equipment and storage medium
CN116739397B (en) Dynamic management method for new energy indexes
CN105141674B (en) A kind of ability cut-in method and system
JP5469834B2 (en) Terminal management system
JPH10308736A (en) Distributed network managing system
CN117033476A (en) Data aggregation method, device and medium for region
CN118041797A (en) Data interaction system management method, device and storage medium
CN116846880A (en) Equipment monitoring method, device, computer equipment and readable storage medium
CN115766171A (en) Internet of things equipment management system and method

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