Container service debugging method and device based on K8s cluster, and electronic device

By deploying server agents and client agents in K8s clusters, localized container service debugging in K8s cluster environment is implemented, which solves the problem that developers cannot localize debugging, simplifies the debugging process and improves efficiency.

CN116132344BActive Publication Date: 2024-12-27CHINA TELECOM CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211697772.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-28
Publication Date
2024-12-27
Estimated Expiration
2042-12-28

AI Technical Summary

Technical Problem

In the K8s cluster environment, developers need to package local applications into container images and deploy them to the cluster, resulting in the inability to perform local debugging. The debugging process is cumbersome and inefficient. In the existing technology, the problem of container log location can only be used, resulting in efficiency Insufficient loss and positioning efficiency.

Method used

By deploying server agents and client agents in K8s clusters, establishing long connections, server agents take over the target container service, client agents obtain domain name information, forward container service requests to the local system for debugging, realizing localized debugging and simplifying Debug the process and improve efficiency.

Benefits of technology

It realizes localized debugging of clients in K8s cluster environment, simplifies the debugging process, improves application debugging efficiency, reduces packaging and deployment steps, and directly debugs and locates problems on the local system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116132344B_ABST
    Figure CN116132344B_ABST
Patent Text Reader

Abstract

The present invention discloses a container service debugging method and device based on K8s cluster, and an electronic device, which relates to the field of network technology and security, wherein the method comprises: receiving a container service request forwarded by a container node proxy component in a K8s cluster, and forwarding the container service request to a client proxy based on a long connection, wherein after receiving the container service request, the client proxy forwards the container service request to a local system in a client host based on domain name information, and the local system debugs the target application to obtain an application debugging result; receiving the application debugging result returned by the client proxy, and returning the application debugging result to a user terminal. The present invention solves the technical problem in the related art that when debugging a container application in a K8s cluster, it is necessary to package the local application into a container image and then deploy it to the K8s cluster environment image, resulting in the client being unable to perform localized application debugging.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of network technology and security, and in particular to a container service debugging method and device based on a K8s cluster, and an electronic device. Background Art

[0002] After the prevalence of containerization, K8s cluster technology has become mainstream. Due to the characteristics of cluster technology, the resources it occupies are beyond the capacity of ordinary developers' hosts. At the same time, due to the complexity of the cluster environment, it is usually a collaborative development of the team, and it is becoming increasingly impractical to build a development environment on a single host.

[0003] When you need to debug an application in a K8s cluster environment, you need to first package the application into an image and push it to the image repository. Figure 1 This is a flowchart of a method for debugging an application in a K8s cluster environment according to the prior art. Figure 1 As shown in the figure, in the prior art, the process of debugging container service applications includes: developers package the application image and input it into the image warehouse, then deploy the application to the K8s cluster for application testing, each module jointly debugs the application to output the debugging log, analyzes the log to locate the problem, and releases the test after the joint debugging is completed. Since the K8s containerized environment is an independent network environment built based on the CNI (Container Network Interface, container network API interface) component, when you need to debug the microservice container in the K8s environment, you need to Figure 1 In the process, the local application is first packaged into a container image and then deployed to the K8s cluster environment. This process makes it impossible for the client to perform local debugging based on the K8s environment, and this debugging process can usually only locate the problem through the container log. In addition, this application debugging method takes a long time to package and deploy the container, which will cause great efficiency loss for developers who often need to debug. In addition, the application debugging process in the prior art is cumbersome, and when jointly debugging the application, the problem can only be located with the help of log output, which greatly reduces the efficiency of problem location, resulting in low business debugging efficiency.

[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0005] The embodiments of the present invention provide a container service debugging method, device, and electronic device based on a K8s cluster, so as to at least solve the technical problem in the related technology that when debugging a container application in a K8s cluster, the local application needs to be packaged into a container image and then deployed into the K8s cluster environment image, resulting in the client being unable to perform localized application debugging.

[0006] According to one aspect of an embodiment of the present invention, a container service debugging method based on a K8s cluster is provided, which is applied to a server agent in a K8s cluster environment, the server agent establishes a long connection with a client agent deployed in a client host, the server agent takes over a target container service in the K8s cluster, and the client agent obtains domain name information of the target container service through the long connection. The container service debugging method includes: receiving a container service request forwarded by a container node agent component in the K8s cluster, wherein the container service request is initiated by a user terminal to the container node agent component, and is used to request the target container service to debug a target application; forwarding the container service request to the client agent based on the long connection, wherein after receiving the container service request, the client agent forwards the container service request to a local system in the client host based on the domain name information, and the local system debugs the target application to obtain an application debugging result; receiving the application debugging result returned by the client agent, and returning the application debugging result to the user terminal.

[0007] Optionally, the server agent establishes a long connection with the client agent deployed in the client host, including: deploying the server agent in the K8s cluster and setting a specified network mode; using the specified network mode to open a host service port in the host network of the cluster host corresponding to the K8s cluster; establishing a first network link between the server agent and the host service port; deploying the client agent in the client host; establishing a second network link between the host service port and the client agent; and establishing a long connection between the server agent and the client agent based on the first network link and the second network link.

[0008] Optionally, before receiving the container service request forwarded by the container node agent component in the K8s cluster, it also includes: receiving a service modification instruction sent by the client agent, wherein the service modification instruction carries at least: the service identifier of the target container service; responding to the service modification instruction, calling the API interface of the K8s cluster, obtaining all container services through the API interface, and collecting the domain name information inside each of the container services; modifying the service link of the target container service indicated by the service identifier to the server agent through the API interface of the K8s cluster, so that the server agent takes over the target container service in the K8s cluster and obtains the instruction execution result; returning the domain name information inside each of the container services and the instruction execution result to the client agent.

[0009] Optionally, after receiving the service modification instruction sent by the client agent, it also includes: obtaining user information in the service modification instruction, wherein the user information includes at least: user name and user authority; authenticating the user information in the service modification instruction to obtain an authentication result, wherein the authentication result indicates whether calling the API interface of the K8s cluster is allowed.

[0010] Optionally, the container service debugging method also includes: receiving a local service request forwarded by the container node agent component, wherein the local service request is initiated by the local system of the client host, and is used to request a designated container service other than the target container service in the K8s cluster to debug a designated application; in response to the local service request, calling an API interface of the K8s cluster to query the designated container service; forwarding the local service request to the designated container service, and having the designated container service debug the designated application to obtain an application debugging result; receiving the application debugging result returned by the designated container service, and returning the application debugging result to the local system.

