Script-based container cluster operation and maintenance methods, devices, equipment, and media

By obtaining environment switching instructions and parameter strings from the container cluster, the script automatically determines the target cluster and executes operation and maintenance operations, overcoming the limitations of existing tools in batch operation and maintenance, and achieving efficient operation and maintenance in the container cluster environment.

CN123123390APending Publication Date: 2026-11-17CHINA PING AN LIFE INSURANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611280999.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-21
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

Existing container cluster operation and maintenance tools have limitations in batch operation and maintenance scenarios. They cannot execute commands on multiple container group replicas, lack integrated script transmission and execution capabilities, and are cumbersome to operate and prone to errors.

Method used

By obtaining the environment switching instructions and parameter strings input by the user, the script assigns values ​​to the path variables in the cluster configuration file, automatically determines the target container cluster, and performs corresponding container operation and maintenance operations based on application matching information, thereby achieving rapid switching and batch operation and maintenance of multiple cluster environments.

Benefits of technology

It eliminates the need for frequent context switching or manual specification of cluster configuration files, improving the efficiency of batch operation and maintenance in container cluster environments, simplifying the operation process, and reducing the possibility of misoperation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123123390A_ABST
    Figure CN123123390A_ABST
Patent Text Reader

Abstract

This invention belongs to the field of cloud operations and maintenance technology, and is applicable to the financial and medical fields. It discloses a method, apparatus, device, and medium for container cluster operations and maintenance based on script encapsulation. The method includes: obtaining a user-inputted environment switching command; assigning values ​​to path variables of a pre-defined cluster configuration file using a script according to the environment switching command, and determining the target container cluster corresponding to the assigned path variables of the cluster configuration file; obtaining a user-inputted parameter string, and parsing application matching information and operation type parameters from the parameter string, wherein the application matching information includes application name fragments or network addresses; responding to the operation type parameters, obtaining matching container group information in the target container cluster based on the application matching information, and performing container operations and maintenance operations corresponding to the operation type parameters based on the container group information. This effectively improves the efficiency of batch operations and maintenance in a container cluster environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of cloud operation and maintenance technology and is applicable to the financial and medical fields. In particular, it relates to a method, device, equipment and medium for container cluster operation and maintenance based on script encapsulation. Background Technology

[0002] With the rapid development of cloud technology, container orchestration platforms have become a core component of enterprise IT infrastructure. In daily operations and maintenance, engineers frequently need to view, log in to, execute commands, and distribute scripts within container clusters. Currently, the daily operations and maintenance of container clusters primarily rely on officially provided command-line tools.

[0003] However, as enterprise container clusters continue to expand and the number of applications continues to grow, the limitations of the aforementioned command-line tools in batch operation and maintenance scenarios are becoming increasingly apparent. First, these tools only support remote command issuance to a single container group, and cannot execute commands in batches on multiple container group replicas of the same application. Second, they do not support remotely transferring script files to container groups for execution, lacking integrated script transfer and execution capabilities. Third, the parameter structures of daily management commands are complex, requiring operations personnel to memorize numerous command formats. Furthermore, in cross-container cluster management scenarios, operations personnel need to frequently switch cluster contexts or manually specify cluster configuration files, which is cumbersome and prone to errors.

[0004] Therefore, improving the efficiency of batch operation and maintenance in a container cluster environment is a technical problem that urgently needs to be solved. Summary of the Invention

[0005] This invention provides a script-based container cluster operation and maintenance method, apparatus, device, and medium to solve the technical problem of how to improve the efficiency of batch operation and maintenance in a container cluster environment.

[0006] In a first aspect, the present invention provides a container cluster operation and maintenance method based on script encapsulation, including: Obtain the environment switching command input by the user, and according to the environment switching command, assign values ​​to the path variables of the pre-set cluster configuration file through the script, and determine the target container cluster corresponding to the path variables of the cluster configuration file after the assignment. Obtain the parameter string input by the user, and parse the application matching information and operation type parameters from the parameter string, wherein the application matching information includes application name fragments or network addresses; In response to the operation type parameter, the matching container group information in the target container cluster is obtained based on the application matching information, and the container operation and maintenance operation corresponding to the operation type parameter is executed based on the container group information.

[0007] Secondly, the present invention provides a container cluster operation and maintenance device based on script encapsulation, comprising: The acquisition module is used to acquire the environment switching command input by the user, and according to the environment switching command, assign values ​​to the path variables of the pre-set cluster configuration file through the script, and determine the target container cluster corresponding to the path variables of the cluster configuration file after the assignment. The parsing module is used to obtain the parameter string input by the user and parse the application matching information and operation type parameters from the parameter string, wherein the application matching information includes application name fragments or network addresses; The execution module is used to respond to the operation type parameter, obtain the matching container group information in the target container cluster based on the application matching information, and perform container operation and maintenance operations corresponding to the operation type parameter based on the container group information.

[0008] Thirdly, the present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described script-based container cluster operation and maintenance method.

