Testing method and device for kubernetes cluster

By obtaining the ID and CA certificate of the kubernetes cluster, the cluster component status is automatically obtained, which solves the problems of low testing efficiency and low security in the existing technology, and realizes efficient and reliable cluster component testing.

CN113810241BActive Publication Date: 2025-01-21BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010545848.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-06-15
Publication Date
2025-01-21
Estimated Expiration
2040-06-15

AI Technical Summary

Technical Problem

The prior art is inefficient when testing components of kubernetes container clusters, and manual login is time-consuming. Traditional automated testing is complex and has low security, and relies on a large amount of cluster information.

Method used

By obtaining the kubernetes cluster ID to be tested, obtain the CA certificate from the cloud server, obtain the cluster component status based on the CA certificate, and generate test results.

Benefits of technology

The test process is simplified, the operation is easy, the test results are highly credible, the test efficiency is improved, and the dependence on cluster information is reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113810241B_ABST
    Figure CN113810241B_ABST
Patent Text Reader

Abstract

The present invention provides a method and device for testing a kubernetes cluster, which relates to the field of computer technology, including obtaining a kubernetes cluster ID to be tested; obtaining a CA certificate corresponding to the kubernetes cluster ID to be tested from a cloud server; and obtaining the component status of the kubernetes cluster to be tested from the cloud server based on the CA certificate; and generating a test result based on the component status of the kubernetes cluster to be tested. The test server can be used to test the components of the kubernetes cluster in the cloud server, which is easy to operate, has high credibility of the test results, and improves the test efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a Kubernetes cluster testing method and device. Background Art

[0002] Currently, there are two main ways to test the components of a kubernetes container cluster:

[0003] Method 1: For a Kubernetes container cluster enabled on a public cloud, you need to manually log in to the Kubernetes container cluster and execute the kubectl command on one of the nodes to check the normal status of the node and service.

[0004] Method 2: Traditional automated testing requires mounting an EIP (Elastic IP Address) on one of the nodes for external access, then logging into the cluster through SSH (Secure Shell) and executing kubectl commands to check the normal status of the nodes and services.

[0005] The first method is direct manual login and manual inspection, which is time-consuming and labor-intensive. The second method, although it realizes automated testing and saves some manpower, has the following shortcomings: applying for an EIP and binding the EIP to a node, and then using SSH to log in to the node, the operation is complicated; and the SSH method requires the node to open port 22 in order to obtain the password on the node, and needs to obtain more cluster information, which depends on a lot of information and needs to obtain the node password, which has low security. Once the network where the cluster is located changes, the automated code needs to be changed accordingly (for example: the vpc information of the virtual machine, the security group opens port 22, etc.). Summary of the invention

[0006] The purpose of the present invention is to provide a Kubernetes cluster testing method and device to alleviate the technical problem of low testing efficiency in the prior art.

[0007] In a first aspect, an embodiment of the present invention provides a method for testing a kubernetes cluster, wherein the kubernetes cluster is located in a cloud server, and the kubernetes cluster includes components, and the method includes:

[0008] Get the Kubernetes cluster ID to be tested;

[0009] Obtain the CA (Certification Authority) certificate corresponding to the Kubernetes cluster ID to be tested from the cloud server;

[0010] Based on the CA certificate, obtain the component status of the kubernetes cluster to be tested from the cloud server;

[0011] Generate test results based on the component status of the Kubernetes cluster to be tested.

[0012] In an optional implementation manner, before the step of obtaining the ID of the kubernetes cluster to be tested, the method further includes:

[0013] Deploy a local Kubernetes cluster, including configuration files.

[0014] In an optional implementation, the step of obtaining the component status of the Kubernetes cluster to be tested from the cloud server based on the CA certificate includes:

[0015] updating the configuration file based on the CA certificate;

[0016] Based on the updated configuration file, obtain resource information of the kubernetes cluster to be tested in the cloud server through the kubectl command;

[0017] Based on the resource information of the Kubernetes cluster to be tested, the component status of the Kubernetes cluster to be tested is determined.

[0018] In an optional implementation manner, the step of obtaining the ID of the kubernetes cluster to be tested includes:

[0019] A test request is received from a user device, where the test request includes the Kubernetes cluster ID to be tested.

[0020] In an optional implementation, the component includes a node and a container, and the component status includes a node status, a container operation status, and whether the container provides external services normally.

[0021] In an optional implementation, the kubernetes cluster further includes an interface, and before the step of obtaining a CA certificate corresponding to the kubernetes cluster ID to be tested from the cloud server, the method further includes:

[0022] Test the interface of the kubernetes cluster to be tested.

[0023] In an optional implementation, the step of obtaining a CA certificate corresponding to the Kubernetes cluster ID to be tested from the cloud server includes:

[0024] Based on the interface of the kubernetes cluster to be tested, obtain the CA certificate corresponding to the ID of the kubernetes cluster to be tested from the cloud server.

[0025] In a second aspect, an embodiment of the present invention provides a testing device for a Kubernetes cluster, wherein the Kubernetes cluster is located in a cloud server, and the Kubernetes cluster includes components, and the device includes:

[0026] The first acquisition module is used to obtain the Kubernetes cluster ID to be tested;

[0027] The second acquisition module is used to obtain the CA certificate corresponding to the Kubernetes cluster ID to be tested from the cloud server;

[0028] The second acquisition module is further used to obtain the component status of the kubernetes cluster to be tested from the cloud server based on the CA certificate;

[0029] A generation module is used to generate test results based on the component status of the kubernetes cluster to be tested.

[0030] In a third aspect, an embodiment of the present invention provides a computer device, including a memory and a processor, wherein the memory stores a computer program that can be executed on the processor, and when the processor executes the computer program, the steps of the method described in any one of the aforementioned implementation methods are implemented.

[0031] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores machine-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions cause the processor to execute the method described in any one of the aforementioned implementations.

[0032] The present invention provides a method and device for testing a kubernetes cluster, which obtains the kubernetes cluster ID to be tested; obtains the CA certificate corresponding to the kubernetes cluster ID to be tested from a cloud server; and obtains the component status of the kubernetes cluster to be tested from the cloud server based on the CA certificate; and generates a test result based on the component status of the kubernetes cluster to be tested. The test server can be used to test the components of the kubernetes cluster in the cloud server, which is easy to operate, has high credibility of the test results, and improves the test efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0034] Figure 1 A schematic diagram of a kubernetes cluster testing method provided in an embodiment of the present application;

[0035] Figure 2 An example of a Kubernetes cluster testing method provided in an embodiment of the present application;

[0036] Figure 3 A schematic diagram of the structure of a test device for a Kubernetes cluster provided in an embodiment of the present application;

[0037] Figure 4 A schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0038] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions 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 part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.

[0039] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0040] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0041] It should be noted that, in the embodiment of the present invention, kubernetes is an open source for managing containerized applications on multiple hosts in a cloud platform. kubernetes can also be referred to as K8s. The goal of kubernetes is to make the deployment of containerized applications simple and powerful. kubernetes provides a mechanism for application deployment, planning, updating, and maintenance.

[0042] A node can be the smallest computing hardware unit in kubernetes. A node can be a representation of a single machine in a cluster. For example, a node can be a physical machine in a data center, or a virtual machine hosted on a cloud platform (e.g., a cloud server). Each node can be simply viewed as a set of CPU and RAM resources that can be used. In this way, any node can replace any other node in a kubernetes cluster.

[0043] For a kubernetes cluster, the kubernetes cluster can be considered as a whole. In kubernetes, nodes pool resources to form a more powerful kubernetes cluster. The kubernetes cluster is used to deploy programs, and the kubernetes cluster can distribute work to various nodes in the kubernetes cluster. If any node is added or removed, the kubernetes cluster will transform in work as needed. Among them, the program running on kubernetes is packaged into a container. The container can include the program and dependencies.

[0044] Kubernetes does not run containers directly, it encapsulates one or more containers into a high-level structure called a Pod. Any container in the same Pod will share the same namespace and local network. Containers can communicate with other containers in the same container.

[0045] A Pod can hold multiple containers, and you can also add multiple programs to a single container.

[0046] The kubernetes cluster can communicate with the outside world through ingress or interface.