[0011] According to another aspect of an embodiment of the present invention, a container service debugging method based on a K8s cluster is also provided, which is applied to a client agent deployed in a client host, the client agent establishes a long connection with a server agent deployed in a K8s cluster environment, the server agent takes over the target container service in the K8s cluster, and the client agent obtains the domain name information of the target container service through the long connection. The container service debugging method includes: based on the long connection, receiving a container service request forwarded by the server agent, wherein the container service request is initiated by a user terminal and is used to request the target container service to debug a target application; forwarding the container service request to a local system in the client host based on the domain name information, and the local system debugs the target application to obtain an application debugging result; sending the application debugging result to the server agent, wherein the server agent returns the application debugging result to the user terminal.

[0012] Optionally, the container service debugging method also includes: after establishing a long connection with the server agent, receiving an instruction execution result sent by the server agent, wherein the instruction execution result indicates whether the service link of the target container service is successfully modified to the server agent through the API interface of the K8s cluster; when the instruction execution result indicates that the modification is successful, the service IP address in the domain name information of the target container service is pointed to the server agent.

[0013] Optionally, the container service debugging method also includes: receiving domain name information inside each container service sent by the server agent; writing the domain name information of all the container services into a local network link file, wherein the local network link file is used to provide the client host with service links for all container services in the K8s cluster; and establishing a bidirectional network transmission channel between the client host, the client agent and the server agent.

[0014] According to another aspect of an embodiment of the present invention, a container service debugging device based on a K8s cluster is also provided, which is applied to a server agent in a K8s cluster environment, the server agent establishes a long connection with a client agent deployed in a client host, the server agent takes over the target container service in the K8s cluster, and the client agent obtains the domain name information of the target container service through the long connection. The container service debugging device includes: a receiving unit, which is used to receive a container service request forwarded by a container node agent component in the K8s cluster, wherein the container service request is initiated by a user terminal to the container node agent component, and is used to request the target container service to debug a target application; a forwarding unit, which is used to forward the container service request to the client agent based on the long connection, wherein after receiving the container service request, the client agent forwards the container service request to a local system in the client host based on the domain name information, and the local system debugs the target application to obtain an application debugging result; a returning unit, which is used to receive the application debugging result returned by the client agent, and return the application debugging result to the user terminal.

[0015] Optionally, the container service debugging device based on the K8s cluster also includes: a first deployment module, used to deploy the server agent in the K8s cluster and set a specified network mode; a first opening module, used to adopt the specified network mode to open the host service port in the host network of the cluster host corresponding to the K8s cluster; a first establishment module, used to establish a first network link between the server agent and the host service port; a second deployment module, used to deploy the client agent in the client host; a second establishment module, used to establish a second network link between the host service port and the client agent; a third establishment module, used to establish a long connection between the server agent and the client agent based on the first network link and the second network link.

[0016] Optionally, the container service debugging device based on the K8s cluster also includes: a first receiving module, used to receive a service modification instruction sent by the client agent, wherein the service modification instruction carries at least: a service identifier of the target container service; a first responding module, used to respond to the service modification instruction, call the API interface of the K8s cluster, obtain all container services through the API interface, and collect the domain name information inside each of the container services; a first modifying module, used to modify the service link of the target container service indicated by the service identifier to the server agent through the API interface of the K8s cluster, so that the server agent takes over the target container service in the K8s cluster and obtains the instruction execution result; a first returning module, used to return the domain name information inside each of the container services and the instruction execution result to the client agent.

[0017] Optionally, the container service debugging device based on the K8s cluster also includes: a first acquisition module, used to obtain user information in the service modification instruction, wherein the user information includes at least: user name and user authority; a first authentication module, used to authenticate the user information in the service modification instruction to obtain an authentication result, wherein the authentication result indicates whether calling the API interface of the K8s cluster is allowed.

[0018] Optionally, the container service debugging device based on the K8s cluster also includes: a second receiving module, used to receive a local service request forwarded by the container node agent component, wherein the local service request is initiated by the local system of the client host, and is used to request a designated container service other than the target container service in the K8s cluster to debug a designated application; a first responding module, used to respond to the local service request, call the API interface of the K8s cluster to query the designated container service; a first forwarding module, used to forward the local service request to the designated container service, and the designated container service debugs the designated application to obtain an application debugging result; a third receiving module, used to receive the application debugging result returned by the designated container service, and return the application debugging result to the local system.

[0019] According to another aspect of an embodiment of the present invention, a container service debugging device based on a K8s cluster is also provided, which is applied to a client agent deployed in a client host, the client agent establishes a long connection with a server agent deployed in a K8s cluster environment, the server agent takes over the target container service in the K8s cluster, and the client agent obtains the domain name information of the target container service through the long connection. The container service debugging device includes: a second receiving unit, based on the long connection, receiving a container service request forwarded by the server agent, wherein the container service request is initiated by a user terminal and is used to request the target container service to debug a target application; a second forwarding unit, used to forward the container service request to a local system in the client host based on the domain name information, and the local system debugs the target application to obtain an application debugging result; a second returning unit, used to send the application debugging result to the server agent, wherein the server agent returns the application debugging result to the user terminal.

[0020] Optionally, the container service debugging device based on the K8s cluster also includes: a fourth receiving module, used to receive the instruction execution result sent by the server agent after establishing a long connection with the server agent, wherein the instruction execution result indicates whether the service link of the target container service is successfully modified to the server agent through the API interface of the K8s cluster; a first pointing module, used to point the service IP address in the domain name information of the target container service to the server agent when the instruction execution result indicates that the modification is successful.

[0021] Optionally, the container service debugging device based on the K8s cluster also includes: a fifth receiving module, used to receive the domain name information inside each container service sent by the server agent; a first writing module, used to write the domain name information of all the container services into a local network link file, wherein the local network link file is used to provide the client host with service links for all container services in the K8s cluster; a first establishing module, used to establish a bidirectional network transmission channel between the client host, the client agent and the server agent.

[0022] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is also provided, the computer-readable storage medium including a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute any one of the above-mentioned container service debugging methods based on the K8s cluster.

[0023] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, comprising one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement any one of the above-mentioned container service debugging methods based on the K8s cluster.

[0024] In the present disclosure, the following steps are adopted: receiving a container service request forwarded by a container node proxy component in a K8s cluster, wherein the container service request is initiated by a user terminal to the container node proxy component, and is used to request a target container service to debug a target application, and forwarding the container service request to a client proxy based on a long connection. After receiving the container service request, the client proxy forwards the container service request to a local system in a client host based on domain name information, and the local system debugs the target application to obtain an application debugging result, receives the application debugging result returned by the client proxy, and returns the application debugging result to the user terminal.

[0025] In the present disclosure, a long connection is established between the server agent and the client agent, and the container service request is forwarded to the client agent based on the long connection, and is forwarded to the client's local system based on the domain name information. The local system debugs the target application, thereby realizing client-localized debugging of the K8s cluster environment service, making the debugging process simpler and improving the efficiency of application debugging, thereby solving the technical problem in the related technology that when debugging the container application in the K8s cluster, the local application needs to be packaged into a container image and then deployed to the K8s cluster environment image, resulting in the client being unable to perform localized application debugging.