[0009] Fourthly, the present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the above-described script-based container cluster operation and maintenance method.

[0010] The aforementioned script-based container cluster operation and maintenance method, apparatus, device, and medium, in their implementation scheme, can obtain user-inputted environment switching commands through a client. Based on these commands, a script assigns values ​​to pre-defined path variables in a cluster configuration file and determines the target container cluster corresponding to the assigned path variable. It also obtains user-inputted parameter strings and parses application matching information and operation type parameters from them. The application matching information includes application name fragments or network addresses. In response to the operation type parameters, it obtains matching container group information within the target container cluster based on the application matching information and executes container operation and maintenance operations corresponding to the operation type parameters based on the container group information. In this invention, by assigning values ​​to path variables and determining the target container cluster through environment switching commands, rapid switching between multiple cluster environments is achieved. This allows subsequent operation and maintenance commands to automatically apply to the switched target cluster, eliminating the need for frequent context switching or manual specification of cluster configuration files, effectively improving the efficiency of batch operation and maintenance in a container cluster environment. Attached Figure Description

[0011] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0012] Figure 1 This is a schematic diagram of an application environment for a container cluster operation and maintenance method based on script encapsulation in one embodiment of the present invention.

[0013] Figure 2 This is a flowchart illustrating a container cluster operation and maintenance method based on script encapsulation in one embodiment of the present invention.

[0014] Figure 3 yes Figure 2 A flowchart illustrating a specific implementation of step S30.

[0015] Figure 4 yes Figure 2 A schematic diagram of a specific implementation of step S40.

[0016] Figure 5 yes Figure 2 A flowchart illustrating a specific implementation of step S50.

[0017] Figure 6 This is a schematic diagram of a container cluster operation and maintenance device based on script encapsulation in one embodiment of the present invention.

[0018] Figure 7 This is a schematic diagram of the structure of a computer device according to an embodiment of the present invention.

[0019] Figure 8 This is another structural schematic diagram of a computer device according to one embodiment of the present invention. Detailed Implementation

[0020] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0021] The script-based container cluster operation and maintenance method provided in this invention can be applied to, for example... Figure 1 In the application environment, Figure 1This is a schematic diagram of an application environment for a script-based container cluster operation and maintenance method according to an embodiment of the present invention. The client communicates with the server via a network. The server can obtain the environment switching command input by the user through the client. Based on the environment switching command, the server assigns a value to the path variable of a pre-set cluster configuration file using a script, and determines the target container cluster corresponding to the assigned path variable of the cluster configuration file. The server also obtains the parameter string input by the user and parses application matching information and operation type parameters from the parameter string. The application matching information includes an application name fragment or a network address. In response to the operation type parameter, the server obtains the matching container group information in the target container cluster based on the application matching information, and executes the container operation and maintenance operation corresponding to the operation type parameter based on the container group information. In this invention, by assigning a value to the path variable and determining the target container cluster through the environment switching command, rapid switching between multiple cluster environments is achieved. This allows subsequent operation and maintenance commands to automatically apply to the switched target cluster, eliminating the need for frequent context switching or manual specification of cluster configuration files, effectively improving the efficiency of batch operation and maintenance in a container cluster environment. The present invention will be described in detail below through specific embodiments.

[0022] Please see Figure 2 As shown, Figure 2 This is a schematic diagram of a script-based container cluster operation and maintenance method provided in an embodiment of the present invention. The script-based container cluster operation and maintenance method specifically includes the following steps: S10: Obtain the user-inputted environment switching command. Based on the environment switching command, assign values ​​to the path variables of the pre-set cluster configuration file through a script, and determine the target container cluster corresponding to the assigned path variables of the cluster configuration file. Specifically, such as... Figure 3 The above, Figure 3 yes Figure 2 A schematic flowchart of a specific implementation of step S10 includes the following steps S11-S14: S11: Obtain the environment switching command input by the user, wherein the environment switching command carries the identification information of the target cluster. Specifically, in this embodiment of the invention, the script receives the environment switching command input by the user, which carries the identification information of the target cluster. In practical applications, the cluster identification information can be the cluster name, cluster number, or other pre-agreed unique identifier. For example, in financial scenarios, enterprises typically have multiple environments such as development clusters, testing clusters, and production clusters. Operations personnel can input a production switching command to pass the production cluster as the target cluster identifier to the script. In medical scenarios, hospital information systems also distinguish between in-hospital testing clusters and core business clusters for external services. Operations personnel can specify the target cluster in a similar way. In this invention, by passing the cluster identifier as a parameter to the script, the cumbersome operation of manually modifying configuration files or switching contexts in the traditional method is replaced.

[0023] S12: Based on the identification information of the target cluster, determine the storage path of the cluster configuration file corresponding to the target cluster. Specifically, in this embodiment of the invention, the script can maintain a mapping table to map cluster identifiers to configuration file storage paths one-to-one. For example, in a financial scenario, the production identifier maps to the dedicated configuration file path of the financial production cluster, and the development identifier maps to the configuration file path of the financial development cluster; in a medical scenario, the configuration file of the core business cluster can be stored in the medical intranet security directory, while the test cluster corresponds to a regular storage directory. In this invention, the conversion from identifier to path is automatically completed through a preset mapping relationship, avoiding the need for manual searching and inputting of complete paths.