[0047] Some embodiments of the present invention are described in detail below in conjunction with the accompanying drawings. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.

[0048] Figure 1 A flow chart of a test method for a kubernetes cluster provided in an embodiment of the present invention. The kubernetes cluster is located in a cloud server, which may belong to a public cloud. The kubernetes cluster may include components such as Figure 1 As shown, the method can be applied to a test server, which can be a client server. The method can specifically include the following steps:

[0049] Step S110, obtaining the ID of the kubernetes cluster to be tested.

[0050] In some embodiments, before step S110, a local kubernetes cluster can be deployed locally, and the local kubernetes cluster includes a configuration file. The local kubernetes cluster can be applied to test the kubernetes cluster in the cloud server. The configuration file can be a kubeconfig file, which is used to store and organize information about clusters, users, namespaces, and authentication mechanisms. Through the kubectl command line tool, the kubeconfig file can be used to find the information required to select a cluster and communicate with the API server of the cluster. By default, the configuration file (kubeconfig file) used by kubectl is the config file in the "$HOME / .kube" directory.

[0051] After the initial deployment of the local Kubernetes cluster is completed, the content of this configuration file can be empty.

[0052] There are several ways to obtain the ID of the kubernetes cluster to be tested:

[0053] As an example, a user may log in to the test server through a user device and input the ID of the kubernetes cluster to be tested through the user device. The test server may receive a test request from the user device, and the test request may include the input kubernetes cluster ID to be tested.

[0054] As another example, the kubernetes cluster ID to be tested may be pre-stored in the test server. For example, multiple kubernetes cluster IDs to be tested may be pre-stored in the test server, and the test server may obtain and test them in a specified order.

[0055] Step S120, obtain the CA certificate corresponding to the Kubernetes cluster ID to be tested from the cloud server.

[0056] After obtaining the ID of the kubernetes cluster to be tested, the test server can request a CA certificate from the cloud server. The CA certificate may include: information about the electronic visa authority, public key user information, public key, signature of an authority (e.g., signature of the electronic visa authority), validity period, etc. The CA certificate corresponding to the ID of the kubernetes cluster to be tested can be obtained from the configuration file corresponding to the kubernetes cluster to be tested.

[0057] Among them, CA is the issuing authority of the certificate, and the CA is the core of the Public Key Infrastructure (PKI). CA is the authority responsible for issuing certificates, authenticating certificates, and managing issued certificates (also known as the electronic visa authority). The signature of the authority in the CA certificate is verified to determine whether it is credible. The information of the sub-visa authority may refer to the identification of the sub-visa authority or the public key of the sub-visa authority; the public key user information may refer to the user information of the owner of the CA certificate, and the public key user information may include the user name or identification of the public key user; the signature of the authority may refer to the authority using the private key to encrypt a piece of plaintext data, and the signature of the authority can be decrypted by the public key of the authority to confirm whether the signature is credible; the validity period is generally set according to demand.

[0058] Step S130: Based on the CA certificate, obtain the component status of the Kubernetes cluster to be tested from the cloud server.

[0059] Based on the above-mentioned local deployment of the local kubernetes cluster and the obtained CA certificate, the components of the kubernetes cluster to be tested can be tested. Based on this, step S130 can be implemented by the following steps:

[0060] Step A), update the configuration file of the local kubernetes cluster based on the CA certificate; after updating the configuration file of the local kubernetes cluster to the CA certificate of the kubernetes cluster to be tested, the local kubernetes cluster can have the ability to communicate with each node in the kubernetes cluster to be tested.

[0061] Step B), based on the updated configuration file, obtain the resource information of the kubernetes cluster to be tested in the cloud server through the kubectl command;

[0062] The resource information may include node resource information and container resource information, etc.

[0063] The resources of the node may refer to the number of nodes, the CPU, memory, hard disk, and link resources of each node, etc. The node resource information may include resource utilization, business load ratio, and so on.

[0064] The container resource may refer to a pod resource. The pod resource information may include the number of pods, the number of normal pods, the number of problematic pods, container resource utilization, application information, etc. The application information may include concurrency, request response, number of project users, number of orders, etc.