[0026] In the present disclosure, the server-side agent discovers and replaces the target container service in the K8s cluster with itself, thereby redirecting the cluster traffic to the server-side agent for request distribution to the client agent, thereby realizing that the local service replaces the target container service in the original cluster, receives all requests flowing to the target container service in the cluster, and realizes localized cluster joint debugging.

[0027] In the present disclosure, local debugging is performed by directly replacing the target container service in the K8s cluster with a local service, and the parameters of the cluster environment are fully utilized. There is no need to modify the service parameters locally, thereby reducing the debugging process and improving developer efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0029] Figure 1It is a flow chart of a method for debugging an application in a K8s cluster environment according to the prior art;

[0030] Figure 2 is a flow chart of an optional application debugging method according to the present invention;

[0031] Figure 3 It is a flowchart of an optional container service debugging method based on a K8s cluster according to an embodiment of the present invention;

[0032] Figure 4 is a flowchart of another optional container service debugging method based on a K8s cluster according to an embodiment of the present invention;

[0033] Figure 5 is an optional container service debugging system architecture diagram according to an embodiment of the present invention;

[0034] Figure 6 is an optional container service debugging system interaction flow chart according to an embodiment of the present invention;

[0035] Figure 7 is a schematic diagram of an optional container service debugging device based on a K8s cluster according to an embodiment of the present invention;

[0036] Figure 8 It is a hardware structure block diagram of an electronic device (or mobile device) according to a container service debugging method based on a K8s cluster according to an embodiment of the present invention. DETAILED DESCRIPTION

[0037] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0038] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0039] To facilitate those skilled in the art to understand the present invention, some terms or nouns involved in the embodiments of the present invention are explained below:

[0040] Container orchestration system, kubernetes, referred to as K8S, is a microservice and cloud native platform used to manage containerized applications on multiple hosts in the cloud platform, making the deployment of containerized applications simple and efficient.

[0041] In HOST network mode, the container does not have any independent network resources of its own (such as the container's IP, network card, and port), and completely shares the network space with the host.

[0042] Debug code is a code used for debugging and troubleshooting in computer networks.

[0043] Domain Name System, or DNS for short, is a distributed database that maps domain names and IP addresses to each other, making it easier for people to access the Internet.

[0044] K8s dev-cli is a lightweight development scaffolding built for front-end projects based on K8s cluster management.

[0045] Container Service, a one-stop container lifecycle management platform, provides high-performance and scalable container application management services.

[0046] Kube-proxy is a network proxy running on each node.

[0047] It should be noted that the container service debugging method and device based on K8s cluster in the present disclosure can be used in the field of network technology and security when performing application debugging, and can also be used in any field other than the field of network technology and security when performing application debugging. The present disclosure does not limit the application field of the container service debugging method and device based on K8s cluster.

[0048] It should be noted that the relevant information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for display, data for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties. For example, an interface is set between this system and the relevant user or organization. Before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or organization through the interface, and obtain relevant information after receiving the consent information fed back by the aforementioned user or organization.

[0049] Figure 2 is a flow chart of an optional application debugging method according to the present invention, such as Figure 2 As shown, the application debugging process of the embodiment of the present invention includes: the developer connects the K8s cluster to the local system, locates the problem based on the debug code, and releases the test after the existing joint debugging is completed. Compared with the prior art, there is no need to package the application image into the image warehouse, nor to deploy the application to the K8s cluster. Instead, the service started on the local host is directly used, and there is no need to add logs for problem analysis. The problem can be located by debugging the code locally. The embodiment of the present invention is simpler in process and greatly improves the efficiency of application testing.

[0050] In this disclosure Figure 2 The scheme shown, compared to Figure 1 The prior art shown has the following advantages:

[0051] 1. The existing technical solution needs to package the application image to the image warehouse first, but the solution in the present disclosure does not need to package the image.

[0052] 2. The existing technical solutions need to deploy the application to the k8s cluster, while the solution in the present disclosure can directly use the services started on the local host.

[0053] 3. The prior art solution needs to continuously add logs to analyze the problem during debugging. The solution disclosed in the present invention does not need to add logs, and the local code can be directly debugged to locate the problem.

[0054] 4. The process of releasing and testing the existing technical solutions is very long, while the process of the solution disclosed in the present invention is very short (saving at least two steps of the process).

[0055] The present invention can be applied to various application debugging devices / apparatus / systems. The application debugging devices / apparatus / systems can be deployed in a K8s cluster environment. The server agent establishes a long connection with the client agent, forwards the container service request to the client agent based on the long connection, and forwards it to the client local system based on the domain name information, thereby realizing client localized debugging of the K8s cluster environment service, making the debugging process simpler and improving the efficiency of application debugging.

[0056] The present invention is described in detail below in conjunction with various embodiments.

[0057] Embodiment 1

[0058] According to an embodiment of the present invention, a method embodiment of container service debugging based on a K8s cluster is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0059] An embodiment of the present invention provides a container service debugging method based on a K8s cluster. The method is applied to a server agent in a K8s cluster environment. The server agent establishes a long connection with a client agent deployed in a client host. The server agent takes over the target container service in the K8s cluster. The client agent obtains the domain name information of the target container service through the long connection.

[0060] Optionally, the server agent establishes a long connection with the client agent deployed in the client host, including: deploying the server agent in the K8s cluster and setting a specified network mode, using the specified network mode to open the host service port in the host network of the cluster host corresponding to the K8s cluster, establishing a first network link between the server agent and the host service port, deploying the client agent in the client host, and establishing a second network link between the host service port and the client agent; based on the first network link and the second network link, establishing a long connection between the server agent and the client agent.

[0061] It should be noted that before establishing a persistent connection, the embodiment of the present invention needs to create a Service Account in the K8s cluster space and name it K8sdev Account. The cluster role associated with the K8sdev Account requires corresponding kubernetes API call permissions, where the API call permissions of this embodiment include but are not limited to: get, list, watch, delete, update, and create.

[0062] Then, a server agent (identified by k8sdev-server) is deployed in the K8s cluster in a specified network mode (for example, the HOST network mode), thereby opening the service port in the host network, and a client agent (identified by k8sdev-cli) is deployed on the client accordingly, and a long connection is established between the server agent and the client agent, thereby building a two-way network link that can access the K8s cluster environment from the network environment where the host is located, and the client accesses the two-way network link to realize interactive access between the client and the K8s cluster.

[0063] It should be noted that before receiving a container service request, the server agent needs to take over the target container service, allocate available container services to the client, and the server agent deployed in the K8s cluster calls the API interface to obtain all container services, and based on the container status, obtains available container services, and collects the internal DNS resolution addresses of all container services. Optionally, each container in the K8s cluster corresponds to a unique IP address in the cluster, and any two containers can communicate directly. After a long connection is established between the client agent and the server agent, the client agent can directly obtain the domain name information corresponding to the required target container service based on the long connection. The domain name information includes but is not limited to: container name, container IP address, and container status.