[0024] S13: The script assigns the storage path of the cluster configuration file to a pre-defined path variable and performs an export operation on the path variable. Specifically, in this embodiment of the invention, the determined storage path of the cluster configuration file is assigned to a pre-defined path variable, and an export operation is performed on the path variable. The path variable is an environment variable pre-declared in the script. Through the export operation, the value of this variable is recorded by the operating system and can be inherited by all subsequently executed commands. For example, in a financial scenario, when the path variable is assigned the configuration file path of the financial production cluster and exported, all subsequent operation and maintenance commands will automatically apply to that production cluster; similarly, in a medical scenario, this ensures that subsequent operations are accurately applied to the specified medical business cluster, avoiding accidental operations on other clusters.

[0025] S14: The cluster corresponding to the path variable after the export operation is performed is determined as the target container cluster. Specifically, in this embodiment of the invention, the script determines the cluster corresponding to the path variable after the export operation is performed as the target container cluster. At this time, the script's running environment is bound to the target cluster, and subsequent operations such as container group information query, command issuance, and script execution are all based on this target cluster. For example, in a financial scenario, after completing the switch to the production cluster, maintenance personnel can immediately perform batch inspections of applications in the production environment; in a medical scenario, after switching to the core business cluster, maintenance operations can be performed on key applications such as electronic medical records and appointment registration. In this invention, through the environment variable activation mechanism, the operation is fixed to the cluster pointing to the current session, and subsequent operations do not need to specify the target cluster again.

[0026] S20: Obtain the parameter string input by the user, and parse the application matching information and operation type parameters from the parameter string, wherein the application matching information includes an application name fragment or a network address. Specifically, such as... Figure 4 The above, Figure 4 yes Figure 2 A schematic flowchart of a specific implementation of step S20 includes the following steps S21-S23: S21: Receive the parameter string input by the user in the command-line interface, extract the first parameter field from the parameter string as the operation type parameter, and extract the second parameter field from the parameter string as the application matching information. Specifically, in this embodiment of the invention, the script receives the parameter string input by the user in the command-line interface and extracts each parameter field from the parameter string. Specifically, the script splits the parameter string using spaces as delimiters, extracts the first parameter field as the operation type parameter, and extracts the second parameter field as the application matching information. The operation type parameter is used to indicate what kind of operation and maintenance operation the script performs, such as query, login, batch commands, or batch scripts; the application matching information is used to locate the target application in the cluster, which can be a partial string of the application name or the network address of the container group. In a financial scenario, operations and maintenance personnel can locate the payment service container group corresponding to the address by inputting a query and a parameter string in the format of a network address; in a medical scenario, operations and maintenance personnel can quickly enter the container group of the application for troubleshooting by inputting login and a partial name of the electronic medical record application.

[0027] S22: Determine the format type of the application matching information. When the application matching information matches the format of a network address, determine that the application matching information is a network address type. Specifically, in this embodiment of the invention, after extracting the application matching information, the script determines the format type of the information. The specific determination method is: check whether the application matching information conforms to the format characteristics of a network address, which includes a four-segment structure composed of numbers and separators. When the application matching information conforms to the above format characteristics, the script determines that the application matching information is a network address type. In a financial scenario, if the operations and maintenance personnel know the network address of a transaction system container group, they can directly input the address as the application matching information. After the script identifies it as a network address type, it will perform accurate matching and positioning based on the address. In a medical scenario, if the network address of a medical image storage service container group has been recorded by the monitoring system, the operations and maintenance personnel can also complete accurate positioning by inputting the address.

[0028] S23: When the application matching information does not match the format of the network address, the application matching information is determined to be an application name fragment type. Specifically, in this embodiment of the invention, when the format judgment result does not conform to the format characteristics of the network address, the script determines that the application matching information is an application name fragment type. The application name fragment can be the complete name of the application or a partial keyword contained in the application name. For example, in a financial scenario, if the operations and maintenance personnel only remember that the application name contains the word "transaction," they can input "transaction" as the application matching information. After the script recognizes it as an application name fragment type, it will search for all container groups in the cluster whose names contain "transaction." In a medical scenario, if the operations and maintenance personnel need to perform batch checks on appointment registration-related services, they can input "registration" as the application matching information. The script will match all application container groups whose names contain "registration."

