K8S cluster-based microservice calling method and device, electronic device, and storage medium
By obtaining the service code and port number of the microservice in the K8S cluster and directly calling the target microservice to avoid hard load, the problem of call link extension and migration risk is solved, and traffic pressure and risk are reduced.
Patent Information
- Application Number
- CN202111642074.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-29
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2041-12-29
AI Technical Summary
In a K8S cluster, the microservice calling method relies on hard loads, resulting in extended call links, traffic amplification, and high upgrade risks during migration.
By obtaining the service code and port number of the target microservice, the target domain name address is determined for direct calls, avoiding the need to use hard load devices to achieve direct calls within the same cluster and indirect calls across clusters.
It reduces the traffic pressure of hard load devices, reduces system upgrade risks and workload during microservice migration, and makes the calling process insensitive.
Smart Images

Figure CN114422602B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a method and device for calling microservices based on a K8S cluster, an electronic device, and a storage medium. Background Art
[0002] In the related technology, the microservice calling method based on the K8S cluster is: the called microservices are uniformly registered to the hard load outside the cluster, and the caller uses the hard load address to call other microservices. The longer the calling link of this calling method is, and the harder the hard load is during the calling process, the more traffic will be amplified. The more traffic is amplified through the hard load, the greater the risk of failure for a business processing.
[0003] In addition, in related technologies, when microservices are migrated in this system, the caller often also needs to upgrade the calling address synchronously, which results in high coupling and risk. Summary of the invention
[0004] In view of the above problems, the present application is proposed to provide a K8S cluster microservice calling method and device, electronic device, and storage medium that overcome the above problems or at least partially solve the above problems, including:
[0005] A microservice calling method based on a K8S cluster, the method comprising:
[0006] Get the target service code and target port number of the target microservice to be called;
[0007] Determine the target domain name address of the target microservice according to the target service code and the target port number;
[0008] The target microservice is called according to the target domain name address.
[0009] Optionally, the step of obtaining a target service code and a target port number of a target microservice to be called includes:
[0010] Obtain a preset index table, which records the service code and port number of each microservice;
[0011] The target service code and target port number of the target microservice are queried from the preset index table.
[0012] Optionally, the step of obtaining a target service code and a target port number of a target microservice to be called includes:
[0013] Sending a call request to a microservice resource management platform, wherein the call request includes identification information of a target microservice, and the microservice resource management platform includes a preset index table, wherein the preset index table records service codes and port numbers of various microservices; the microservice resource management platform queries the corresponding target service code and target port number from the preset index table according to the identification information of the target microservice;
[0014] Receive the target service code and the target port number returned by the microservice resource management platform.
[0015] Optionally, determining a target domain name address of the target microservice according to the target service code and the target port number includes:
[0016] The target service code and the target port number are sent to the domain name resolution DNS, and the DNS returns the target domain name address of the target microservice to the caller of the target microservice.
[0017] Optionally, the method comprises:
[0018] In the K8S cluster, when a microservice is released, a namespace is created with the platform code corresponding to the microservice as the namespace name;
[0019] Create a service under the namespace with the service code corresponding to the microservice as the service name.
[0020] Optionally, calling the target microservice according to the target domain name address includes:
[0021] When the target microservice and the caller that calls the target microservice are located in the same cluster, the target microservice is called in the cluster where the target microservice is located according to the target domain name address.
[0022] Optionally, calling the target microservice according to the target domain name address includes:
[0023] When the target microservice and the caller that calls the target microservice are located in different clusters, the target domain name address is sent to a corresponding hard load device to call the target microservice through the hard load device.
[0024] A microservice calling device based on K8S cluster, the device comprising:
[0025] The first acquisition module is used to obtain the target service code and target port number of the target microservice to be called;
[0026] A first determination module is used to determine the target domain name address of the target microservice according to the target service code and the target port number;
[0027] The first calling module is used to call the target microservice according to the target domain name address.
[0028] Optionally, the first acquisition module includes:
[0029] A preset index table acquisition module is used to obtain a preset index table, which records the service code and port number of each microservice;
[0030] The target service code and target port number determination module is used to query the target service code and target port number of the target microservice from the preset index table.
[0031] Optionally, the first acquisition module includes:
[0032] A sending module is used to send a call request to a microservice resource management platform, wherein the call request includes identification information of a target microservice, and the microservice resource management platform includes a preset index table, wherein the preset index table records the service code and port number of each microservice; the microservice resource management platform queries the corresponding target service code and target port number from the preset index table according to the identification information of the target microservice;
[0033] The receiving module is used to receive the target service code and the target port number returned by the microservice resource management platform.
[0034] Optionally, the first determination module is used 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 microservice to the caller of the target microservice.
[0035] Optionally, the device comprises:
[0036] The namespace creation module is used to create a namespace in the K8S cluster with the platform code corresponding to the microservice as the namespace name when the microservice is released;
[0037] The service name creation module is used to create a service under the namespace using the service code corresponding to the microservice as the service name.
[0038] Optionally, the first calling module includes:
[0039] The in-cluster calling module is used to call the target microservice in the cluster according to the target domain name address when the target microservice and the caller of the target microservice are in the same cluster.
[0040] Optionally, the first calling module includes:
[0041] The cross-cluster calling module is used to send the target domain name address to the corresponding hard load device when the target microservice and the caller that calls the target microservice are in different clusters, so as to call the target microservice through the hard load device.
[0042] An electronic device comprises a processor, a memory and a computer program stored in the memory and capable of running on the processor, wherein when the computer program is executed by the processor, the steps of the K8S cluster microservice calling method as described above are implemented.
[0043] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the K8S cluster microservice calling method as described above are implemented.
[0044] This application has the following advantages:
[0045] In an embodiment of the present application, the target service code and target port number of the target microservice to be called are obtained based on the caller in the K8S cluster; the target domain name address of the target microservice is determined according to the target service code and the target port number; and the target microservice is called according to the target domain name address. In an embodiment of the present application, when calling the target microservice, the caller calls the target microservice according to the target domain name address corresponding to the target microservice, instead of calling the target microservice according to the hard load device address. When the target microservice and the caller are in the same cluster, the caller can directly call the target microservice without going through the hard load device, thereby reducing the traffic pressure of the hard load device; and, since the caller calls the target microservice through the target domain name address corresponding to the target microservice, when the target microservice is migrated, it is imperceptible to the caller, which can greatly reduce the risk of system upgrades and the workload of related personnel. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the technical solution of the present application, the drawings required for use in the description of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0047] Figure 1 This is a flowchart of a method for calling a microservice based on a K8S cluster in an embodiment of the present application;
[0048] Figure 2 This is a system architecture diagram for implementing a K8S cluster-based microservice calling method in an embodiment of the present application;
[0049] Figure 3 This is a structural block diagram of a K8S cluster microservice calling device according to an embodiment of the present application. DETAILED DESCRIPTION
[0050] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0051] K8S cluster is short for kubernetes, which is an open source system for automatically deploying, scaling and managing containerized applications. In related technologies, the way to call microservices in K8S clusters is: the called microservices are uniformly registered to the hard load outside the cluster, and the caller uses the hard load address to call other microservices. The longer the call link of this calling method, and the harder the call passes through, the more traffic will be amplified. The more traffic passes through the hard load, the greater the risk of failure for a business process. In addition, in related technologies, when microservices are migrated in this system, the caller often needs to upgrade the call address synchronously, which results in high coupling and risk.
[0052] In view of this, an embodiment of the present application provides a microservice calling method based on a K8S cluster to overcome the shortcomings of the prior art.
[0053] Reference Figure 1 , shows a flow chart of a method for calling a microservice based on a K8S cluster provided by an embodiment of the present application. In the embodiment of the present application, the method may include the following steps:
[0054] Step 101, obtaining the target service code and target port number of the target microservice to be called;
[0055] Step 102, determining the target domain name address of the target microservice according to the target service code and the target port number;
[0056] Step 103: Call the target microservice according to the target domain name address.
[0057] In an embodiment of the present application, the target service code and target port number of the target microservice to be called are obtained based on the caller in the K8S cluster; the target domain name address of the target microservice is determined according to the target service code and the target port number; and the target microservice is called according to the target domain name address. In an embodiment of the present application, when calling the target microservice, the caller calls the target microservice according to the target domain name address corresponding to the target microservice, instead of calling the target microservice according to the hard load device address. When the target microservice and the caller are in the same cluster, the caller can directly call the target microservice without going through the hard load device, thereby reducing the traffic pressure of the hard load device; and, since the caller calls the target microservice through the target domain name address corresponding to the target microservice, when the target microservice is migrated, it is imperceptible to the caller, which can greatly reduce the risk of system upgrades and the workload of related personnel.
[0058] Next, the microservice calling method based on the K8S cluster in this exemplary embodiment will be further explained.
[0059] In the embodiment of the present application, in the K8S cluster, when a microservice is published, a namespace is created with the platform code of its service as the space name, and a service is created under the namespace with the service code of the microservice as the service name. Since the name letters of the named controls of the K8S cluster need to be lowercase, when the platform code of the microservice contains uppercase letters, they need to be converted into corresponding lowercase letters.
[0060] In step 101, the target service code and target port number of the target microservice to be called are obtained.
[0061] In this embodiment, the caller can be any microservice in the K8S cluster that has the need to call other microservices; for easy distinction, the microservice that calls other microservices is defined as the caller, and the microservice called by the callee is defined as the target microservice.
[0062] In this embodiment, when the caller needs to call other microservices, it is necessary to obtain the service code and port number of the target microservice (i.e., the called party). For easy distinction, the service code of the target microservice is recorded as the target service code, and the port number of the target microservice is recorded as the target port number.
[0063] In an optional embodiment, the process of the caller obtaining the target service code and target port number of the target microservice to be called may include:
[0064] The caller obtains a preset index table, which records the service code and port number of each microservice;
[0065] The caller queries the target service code and target port number of the target microservice from the preset index table.
[0066] In this embodiment, the staff can fill in the identification information of each microservice, as well as the service code and port number of each microservice into the preset index table, that is, the preset index table records the association between the identification information of the microservice and its service code and port number; wherein the identification information of the microservice can be the service name corresponding to the microservice; the port number of each microservice corresponds to the service code one by one, and is not allocated repeatedly.
[0067] The caller can obtain in advance a preset index table that records the service codes and port numbers of each microservice. For example, the staff can maintain the preset index table in the microservice resource management platform. The caller can communicate with the microservice resource management platform to obtain the preset index table maintained in the microservice resource management platform, and then find the target service code and target port number of the target microservice from the preset index table according to the identification information of the target microservice to be called.
[0068] In another optional embodiment, the process of the caller obtaining the target service code and target port number of the target microservice to be called may include:
[0069] The calling party sends a call request to the microservice resource management platform, wherein the call request includes identification information of the target microservice, and the microservice resource management platform includes a preset index table, wherein the preset index table records the service code and port number of each microservice;
[0070] The microservice resource management platform queries the corresponding target service code and target port number from the preset index table according to the identification information of the target microservice, and returns the target service code and the target port number to the caller.
[0071] In this embodiment, the caller can communicate with the microservice resource management platform to request the microservice resource management platform to search for the target service code and target port number corresponding to the target microservice according to the preset index table it maintains, and return the found target service code and target port number to the caller.
[0072] In step 102, the target domain name address of the target microservice is determined according to the target service code and the target port number.
[0073] In this embodiment, in the domain name resolution DNS management, the format of the domain name address of the microservice is [service code]. [platform code]: port number; and, in this embodiment, the service code of the microservice has a unified coding format. Specifically, the service code of the microservice is generated by arranging the platform code, category code, service sequence number and cluster sequence number in a specific order. Exemplarily, the service code can be 4-bit platform code, 2-bit category code, 2-bit service sequence number, and 2-bit cluster sequence number from high to low. For example, when the platform code of the corresponding platform of the microservice is P101, the category code is 01, the service sequence number is 01, and the cluster sequence number is 01, the service code of the microservice is P101010101.
[0074] It should be noted that the number of digits and order of the platform code, category code, service serial number and cluster serial number are not limited to the above examples, but it should be emphasized that although the format of the service code is not restricted, the service codes of all microservices in the K8S cluster need to adopt a unified coding format.
[0075] Therefore, when the caller obtains the target service code and target port number of the target microservice, the target domain name address of the target microservice can be determined.
[0076] Specifically, the caller determines the target domain name address of the target microservice according to the target service code and the target port number, including:
[0077] The caller sends the target service code and the target port number to the domain name resolution DNS, and the DNS returns the target domain name address of the target microservice to the caller.
[0078] In this example, the caller can also send the target service code and target port number to the DNS, which determines the target platform code, target service code, and target port number of the target microservice based on the target service code and target port number, and then determines the target domain name address of the target microservice, and then returns it to the caller.
[0079] In step 103, the target microservice is called according to the target domain name address.
[0080] In this embodiment, after the caller determines the target domain name address of the target microservice, the target microservice can be called using the target domain name address. The target microservice may be in the same cluster as the caller, or it may be in a different cluster from the caller. When the target microservice and the caller are in the same cluster, the caller can directly call the target microservice according to the target domain name address of the target microservice. When the target microservice and the caller are in different clusters, the caller needs to call the target microservice through a hard load device. In this embodiment, regardless of whether the target microservice is in the same cluster as the caller, the caller can directly or indirectly call the target microservice according to the target domain name address of the target microservice.
[0081] Specifically, Figure 2 As shown, the caller is microservice A, and the target microservices are B and B' respectively. The caller asks DNS for the target domain name address of the target microservice. When DNS returns the target domain name address to the caller, it also returns the cluster IP of the target microservice. When the cluster IP corresponding to the target microservice is the same as the cluster IP corresponding to the caller, it means that the target microservice and the caller are in the same cluster. The caller can directly use the basis that microservices in the same cluster of K8S can directly call each other, and directly call the target microservice without going through hard load devices. The mutual calls between microservices within the cluster are digested within the cluster without going through external hard load devices. For large-scale microservice systems where microservices within the cluster frequently call each other, it can greatly reduce the traffic pressure of hard load devices.
[0082] When the cluster IP corresponding to the target microservice is different from the cluster IP corresponding to the caller, it means that the target microservice and the caller are in different clusters, that is, the target microservice needs to be called across clusters, and the caller needs to call the target microservice through a hard load device. Specifically, when the target microservice and the caller are in different clusters, the caller sends the target domain name address to the corresponding hard load device and calls the target microservice through the hard load device; wherein, the process of calling the target microservice through the hard load device may include: the hard load device can determine the target cluster where the target microservice is located according to the cluster IP corresponding to the target microservice, and call the target microservice from the target cluster according to the target domain name address. Therefore, in this embodiment, when the target microservice is migrated from the original cluster to the new cluster, the target domain name address corresponding to the target microservice is maintained to the new cluster IP, so that when the target microservice is migrated, the caller who calls the target microservice is not affected; that is, in this embodiment, no matter which cluster the target microservice is in, the caller only needs to use the target domain name address of the target microservice to call the target microservice.
[0083] In the embodiment of the present application, the microservices in the K8S cluster are uniformly coded, and the service coding format of the microservices is that the platform code, category code, service serial number, and cluster serial number of the microservices are arranged in a specified order; in the K8S cluster, a namespace is created with the platform code of the service as the namespace name, and a service is created under this namespace with the service code as the service name. The service code of the microservice has a clear correspondence with the naming control and the service name. The caller only needs to query the service code and port number of the called target microservice in the microservice resource management platform to calculate the domain name address of the target microservice by itself; and then call the target microservice according to the target domain name address. In the embodiment of the present application, when the caller calls the target microservice, the caller calls the target microservice according to the target domain name address corresponding to the target microservice. When the target microservice and the caller are in the same cluster, the caller can directly call the target microservice without going through the hard load device, thereby reducing the traffic pressure of the hard load device; and, because the caller calls the target microservice through the target domain name address corresponding to the target microservice, when the target microservice is migrated, it is imperceptible to the caller, which can greatly reduce the risk of system upgrades and the workload of related personnel.
[0084] It should be noted that, for the method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present application are not limited by the described order of actions, because according to the embodiments of the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present application.
[0085] Reference Figure 3 , shows a structural block diagram of an embodiment of a K8S cluster microservice calling device of the present application, and Figure 1 Corresponding to the method embodiment, in the embodiment of the present application, the device may include the following modules:
[0086] The first acquisition module 301 is used to obtain the target service code and target port number of the target microservice to be called;
[0087] A first determination module 302 is used to determine the target domain name address of the target microservice according to the target service code and the target port number;
[0088] The first calling module 303 is used to call the target microservice according to the target domain name address.
[0089] Optionally, the first acquisition module 301 includes:
[0090] A preset index table acquisition module is used to obtain a preset index table, which records the service code and port number of each microservice;
[0091] The target service code and target port number determination module is used to query the target service code and target port number of the target microservice from the preset index table.
[0092] Optionally, the first acquisition module 301 includes:
[0093] A sending module is used to send a call request to a microservice resource management platform, wherein the call request includes identification information of a target microservice, and the microservice resource management platform includes a preset index table, wherein the preset index table records the service code and port number of each microservice; the microservice resource management platform queries the corresponding target service code and target port number from the preset index table according to the identification information of the target microservice;
[0094] The receiving module is used to receive the target service code and the target port number returned by the microservice resource management platform.
[0095] Optionally, the first determination module 302 is used 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 microservice to the caller of the target microservice.
[0096] Optionally, the device comprises:
[0097] The namespace creation module is used to create a namespace in the K8S cluster with the platform code corresponding to the microservice as the namespace name when the microservice is released;
[0098] The service name creation module is used to create a service under the namespace using the service code corresponding to the microservice as the service name.
[0099] Optionally, the first calling module 303 includes:
[0100] The in-cluster calling module is used to call the target microservice in the cluster according to the target domain name address when the target microservice and the caller of the target microservice are in the same cluster.
[0101] Optionally, the first calling module 303 includes:
[0102] The cross-cluster calling module is used to send the target domain name address to the corresponding hard load device when the target microservice and the caller that calls the target microservice are in different clusters, so as to call the target microservice through the hard load device.
[0103] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0104] An embodiment of the present application also discloses an electronic device, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, the steps of the K8S cluster microservice calling method as described above are implemented.
[0105] An embodiment of the present application also discloses a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the K8S cluster microservice calling method as described above are implemented.
[0106] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0107] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, devices, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0108] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0109] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0110] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0111] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.
[0112] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0113] The above is a detailed introduction to a K8S cluster microservice calling method and device, electronic device and storage medium provided by the present application. This article uses specific examples to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A microservice calling method based on K8S cluster, characterized in that: The caller is any microservice in the K8S cluster that has the need to call other microservices. The method includes: Get the target service code and target port number of the target microservice to be called; Determine the target domain name address of the target microservice according to the target service code and the target port number; Call the target microservice according to the target domain name address; The step of obtaining the target service code and the target port number of the target microservice to be called includes: Sending a call request to a microservice resource management platform, wherein the call request includes identification information of a target microservice, and the microservice resource management platform includes a preset index table, wherein the preset index table records service codes and port numbers of various microservices; the microservice resource management platform queries the corresponding target service code and target port number from the preset index table according to the identification information of the target microservice; Receive the target service code and the target port number returned by the microservice resource management platform.
2. The method according to claim 1, characterized in that The step of obtaining the target service code and the target port number of the target microservice to be called includes: Obtain a preset index table, which records the service code and port number of each microservice; The target service code and target port number of the target microservice are queried from the preset index table.
3. The method according to claim 1, characterized in that The determining the target domain name address of the target microservice according to the target service code and the target port number includes: The target service code and the target port number are sent to the domain name resolution DNS, and the DNS returns the target domain name address of the target microservice to the caller of the target microservice.
4. The method according to claim 1, characterized in that: The method comprises: In the K8S cluster, when a microservice is released, a namespace is created with the platform code corresponding to the microservice as the namespace name; Create a service under the namespace with the service code corresponding to the microservice as the service name.
5. The method according to claim 1, characterized in that The calling the target microservice according to the target domain name address includes: When the target microservice and the caller of the target microservice are located in the same cluster, the target microservice is called in the cluster according to the target domain name address.
6. The method according to claim 1, characterized in that The calling the target microservice according to the target domain name address includes: When the target microservice and the caller that calls the target microservice are located in different clusters, the target domain name address is sent to a corresponding hard load device to call the target microservice through the hard load device.
7. A microservice calling device based on K8S cluster, characterized in that: The caller is any microservice in the K8S cluster that has the need to call other microservices. The device includes: The first acquisition module is used to obtain the target service code and target port number of the target microservice to be called; A first determination module is used to determine the target domain name address of the target microservice according to the target service code and the target port number; A first calling module, used to call the target microservice according to the target domain name address; The first acquisition module includes: A sending module is used to send a call request to a microservice resource management platform, wherein the call request includes identification information of a target microservice, and the microservice resource management platform includes a preset index table, wherein the preset index table records the service code and port number of each microservice; the microservice resource management platform queries the corresponding target service code and target port number from the preset index table according to the identification information of the target microservice; The receiving module is used to receive the target service code and the target port number returned by the microservice resource management platform.
8. An electronic device, characterized in that: It includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, the steps of the K8S cluster microservice calling method based on any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the steps of the K8S cluster microservice calling method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Microservice management method and system based on artificial intelligence service cloud platform
CN108418862A
Service calling method and device
CN110225131A
Service calling method and device under micro-service framework and server
CN110928709A
Micro-service calling method and device, terminal equipment and storage medium
CN112433863A
Deploying microservices into virtualized computing systems
US20200401457A1