[0064] Through the above implementation method, after the server-side agent parses the service modification instruction, the service discovery of the target container in the instruction is modified through the API interface, and its service discovery is modified to the server-side agent itself, so that the traffic of the target container service is forwarded to the server-side agent, and then the server-side agent returns the instruction execution result to the client. Based on the return result, the client obtains the DNS information of all service discoveries in the cluster, and writes all IP addresses into the local HOST file based on the information. At the same time, the target IPs of these DNS all point to the host where the server-side agent is located, and a full-duplex channel from the client to the server is established.

[0065] By opening up the path between the K8s cni network and the host network, a two-way network link is constructed that can access the K8s cluster environment from the network environment where the host is located. Then the client is deployed on the developer's client host (referred to as the development host), and the client accesses the above two-way network link to realize the ability of the client on the network to interact with K8s. The developer client takes over or uninstalls the target service in the K8s cluster through the instruction set. The final result after the takeover is to build a developer client service to replace the target service in the cluster environment, thereby realizing the debugging of local services in the cluster.

[0066] Figure 3 is a flowchart of an optional container service debugging method based on a K8s cluster according to an embodiment of the present invention, such as Figure 3 As shown, the method comprises the following steps:

[0067] Step S301, receiving a container service request forwarded by a container node proxy component in a K8s cluster, wherein the container service request is initiated by a user terminal to the container node proxy component and is used to request a target container service to debug a target application;

[0068] Step S302: forwarding the container service request to the client proxy based on the persistent connection, wherein after receiving the container service request, the client proxy forwards the container service request to the local system in the client host based on the domain name information, and the local system debugs the target application to obtain the application debugging result;

[0069] Step S303: receiving the application debugging result returned by the client agent, and returning the application debugging result to the user terminal.

[0070] Through the above steps, the container service request forwarded by the container node proxy component in the K8s cluster is first received, and then the container service request is forwarded to the client proxy based on the long connection. After receiving the container service request, the client proxy forwards the container service request to the local system in the client host based on the domain name information. The local system debugs the target application and obtains the application debugging result. Finally, the application debugging result returned by the client proxy is received and returned to the user terminal.

[0071] In this embodiment, a long connection is established between the server agent and the client agent, and the container service request is forwarded to the client agent based on the long connection, and is forwarded to the client's local system based on the domain name information. The local system debugs the target application, thereby realizing client-localized debugging of the K8s cluster environment service, making the debugging process simpler and improving the efficiency of application debugging, thereby solving the technical problem in the related technology that when debugging the container application in the K8s cluster, the local application needs to be packaged into a container image and then deployed to the K8s cluster environment image, resulting in the client being unable to perform localized application debugging.

[0072] The following is a detailed description of each of the above implementation steps.

[0073] Optionally, before receiving the container service request forwarded by the container node proxy component in the K8s cluster, it also includes: receiving a service modification instruction sent by the client proxy, wherein the service modification instruction carries at least: the service identifier of the target container service; responding to the service modification instruction, calling the API interface of the K8s cluster, obtaining all container services through the API interface, and collecting the domain name information inside each container service; modifying the service link of the target container service indicated by the service identifier to the server proxy through the API interface of the K8s cluster, so that the server proxy takes over the target container service in the K8s cluster and obtains the instruction execution result; returning the domain name information inside each container service and the instruction execution result to the client proxy.

[0074] The user terminal (or development terminal) sends a takeover container service instruction (used to take over the target container service) to the server agent (k8sdev-server) through the client agent (k8sdev-cli), that is, after the service modification instruction (wherein the instruction has specified the service discovery name and local agent port that need to be proxied in the cluster namespace), the server agent will respond to the service modification instruction, call the API interface of the K8s cluster according to the target container service and corresponding port in the instruction, and modify the service link of the target container service in the cluster to the server agent (k8sdev-server) itself. At this time, all traffic of the target container service will flow to the server agent (k8sdev-server) for forwarding.

[0075] Another optional method, after receiving the service modification instruction sent by the client agent, also includes: obtaining user information in the service modification instruction, wherein the user information includes at least: user name and user authority; authenticating the user information in the service modification instruction to obtain an authentication result, wherein the authentication result indicates whether calling the API interface of the K8s cluster is allowed.

[0076] It should be noted that the user terminal / developer uses the terminal to send service modification instructions to the server agent through the client. After receiving the service modification instructions, the user information is obtained and the user accessor is authenticated. The task can only be executed if the user's execution permissions show that the API interface of the K8s cluster is allowed to be called. Otherwise, failure is returned.

[0077] Step S301, receiving a container service request forwarded by a container node agent component in a K8s cluster.

[0078] It should be noted that when the user has application debugging requirements, the container service request is first sent to the cluster host through the local parsing file of the specified network mode, and is received and forwarded to the server agent by the container node agent component (identified by Kube-praxy) in the cluster. The container service request includes: target container IP address, local system IP address, request type, and request content.

[0079] Step S302: forwarding the container service request to the client proxy based on the persistent connection.

[0080] In this embodiment, after receiving the container service request, the client agent forwards the container service request to the local system in the client host based on the domain name information, and the local system debugs the target application to obtain the application debugging result.

[0081] Step S303: receiving the application debugging result returned by the client agent, and returning the application debugging result to the user terminal.

[0082] It should be noted that the server-side proxy forwards the traffic of the target service to the client proxy through the long connection established between the client proxy and the server-side proxy. After receiving the forwarded request, the client proxy forwards the request to the local system of the client host, and then starts the debugging system to debug the application. After debugging is completed, the debugging results are returned to the user terminal, and the test results are published on the terminal interface.

[0083] The above implementation method illustrates that after the server-side proxy takes over the target container service among all container services, all service requests initiated to the target container service are intercepted and forwarded to the local system in the client host, and the local system in the client host performs application debugging.

[0084] As for other container services that have not been taken over / replaced by the server host, the service process of other container services in the cluster is described below. In this embodiment, optionally, the container service debugging method also includes: receiving a local service request forwarded by the container node agent component, wherein the local service request is initiated by the local system of the client host, and is used to request a designated container service other than the target container service in the K8s cluster to debug a designated application; responding to the local service request, calling the API interface of the K8s cluster to query the designated container service; forwarding the local service request to the designated container service, and having the designated container service debug the designated application to obtain the application debugging result; receiving the application debugging result returned by the designated container service, and returning the application debugging result to the local system.