[0029] S30: In response to the operation type parameter, obtain the matching container group information in the target container cluster based on the application matching information, and execute the container operation and maintenance operation corresponding to the operation type parameter based on the container group information. Specifically, such as... Figure 5 The above, Figure 5 yes Figure 2 A schematic flowchart of a specific implementation of step S30 includes the following steps S31-S33: S31: Obtain extended information about the running container groups within each resource isolation space of the target container cluster through cluster management commands. Specifically, in this embodiment of the invention, the script obtains extended information about the running container groups within each resource isolation space of the target container cluster through cluster management commands. This cluster management command is a native management command provided by the container orchestration platform. When the script is called, it automatically appends the cluster configuration file path parameter previously set through environment variables to ensure that the command applies to the switched target cluster. The extended information returned after the command is executed includes fields such as container group name, resource isolation space to which the container group belongs, container group network address, container group running status, and the node where it is located. The script filters the returned results, retaining only the records of container groups with normal running status and excluding container groups in abnormal or pending startup status. For example, in a financial scenario, if the target cluster is a production cluster, it will obtain information about all normally running application container groups in the production cluster, such as the resource isolation spaces and running status of payment gateway services, account management services, and risk control services, respectively; in a medical scenario, if the target cluster is a core business cluster, it will obtain the running distribution of container groups such as electronic medical record services, registration services, and pharmacy management services.

[0030] S32: Match the extended information of the container group using the application matching information, and extract the resource isolation space identifier and container group identifier corresponding to the successfully matched container group. Specifically, in this embodiment of the invention, the script uses the obtained user-input application matching information to match and filter the obtained container group extended information. If the application matching information is determined to be a network address type, the script uses an exact match method to search for container group records in the extended information whose network address field is completely consistent with the application matching information; if the application matching information is determined to be an application name fragment type, the script uses a fuzzy match method to search for all container group records in the extended information whose container group name field contains the application name fragment. After a successful match, the script extracts the resource isolation space identifier and container group identifier from the corresponding record as the target objects for subsequent operation and maintenance. For example, in a financial scenario, if an operations and maintenance personnel input a transaction as application matching information, the script will match all container groups whose names contain "transaction," such as real-time transaction service and batch transaction processing service, and extract their respective resource isolation space identifiers and container group identifiers. In a medical scenario, if an operations and maintenance personnel input the network address of a medical record service, the script will accurately match the container group corresponding to that address and its corresponding resource isolation space information.

[0031] S33: Based on the resource isolation space identifier and container group identifier, execute the container operation and maintenance operation corresponding to the operation type parameter. Specifically, in this embodiment of the invention, the script executes the corresponding container operation and maintenance operation based on the extracted resource isolation space identifier and container group identifier, as well as the parsed operation type parameter. When the operation type is a query, the script outputs the extracted resource isolation space identifier and container group identifier in a formatted manner, allowing operation and maintenance personnel to view the distribution of the application in each resource isolation space. For example, in a financial scenario, after completing the matching of transaction-related container groups, operation and maintenance personnel can batch execute account balance query commands to verify the data consistency of each transaction service instance; in a medical scenario, operation and maintenance personnel can batch distribute health check scripts to all container group instances of the registration service to confirm the running status and response capability of each instance.

[0032] In one embodiment of the present invention, the step of performing container operation and maintenance operations corresponding to the operation type parameter based on the resource isolation space identifier and the container group identifier specifically includes the following steps S331-S332: S331: When the operation type parameter is login, the first container group identifier is selected from the extracted container group identifiers. Specifically, in this embodiment of the invention, when the script determines that the operation type parameter is login, it selects the first container group identifier from the list of extracted container group identifiers as the login target. Since an application may correspond to multiple container group replicas, the extracted list may contain multiple identifiers. The script defaults to selecting the container group identifier that is first in the list. This selection strategy is simple and efficient, and can quickly determine a specific instance that can be logged into. For example, in a financial scenario, a payment service may be deployed with multiple replicas in a production cluster. After the operations and maintenance personnel issue a login command, the script automatically selects the first payment service container group identifier, without requiring the operations and maintenance personnel to manually select from multiple replicas. In a medical scenario, an electronic medical record service may also be extended to multiple instances. The script automatically selects the first instance identifier, enabling the operations and maintenance personnel to quickly enter one of the instances for fault diagnosis.

[0033] S332: Using cluster management commands, based on the first container group identifier and its corresponding resource isolation space identifier, the script enables the interactive terminal option and configures the command interpreter path to establish an interactive session with the container group corresponding to the first container group identifier. Specifically, in this embodiment of the invention, the script establishes an interactive session with the selected container group based on the first container group identifier and its corresponding resource isolation space identifier using cluster management commands. During execution, the script constructs cluster management commands, passing the container group identifier and resource isolation space identifier as necessary parameters. Simultaneously, it enables the interactive terminal option, which allocates a pseudo-terminal to support interactive operation and configures the command interpreter path, specifying the command interpreter inside the container used to receive user input and return execution results. After successful command execution, the operator's terminal interface switches to the container group, allowing them to execute various commands as if on a local terminal. For example, in financial scenarios, after logging into the payment service container group in this way, operations and maintenance personnel can directly view transaction logs, check database connection status, or temporarily execute diagnostic commands to quickly locate the cause of transaction anomalies; in medical scenarios, after logging into the electronic medical record service container group, operations and maintenance personnel can view service operation logs, check cache status, or temporarily verify data consistency.