[0065] In addition, the resource information may be a running log of the kubernetes cluster to be tested. When the kubernetes cluster is running, events generated in the cluster may be recorded in the running log, and the events may include events occurring during the creation or operation of nodes and containers.

[0066] It should be noted that in the embodiment of the present application, all resource information can be obtained through the kubectl command, or targeted resource information can be obtained. For example, only the number of successfully deployed nodes and containers and / or the number of undeployed nodes and containers can be obtained.

[0067] Step C), based on the resource information of the kubernetes cluster to be tested, determine the component status of the kubernetes cluster to be tested.

[0068] Among them, kubectl is a command line interface for operating a kubernetes cluster, and various functions can be implemented by using various kubectl commands. For example, the kubectl command may include a kubectl get node command and a kubectl get pod command.

[0069] The kubernetes API service provides HTTP REST interfaces for adding, deleting, modifying, checking, and watching various kubernetes resource objects (such as Pod, RC, Service, etc.). It is the data bus and data center of the entire system. The command line tool kubectl client converts command line parameters into REST API calls to the kubernetes API service and outputs the call results.

[0070] Among them, the components may include nodes and containers, and the component status includes the node status, the container (or pod) running status, and whether the container (or pod) provides external services normally. The component status can be determined based on the resource information. For example, it can be determined whether the container provides external services normally based on the resource utilization of the container. If the resource utilization is less than a certain threshold (for example, 0), the container can be tasked to provide external services abnormally. For another example, it can be determined whether each container provides external services normally based on the service exception records in the operation log. For another example, the node status and container status can be the node deployment status and the container deployment status. The deployment status of the node and container can be determined based on the number of nodes and containers that have not been deployed; the successfully deployed containers can also be determined based on the events of node and container deployment completion in the operation log, and the other containers are containers that have not been deployed.

[0071] A container is the smallest unit that can be created and managed in the k8s system. It is the smallest resource object model created or deployed by the user in the resource object model, and it is also the resource object for running containerized applications on k8s.

[0072] Step S140: Generate a test result based on the component status of the Kubernetes cluster to be tested.

[0073] The test result can be determined according to actual needs. For example, the user only needs to know whether the components of the kubernetes cluster to be tested have been deployed and function normally. In this case, the test result can be yes or no.

[0074] After receiving the test result, the user can query the status of each specific component in the test server.

[0075] The embodiment of the present invention obtains the ID of the kubernetes cluster to be tested; obtains the CA certificate corresponding to the kubernetes cluster ID to be tested from the cloud server; and obtains the component status of the kubernetes cluster to be tested from the cloud server based on the CA certificate; and generates a test result based on the component status of the kubernetes cluster to be tested. The test server can be used to test the components of the kubernetes cluster in the cloud server, which is easy to operate, has high credibility of the test results, and improves the test efficiency.

[0076] In some embodiments, the kubernetes cluster also includes an interface. Before testing the components of the kubernetes cluster, the interface of the kubernetes cluster to be tested can also be tested. After testing the interface of the kubernetes cluster to be tested, if the interface is normal, the components of the kubernetes cluster are tested; if the interface is abnormal, the test result can be directly output, and the test result can indicate that the interface is abnormal. Based on this, the above step S120 can specifically include: based on the interface of the kubernetes cluster to be tested, obtaining the CA certificate corresponding to the ID of the kubernetes cluster to be tested from the cloud server.

[0077] In some embodiments, Figure 2 As shown, the corresponding kubernetes components of the local kubernetes cluster are initialized and deployed on a test server (which can access the external network) (the kubernetes components can execute the kubectl command, and the tests of each component in the kubernetes cluster to be tested can be performed on the test server). Based on this, the method may include the following steps:

[0078] Step 1), the user accesses the service on the client and passes the parameter container cluster ID. The container cluster is the kubernetes cluster, the client refers to the test server, and the service on the client refers to the test service of the kubernetes cluster component on the test server.

[0079] Step 2), the test server obtains the CA certificate of the container cluster through the container cluster ID. Among them, the container OPENAPI service in the public cloud (also known as the cloud server) can provide an interface, through which the CA certificate of the kubernetes cluster created on the public cloud can be obtained: that is, the kubeconfig file of the kubernetes cluster.