[0085] When calling other container services in the cluster locally, the service request is first sent to the server-side agent k8sdev-server through the DNS resolution in the local hosts file. After receiving the local service request, the server-side agent obtains the service discovery information of the other container service through the API interface of the k8s cluster, and forwards the local service request to the corresponding other container services in the cluster. After receiving the forwarded local service request, other container services in the cluster process the request and return the processing result. After receiving the processing result returned by other container services in the cluster, the server-side agent returns the result to the local system service.

[0086] Through this embodiment, a long connection is established between the server agent and the client agent to connect the client and the server. Based on the long connection, the container service request is forwarded to the client agent, and then forwarded to the local system of the client host based on the domain name information, thereby realizing client-side localized debugging of the K8s cluster environment service, making the debugging process simpler and improving the efficiency of application debugging.

[0087] In this embodiment, a server agent (ks8dev-server) can be deployed in a K8s cluster environment, a network link can be opened in the K8s cluster environment and the local network of the server, and the client host can locally start a client agent (k8sdev-cli) to establish a long connection with the server agent (ks8dev-server). On this basis, the user terminal can send instructions to the server agent (ks8dev-server) through the client agent (k8sdev-cli), and the server agent (ks8dev-server) can replace or uninstall one or more target container services in the K8s cluster according to the instructions. The server agent (ks8dev-server) proxies the service link of the target container service in the K8s cluster to itself through the kubernetes API Server, thereby redirecting the cluster traffic to the server agent (ks8dev-server) to distribute the request to the client agent (k8sdev-cli), thereby realizing the local service replacing the target container service in the original cluster, receiving all requests flowing to the target container service in the cluster, and realizing localized cluster joint debugging.

[0088] When enterprise developers debug microservices in a K8s cluster environment, they no longer need to package their local applications into images and then deploy them to the K8s cluster environment. Instead, they can directly perform local debugging by replacing services in the K8s cluster with local services, and make full use of the parameters of the cluster environment. There is no need to modify service parameters locally, thereby reducing the debugging process and improving developer efficiency.

[0089] The present invention is described below in conjunction with another optional embodiment.

[0090] Embodiment 2

[0091] According to an embodiment of the present invention, an embodiment of a container service debugging method based on a K8s cluster is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0092] The container service debugging method based on K8s cluster in an embodiment of the present invention is applied to the client agent deployed in the client host. The client agent establishes a long connection with the server agent deployed in the K8s cluster environment. The server agent takes over the target container service in the K8s cluster. The client agent obtains the domain name information of the target container service through the long connection.

[0093] Figure 4 is a flowchart of another optional container service debugging method based on a K8s cluster according to an embodiment of the present invention, such as Figure 4 As shown, the container service debugging method includes the following steps:

[0094] Step S401: receiving a container service request forwarded by a server agent based on a persistent connection, wherein the container service request is initiated by a user terminal and is used to request a target container service to debug a target application;

[0095] The client agent communicates with the server agent in the server based on a long connection, thereby realizing communication between the client and the server. Optionally, the server agent establishes a long connection with the client agent deployed in the client host, including: deploying the server agent in the K8s cluster, and setting a specified network mode, using the specified network mode to open the host service port in the host network of the cluster host corresponding to the K8s cluster, establishing a first network link between the server agent and the host service port, deploying the client agent in the client host, and establishing a second network link between the host service port and the client agent; based on the first network link and the second network link, establishing a long connection between the server agent and the client agent.

[0096] It should be noted that before establishing a persistent connection, the embodiment of the present invention needs to create a Service Account in the K8s cluster space and name it K8sdev Account. The cluster role associated with the K8sdev Account requires corresponding kubernetes API call permissions, where the API call permissions of this embodiment include but are not limited to: get, list, watch, delete, update, and create.

[0097] It should be noted that the embodiment of the present invention first deploys a server agent in the K8s cluster in the HOST network mode, thereby opening the service port in the host network, deploys a client agent on the client accordingly, and establishes a long connection between the server agent and the client agent, thereby constructing a two-way network link that can access the K8s cluster environment from the network environment where the host is located, and the client accesses the two-way network link to realize interactive access between the client and the K8s cluster.

[0098] It should be noted that each container in the K8s cluster corresponds to a unique IP address in the cluster. Any two containers can communicate directly. After a persistent connection is established between the client agent and the server agent, the client agent can directly obtain the domain name information corresponding to the required target container service based on the persistent connection. The domain name information includes but is not limited to: container name, container IP address, and container status.

[0099] It should be noted that before receiving a container service request, the server-side agent needs to take over the target container service and allocate available container services to the client. The server-side agent deployed in the K8s cluster calls the API interface to obtain all container services, obtains available container services based on the container status, and collects the internal DNS resolution addresses of all container services.

[0100] In an embodiment of the present invention, after establishing a long connection with the server agent, an instruction execution result sent by the server agent is received, wherein the instruction execution result indicates whether the service link of the target container service is successfully modified to the server agent through the API interface of the K8s cluster; when the instruction execution result indicates that the modification is successful, the service IP address in the domain name information of the target container service is pointed to the server agent.

[0101] In an embodiment of the present invention, domain name information inside each container service sent by a server-side agent is received; domain name information of all container services is written into a local network link file, wherein the local network link file is used to provide service links for all container services in the K8s cluster for the client host; and a two-way network transmission channel is established between the client host, the client agent, and the server-side agent.

[0102] It should be noted that the developer sends the service modification instruction to the server agent through the client on the client host. After receiving the service modification instruction, the user information is obtained and the user access is authenticated. The task can only be continued if the user's execution permission shows that the API interface of the K8s cluster is allowed to be called, otherwise it returns failure. After the server agent parses the service modification instruction, the service link / service discovery of the target container in the instruction is modified through the API interface, and its service link is modified to the server agent, so that the traffic of the target container service is forwarded to the server agent, and then the server agent returns the instruction execution result to the client. Based on the return result, the client obtains the DNS information of all service discovery in the cluster, and writes all IP addresses to the local HOST file based on this information. At the same time, the target IP of these domain name DNS all points to the host where the server agent is located, and a full-duplex channel from the client to the server is established.

[0103] It should be noted that when the user has application debugging requirements, the container service request is first sent to the server through the local HOST parsing file, which is received by the container node agent component in the cluster and forwarded to the server agent. The container service request includes: target container IP address, local system IP address, request type, and request content.

[0104] Step S402: forward the container service request to the local system in the client host based on the domain name information, and the local system debugs the target application to obtain the application debugging result.

[0105] Step S403: Send the application debugging result to the server agent, wherein the server agent returns the application debugging result to the user terminal.

[0106] The server proxy forwards the traffic of the target container service to the client proxy through the persistent connection established between the client proxy and the server proxy. After receiving the forwarded request, the client proxy forwards the request to the local system of the client host, and then starts the debugging system to debug the application. After debugging is completed, the debugging results are returned to the user terminal, and the test results are published on the terminal interface.