[0034] In one embodiment of the present invention, the step of performing container operation and maintenance operations corresponding to the operation type parameter based on the resource isolation space identifier and the container group identifier further includes steps S333-S335: S333: When the operation type parameter is a batch command, obtain the user command text. Specifically, in this embodiment of the invention, the user command text is the specific operation instruction that the operations and maintenance personnel want to execute in each target container group, such as checking disk usage, checking process running status, reading configuration file content, etc. This command text usually appears as the third parameter field in the parameter string. Based on parsing the operation type parameter and application matching information, the script further extracts this field as the user command text. For example, in a financial scenario, when operations and maintenance personnel perform batch inspections of transaction services, they can input the command to check the data cache status as the user command text; in a medical scenario, when operations and maintenance personnel perform batch inspections of multiple instances of the registration service, they can input the command to query the service response log as the user command text.

[0035] S334: Traverse the extracted container group identifiers and execute the user command text in the resource isolation space corresponding to each container group identifier using cluster management commands. Specifically, in this embodiment of the invention, all extracted container group identifiers are executed in the resource isolation space corresponding to each container group identifier using cluster management commands. During execution, the script iterates through the container group identifier list one by one, constructing a cluster management command in each iteration. The container group identifier and resource isolation space identifier corresponding to this iteration are used as target location parameters, and the user command text is used as the content parameter to be executed. A remote execution request is then initiated to the target container cluster. The cluster management command executes the user command text within each container group and returns the execution result for that container group. For example, in a financial scenario, operations personnel need to batch execute database connection status check commands on all replicas of the payment service in the production cluster. The script will automatically traverse each container group replica of the payment service and execute the command in each replica sequentially. In a medical scenario, operations personnel need to batch execute log viewing commands on all instances of the electronic medical record service. The script will also automatically traverse each instance to complete the command execution.

[0036] S335: Collect the output content returned by each container group after executing the user command text, associate and summarize the container group identifier with the corresponding output content, and output the summarized result. Specifically, in this embodiment of the invention, the script collects the output content returned by each container group after executing the user command text, associates and summarizes the container group identifier with the corresponding output content, and outputs the summarized result. The output content returned by each execution is bound and stored with the container group identifier corresponding to that execution. After all container groups have completed execution, the output is organized and output in a unified format, such as adding the container group identifier as a label before each output content, or presenting a comparison of the execution results of each container group in tabular form. For example, in a financial scenario, after operations and maintenance personnel batch check the cache status of transaction services, the script summarizes and outputs the cache hit rate and cache usage of each transaction service replica, quickly locating replicas with abnormalities; in a medical scenario, after operations and maintenance personnel batch query the response logs of the registration service, the script summarizes and outputs the request processing volume and average response time of each registration service instance, making it easier for operations and maintenance personnel to identify performance bottlenecks or instances with uneven load.

[0037] In one embodiment of the present invention, the step of performing container operation and maintenance operations corresponding to the operation type parameter based on the resource isolation space identifier and the container group identifier further includes steps S336-S339: S336: When the operation type parameter is a batch script, obtain the storage path of the local script file. Specifically, in this embodiment of the invention, when the script determines that the operation type parameter is a batch script, it obtains the storage path of the local script file from the parameter string input by the user. This storage path points to a script file that the operations and maintenance personnel have pre-written and saved on the local host. The script file contains a series of complex operation instructions that need to be executed in batches, such as multi-step environment checks, configuration verification, log collection, or data repair. The local script file is usually pre-written by the operations and maintenance personnel according to the actual operations and maintenance needs and placed in a local directory accessible to the script. For example, in a financial scenario, the operations and maintenance personnel can pre-write a comprehensive diagnostic script to check various indicators of the trading system. This script checks multiple indicators such as database connection, cache status, message queue backlog, and service response time in sequence, and passes the local storage path of the script file as a parameter to the operations and maintenance script; in a medical scenario, the operations and maintenance personnel can pre-write a check script to verify the consistency of electronic medical record service data. This script samples and compares each data table and outputs the comparison results, and passes the storage path of the script file to the operations and maintenance script.

[0038] S337: Traverse the extracted container group identifiers and copy the local script file corresponding to the storage path to the temporary directory within the container group corresponding to each container group identifier using a cluster management command. Specifically, in this embodiment of the invention, the script traverses all extracted container group identifiers and copies the local script file corresponding to the obtained storage path to the temporary directory within the container group corresponding to each container group identifier using a cluster management command. During execution, the script iterates through the container group identifier list one by one, constructing a cluster management command in each iteration. The local script file path is used as the source parameter, and the target container group identifier and resource isolation space identifier are combined into the target path parameter. The local script file is copied to a preset temporary directory within the target container group using the built-in file transfer function of the cluster management command. For example, in a financial scenario, the operation and maintenance script batch copies the comprehensive diagnostic script for the transaction system to the temporary directory of all container group replicas of the payment service, preparing for the subsequent unified execution of the diagnostic script in each replica; in a medical scenario, the operation and maintenance script batch copies the electronic medical record data consistency check script to all instances of the medical record service, ensuring that each instance obtains the same version of the check script.

