Inspection method, device and equipment and computer readable storage medium
By executing inspection scripts in Kubernetes clusters, the problem of inefficiency of traditional inspection tools in large-scale cluster environments is solved, and a more efficient inspection process is achieved.
Patent Information
- Application Number
- CN202411833334.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-12
- Publication Date
- 2025-03-21
AI Technical Summary
In a large-scale Kubernetes cluster environment, traditional inspection tools need to send SSH commands one by one for inspection, resulting in excessive pressure on inspection tools and excessive inspection time, which is inefficient.
By determining the corresponding inspection script for each inspection item in the inspection tool and sending it to the task of the container orchestration platform environment, the inspection script is executed using the task of the container orchestration platform environment to obtain the inspection results. The method includes setting execution priority, creating a patrol mirror and storing it in the mirror warehouse so that it can be quickly pulled and executed during patrol.
It reduces the pressure on inspection tools, improves the efficiency of inspection, reduces the impact on the system, and allows inspections to be carried out efficiently in large-scale cluster environments.
Smart Images

Figure CN119668784A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of cloud computing data centers, and in particular to an inspection method, device, equipment and computer-readable storage medium. Background Art
[0002] It is very important to understand the running status of these Kubernetes clusters under the cloud platform. Currently, inspection tools are often used for inspection. In order to reduce the impact on the system itself, inspection tools are often run independently in a certain environment, such as the operation and maintenance personnel's own computer, and then the running status of the Kubernetes cluster under the cloud platform is inspected through interface calls or SSH remote commands. However, in a large-scale environment, when the Kubernetes cluster is large and each cluster contains many nodes, traditional inspection tools often require the inspection tool to issue an inspection execution. The inspection tool sends SSH commands to the cluster one by one for inspection. After each node is inspected, the results are generated and returned to the inspection tool. This mode will cause too much pressure on the inspection tool itself and too long inspection time when there are many nodes.
[0003] It can be seen that how to reduce the pressure of inspection tools and improve inspection efficiency is a technical problem that technical personnel in this field need to solve. Summary of the invention
[0004] In view of this, an object of the present invention is to provide an inspection method, device, equipment and computer-readable storage medium to solve the technical problem of low inspection efficiency in the prior art.
[0005] In order to solve the above technical problems, the present invention provides an inspection method, comprising:
[0006] Determine the inspection script corresponding to each inspection item in the inspection tool;
[0007] Send each inspection script to the task of the container orchestration platform environment;
[0008] When it is determined to execute the inspection script, the inspection script is executed based on the task of the container orchestration platform environment to obtain an inspection result.
[0009] On the one hand, when it is determined to execute the inspection script, the inspection script is executed based on the task of the container orchestration platform environment to obtain the inspection result, including:
[0010] Set the execution priority of the inspection script based on the requirements;
[0011] Determine the inspection script that needs to be executed currently based on the execution priority;
[0012] The task based on the container orchestration platform environment executes the current inspection script and obtains the inspection result corresponding to the current inspection script.
[0013] On the one hand, after determining the inspection script corresponding to each inspection item in the inspection tool, it also includes:
[0014] Based on the type of inspection script, determine whether to create an inspection image corresponding to the current inspection script;
[0015] When it is determined to make an inspection image, a corresponding inspection image is made based on the current inspection script and the execution environment corresponding to the inspection script, and the inspection image is stored in the inspection image warehouse of the container orchestration platform environment, so that during inspection, the inspection image corresponding to the current task is pulled for execution based on the image address corresponding to the current task;
[0016] When it is determined not to create the inspection image, it is determined to execute a step in the task of sending the inspection script to the container orchestration platform environment.
[0017] On the one hand, the method of creating a corresponding inspection image based on the current inspection script and the execution environment corresponding to the inspection script, and storing the inspection image in the inspection image warehouse of the container orchestration platform environment includes:
[0018] When the type of the inspection script is a script based on a high-level, interpreted programming language, generating a corresponding inspection image based on the current inspection script and the environment corresponding to the high-level, interpreted programming language;
[0019] When the type of the inspection script is a script based on a high-level, object-oriented programming language, a corresponding inspection image is generated based on the current inspection script and an environment corresponding to the high-level, object-oriented programming language.
[0020] On the one hand, when it is determined to execute the inspection script, the inspection script is executed based on the task of the container orchestration platform environment to obtain the inspection result, including:
[0021] Based on the inspection parameters corresponding to each inspection script, determine the startup parameters of the corresponding task;
[0022] Determine whether to execute the current inspection script based on the startup parameters;
[0023] When it is determined to execute the inspection script, the inspection script is executed based on the task of the container orchestration platform environment to obtain the inspection result.
[0024] On the one hand, based on the inspection parameters corresponding to each inspection script, the startup parameters of the corresponding task are determined, including:
[0025] Based on the resource limit parameters corresponding to the current inspection script, determine the resource consumption limit of the task corresponding to the current inspection script; wherein the resource consumption is the resources consumed by the container at runtime when executing the task;
[0026] Based on the task parameters corresponding to the current inspection script, determine the task running parameters of the task corresponding to the current inspection script; wherein the task running parameters include starting the tasks on a set number of nodes;
[0027] Based on the inspection parameters corresponding to the current inspection script, determine the inspection execution parameters of the task corresponding to the current inspection script; wherein the inspection execution parameters are the inspection time strategy of the current inspection script;
[0028] Based on the inspection requirement parameters corresponding to the current inspection script, determine the inspection content parameters of the task corresponding to the current inspection script; wherein the inspection content parameters are the specific inspection content corresponding to the current inspection script;
[0029] Based on the inspection recovery strategy corresponding to the current inspection script, the deletion parameter of the task corresponding to the current inspection script is determined; wherein the deletion parameter is the parameter strategy of the task corresponding to the current inspection script after the inspection is completed.
[0030] On the one hand, when it is determined to execute the inspection script, the inspection script is executed based on the task of the container orchestration platform environment, and after the inspection result is obtained, it also includes:
[0031] The inspection result is reported to the inspection tool so that the inspection tool can visually display the inspection result.
[0032] The embodiment of the present invention further provides a patrol inspection device, including:
[0033] An inspection script determination module is used to determine the inspection script corresponding to each inspection item in the inspection tool;
[0034] The sending module is used to send each inspection script to the task of the container orchestration platform environment;
[0035] The inspection module is used to execute the inspection script based on the task of the container orchestration platform environment when it is determined to execute the inspection script to obtain the inspection result.
[0036] The embodiment of the present invention further provides an inspection device, including:
[0037] Memory for storing computer programs;
[0038] A processor is used to execute the computer program to implement the steps of the above inspection method.
[0039] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above inspection method are implemented.
[0040] The present invention also provides a computer program product, comprising a computer program / instruction, which implements the steps of the above inspection method when executed by a processor.
[0041] To solve the above technical problems, an embodiment of the present invention provides an inspection method, which may include: determining an inspection script corresponding to each inspection item in an inspection tool; sending each inspection script to a task in a container orchestration platform environment; and when it is determined to execute the inspection script, executing the inspection script based on the task of the container orchestration platform environment to obtain an inspection result.
[0042] It can be seen from the above technical solution that the beneficial effect of the present invention is that compared with the current inspection tool that needs to make and execute inspection scripts, the present invention sends the task of executing the inspection script to the task of the container orchestration platform environment, and uses the task of the container orchestration platform environment to execute the inspection script to obtain the inspection result. The inspection tool only needs to collect the inspection results, which reduces the pressure on the inspection tool and improves the efficiency of the inspection. . BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0044] Figure 1 A flowchart of an inspection method provided by an embodiment of the present invention;
[0045] Figure 2 An example flow chart of an inspection method provided by an embodiment of the present invention;
[0046] Figure 3 A flowchart of another inspection method provided by an embodiment of the present invention;
[0047] Figure 4 A schematic diagram of an inspection system provided by an embodiment of the present invention;
[0048] Figure 5 A schematic diagram of the structure of an inspection device provided by an embodiment of the present invention;
[0049] Figure 6 A schematic diagram of the structure of an inspection device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0050] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions 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 are within the scope of protection of the present invention.
[0051] The terms "including" and "having" in the specification of the present invention and the above-mentioned drawings, as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device including a series of steps or units is not limited to the listed steps or units, but may include steps or units that are not listed.
[0052] Some of the terms that appear in the description of the embodiments of the present invention may be interpreted as follows:
[0053] Kubernetes, also known as K8S, is an open source container orchestration tool. Its main function is to automate the deployment, expansion and management of applications, thereby simplifying the process of running containerized applications in large-scale computing environments.
[0054] A job is a Kubernetes resource object used to perform one-time tasks or batch jobs. A job can control the number of Pods (containers) to ensure that a certain number of Pods stop and complete the job after successfully completing the task. In Kubernetes, the job type is usually used in scenarios such as data processing, backup and recovery operations.
[0055] In order to enable those skilled in the art to better understand the solution of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0056] Next, a patrol inspection method provided by an embodiment of the present invention is described in detail. Figure 1 A flowchart of an inspection method provided by an embodiment of the present invention, the inspection method may include:
[0057] S101, determining the inspection script corresponding to each inspection item in the inspection tool.
[0058] The execution subject in this embodiment is a cluster, or the execution subject in this embodiment can also be a node in the cluster. The inspection items in this embodiment are parameters for determining the inspection content. This embodiment does not limit specific inspection items. For example, the inspection items in this embodiment can be the memory usage rate and CPU (central processing unit) usage rate of the node; or the inspection items in this embodiment can also be system alarms, licenses, database brain splits, etc. The inspection script in this embodiment is a script that can inspect the inspection items. The inspection script is an automated tool for regularly checking the operating status and performance of the system, network or application.
[0059] It should be further explained that, in order to improve the adaptability of the inspection, after determining the inspection script corresponding to each inspection item in the inspection tool, the following may also be included:
[0060] S1: Based on the type of inspection script, determine whether to create an inspection image corresponding to the current inspection script;
[0061] S2: When it is determined to produce an inspection image, a corresponding inspection image is produced based on the current inspection script and the execution environment corresponding to the inspection script, and the inspection image is stored in the inspection image warehouse of the container orchestration platform environment, so that during inspection, the inspection image corresponding to the current task is pulled for execution based on the image address corresponding to the current task;
[0062] S3: When it is determined not to create an inspection image, determine to execute a step in a task of sending the inspection script to the container orchestration platform environment.
[0063] This embodiment does not limit the specific type of inspection image to be produced. As long as it can be determined based on the type that the current inspection script cannot adapt to the current environment, this embodiment can use pre-made inspection images for complex inspection items or inspection items developed in different languages. The inspection script can be saved as an inspection image and uploaded to the inspection image repository (Kubernetes cluster image repository). The image can be quickly pulled for execution during inspection execution.
[0064] It should be further explained that, in order to improve the accuracy of inspection image production, the above-mentioned production of the corresponding inspection image based on the current inspection script and the execution environment corresponding to the inspection script, and the storage of the inspection image in the inspection image warehouse of the container orchestration platform environment, may include: when the type of the inspection script is a script based on a high-level, interpreted programming language, the corresponding inspection image is generated based on the current inspection script and the environment corresponding to the high-level, interpreted programming language; when the type of the inspection script is a script based on a high-level, object-oriented programming language, the corresponding inspection image is generated based on the current inspection script and the environment corresponding to the high-level, object-oriented programming language. In this embodiment, the inspection script is written in Python (an advanced, interpreted programming language, known for its readability and versatility. It supports a variety of programming paradigms, including procedural, object-oriented and functional programming, and Python's design philosophy emphasizes the readability of the code). The Python environment is required when the inspection script is executed, so the basic image needs to include a Python virtual machine; similarly, the inspection program developed in Java (Java is an advanced, object-oriented programming language) needs to include a Jvm virtual machine. That is, in this embodiment, when the type of the inspection script requires a specific basic environment, an inspection image needs to be created.
[0065] S102, sending each inspection script to a task in the container orchestration platform environment.
[0066] This embodiment does not limit the specific method of sending each inspection script to the task of the container orchestration platform environment. For example, this embodiment can send the inspection script according to its priority; or this embodiment can send the inspection script according to the generation time; or this embodiment can directly send all the inspection scripts to the container orchestration platform environment at one time.
[0067] S103: When it is determined to execute the inspection script, the inspection script is executed based on the task of the container orchestration platform environment to obtain the inspection result.
[0068] In this embodiment, when there is one inspection script, the inspection script can be directly executed based on the task of the container orchestration platform environment to obtain the inspection result; when there are multiple inspection scripts in this embodiment, the inspection script can be assigned to the task for execution based on the priority of the inspection script. In this embodiment, in the Kubernetes cluster, Kubernetes Job is a resource object for executing batch tasks. Job ensures that batch tasks are eventually completed (even if failure occurs), and a retry mechanism can be configured to handle task failures. Kubernetes Job is used to execute one-time tasks, that is, those tasks that are expected to be completed at a certain time. Unlike long-running Pods, Pods managed by Jobs terminate after completing tasks. Jobs ensure that tasks are eventually completed, and if tasks fail, they will be retried according to the configuration. Job is a resource object in Kubernetes that is used to manage and monitor one or more Pods to ensure that specified tasks are completed. Pod: Job creates one or more Pods to perform tasks. Each Job creates at least one Pod unless parallelism is specified.
[0069] It should be further explained that in order to improve the user experience, when it is determined to execute the inspection script, the inspection script is executed based on the task of the container orchestration platform environment to obtain the inspection result, which may include: setting the execution priority of the inspection script based on the demand; determining the inspection script to be executed currently based on the execution priority; executing the current inspection script based on the task of the container orchestration platform environment to obtain the inspection result corresponding to the current inspection script. This embodiment does not limit the execution priority determination method, and the above execution priority may be a static priority, or the priority in this embodiment may be a dynamic priority. In this embodiment, the priority of all inspection scripts can be set in the task of the container orchestration platform environment, so that inspection scripts with higher priorities can be executed first according to the priority, and the inspection results are obtained, which are fed back to the user in a timely manner to improve the user experience.
[0070] In order to improve the accuracy of determining the execution priority, the above-mentioned determination of the priority of executing the script may include: dynamically adjusting the priority based on the criticality assessment, resource consumption, execution frequency and time window, and the actual operation and business demand changes to obtain the execution priority. Criticality assessment in this embodiment: First, a criticality assessment is performed on each inspection item to identify those tasks that are critical to system stability, security or business continuity, and set them to high priority. For example, database connection checks, key service operation status checks, etc. should take precedence over non-critical log analysis or performance monitoring. Dependency analysis: Analyze the dependencies between inspection items. If some tasks depend on the results of other tasks, ensure that the dependent tasks are executed first. For example, if a task requires the data of another task as input, the task that provides the data should have a higher priority. Resource consumption consideration: Consider the resource consumption of each inspection task. High-priority tasks should be those that consume less system resources and have a faster execution speed to avoid occupying system resources for a long time and affecting the execution of other tasks. Execution frequency and time window: Set the priority according to the execution frequency of the task and the required time window. For tasks that need to be executed frequently, they can be set to a higher priority to ensure that the latest data is obtained in a timely manner. For tasks that can be executed within a specific time window, their priority can be flexibly adjusted according to the system load. Error handling and retry mechanism: Set a stricter error handling and retry mechanism for high-priority tasks. When a task fails, a retry or alarm should be triggered immediately to ensure that the problem is resolved in a timely manner. Dynamically adjust priority: Dynamically adjust the priority of inspection tasks according to the actual operation of the system and changes in business needs. For example, during peak system load periods, the priority of non-critical tasks can be appropriately lowered to free up more resources for critical tasks. Recording and monitoring: Establish a complete logging and monitoring system to track the execution of inspection tasks and the effect of priority adjustment. By regularly analyzing log data, potential problems can be discovered and inspection strategies can be optimized.
[0071] It should be further explained that, in order to improve the accuracy of starting the inspection script, when it is determined to execute the inspection script, the inspection script is executed based on the task of the container orchestration platform environment to obtain the inspection result, which may include:
[0072] S1031, based on the inspection parameters corresponding to each inspection script, determine the startup parameters of the corresponding task.
[0073] S1032: Determine whether to execute the current inspection script based on the startup parameters.
[0074] S1033: When it is determined to execute the inspection script, the inspection script is executed based on the task of the container orchestration platform environment to obtain the inspection result.
[0075] This embodiment does not limit specific inspection parameters, and the inspection parameters in this embodiment are parameters for starting each inspection script. This embodiment sets the startup parameters corresponding to the tasks of each inspection script so that each inspection script can be started according to the startup parameters, thereby improving the accuracy of starting the inspection script.
[0076] It needs to be further explained that the above-mentioned determination of the startup parameters of the corresponding task based on the inspection parameters corresponding to each inspection script may include: determining the resource consumption limit of the task corresponding to the current inspection script based on the resource limit parameters corresponding to the current inspection script; wherein the resource consumption is the resource consumed by the container at runtime when executing the task; determining the task running parameters of the task corresponding to the current inspection script based on the task parameters corresponding to the current inspection script; wherein the task running parameters include starting tasks on a set number of nodes; determining the inspection execution parameters of the task corresponding to the current inspection script based on the inspection parameters corresponding to the current inspection script; wherein the inspection execution parameters are the inspection time strategy of the current inspection script; determining the inspection content parameters of the task corresponding to the current inspection script based on the inspection requirement parameters corresponding to the current inspection script; wherein the inspection content parameters are the specific inspection content corresponding to the current inspection script; determining the deletion parameters of the task corresponding to the current inspection script based on the inspection recovery strategy corresponding to the current inspection script; wherein the deletion parameters are the parameter strategy of the task corresponding to the current inspection script after the inspection is completed. In this embodiment, after the inspection script is received on the node of the cluster on Kubernetes, the Job is started, and the inspection script is copied into the Job for execution. When starting the Job, it is necessary to start it according to the inspection parameters issued by the inspection item, and modify the yaml file of the corresponding Job (the modification file for the environment). For example, by setting the resource consumption limit of the Job, you can limit the resource consumption to a certain amount to avoid affecting the business of the node itself. Secondly, according to the inspection parameters issued by the inspection item, whether all nodes are started or only one node is started, generally, it is sufficient to collect information related to the Kubernetes cluster to start the Job on a node, but if you want to obtain certain information on the node, you must start the Job on all nodes;
[0077] After setting the startup parameters of the Job, you also need to obtain the startup parameters of the inspection script issued by the inspection item so that you can execute more accurate commands according to the parameters when running the inspection script. After the inspection is completed, the corresponding Job task needs to be deleted. For scheduled tasks, if no inspection request from the inspection tool is received for more than 1 hour, it will be automatically deleted. This embodiment sets the startup parameters so that the inspection tool can be started and deleted, thereby improving the accuracy of the inspection.
[0078] It should be further explained that when it is determined to execute the inspection script, the inspection script is executed based on the task of the container orchestration platform environment, and after the inspection result is obtained, it can also include: reporting the inspection result to the inspection tool so that the inspection tool can visualize the inspection result. The inspection tool in this embodiment is only responsible for collecting the inspection results, which improves the accuracy of the use of the inspection tool.
[0079] In order to make the present invention easier to understand, please refer to Figure 2 , Figure 2 An example flow chart of an inspection method provided by an embodiment of the present invention may specifically include:
[0080] S201, send the inspection script in the inspection tool to the underlying Kubernetes environment.
[0081] S202, using the Job function of Kubernetes, integrate the inspection script corresponding to each inspection item into the Kubernetes task.
[0082] S203, when executing the inspection script, one or more pods are started in a Job task mode.
[0083] S204: Execute the inspection script inside the pod based on the inspection task execution rule sent by the inspection tool to obtain a first inspection result.
[0084] S205, when it is determined that there is an inspection image corresponding to the inspection script of the inspection item in the cluster image library, the corresponding image is pulled during the inspection to execute the inspection image and obtain a second inspection result.
[0085] S206: Return the first inspection result and the second inspection result to the inspection tool.
[0086] The embodiment of the present invention sends the execution of the inspection script of the inspection item to the Kubernetes cluster, and the inspection tool itself is only responsible for collecting the inspection results, and is no longer responsible for the execution of the inspection items. In the Kubernetes cluster, the execution mode of Kubernetes Job is adopted, and the execution strategy of the specific task issued by the inspection tool, such as the execution node selection, number of copies, resource restrictions and time period, can be combined to start the Job task to execute the inspection script and return the result, thereby reducing the inspection pressure of the Kubernetes inspection tool itself and improving the inspection speed.
[0087] Now, more and more companies are exposed to Kubernetes clusters and incorporate their own applications and services into Kubernetes clusters for management. Some companies or enterprises may have multiple Kubernetes clusters to meet different business needs. They often introduce cloud management platforms to manage multiple Kubernetes clusters. For operation and maintenance personnel, it is also very important to understand the operating status of these Kubernetes clusters under the cloud platform. At this time, we often use inspection tools to conduct inspections. In order to reduce the impact on the system itself, inspection tools often run independently in a certain environment, such as the operation and maintenance personnel's own computer, and then inspect the operating status of the Kubernetes cluster under the cloud platform through interface calls or SSH remote commands. However, in a large-scale environment, when the Kubernetes cluster is large, each cluster contains many nodes, or there are too many Kubernetes clusters managed by the cloud management platform, the inspection tool often has difficulty in running inspection items. For example, when obtaining information about each host, it is necessary to traverse the host one by one to obtain information, making the inspection efficiency low.
[0088] In order to make the present invention easier to understand, please refer to Figure 3 , Figure 3 Another example flow chart of an inspection method provided by an embodiment of the present invention may specifically include:
[0089] S301, obtain the target inspection script corresponding to each inspection item; wherein the target inspection script includes a first inspection script and a second inspection script; the first inspection script is sent to the Kubernetes cluster before the inspection, and the second inspection script is generated into an inspection image and stored in the inspection image warehouse in the Kubernetes cluster environment.
[0090] For easier understanding, please refer to Figure 4 , Figure 4 A schematic diagram of an inspection system provided by an embodiment of the present invention, from Figure 4 It can be seen that the inspection tool is only responsible for collecting inspection results. The inspection results can be obtained by using the inspection scripts in the inspection image library. a, b, c, and d represent a job.
[0091] The inspection script in this embodiment needs to be initialized. For inspection items that do not require the production of inspection images, the inspection script needs to be initialized and the script is stored on the inspection tool. During the inspection, the remote delivery function of the inspection tool is used to send the script to the host of the Kubernetes cluster before the inspection, and then it is executed in the form of a Kubernetes Job. If it is an inspection item that requires the production of an inspection image, the inspection image can be uploaded to the inspection image warehouse in the Kubernetes cluster environment. When executing the inspection Job (that is, executing an image once, which may end in a short time), the corresponding image can be pulled for rapid execution. In this embodiment, the inspection image can be solidified, and the solidified inspection image can be uploaded to the image warehouse of the Kubernetes cluster. During the inspection, it is only necessary to pass in the address of the images of the image corresponding to the inspection item (the address of the images of the image depends on the operating system), so that the Job can be started using this image to perform the inspection task.
[0092] S302, setting inspection parameters corresponding to each target inspection script; wherein the inspection parameters include scheduled inspection, inspection time, and inspection cycle; and parameters corresponding to each inspection item, the parameters include checking alarms for the last N days, and detecting logs for the last M days.
[0093] In this embodiment, when performing inspection, specific inspection parameters can be set, such as whether it is a scheduled inspection, the inspection time, whether it is a periodic inspection, the inspection period, etc. Some inspection items have their own unique parameters, such as checking the alarms of the last N days, N needs to be set. Checking the logs of the last M days, etc., specific inspection items need to be specifically set.
[0094] S303, setting the inspection strategy corresponding to each target inspection script; wherein the inspection strategy includes the running strategy of the Job.
[0095] In this embodiment, different inspection items need to be set with different inspection strategies. For example, the running strategy of the Job is set to be executed on each node (for example, the information of each host needs to be obtained) or on one of the nodes in Kubernetes (for example, the configuration information of some Kubernetes clusters needs to be obtained).
[0096] S304, setting resource restriction conditions corresponding to each target inspection script.
[0097] In this embodiment, each inspection item can be set with a resource usage amount so that when the inspection item is executed, it can be limited to a certain resource consumption range and will not affect the execution of the Kubernetes business itself.
[0098] S305, setting a recycling policy corresponding to each target inspection script; wherein the recycling policy refers to a deletion policy for the target inspection script.
[0099] S306: directly execute the first inspection script using the Job based on the set information to obtain a first inspection result.
[0100] S307, determining the inspection image corresponding to the current Job, and obtaining the corresponding inspection image from the inspection image warehouse, executing the inspection image based on the set information, and obtaining a second inspection result.
[0101] S308: Report the first inspection result and the second inspection result as target inspection results to the inspection tool, and visualize the target inspection results.
[0102] The present invention runs the inspection script by adopting the Job mode of Kubernetes, issues the execution of the inspection items of the inspection tool, and reduces the pressure of the inspection tool itself. At the same time, through the parameter setting of the Job, the resource consumption, execution parameters, cycle strategy and recycling mechanism of the inspection script execution can be limited, so that the inspection of the inspection tool can be completely safe and controllable, reducing the impact on the business of the Kubernetes cluster itself. Finally, for complex inspection items, or inspection items developed in different languages and environments, the characteristics of the Kubernetes environment itself can be used to prefabricate the inspection items as inspection images in advance, so that the image can be quickly pulled up for execution when the task is executed, which increases the richness of the implementation methods of the inspection items, can obtain inspection results more quickly and accurately, and also enhances the convenience of adding inspection items to the inspection tool.
[0103] A patrol inspection device provided in an embodiment of the present invention is introduced below. The patrol inspection device described below and the patrol inspection method described above can be referenced to each other.
[0104] Figure 5 A schematic diagram of the structure of a patrol inspection device provided in an embodiment of the present invention may include:
[0105] The inspection script determination module 100 is used to determine the inspection script corresponding to each inspection item in the inspection tool;
[0106] A sending module 200 is used to send each inspection script to a task in a container orchestration platform environment;
[0107] The inspection module 300 is used to execute the inspection script based on the task of the container orchestration platform environment when it is determined to execute the inspection script to obtain the inspection result.
[0108] Further, based on the above embodiment, the inspection module 300 may include:
[0109] An execution priority determination unit, used to set the execution priority of the inspection script based on demand;
[0110] The inspection script execution unit is used to determine the inspection script to be executed currently based on the execution priority;
[0111] The inspection result determination unit is used to execute the current inspection script based on the task of the container orchestration platform environment to obtain the inspection result corresponding to the current inspection script.
[0112] Further, based on any of the above embodiments, the above inspection device may further include:
[0113] The inspection image production judgment module is used to determine whether to produce the inspection image corresponding to the current inspection script based on the type of the inspection script;
[0114] The inspection image storage module is used to, when it is determined to make an inspection image, make a corresponding inspection image based on the current inspection script and the execution environment corresponding to the inspection script, and store the inspection image in the inspection image warehouse of the container orchestration platform environment, so that during the inspection, based on the image address corresponding to the current task, the inspection image corresponding to the current task is pulled for execution;
[0115] The inspection image not being produced determination unit is configured to, when it is determined that the inspection image is not being produced, determine to execute a step in a task of sending the inspection script to a container orchestration platform environment.
[0116] Further, based on the above embodiment, the above inspection mirror storage module may include:
[0117] A first inspection image making unit, configured to generate a corresponding inspection image based on the current inspection script and an environment corresponding to the high-level, interpreted programming language when the type of the inspection script is a script based on a high-level, interpreted programming language;
[0118] The second inspection image making unit is used to generate a corresponding inspection image based on the current inspection script and the environment corresponding to the high-level, object-oriented programming language when the type of the inspection script is a script based on a high-level, object-oriented programming language.
[0119] Further, based on any of the above embodiments, the inspection module 300 may include:
[0120] A startup parameter determination unit, used to determine the startup parameters of the corresponding task based on the inspection parameters corresponding to each inspection script;
[0121] A unit for executing an inspection script based on startup parameters, used for determining whether to execute a current inspection script based on the startup parameters;
[0122] The inspection result determination unit is used to execute the inspection script based on the task of the container orchestration platform environment to obtain the inspection result when it is determined to execute the inspection script.
[0123] Further, based on the above embodiment, the startup parameter determination unit may include:
[0124] The first parameter determination subunit is used to determine the resource consumption limit of the task corresponding to the current inspection script based on the resource limit parameter corresponding to the current inspection script; wherein the resource consumption is the resource consumed by the container at runtime when executing the task;
[0125] A second sub-parameter determination unit is used to determine the task running parameters of the task corresponding to the current inspection script based on the task parameters corresponding to the current inspection script; wherein the task running parameters include starting the tasks on a set number of nodes;
[0126] The third sub-parameter determination unit is used to determine the inspection execution parameter of the task corresponding to the current inspection script based on the inspection parameter corresponding to the current inspection script; wherein the inspection execution parameter is the inspection time strategy of the current inspection script;
[0127] The fourth sub-parameter determination unit is used to determine the inspection content parameter of the task corresponding to the current inspection script based on the inspection requirement parameter corresponding to the current inspection script; wherein the inspection content parameter is the specific inspection content corresponding to the current inspection script;
[0128] The fifth sub-parameter determination unit is used to determine the deletion parameters of the task corresponding to the current inspection script based on the inspection recovery strategy corresponding to the current inspection script; wherein the deletion parameters are the parameter strategy of the task corresponding to the current inspection script after the inspection is completed.
[0129] Further, based on any of the above embodiments, the above inspection device may further include:
[0130] The inspection result display module is used to report the inspection result to the inspection tool so that the inspection tool can visually display the inspection result.
[0131] It should be noted that the order of the modules and units in the above inspection device can be changed without affecting the logic.
[0132] Figure 5 The description of the features in the corresponding embodiments can be found in Figure 5 The relevant descriptions of the corresponding embodiments will not be repeated here one by one.
[0133] An inspection device provided by an embodiment of the present invention may include: an inspection script determination module 100, which is used to determine the inspection script corresponding to each inspection item in the inspection tool; a sending module 200, which is used to send each inspection script to a task in a container orchestration platform environment; and an inspection module 300, which is used to execute the inspection script based on the task of the container orchestration platform environment when it is determined to execute the inspection script to obtain an inspection result. Compared with the current inspection tool that needs to make and execute the inspection script, the present invention sends the task of executing the inspection script to the task of the container orchestration platform environment, and uses the task of the container orchestration platform environment to execute the inspection script to obtain the inspection result. The inspection tool only needs to collect the inspection results, which reduces the pressure on the inspection tool and improves the efficiency of the inspection.
[0134] A patrol inspection device provided in an embodiment of the present invention is introduced below. The patrol inspection device described below and the patrol inspection method described above can be referenced to each other.
[0135] Figure 6 A schematic diagram of the structure of an inspection device provided by an embodiment of the present invention is shown in FIG. Figure 6 As shown, the inspection device includes: a memory 60 for storing a computer program;
[0136] The processor 61 is used to implement the steps of the inspection method in the above embodiment when executing the computer program.
[0137] The inspection equipment provided in this embodiment may include but is not limited to a smart phone, a tablet computer, a laptop computer, or a desktop computer.
[0138] Among them, the processor 61 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 61 can be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and programmable logic array (PLA). The processor 61 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 61 may be integrated with a graphics processing unit (GPU), and the GPU is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 61 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.
[0139] The memory 60 may include one or more computer-readable storage media, which may be non-transitory. The memory 60 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 60 is at least used to store the following computer program 601, wherein, after the computer program is loaded and executed by the processor 61, it can implement the relevant steps of the inspection method disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 60 may also include an operating system 602 and data 603, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 602 may include Windows, Unix, Linux, etc. The data 603 may include but is not limited to the data required for the inspection method, etc.
[0140] In some embodiments, the inspection device may further include a display screen 62 , an input / output interface 63 , a communication interface 64 , a power supply 65 , and a communication bus 66 .
[0141] Those skilled in the art will understand that Figure 6 The structure shown in the figure does not constitute a limitation on the inspection device, and may include more or fewer components than shown in the figure.
[0142] It is understandable that if the inspection method in the above embodiment 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 is essentially or the part that contributes to the current technology or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and executes all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), electrically erasable programmable ROM, register, hard disk, removable disk, CD-ROM, magnetic disk or optical disk and other media that can store program codes.
[0143] Based on this, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above inspection method are implemented.
[0144] Based on this, an embodiment of the present invention further provides a computer program product, including a computer program / instruction, which implements the steps of the above inspection method when executed by a processor.
[0145] The above is a detailed introduction to a patrol inspection method provided by an embodiment of the present invention. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0146] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0147] The above is a detailed introduction to the inspection method, device, equipment and computer-readable storage medium provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present invention, several improvements and modifications can be made to the present invention, and these improvements and modifications also fall within the scope of protection of the claims of the present invention.
Claims
1. A patrol inspection method, characterized in that: include: Determine the inspection script corresponding to each inspection item in the inspection tool; Send each inspection script to the task of the container orchestration platform environment; When it is determined to execute the inspection script, the inspection script is executed based on the task of the container orchestration platform environment to obtain an inspection result.
2. The inspection method according to claim 1, characterized in that: When it is determined to execute the inspection script, the inspection script is executed based on the task of the container orchestration platform environment to obtain the inspection result, including: Set the execution priority of the inspection script based on the requirements; Determine the inspection script that needs to be executed currently based on the execution priority; The task based on the container orchestration platform environment executes the current inspection script and obtains the inspection result corresponding to the current inspection script.
3. The inspection method according to claim 1, characterized in that: After determining the inspection script corresponding to each inspection item in the inspection tool, it also includes: Based on the type of inspection script, determine whether to create an inspection image corresponding to the current inspection script; When it is determined to make an inspection image, a corresponding inspection image is made based on the current inspection script and the execution environment corresponding to the inspection script, and the inspection image is stored in the inspection image warehouse of the container orchestration platform environment, so that during inspection, the inspection image corresponding to the current task is pulled for execution based on the image address corresponding to the current task; When it is determined not to create the inspection image, it is determined to execute a step in the task of sending the inspection script to the container orchestration platform environment.
4. The inspection method according to claim 3, characterized in that: The step of creating a corresponding inspection image based on the current inspection script and the execution environment corresponding to the inspection script, and storing the inspection image in the inspection image warehouse of the container orchestration platform environment includes: When the type of the inspection script is a script based on a high-level, interpreted programming language, generating a corresponding inspection image based on the current inspection script and the environment corresponding to the high-level, interpreted programming language; When the type of the inspection script is a script based on a high-level, object-oriented programming language, a corresponding inspection image is generated based on the current inspection script and an environment corresponding to the high-level, object-oriented programming language.
5. The inspection method according to any one of claims 1 to 4, characterized in that: When it is determined to execute the inspection script, the inspection script is executed based on the task of the container orchestration platform environment to obtain the inspection result, including: Based on the inspection parameters corresponding to each inspection script, determine the startup parameters of the corresponding task; Determine whether to execute the current inspection script based on the startup parameters; When it is determined to execute the inspection script, the inspection script is executed based on the task of the container orchestration platform environment to obtain the inspection result.
6. The inspection method according to claim 5, characterized in that: Based on the inspection parameters corresponding to each inspection script, determine the startup parameters of the corresponding task, including: Based on the resource limit parameters corresponding to the current inspection script, determine the resource consumption limit of the task corresponding to the current inspection script; wherein the resource consumption is the resources consumed by the container at runtime when executing the task; Based on the task parameters corresponding to the current inspection script, determine the task running parameters of the task corresponding to the current inspection script; wherein the task running parameters include starting tasks on a set number of nodes; Based on the inspection parameters corresponding to the current inspection script, determine the inspection execution parameters of the task corresponding to the current inspection script; wherein the inspection execution parameters are the inspection time strategy of the current inspection script; Based on the inspection requirement parameters corresponding to the current inspection script, determine the inspection content parameters of the task corresponding to the current inspection script; wherein the inspection content parameters are the specific inspection content corresponding to the current inspection script; Based on the inspection recovery strategy corresponding to the current inspection script, the deletion parameter of the task corresponding to the current inspection script is determined; wherein the deletion parameter is the parameter strategy of the task corresponding to the current inspection script after the inspection is completed.
7. The inspection method according to claim 1, characterized in that: When it is determined to execute the inspection script, the inspection script is executed based on the task of the container orchestration platform environment, and after the inspection result is obtained, the method further includes: The inspection result is reported to the inspection tool so that the inspection tool can visually display the inspection result.
8. A patrol inspection device, characterized in that: include: An inspection script determination module is used to determine the inspection script corresponding to each inspection item in the inspection tool; The sending module is used to send each inspection script to the task of the container orchestration platform environment; The inspection module is used to execute the inspection script based on the task of the container orchestration platform environment when it is determined to execute the inspection script to obtain the inspection result.
9. A patrol inspection device, characterized in that: include: Memory for storing computer programs; A processor, configured to execute the computer program to implement the steps of the inspection method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the inspection method according to any one of claims 1 to 7 are implemented.