[0107] Through the above embodiment, a long connection is established between the server agent and the client agent, thereby connecting the client and the server, and the container service request is forwarded to the client agent based on the long connection, and forwarded to the client local system based on the domain name information. The local system debugs the target application, thereby realizing client-localized debugging of K8s cluster environment services, making the debugging process simpler, thereby realizing client-localized debugging of K8s cluster environment services, making the debugging process simpler, and improving the efficiency of application debugging, thereby solving the technical problem in the related technology that when debugging the container application in the K8s cluster, the local application needs to be packaged into a container image and then deployed to the K8s cluster environment image, which makes the client unable to perform localized application debugging.

[0108] The present invention is described below in conjunction with another optional embodiment.

[0109] Embodiment 3

[0110] This embodiment provides a container service debugging system based on K8s cluster. Figure 5 is an optional container service debugging system architecture diagram according to an embodiment of the present invention, such as Figure 5 As shown, the container service debugging system includes two main bodies, the development host (for the client host of the above-mentioned embodiment 1) and the K8s cluster host. The development host includes a local DNS and a local system, as well as the deployed k8sdev-cli (corresponding to the client agent of the above-mentioned embodiment 1). The k8sdev-server (corresponding to the server agent of the above-mentioned embodiment 1) is deployed in the K8s cluster space in the HOST network mode, and the host service port is opened in the host network in the HOST mode. A long connection is established between the client agent and the server agent. The request file of the development host is forwarded into the K8s cluster network through the forwarding node Kube-proxy. When forwarding the request to the target container service, the request will be received by the k8s-server service, and then the host service port (deployed in the host network, a service port of the associated server agent k8sdev-server in the associated cluster host is opened in the host network, that is, Figure 5 The host service port of k8sdev-server in the development host) forwards the request to k8sdev-cli, and then forwards it to the local system in the development host.

[0111] There may be many types of container services deployed in the K8s network, such as Figure 5As shown, it shows the cluster container service (which may correspond to other container services except the target container service shown in the above embodiment 1) and the target container service. The service link / service discovery of the target container service is taken over by k8sdev-server. All requests sent to k8sdev-server will be forwarded by k8sdev-server to the k8sdev-cli of the development host, and k8sdev-cli will forward the requests to the local system.

[0112] Among them, the specific deployment steps for k8sdev-server and k8sdev-cli to directly establish a long connection and request forwarding are as follows:

[0113] 1. Create a Service Account in the K8s cluster space and name it K8sdev Account. The cluster role associated with the K8sdev Account requires corresponding kubernetes API call permissions, including: get, list, watch, delete, update, and create.

[0114] 2. Deploy k8sdev-server in the K8s cluster space, set the network mode to HOST, and assign the Service Account of the server ks8dev-server to K8sdev Account.

[0115] 3. Install k8sdev-cli on the client host, specify k8sdev-server, and establish a long connection.

[0116] 4. The user terminal sends a takeover container service instruction to k8sdev-server through k8sdev-cli. After the instruction specifies the service discovery name and local proxy port that need to be proxied in the cluster namespace, k8sdev-server changes the service discovery of the target service in the cluster to k8sdev-server itself through the kubernetes API according to the target service and corresponding port in the instruction. At this time, all traffic of the target container service will flow to k8sdev-server for forwarding.

[0117] Figure 6 is an optional container service debugging system interaction flow chart according to an embodiment of the present invention, such as Figure 6 As shown in the figure, the container service debugging system includes five modules: client user, client host, K8s dev-server, K8s cluster generation, and K8s cluster. Its interaction process includes:

[0118] The interaction process includes three parts. The first part is the process of local service taking over the cluster target service, corresponding to S601-S610 in the figure. The second part is the process of calling other cluster services after the local system takes over the cluster target service, corresponding to S611-S616 in the figure. The third part is the common cluster using access to the taken over target service, corresponding to S617-S623 in the figure. The following is a detailed description:

[0119] The first part is the process of local service taking over the cluster target service.

[0120] S601, the client user sends a command (sends a takeover container service command) to the k8sdev-server through the K8s dev-cli on the client host;

[0121] S602, k8sdev-server authenticates and analyzes the user access, and continues to execute if the authentication passes, otherwise it returns failure;

[0122] S603, k8sdev-server calls the API interface to obtain all container services in the K8s cluster space and collects the internal DNS resolution addresses of all container services;

[0123] S604, k8s cluster returns all container services to k8sdev-server;

[0124] S605, k8sdev-server confirms the container service result and initiates the container service modification instruction;

[0125] S606, k8sdev-server requests the K8s cluster to modify the container service to k8sdev-server;

[0126] S607, K8s cluster side changes the service discovery / service link of the target container service to k8sdev-server;

[0127] S608, K8s cluster returns the modification result to k8sdev-server;

[0128] S609, k8sdev-server returns the command execution result to K8s dev-cli;

[0129] S610, modify the local HOST and create a channel;

[0130] After receiving the execution result, K8s dev-cli obtains the DNS information of all container services in the cluster from the returned result, writes all the resolved addresses into the local hosts file, and all the target IP addresses of these DNS point to the host where k8sdev-server is located, establishing a full-duplex channel from the client k8sdev-cli to the server k8sdev-server.

[0131] In the second part, the local system takes over the cluster target service and then calls other service processes of the cluster.

[0132] S611, the local system of the client host calls other cluster services (non-target container services, not taken over by k8sdev-server), and k8sdev-cli generates a service request to k8sdev-server;

[0133] S612, k8sdev-server forwards the service request. After receiving the request, k8sdev-server forwards the request to other applications in the corresponding K8s cluster based on the service discovery information obtained through the API interface.

[0134] S613, after receiving the forwarding request, the target service in the cluster processes the request and performs a cluster call;

[0135] S614, K8s cluster returns the service request result to k8sdev-server;

[0136] S615, k8sdev-server performs proxy processing;

[0137] S616, k8sdev-server returns the result to k8sdev-cli.

[0138] In the third part, ordinary cluster users access the taken-over target container service. Since the target container service is taken over by k8sdev-server at this time, all requests flowing to the target container service will be forwarded to k8sdev-server.

[0139] S617, the client user sends a user request to the k8s cluster proxy;

[0140] S618, the K8s cluster proxy forwards the request according to the modified container service;

[0141] S619, K8s cluster proxy forwards the request to k8sdev-server;

[0142] S620, k8sdev-server forwards the request to k8sdev-cli;

[0143] S621, after receiving the forwarded request, the k8sdev-cli service forwards the request to the locally started debugging system for application debugging, and returns the processing result to the k8sdev-server;

[0144] S622, k8sdev-server returns the processing result to the K8s cluster agent;

[0145] S623, the K8s cluster proxy returns the processing result to the client user.