[0039] S338: The command interpreter is invoked via cluster management commands to execute the script files copied to each container group. Specifically, in this embodiment of the invention, the script invokes the command interpreter via cluster management commands to execute the script files copied to each container group. After the script files are distributed, the script iterates through all container group identifiers again, constructing a cluster management command in each iteration. The container group identifier and resource isolation space identifier are used as target location parameters, the storage path of the script file within the container group is used as the execution object parameter, and the command interpreter is specified as the script's execution engine. A remote execution request is then initiated to the target cluster. The command interpreter reads and executes the instructions in the script file line by line within the container group, and returns the complete output of the script after execution. For example, in the financial scenario, the operation and maintenance script calls the command interpreter in each payment service container group replica to execute the previously distributed transaction system comprehensive diagnostic script. Each replica sequentially completes multiple diagnostic operations such as database connection check, cache status detection, message queue backlog query and service response time test. In the medical scenario, the operation and maintenance script executes the data consistency check script in each electronic medical record service instance. Each instance completes data table sampling comparison and generates comparison results.

[0040] S339: Collect the output content returned by each container group after executing the script file, associate and summarize the container group identifier with the corresponding output content, and output the associated and summarized result. Specifically, in this embodiment of the invention, the script collects the output content returned by each container group after executing the script file, associates and summarizes the container group identifier with the corresponding output content, and outputs the associated and summarized result. In specific implementation, during the traversal execution process, the script pairs and stores the complete output content returned by each container group after executing the script with the container group identifier. After all container groups have finished executing, the output content is organized and presented in a unified format. For example, the container group identifier and the resource isolation space to which it belongs are appended as distinguishing labels before the output content of each container group, or key indicators are extracted and compared horizontally in tabular form. For example, in financial scenarios, the operation and maintenance scripts summarize the results of the transaction system comprehensive diagnostic scripts executed by each payment service instance. Operation and maintenance personnel can view key indicators such as database connection status, cache hit rate, message queue backlog, and service response time for each instance, quickly identifying instances with abnormal database connections or excessively long response times and prioritizing their handling. In medical scenarios, the operation and maintenance scripts summarize the results of the data consistency check scripts executed by each electronic medical record service instance. Operation and maintenance personnel can compare the data comparison results of each instance. If an instance is found to have data inconsistencies, data repair can be performed immediately for that instance to ensure the accuracy and reliability of patient medical data.

[0041] As can be seen, in the above solution, in this invention, the path variable is assigned a value and the target container cluster is determined by the environment switching command, so that the rapid switching of multiple cluster environments can be achieved. This allows subsequent operation and maintenance commands to be automatically applied to the switched target cluster without the need to frequently switch contexts or manually specify cluster configuration files, which effectively improves the efficiency of batch operation and maintenance in the container cluster environment.

[0042] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0043] In one embodiment, a script-based container cluster operation and maintenance device is provided, which corresponds one-to-one with the script-based container cluster operation and maintenance method described in the above embodiments. For example... Figure 6 As shown, Figure 6 This is a schematic diagram of a script-based container cluster operation and maintenance device according to an embodiment of the present invention. The script-based container cluster operation and maintenance device includes an acquisition module 61, a parsing module 62, and an execution module 63. Detailed descriptions of each functional module are as follows: The acquisition module 61 is used to acquire the environment switching command input by the user, and according to the environment switching command, assign values ​​to the path variables of the pre-set cluster configuration file through the script, and determine the target container cluster corresponding to the path variables of the assigned cluster configuration file. The parsing module 62 is used to obtain the parameter string input by the user and parse the application matching information and operation type parameters from the parameter string, wherein the application matching information includes application name fragments or network addresses; The execution module 63 is used to respond to the operation type parameter, obtain the matching container group information in the target container cluster based on the application matching information, and perform container operation and maintenance operations corresponding to the operation type parameter based on the container group information.

[0044] In one embodiment, the acquisition module 61 is specifically used for: Obtain the environment switching command input by the user, wherein the environment switching command carries the identification information of the target cluster; Based on the identification information of the target cluster, determine the storage path of the cluster configuration file corresponding to the target cluster; The script assigns the storage path of the cluster configuration file to a pre-defined path variable and performs an export operation on the path variable. The cluster corresponding to the path variable after the export operation is performed is determined as the target container cluster.

[0045] In one embodiment, the parsing module 62 is specifically used for: Receive the parameter string input by the user in the command line interface, extract the first parameter field from the parameter string as the operation type parameter, and extract the second parameter field from the parameter string as the application matching information; Determine the format type of the application matching information; when the application matching information matches the format of the network address, determine that the application matching information is of network address type. When the application matching information does not match the format of the network address, the application matching information is determined to be an application name fragment type.