[0080] Step 3), the cloud server returns the CA certificate of the container cluster.

[0081] Step 4) Import the CA certificate and replace it in the local "$HOME / .kube / config" file.

[0082] Among them, by replacing the content of the "$HOME / .kube / config" file on the test server with the CA certificate in the kubernetes cluster, the nodes outside the test server cluster can also be connected to the kubernetes cluster; in other words, executing the kubectl command on this test server obtains the resource information inside the kubernetes cluster to be tested.

[0083] Step 5) Run the kubectl command locally to check the node and pod status and other component inspection commands.

[0084] Step 6), check whether the service provided by the pod is normal through the serviceIP. Based on the above, you can connect to the kubernetes cluster to obtain resource information by obtaining the CA certificate, so you only need to deploy a set of general inspection services on this client side. The service covers the following general checkpoints, such as: kubernetes node status check, such as: kubectl get node; Pod status check, such as: kubectl get pod; Pod service access check, such as nginx port 80 access: curl http: / / serviceIP:80 / . If you want to check other common checkpoints, just add modifications to the script.

[0085] Step 7), analyze the information obtained from the execution results.

[0086] Finally, analyze the query results of these checkpoints. The above checkpoints can be encapsulated into a web service; receive the corresponding kubernetes cluster ID parameter, obtain the CA certificate of the cluster (that is, the content of the kubeconfig file), and replace it in the local "$HOME / .kube / config"; execute the above command checkpoints, all of which are connected to the query executed in the APIServer in the kubernetes cluster; finally, analyze the results of the command query and return the corresponding information.

[0087] Step 9), returning the detection and analysis results to the user.

[0088] As an example, the method can also be implemented by the following steps:

[0089] Step 1.1), start a client server, open the external network for the client server, and initialize and deploy a set of kubernetes components. After that, any cluster test can be performed on this client server;

[0090] Step 1.2), deploy a set of inspection scripts, open port 80, and provide web services to the outside world. Based on the web services, users can interact with each other to obtain relevant information of the kubernetes cluster to be tested;

[0091] In step 1.3), the user accesses port 80 in the client server and passes the ID of the kubernetes cluster to be tested; the ID of the kubernetes cluster to be tested can be entered by the user.

[0092] Step 1.4), after the service obtains the ID of the kubernetes cluster, it obtains the CA certificate of the cluster (that is, the content of the kubeconfig file of the cluster) through the service interface on the public cloud and imports it into the local "$HOME / .kube / config";

[0093] Step 1.5), the client server accesses the APIServer service in the kubernetes cluster through the kubectl command to obtain the resource information inside the kubernetes cluster to be tested;

[0094] Step 1.6), execute the local check code to check the corresponding cluster information; for example, check whether there is an event of successful component creation in the resource information inside the kubernetes cluster to be tested through the local check code, and if so, determine that the component is created successfully.

[0095] Step 1.7) Parse the results returned by executing the kubectl command checkpoint and other checkpoints, and return them to the user;

[0096] For example, to test the node status and pod operation of the kubernetes cluster, and whether the external nginx service provided by the pod is normal; if the client address is "ip", the open web service port is "80", the ID of the kubernetes cluster is "aaabbb", and the interface for the container server on the public cloud to obtain the CA certificate is "http: / / k8sopenapi / userid / cluster_id / ca / file", you can perform automated testing using the following methods:

[0097] In step 2.1), the user accesses and passes the cluster ID of the kubernetes cluster (the cluster to be tested), for example, this can be achieved through the following URL: "http: / / ip:80 / php?cluster_id=aaabbb".

[0098] Step 2.2), the service accesses the OPENAPI of k8s through the cluster ID to read the CA certificate, and imports the CA certificate into the "$HOME / .kube / config" of the test server. Among them, reading the CA certificate can be achieved through the following URL: "http: / / k8sopenapi / userid / aaabbb / ca / file".

[0099] In step 2.3), execute the check script, for example, execute commands such as "kubectl get node" and "kubectl getpod".

[0100] Step 2.4) Analyze and organize the results obtained by executing the command and finally return them to the user.