[0146] The above-mentioned container service debugging system establishes a persistent connection between the server agent and the client agent to connect the client and the server, forwards the container service request to the client agent based on the persistent connection, and forwards it to the client local system based on the domain name information, thereby realizing client-localized debugging of the K8s cluster environment service, making the debugging process simpler and improving the efficiency of application debugging.

[0147] In this embodiment, a two-way network link is constructed to access the K8s cluster environment from the network environment where the host is located by opening up the path between the K8s cni network and the host network. Then the client is deployed on the developer's client host (referred to as the development host), and the client accesses the above two-way network link to realize the ability of the client on the network to interact with K8s. The developer client takes over or uninstalls the target container service in the K8s cluster through the instruction set. The final result after the takeover is to build a developer client service to replace the target container service in the cluster environment, thereby realizing the debugging of local services in the cluster.

[0148] The present invention is described below in conjunction with another optional embodiment.

[0149] Embodiment 4

[0150] This embodiment provides a container service debugging device based on a K8s cluster. The various implementation units included in the container service debugging device based on a K8s cluster correspond to the various implementation steps in the first embodiment.

[0151] Figure 7 is a schematic diagram of an optional container service debugging device based on a K8s cluster according to an embodiment of the present invention, such as Figure 7 As shown, the container service debugging device includes: a first receiving unit 71, a first forwarding unit 72, and a first returning unit 73, wherein:

[0152] The first receiving unit 71 is used to receive a container service request forwarded by a container node agent component in a K8s cluster, wherein the container service request is initiated by a user terminal to the container node agent component, and is used to request a target container service to debug a target application;

[0153] A first forwarding unit 72 is configured to forward the container service request to the client agent based on the persistent connection, wherein after receiving the container service request, the client agent forwards the container service request to the local system in the client host based on the domain name information, and the local system debugs the target application to obtain the application debugging result;

[0154] The first returning unit 73 is configured to receive the application debugging result returned by the client agent, and return the application debugging result to the user terminal.

[0155] The above-mentioned container service debugging device based on K8s cluster receives the container service request forwarded by the container node agent component in the K8s cluster through the first receiving unit 71, wherein the container service request is initiated by the user terminal to the container node agent component, and is used to request the target container service to debug the target application; forwards the container service request to the client agent based on the long connection through the first forwarding unit 72, wherein after receiving the container service request, the client agent forwards the container service request to the local system in the client host based on the domain name information, and the local system debugs the target application to obtain the application debugging result; receives the application debugging result returned by the client agent through the first return unit 73, and returns the application debugging result to the user terminal.

[0156] In this embodiment, a long connection is established between the server agent and the client agent, and the container service request is forwarded to the client agent based on the long connection, and is forwarded to the client's local system based on the domain name information. The local system debugs the target application, thereby realizing client-localized debugging of the K8s cluster environment service, making the debugging process simpler and improving the efficiency of application debugging, thereby solving the technical problem in the related technology that when debugging the container application in the K8s cluster, the local application needs to be packaged into a container image and then deployed to the K8s cluster environment image, resulting in the client being unable to perform localized application debugging.

[0157] Optionally, the container service debugging device based on the K8s cluster also includes: a first deployment module, used to deploy the server agent in the K8s cluster and set a specified network mode; a first opening module, used to use the specified network mode to open the host service port in the host network of the cluster host corresponding to the K8s cluster; a first establishment module, used to establish a first network link between the server agent and the host service port; a second deployment module, used to deploy the client agent in the client host; a second establishment module, used to establish a second network link between the host service port and the client agent; a third establishment module, used to establish a long connection between the server agent and the client agent based on the first network link and the second network link.

[0158] Optionally, the container service debugging device based on the K8s cluster also includes: a first receiving module, used to receive a service modification instruction sent by a client agent, wherein the service modification instruction carries at least: a service identifier of a target container service; a first responding module, used to respond to the service modification instruction, call the API interface of the K8s cluster, obtain all container services through the API interface, and collect the domain name information inside each container service; a first modifying module, used to modify the service link of the target container service indicated by the service identifier to a server agent through the API interface of the K8s cluster, so that the server agent takes over the target container service in the K8s cluster and obtains the instruction execution result; a first returning module, used to return the domain name information inside each container service and the instruction execution result to the client agent.

[0159] Optionally, the container service debugging device based on the K8s cluster also includes: a first acquisition module, used to obtain user information in the service modification instruction, wherein the user information includes at least: user name and user authority; a first authentication module, used to authenticate the user information in the service modification instruction to obtain an authentication result, wherein the authentication result indicates whether calling the API interface of the K8s cluster is allowed.

[0160] Optionally, the container service debugging device based on the K8s cluster also includes: a second receiving module, used to receive a local service request forwarded by the container node agent component, wherein the local service request is initiated by the local system of the client host, and is used to request a designated container service other than the target container service in the K8s cluster to debug a designated application; a first response module, used to respond to the local service request, and call the API interface of the K8s cluster to query the designated container service; a first forwarding module, used to forward the local service request to the designated container service, and the designated container service debugs the designated application to obtain an application debugging result; a third receiving module, used to receive the application debugging result returned by the designated container service, and return the application debugging result to the local system.

[0161] According to another aspect of an embodiment of the present invention, a container service debugging device based on a K8s cluster is also provided, which is applied to a client agent deployed in a client host. The client agent establishes a long connection with a server agent deployed in a K8s cluster environment. The server agent takes over the target container service in the K8s cluster. The client agent obtains the domain name information of the target container service through the long connection. The container service debugging device includes: a second receiving unit, which receives a container service request forwarded by the server agent based on a long connection, wherein the container service request is initiated by a user terminal and is used to request the target container service to debug a target application; a second forwarding unit, which is used to forward the container service request to a local system in the client host based on the domain name information, and the local system debugs the target application to obtain an application debugging result; a second return unit, which is used to send the application debugging result to the server agent, wherein the server agent returns the application debugging result to the user terminal.

[0162] Optionally, the container service debugging device based on the K8s cluster also includes: a fourth receiving module, used to receive the instruction execution result sent by the server agent after establishing a long connection with the server agent, wherein the instruction execution result indicates whether the service link of the target container service is successfully modified to the server agent through the API interface of the K8s cluster; a first pointing module, used to point the service IP address in the domain name information of the target container service to the server agent when the instruction execution result indicates that the modification is successful.

[0163] Optionally, the container service debugging device based on the K8s cluster also includes: a fifth receiving module, used to receive the domain name information inside each container service sent by the server agent; a first writing module, used to write the domain name information of all container services into a local network link file, wherein the local network link file is used to provide the client host with service links for all container services in the K8s cluster; a first establishing module, used to establish a bidirectional network transmission channel between the client host, the client agent and the server agent.

[0164] The above-mentioned container service debugging device based on K8s cluster may also include a processor and a memory. The above-mentioned first receiving unit 71, the first forwarding unit 72, the first return unit 73, etc. are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize corresponding functions.