[0046] In one embodiment, the execution module 63 is specifically used for: The extended information of the running container groups in each resource isolation space of the target container cluster is obtained through cluster management commands; The extended information of the container group is matched with the application matching information, and the resource isolation space identifier and container group identifier corresponding to the successfully matched container group are extracted. Based on the resource isolation space identifier and container group identifier, perform container operation and maintenance operations corresponding to the operation type parameters.

[0047] In one embodiment, the execution module 63 is further configured to: When the operation type parameter is login, the first container group identifier is selected from the extracted container group identifiers; Using cluster management commands, based on the first container group identifier and the corresponding resource isolation space identifier, the interactive terminal option is enabled and the command interpreter path is configured to establish an interactive session with the container group corresponding to the first container group identifier.

[0048] In one embodiment, the execution module 63 is further configured to: When the operation type parameter is a batch command, obtain the user command text; The extracted container group identifiers are traversed, and the user command text is executed in the resource isolation space corresponding to each container group identifier using cluster management commands. Collect the output content returned by each container group after executing the user command text, associate and summarize the identifier of each container group with the corresponding output content, and output the associated and summarized result.

[0049] In one embodiment, the execution module 63 is further configured to: When the operation type parameter is batch script, obtain the storage path of the local script file; Iterate through the extracted container group identifiers and use cluster management commands to copy the local script files corresponding to the storage paths to the temporary directories within the container groups corresponding to the container group identifiers. The cluster management command invokes the command interpreter to execute the script files copied to each container group. Collect the output content returned by each container group after executing the script file, associate and summarize the identifier of each container group with the corresponding output content, and output the associated and summarized result.

[0050] This invention provides a container cluster operation and maintenance device based on script encapsulation. By assigning values ​​to path variables and determining the target container cluster through environment switching commands, it enables rapid switching between multiple cluster environments. This allows subsequent operation and maintenance commands to automatically apply to the switched target cluster without the need for frequent context switching or manual specification of cluster configuration files, effectively improving the efficiency of batch operation and maintenance in a container cluster environment.

[0051] Specific limitations regarding the script-based container cluster operation and maintenance device can be found in the limitations of the script-based container cluster operation and maintenance method described above, and will not be repeated here. Each module in the aforementioned script-based container cluster operation and maintenance device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in the computer device in hardware form, or stored in the memory of the computer device in software form, so that the processor can call and execute the corresponding operations of each module.

[0052] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 7 As shown, Figure 7 This is a schematic diagram of a computer device according to an embodiment of the present invention. The computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile and / or volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface is used to communicate with external clients via a network connection. When the computer program is executed by the processor, it implements the server-side functions or steps of a script-based container cluster operation and maintenance method.

[0053] In one embodiment, a computer device is provided, which may be a client, and its internal structure diagram may be as follows: Figure 8 As shown, Figure 8This is another structural schematic diagram of a computer device according to an embodiment of the present invention. The computer device includes a processor, memory, network interface, display screen, and input device connected via a system bus. The processor of the computer device provides computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external server via a network connection. When the computer program is executed by the processor, it implements the functions or steps on the client side of a script-based container cluster operation and maintenance method.

[0054] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to perform the following steps: Obtain the environment switching command input by the user, and according to the environment switching command, assign values ​​to the path variables of the pre-set cluster configuration file through the script, and determine the target container cluster corresponding to the path variables of the cluster configuration file after the assignment. Obtain the parameter string input by the user, and parse the application matching information and operation type parameters from the parameter string, wherein the application matching information includes application name fragments or network addresses; In response to the operation type parameter, the matching container group information in the target container cluster is obtained based on the application matching information, and the container operation and maintenance operation corresponding to the operation type parameter is executed based on the container group information.

[0055] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor: Obtain the environment switching command input by the user, and according to the environment switching command, assign values ​​to the path variables of the pre-set cluster configuration file through the script, and determine the target container cluster corresponding to the path variables of the cluster configuration file after the assignment. Obtain the parameter string input by the user, and parse the application matching information and operation type parameters from the parameter string, wherein the application matching information includes application name fragments or network addresses; In response to the operation type parameter, the matching container group information in the target container cluster is obtained based on the application matching information, and the container operation and maintenance operation corresponding to the operation type parameter is executed based on the container group information.

[0056] It should be noted that the functions or steps that can be implemented by the computer-readable storage medium or computer device described above can be referred to the relevant descriptions on the server side and client side in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.

[0057] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0058] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.

[0059] It should be noted that any AI models, software tools, or components not belonging to this company appearing in the embodiments of this application are merely illustrative examples and do not represent actual use. All user personal information involved in the embodiments of this application has been authorized (with the knowledge and consent) by the relevant parties or has been fully authorized by all parties, and the executing entity may obtain it through various legal and compliant means. The collection, storage, use, processing, transmission, provision, and disclosure of the information, data, and signals involved all comply with relevant laws and regulations and do not violate public order and good morals.

[0060] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.

Claims