[0101] An automated testing solution for component loading, cluster node status, and external pod connectivity in a built Kubernetes cluster is proposed. It can realize automated testing of the Kubernetes cluster opened by the user on the public cloud and the external pod service built. The cluster availability check can be completed with one click, which reduces the testing cost, improves the testing efficiency, and saves the testing time. As long as the ID number of the Kubernetes cluster to be tested is given, the automated inspection of the Kubernetes cluster can be realized, and the checkpoints can be further enriched, which has high scalability and portability.

[0102] Figure 3 A schematic diagram of a test device structure of a kubernetes cluster provided in an embodiment of the present invention, wherein the kubernetes cluster is located in a cloud server and includes components.

[0103] The device may include:

[0104] The first acquisition module 301 is used to obtain the ID of the kubernetes cluster to be tested;

[0105] The second acquisition module 302 is used to obtain the CA certificate corresponding to the Kubernetes cluster ID to be tested from the cloud server;

[0106] The second acquisition module 302 is also used to obtain the component status of the kubernetes cluster to be tested from the cloud server based on the CA certificate;

[0107] The generation module 303 is used to generate a test result based on the component status of the kubernetes cluster to be tested.

[0108] In some embodiments, the apparatus may further include:

[0109] The deployment module is used to deploy a local Kubernetes cluster, which includes configuration files.

[0110] In some embodiments, the second acquisition module 302 is specifically used to:

[0111] Update the configuration file based on the CA certificate;

[0112] Based on the updated configuration file, use the kubectl command to obtain the resource information of the Kubernetes cluster to be tested in the cloud server;

[0113] Based on the resource information of the Kubernetes cluster to be tested, determine the component status of the Kubernetes cluster to be tested.

[0114] In some embodiments, the first acquisition module 301 is specifically used for:

[0115] Receive a test request from a user device, where the test request includes the ID of the kubernetes cluster to be tested.

[0116] In some embodiments, the components include nodes and containers, and the component status includes the node status, the container operation status, and whether the container provides external services normally.

[0117] In some embodiments, the apparatus may further include:

[0118] The interface test module is used to test the interface of the kubernetes cluster to be tested.

[0119] In some embodiments, the second acquisition module 302 is specifically used to: based on the interface of the kubernetes cluster to be tested, obtain the CA certificate corresponding to the ID of the kubernetes cluster to be tested from the cloud server.

[0120] The testing device for the Kubernetes cluster provided in the embodiment of the present application has the same technical features as the testing method for the Kubernetes cluster provided in the above embodiment, so it can also solve the same technical problems and achieve the same technical effects.

[0121] like Figure 4 As shown, a computer device 700 provided in an embodiment of the present application includes: a processor 701, a memory 702 and a bus, wherein the memory 702 stores machine-readable instructions executable by the processor 701. When the electronic device is running, the processor 701 communicates with the memory 702 through the bus, and the processor 701 executes the machine-readable instructions to perform the steps of the above-mentioned Kubernetes cluster testing method.

[0122] Specifically, the above-mentioned memory 702 and processor 701 can be general-purpose memory and processor, which are not specifically limited here. When the processor 701 runs the computer program stored in the memory 702, the above-mentioned Kubernetes cluster testing method can be executed.

[0123] Corresponding to the above-mentioned Kubernetes cluster testing method, an embodiment of the present application also provides a computer-readable storage medium, which stores machine-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to execute the steps of the above-mentioned Kubernetes cluster testing method.

[0124] The test device for the kubernetes cluster provided in the embodiment of the present application can be specific hardware on the device or software or firmware installed on the device. The device provided in the embodiment of the present application has the same implementation principle and technical effects as the aforementioned method embodiment. For the sake of brief description, the parts not mentioned in the device embodiment can refer to the corresponding contents in the aforementioned method embodiment. Technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, devices and units described above can all refer to the corresponding processes in the aforementioned method embodiment, and will not be repeated here.

[0125] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only 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 communication interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0126] 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 network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0127] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0128] In addition, each functional unit in the embodiments provided in the present application 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.

[0129] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the mobile control method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, and other media that can store program codes.

[0130] It should be noted that similar numbers and letters represent similar items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are only used to distinguish the description and are not to be understood as indicating or implying relative importance.