[0165] The above processor includes a kernel, which calls the corresponding program unit from the memory. One or more kernels can be set, and the application can be debugged by adjusting kernel parameters.

[0166] The above-mentioned memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one storage chip.

[0167] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is further provided, the computer-readable storage medium including a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute any one of the above-mentioned container service debugging methods based on the K8s cluster.

[0168] According to another aspect of an embodiment of the present invention, there is further provided an electronic device, comprising one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by one or more processors, the one or more processors implement any one of the above-mentioned container service debugging methods based on a K8s cluster.

[0169] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program that is initialized with the following method steps: receiving a container service request forwarded by a container node proxy component in a K8s cluster, wherein the container service request is initiated by a user terminal to the container node proxy component, and is used to request the target container service to debug a target application; forwarding the container service request to a client proxy based on a long connection, wherein after receiving the container service request, the client proxy forwards the container service request to a local system in a client host based on domain name information, and the local system debugs the target application to obtain an application debugging result; receiving the application debugging result returned by the client proxy, and returning the application debugging result to the user terminal.

[0170] Figure 8 1 is a hardware structure block diagram of an electronic device (or mobile device) according to a container service debugging method based on a K8s cluster according to an embodiment of the present invention. Figure 8 As shown, the electronic device may include one or more (802a, 802b, ..., 802n are used to illustrate) processors 802 (the processor 802 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), and a memory 804 for storing data. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a keyboard, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 8 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 8More or fewer components as shown, or with Figure 8 Different configurations are shown.

[0171] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0172] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0173] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0174] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0175] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0176] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.

[0177] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A container service debugging method based on K8s cluster, characterized in that: A server agent is applied in a K8s cluster environment, wherein the server agent establishes a persistent connection with a client agent deployed in a client host, wherein the server agent takes over a target container service in the K8s cluster, and wherein the client agent obtains domain name information of the target container service through the persistent connection. The container service debugging method includes: Receive a container service request forwarded by a container node agent component in the K8s cluster, wherein the container service request is initiated by a user terminal to the container node agent component and is used to request the target container service to debug a target application; forwarding the container service request to the client agent based on the persistent connection, wherein after receiving the container service request, the client agent forwards the container service request to a local system in the client host based on the domain name information, and the local system debugs the target application to obtain an application debugging result; The application debugging result returned by the client agent is received, and the application debugging result is returned to the user terminal.

2. The container service debugging method according to claim 1, characterized in that: The server agent establishes a persistent connection with the client agent deployed in the client host, including: Deploy the server agent in the K8s cluster and set a specified network mode; Using the specified network mode to open the host service port in the host network of the cluster host corresponding to the K8s cluster; Establishing a first network link between the server agent and the host service port; Deploying the client agent in the client host; establishing a second network link between the host service port and the client agent; Based on the first network link and the second network link, a long connection is established between the server agent and the client agent.

3. The container service debugging method according to claim 1, characterized in that: Before receiving the container service request forwarded by the container node agent component in the K8s cluster, it also includes: receiving a service modification instruction sent by the client agent, wherein the service modification instruction carries at least: a service identifier of the target container service; In response to the service modification instruction, the API interface of the K8s cluster is called, all container services are obtained through the API interface, and the domain name information inside each container service is collected; Modify the service link of the target container service indicated by the service identifier to the server proxy through the API interface of the K8s cluster, so that the server proxy takes over the target container service in the K8s cluster, and obtains the instruction execution result; The domain name information inside each container service and the instruction execution result are returned to the client agent.

4. The container service debugging method according to claim 3, characterized in that: After receiving the service modification instruction sent by the client agent, the method further includes: Acquire user information in the service modification instruction, wherein the user information at least includes: user name and user authority; The user information in the service modification instruction is authenticated to obtain an authentication result, wherein the authentication result indicates whether calling the API interface of the K8s cluster is allowed.

5. The container service debugging method according to claim 1, characterized in that: Also includes: Receive a local service request forwarded by the container node proxy component, wherein the local service request is initiated by a local system of the client host and is used to request a specified container service other than the target container service in the K8s cluster to debug a specified application; In response to the local service request, the API interface of the K8s cluster is called to query the specified container service; Forwarding the local service request to the designated container service, allowing the designated container service to debug the designated application to obtain an application debugging result; The application debugging result returned by the designated container service is received, and the application debugging result is returned to the local system.

6. A container service debugging method based on K8s cluster, characterized in that: The client agent is applied to the client host, the client agent establishes a long connection with the server agent deployed in the K8s cluster environment, the server agent takes over the target container service in the K8s cluster, and the client agent obtains the domain name information of the target container service through the long connection. The container service debugging method includes: Based on the persistent connection, receiving a container service request forwarded by the server agent, wherein the container service request is initiated by a user terminal and is used to request the target container service to debug a target application; forwarding the container service request to a local system in the client host based on the domain name information, and having the local system debug the target application to obtain an application debugging result; The application debugging result is sent to the server agent, wherein the server agent returns the application debugging result to the user terminal.

7. The container service debugging method according to claim 6, characterized in that: Also includes: After establishing a long connection with the server proxy, receiving an instruction execution result sent by the server proxy, wherein the instruction execution result indicates whether the service link of the target container service is successfully modified to the server proxy through the API interface of the K8s cluster; When the instruction execution result indicates that the modification is successful, the service IP address in the domain name information of the target container service is pointed to the server proxy.

8. The container service debugging method according to claim 6, characterized in that: Also includes: Receive domain name information inside each container service sent by the server agent; Write the domain name information of all the container services into a local network link file, wherein the local network link file is used to provide the client host with service links for all the container services in the K8s cluster; A bidirectional network transmission channel is established between the client host, the client agent and the server agent.

9. A container service debugging device based on K8s cluster, characterized in that: A server agent is applied in a K8s cluster environment, wherein the server agent establishes a persistent connection with a client agent deployed in a client host, wherein the server agent takes over a target container service in the K8s cluster, and wherein the client agent obtains domain name information of the target container service through the persistent connection. The container service debugging device includes: A first receiving unit is used to receive a container service request forwarded by a container node agent component in the K8s cluster, wherein the container service request is initiated by a user terminal to the container node agent component, and is used to request the target container service to debug a target application; a first forwarding unit, configured to forward the container service request to the client agent based on the persistent connection, wherein after receiving the container service request, the client agent forwards the container service request to a local system in the client host based on the domain name information, and the local system debugs the target application to obtain an application debugging result; The first returning unit is configured to receive the application debugging result returned by the client agent, and return the application debugging result to the user terminal.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the container service debugging method based on the K8s cluster as described in any one of claims 1 to 8.

11. An electronic device, characterized in that: It includes one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the container service debugging method based on the K8s cluster as described in any one of claims 1 to 8.