1. A script-based container cluster operation and maintenance method, the method comprising: Obtain the environment switching command input by the user, and according to the environment switching command, assign values ​​to the path variables of the pre-set cluster configuration file through the script, and determine the target container cluster corresponding to the path variables of the cluster configuration file after the assignment. Obtain the parameter string input by the user, and parse the application matching information and operation type parameters from the parameter string, wherein the application matching information includes application name fragments or network addresses; In response to the operation type parameter, the matching container group information in the target container cluster is obtained based on the application matching information, and the container operation and maintenance operation corresponding to the operation type parameter is executed based on the container group information.

2. The container cluster operation and maintenance method based on script encapsulation according to claim 1, characterized in that, The process of obtaining the user-inputted environment switching command, assigning values ​​to the path variables of a pre-defined cluster configuration file via a script based on the environment switching command, and determining the target container cluster corresponding to the assigned path variables of the cluster configuration file includes: Obtain the environment switching command input by the user, wherein the environment switching command carries the identification information of the target cluster; Based on the identification information of the target cluster, determine the storage path of the cluster configuration file corresponding to the target cluster; The script assigns the storage path of the cluster configuration file to a pre-defined path variable and performs an export operation on the path variable. The cluster corresponding to the path variable after the export operation is performed is determined as the target container cluster.

3. The container cluster operation and maintenance method based on script encapsulation according to claim 1, characterized in that, The step involves obtaining the parameter string input by the user and parsing the application matching information and operation type parameters from the parameter string. The application matching information includes an application name fragment or network address, including: Receive the parameter string input by the user in the command line interface, extract the first parameter field from the parameter string as the operation type parameter, and extract the second parameter field from the parameter string as the application matching information; Determine the format type of the application matching information; when the application matching information matches the format of the network address, determine that the application matching information is of network address type. When the application matching information does not match the format of the network address, the application matching information is determined to be an application name fragment type.

4. The container cluster operation and maintenance method based on script encapsulation according to claim 1, characterized in that, The step of responding to the operation type parameter, obtaining matching container group information in the target container cluster based on the application matching information, and performing container operation and maintenance operations corresponding to the operation type parameter based on the container group information includes: The extended information of the running container groups in each resource isolation space of the target container cluster is obtained through cluster management commands; The extended information of the container group is matched with the application matching information, and the resource isolation space identifier and container group identifier corresponding to the successfully matched container group are extracted. Based on the resource isolation space identifier and container group identifier, perform container operation and maintenance operations corresponding to the operation type parameters.

5. The container cluster operation and maintenance method based on script encapsulation according to claim 4, characterized in that, The step of performing container operation and maintenance operations corresponding to the operation type parameter based on the resource isolation space identifier and container group identifier includes: When the operation type parameter is login, the first container group identifier is selected from the extracted container group identifiers; Using cluster management commands, based on the first container group identifier and the corresponding resource isolation space identifier, the interactive terminal option is enabled and the command interpreter path is configured to establish an interactive session with the container group corresponding to the first container group identifier.

6. The container cluster operation and maintenance method based on script encapsulation according to claim 4, characterized in that, The step of performing container operation and maintenance operations corresponding to the operation type parameter based on the resource isolation space identifier and container group identifier further includes: When the operation type parameter is a batch command, obtain the user command text; The extracted container group identifiers are traversed, and the user command text is executed in the resource isolation space corresponding to each container group identifier using cluster management commands. Collect the output content returned by each container group after executing the user command text, associate and summarize the identifier of each container group with the corresponding output content, and output the associated and summarized result.

7. The container cluster operation and maintenance method based on script encapsulation according to claim 4, characterized in that, The step of performing container operation and maintenance operations corresponding to the operation type parameter based on the resource isolation space identifier and container group identifier further includes: When the operation type parameter is batch script, obtain the storage path of the local script file; Iterate through the extracted container group identifiers and use cluster management commands to copy the local script files corresponding to the storage paths to the temporary directories within the container groups corresponding to the container group identifiers. The cluster management command invokes the command interpreter to execute the script files copied to each container group. Collect the output content returned by each container group after executing the script file, associate and summarize the identifier of each container group with the corresponding output content, and output the associated and summarized result.

8. A container cluster operation and maintenance device based on script encapsulation, the device comprising: The acquisition module is used to acquire the environment switching command input by the user, and according to the environment switching command, assign values ​​to the path variables of the pre-set cluster configuration file through the script, and determine the target container cluster corresponding to the path variables of the cluster configuration file after the assignment. The parsing module is used to obtain the parameter string input by the user and parse the application matching information and operation type parameters from the parameter string, wherein the application matching information includes application name fragments or network addresses; The execution module is used to respond to the operation type parameter, obtain the matching container group information in the target container cluster based on the application matching information, and perform container operation and maintenance operations corresponding to the operation type parameter based on the container group information.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the script-encapsulated container cluster operation and maintenance method as described in any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the script-encapsulated container cluster operation and maintenance method as described in any one of claims 1 to 7.