[0131] Finally, it should be noted that the above-mentioned embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-mentioned embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-mentioned embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application. They should all be covered within the protection scope of the present application.

Claims

1. A method for testing a kubernetes cluster, wherein the kubernetes cluster is located in a cloud server, and the kubernetes cluster includes components, characterized in that: The method is applied in a test server, and the method comprises: Deploy a local kubernetes cluster, wherein the local kubernetes cluster includes a configuration file; Get the Kubernetes cluster ID to be tested; Obtain the CA certificate corresponding to the Kubernetes cluster ID to be tested from the cloud server; updating the configuration file based on the CA certificate; Based on the updated configuration file, obtain resource information of the kubernetes cluster to be tested in the cloud server through the kubectl command; Based on the resource information of the kubernetes cluster to be tested, determine the component status of the kubernetes cluster to be tested; wherein, the components include nodes and containers, and the component status includes node status, container operation status, and whether the container provides external services normally; the resource information of the kubernetes cluster to be tested includes resource utilization and operation logs; determine whether the container provides external servers normally according to the resource utilization of the container; determine whether each container provides external services normally according to the service exception records in the operation log; for the node status and container status, which are the node deployment status and the container deployment status, the node deployment status and the container deployment status are determined according to the number of nodes and containers that have not been deployed, wherein the successfully deployed containers are determined according to the events of node and container deployment completion in the operation log, and the other containers are containers that have not been deployed; Based on the CA certificate, obtain the component status of the kubernetes cluster to be tested from the cloud server; Generate test results based on the component status of the Kubernetes cluster to be tested.

2. The method according to claim 1, characterized in that The step of obtaining the ID of the kubernetes cluster to be tested includes: A test request is received from a user device, where the test request includes the Kubernetes cluster ID to be tested.

3. According to the method of claim 1, the kubernetes cluster further comprises an interface, characterized in that: Before the step of obtaining the CA certificate corresponding to the Kubernetes cluster ID to be tested from the cloud server, the method further includes: Test the interface of the kubernetes cluster to be tested.

4. The method according to claim 3, characterized in that The step of obtaining the CA certificate corresponding to the Kubernetes cluster ID to be tested from the cloud server includes: Based on the interface of the kubernetes cluster to be tested, obtain the CA certificate corresponding to the ID of the kubernetes cluster to be tested from the cloud server.

5. A test device for a kubernetes cluster, wherein the kubernetes cluster is located in a cloud server, and the kubernetes cluster includes components, characterized in that: The device comprises: A deployment module, used to deploy a local kubernetes cluster, wherein the local kubernetes cluster includes a configuration file; The first acquisition module is used to obtain the Kubernetes cluster ID to be tested; The second acquisition module is used to obtain the CA certificate corresponding to the ID of the kubernetes cluster to be tested from the cloud server; update the configuration file based on the CA certificate; based on the updated configuration file, obtain the resource information of the kubernetes cluster to be tested in the cloud server through the kubectl command; based on the resource information of the kubernetes cluster to be tested, determine the component status of the kubernetes cluster to be tested; wherein the components include nodes and containers, and the component status includes node status, container operation status, and whether the container provides external services normally; the resource information of the kubernetes cluster to be tested includes resource utilization and operation log; determine whether the container provides external servers normally according to the resource utilization of the container; determine whether each container provides external services normally according to the service exception records in the operation log; for the node status and container status, which are the node deployment status and the container deployment status, the node deployment status and the container deployment status are determined according to the number of nodes and containers that have not been deployed, wherein the successfully deployed containers are determined according to the events of node and container deployment completion in the operation log, and the other containers are containers that have not been deployed; The second acquisition module is further used to obtain the component status of the kubernetes cluster to be tested from the cloud server based on the CA certificate; A generation module is used to generate test results based on the component status of the kubernetes cluster to be tested.

6. A computer device comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 4 are implemented.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores machine executable instructions. When the computer executable instructions are called and executed by a processor, the computer executable instructions prompt the processor to execute the method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Kuberrnates Pod health monitoring method

    CN110825580A

  • Method and device for accessing Kubernetes cluster, electronic equipment and medium

    CN111274591A