ConfigMap format disorder processing method and device based on cloud edge collaboration, medium and equipment

The kubectl plug-in extends the subcommand, solves the problem of ConfigMap format disorder, realizes the format repair and saving of ConfigMap resources, and improves the readability and operation efficiency in the cloud-edge collaborative environment.

CN120353497APending Publication Date: 2025-07-22INSPUR ENTERPRISE CLOUD TECHNOLOGY (SHANDONG) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510414674.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-03
Publication Date
2025-07-22

AI Technical Summary

Technical Problem

In a cloud-edge collaborative environment, the confusing ConfigMap resource format makes it difficult to view and modify content, affecting readability.

Method used

Using the custom features of the kubectl plug-in, add subcommands of different processing scopes and processing methods, including viewing and formatting after temporary format repair and saving to preset database, and formatting the ConfigMap resource through string parsing tools.

Benefits of technology

It realizes formatting and repair of ConfigMap resources to meet readability requirements and saves the repaired content to the database for easier subsequent queries and editing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120353497A_ABST
    Figure CN120353497A_ABST
Patent Text Reader

Abstract

The invention provides a ConfigMap format disorder processing method and device based on cloud edge collaboration, a medium and equipment. The method comprises the following steps of: increasing sub-commands corresponding to different processing ranges and different processing modes by utilizing the custom characteristic of a kubectl plug-in; wherein the processing range comprises format disordered contents in all ConfigMap resources and format disordered contents in ConfigMap resources with specified namespace and specified name; the processing mode comprises checking after the temporary format is repaired, repairing the format, and storing the repaired ConfigMap resource in a preset database; and when the processing demand of ConfigMap format disorder exists, according to the sub-command corresponding to the processing demand, processing the format disorder content in the ConfigMap resource in the corresponding processing range according to the corresponding processing mode. According to the invention, the readability requirement can be met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of cloud-edge collaboration technology, and in particular to a method, device, medium, and equipment for processing ConfigMap format disorder based on cloud-edge collaboration. Background Art

[0002] With the increasing application of container technology in public cloud, private cloud, hybrid cloud and other fields, the latest container technology has been widely used in the field of cloud computing due to its excellent performance and ease of use. Cloud computing is a computing model based on the Internet and with mass participation. It provides dynamic and scalable computing resources to demanders in the form of services. Cloud computing is mainly divided into three types of services: infrastructure as a service, platform as a service and software as a service. Edge computing is a distributed computing architecture that delegates computing tasks to devices close to the data source. The purpose of edge computing is to reduce response time, improve stability, and reduce network pressure and energy consumption on the central cloud. Cloud-edge collaboration closely combines cloud computing and edge computing. It is responsible for real-time data collection, processing and preliminary analysis through edge nodes, while cloud data centers are responsible for large-scale computing tasks such as data analysis, machine learning and model training. In this way, cloud-edge collaboration takes advantage of the network advantages of the edge side and the elastic computing capabilities of cloud computing.

[0003] In the cloud-edge collaborative environment, ConfigMap, as an important Kubernetes resource type, stores the relevant configuration file content of the application service container. In the actual R&D and production process, you may need to view and modify the content in the configuration file. However, Kubernetes has strict requirements on the content format in ConfigMap. Once a tab or trailing space appears in a long paragraph, it will automatically convert it to characters such as \n and \t. The originally expected indentation and line break format will all be disrupted, seriously affecting the viewing and modification of these contents. Among them, kubernetes, referred to as K8s, is an open source containerized application for managing multiple hosts in the cloud platform.

[0004] Therefore, in order to meet the demand for more readability in scenarios where ConfigMap resource formats are disordered under cloud-edge collaboration, it is necessary to propose a solution for handling ConfigMap format disorder based on cloud-edge collaboration. Summary of the invention

[0005] In response to at least one of the above technical problems, an embodiment of the present invention provides a method, device, medium, and equipment for processing ConfigMap format disorder based on cloud-edge collaboration.

[0006] According to a first aspect, the method for processing ConfigMap format disorder based on cloud-edge collaboration provided by an embodiment of the present invention includes:

[0007] Utilize the custom features of the kubectl plugin to add subcommands corresponding to different processing scopes and different processing methods respectively; wherein, the processing scope includes the format disorder content in all ConfigMap resources and the format disorder content in the ConfigMap resources with a specified namespace and a specified name; the processing methods include viewing after temporary format repair and repairing the format and saving the repaired ConfigMap resources to a preset database.

[0008] When there is a processing requirement for ConfigMap format disorder, according to the subcommand corresponding to the processing requirement, process the format disorder content in the ConfigMap resources within the corresponding processing scope according to the corresponding processing method.

[0009] In one embodiment, the step of utilizing the custom features of the kubectl plugin to add subcommands corresponding to different processing scopes and different processing methods respectively includes:

[0010] Implement the kubectl plugin;

[0011] Based on the implementation file of the kubectl plugin, determine the corresponding parameters according to different usage scenarios; wherein, the parameters include the processing scope and the processing method, and the implementation file is a shell script or an executable binary program file;

[0012] Generate corresponding subcommands according to the parameters;

[0013] Deploy the executable file containing the subcommands on the Kubernetes cluster nodes and grant executable permissions.

[0014] In one embodiment, the step of when there is a processing requirement for ConfigMap format disorder, according to the subcommand corresponding to the processing requirement, process the format disorder content in the ConfigMap resources within the corresponding processing scope according to the corresponding processing method includes:

[0015] If the processing requirement is to view after temporarily repairing the format disorder content in the ConfigMap resources with a specified namespace and a specified name, determine the corresponding first subcommand;

[0016] Execute the first subcommand to implement the following steps:

[0017] Query the ConfigMap resource with the specified namespace and name through the native standard query method; the ConfigMap resource is in json format;

[0018] Extract the data fields in the queried ConfigMap resource; wherein, the form of the data field is key-value;

[0019] Use a string parsing tool to format the value in the data field;

[0020] Combine the key and the formatted value in the data field to obtain a formatted data field, determine the formatted ConfigMap resource according to the formatted data field, and display the formatted ConfigMap resource.

[0021] In one embodiment, before combining the key and the formatted value in the data field, the method further includes:

[0022] Convert the format of the key and the formatted value to yaml format;

[0023] Correspondingly, the combining the key and the formatted value in the data field includes: combining the key and the formatted value in yaml format to obtain a data field in yaml format.

[0024] In one embodiment, when there is a processing requirement for the format disorder of the ConfigMap format, according to the subcommand corresponding to the processing requirement, process the format disorder content in the ConfigMap resource within the corresponding processing range, including:

[0025] If the processing requirement is to repair the format disorder content in the ConfigMap resource with the specified namespace and name and save the repaired ConfigMap resource to a preset database, determine the corresponding second subcommand;

[0026] Execute the second subcommand to implement the following steps:

[0027] Query the ConfigMap resource with the specified namespace and name through the native standard query method; the ConfigMap resource is in json format;

[0028] Extract the data fields in the queried ConfigMap resource; wherein, the form of the data field is key-value;

[0029] Use a string parsing tool to format the value in the data field;

[0030] Combine the key in the data field and the formatted value to obtain a formatted data field, and determine the formatted ConfigMap resource according to the formatted data field;

[0031] Save the formatted ConfigMap resource to a first temporary file;

[0032] Check whether there are missing format errors in the first temporary file, and if so, repair the missing format errors;

[0033] Save the first temporary file after repairing the missing format errors to a preset database so that the repaired ConfigMap resource can be queried by the native standard query method next time.

[0034] In one embodiment, before combining the key in the data field and the formatted value, the method further includes:

[0035] Convert the formats of the key and the formatted value to the yaml format;

[0036] Correspondingly, the combining of the key in the data field and the formatted value: Combine the key in the yaml format and the formatted value to obtain a data field in the yaml format;

[0037] Correspondingly, the first temporary file is in the yaml format.

[0038] In one embodiment, when there is a processing requirement for the disordered format of the ConfigMap, according to the sub-command corresponding to the processing requirement, process the disordered content in the ConfigMap resource within the corresponding processing range according to the corresponding processing method, including:

[0039] If the processing requirement is to repair the disordered content in all ConfigMap resources and save the repaired ConfigMap resources to a preset database, determine the corresponding second sub-command;

[0040] Execute the third sub-command to implement the following steps:

[0041] Query all ConfigMap resources through the native standard query method; the ConfigMap resources are in the json format;

[0042] Extract the data fields in each ConfigMap resource retrieved by the query; wherein, the form of the data field is key-value;

[0043] Use a string parsing tool to format the values in the data fields of each ConfigMap resource;

[0044] Combine the keys and the formatted values in the data fields of each ConfigMap resource to obtain the formatted data fields in this ConfigMap resource, and determine the formatted ConfigMap resource according to the formatted data fields;

[0045] Save each formatted ConfigMap resource to its corresponding second temporary file respectively;

[0046] Check whether there are missing format errors in each second temporary file, and if so, repair the missing format errors;

[0047] Save each second temporary file after repairing the missing format errors to a preset database, so that the corresponding ConfigMap resources after repair can be queried by the native standard query method next time.

[0048] According to the second aspect, the apparatus for processing ConfigMap format disorder based on cloud-edge collaboration provided by the embodiments of the present invention includes:

[0049] A command definition module, configured to use the custom features of the kubectl plug-in to add subcommands corresponding to different processing scopes and different processing methods respectively; wherein, the processing scope includes the format disorder content in all ConfigMap resources and the format disorder content in the ConfigMap resources with a specified namespace and a specified name; the processing methods include viewing after temporary format repair and repairing the format and saving the repaired ConfigMap resources to a preset database;

[0050] A command execution module, configured to, when there is a processing requirement for ConfigMap format disorder, process the format disorder content in the ConfigMap resources within the corresponding processing scope according to the subcommand corresponding to the processing requirement and in the corresponding processing method.

[0051] In one embodiment, the command definition module is specifically configured to: implement the kubectl plugin; determine corresponding parameters according to different usage scenarios based on the implementation file of the kubectl plugin; where the parameters include the processing scope and the processing method, and the implementation file is a shell script or an executable binary program file; generate corresponding sub-commands according to the parameters; deploy the executable file containing the sub-commands on the Kubernetes cluster nodes and grant executable permissions.

[0052] In one embodiment, the command execution module includes:

[0053] The first processing unit is configured to, if the processing requirement is to temporarily repair the format of the scrambled content in the ConfigMap resource with a specified namespace and a specified name and then view it, determine the corresponding first sub-command; execute the first sub-command to implement the following steps: query the ConfigMap resource with the specified namespace and the specified name through the native standard query method; the ConfigMap resource is in json format; extract the data fields in the queried ConfigMap resource; where the form of the data fields is key-value; use a string parsing tool to format the values in the data fields; combine the keys and the formatted values in the data fields to obtain the formatted data fields, determine the formatted ConfigMap resource according to the formatted data fields, and display the formatted ConfigMap resource.

[0054] Further, before the first processing unit combines the keys and the formatted values in the data fields, it is further configured to: convert the formats of the keys and the formatted values into yaml format; correspondingly, the process of the first processing unit combining the keys and the formatted values in the data fields includes: combining the keys and the formatted values in yaml format to obtain the data fields in yaml format.

[0055] In one embodiment, the command execution module includes:

[0056] A second processing unit, which is configured to determine a corresponding second sub-command if the processing requirement is to repair the incorrectly formatted content in a ConfigMap resource with a specified namespace and a specified name and save the repaired ConfigMap resource to a preset database; execute the second sub-command to implement the following steps: query a ConfigMap resource with a specified namespace and a specified name through a native standard query method; the ConfigMap resource is in json format; extract the data fields in the queried ConfigMap resource; wherein the data fields are in the form of key-value; use a string parsing tool to format the values in the data fields; combine the keys and the formatted values in the data fields to obtain formatted data fields, determine a formatted ConfigMap resource according to the formatted data fields; save the formatted ConfigMap resource to a first temporary file; check whether there are missing format errors in the first temporary file, and if so, repair the missing format errors; save the first temporary file after repairing the missing format errors to a preset database so that the repaired ConfigMap resource can be queried through the native standard query method next time.

[0057] Further, before the second processing unit combines the keys and the formatted values in the data fields, it is further configured to: convert the formats of the keys and the formatted values to the yaml format; correspondingly, the process of the second processing unit combining the keys and the formatted values in the data fields includes: combining the keys and the formatted values in the yaml format to obtain data fields in the yaml format; the first temporary file is in the yaml format.

[0058] In one embodiment, the command execution module includes:

[0059] A third processing unit, configured to determine a corresponding second sub-command if the processing requirement is to repair the format of the content with format disorder in all ConfigMap resources and save the repaired ConfigMap resources to a preset database; execute the third sub-command to implement the following steps: query all ConfigMap resources through a native standard query method; the ConfigMap resources are in json format; extract the data fields in each of the queried ConfigMap resources; wherein, the form of the data field is key-value; use a string parsing tool to format the value in the data field of each ConfigMap resource; combine the key and the formatted value in the data field of each ConfigMap resource to obtain the formatted data field in the ConfigMap resource, and determine the formatted ConfigMap resource according to the formatted data field; save each of the formatted ConfigMap resources to their respective corresponding second temporary files; check whether there are missing format errors in each second temporary file, and if so, repair the missing format errors; save the second temporary files after repairing the missing format errors to a preset database, so that the corresponding repaired ConfigMap resources can be queried through the native standard query method next time.

[0060] According to a third aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed in a computer, the computer is made to execute the method provided in the first aspect.

[0061] According to a fourth aspect, a computing device provided by an embodiment of the present invention includes a memory and a processor. An executable code is stored in the memory. When the processor executes the executable code, the method provided in the first aspect is implemented.

[0062] The method, device, medium, and device for processing ConfigMap format disorder based on cloud-edge collaboration provided by the embodiments of the present invention first use the custom characteristics of the kubectl plug-in to add sub-commands corresponding to different processing scopes and different processing methods. The processing method can be to view after temporary format repair, or to repair the format and save the repaired ConfigMap resources to a preset database. The processing scope can be all ConfigMap resources or some ConfigMap resources. When there is a processing requirement for ConfigMap format disorder, just execute the sub-command corresponding to the processing requirement. No matter which processing method is used, the format error content in the ConfigMap resources can be repaired, thus meeting the readability requirement. Description of the Drawings

[0063] Figure 1 This is a schematic flowchart of a method for processing ConfigMap format disorder based on cloud-edge collaboration in an embodiment of the present invention;

[0064] Figure 2 This is a structural block diagram of a device for processing ConfigMap format disorder based on cloud-edge collaboration in an embodiment of the present invention. Detailed implementation manners

[0065] In a first aspect, an embodiment of the present invention provides a method for processing ConfigMap format disorder based on cloud-edge collaboration. Refer to Figure 1 , the method includes the following steps S110 to S120:

[0066] S110. Utilize the custom features of the kubectl plugin to add sub-commands corresponding to different processing scopes and different processing methods respectively; wherein, the processing scope includes the disordered content in all ConfigMap resources and the disordered content in the ConfigMap resources with a specified namespace and a specified name; the processing methods include viewing after temporary format repair and repairing the format and saving the repaired ConfigMap resources to a preset database;

[0067] Among them, the disordered content in the ConfigMap resources with a specified namespace and a specified name in the protection scope refers to a part of the ConfigMap resources.

[0068] Among them, viewing after temporary format repair in the processing method means that after repairing the disordered content in the ConfigMap resources, it is displayed but not saved, and the ConfigMap resources queried by the native standard query method next time are still the native ConfigMap resources with format errors.

[0069] Among them, the Kubectl plugin is a command-line tool that uses the Kubernetes API to communicate with the control plane of the Kubernetes cluster.

[0070] In one embodiment, the utilization of the custom features of the kubectl plugin in S110 to add sub-commands corresponding to different processing scopes and different processing methods respectively may include:

[0071] 1. Implement the kubectl plugin;

[0072] 2. Based on the implementation file of the kubectl plugin, determine the corresponding parameters according to different usage scenarios; wherein, the parameters include the processing scope and the processing method, and the implementation file is a shell script or an executable binary program file;

[0073] 3. Generate the corresponding sub-commands according to the parameters;

[0074] 4. Deploy the executable file containing the sub-commands on the Kubernetes cluster nodes and grant executable permissions.

[0075] It can be understood that the native commands for viewing and editing ConfigMap resources are kubectl get / edit configmap –n namespace. Such a long display content is very likely to have characters such as \n and \t, seriously affecting the viewing and reading experience. The embodiments of the present invention do not damage the native commands for the repair and viewing of ConfigMap format error content, but use the customizable feature of the kubectl plugin to extend sub-commands. On the basis of keeping the original command system intact, additional sub-commands related to format repair and viewing are added, which is more efficient, convenient and integrated.

[0076] For example, based on the above steps 1 to 4, the process of adding sub-commands corresponding to different processing scopes and different processing methods is roughly as follows:

[0077] First, implement the kubectl plugin in the form of a shell script or an executable binary program file, and name the plugin kubectl-format;

[0078] Then, at the specific implementation level of the script or binary code program file, support specifying different parameters according to different usage scenarios. For example, in the scenario of formatting and viewing a specified ConfigMap, the parameter of action is specified as get, and the specific command executed at this time is kubectl format get configMapName –n namespace; in the scenario of formatting and repairing a specified ConfigMap, the parameter of action is specified as fix, and the specific command executed at this time is kubectl format fix configMapName –n namespace; in the scenario of formatting and repairing all ConfigMaps, the parameter of action is specified as fix, and at the same time, the specific namespace and name are no longer specified, but the –all parameter is used instead. The specific command executed at this time is kubectl format fix –all.

[0079] Finally, place the finally compiled kubectl-format executable file in the / usr / local / bin / directory on the Kubernetes cluster nodes, and execute chmod +x to give it executable permissions, and this formatting plugin can be used in the cluster.

[0080] S120. When there is a need to process the ConfigMap with incorrect format, according to the sub-command corresponding to the processing requirement, process the content with incorrect format in the ConfigMap resources within the corresponding processing range according to the corresponding processing method.

[0081] It can be seen that when there are different requirements, different sub-commands are adopted, and then the processing operations for different processing ranges and different processing methods are realized.

[0082] In one embodiment, when there is a need to process the ConfigMap with incorrect format in S120, according to the sub-command corresponding to the processing requirement, process the content with incorrect format in the ConfigMap resources within the corresponding processing range according to the corresponding processing method, including:

[0083] a1. If the processing requirement is to view the ConfigMap resource with a specified namespace and a specified name after temporarily fixing the incorrect format of the content, determine the corresponding first sub-command;

[0084] a2. Execute the first sub-command to achieve the following steps:

[0085] a21. Query the ConfigMap resource with a specified namespace and a specified name through the native standard query method; the ConfigMap resource is in json format;

[0086] a22. Extract the data fields in the queried ConfigMap resource; among them, the form of the data field is key-value;

[0087] a23. Use a string parsing tool to format the value in the data field;

[0088] a24. Combine the key and the formatted value in the data field to obtain the formatted data field, determine the formatted ConfigMap resource according to the formatted data field, and display the formatted ConfigMap resource.

[0089] It can be seen that based on the above first sub-command, it is possible to view the ConfigMap resource with a specified namespace and a specified name after temporarily fixing the incorrect format of the content.

[0090] Further, before combining the key in the data field and the formatted value, the method may further include:

[0091] Convert the formats of the key and the formatted value to the yaml format;

[0092] Correspondingly, combining the key in the data field and the formatted value includes: combining the key and the formatted value in the yaml format to obtain a data field in the yaml format.

[0093] For example, when the Kubectl plugin formats a query execution call, it mainly uses the native ConfigMap query logic and only performs an extended query on the formatted content. The specific process is as follows:

[0094] (1) Specify the input parameters when querying in the Kubectl plugin: the namespace name and the ConfigMap name;

[0095] (2) When formatting the query, first perform a native standard query inside the plugin to obtain the native ConfigMap resource in the json format;

[0096] (3) Traverse the data field in the ConfigMap resource queried in the previous step to obtain the data of the key and value in the corresponding map, that is, the key-value.

[0097] (4) Since the data of the key does not involve format chaos, it remains unchanged, while the content of the value data needs to be formatted and corrected;

[0098] (5) jq is a json string parsing tool. The value data obtained in the previous step can be directly formatted using the jq tool. The command is similar to jq '.data."cloud.conf"' –r. In this way, the output value data is the value data with the chaotic content already formatted, but this value data is in the json format;

[0099] (6) The most commonly used format of the kubectl plugin is the yaml format. Therefore, the json format data needs to be converted to the yaml format again. The conversion method can use another tool called yq. This tool can convert between json and yaml formats. The specific command used here is similar to yq eval –P data.json. In this way, all the format error parts in the value part of the data field in the ConfigMap resource have been converted;

[0100] (7)Finally, combine the value part output in the previous step with the key part of the data retrieved previously, and supplement the other original fields of the ConfigMap resource to form a complete and formatted ConfigMap resource.

[0101] In one embodiment, when there is a processing requirement for a ConfigMap format disorder in S120, according to the sub-command corresponding to the processing requirement, process the disordered content in the ConfigMap resource within the corresponding processing range according to the corresponding processing method, including:

[0102] a3. If the processing requirement is to repair the disordered content in the ConfigMap resource with a specified namespace and a specified name and save the repaired ConfigMap resource to a preset database, determine the corresponding second sub-command;

[0103] a4. Execute the second sub-command to implement the following steps:

[0104] a41. Query the ConfigMap resource with a specified namespace and a specified name through the native standard query method; the ConfigMap resource is in json format;

[0105] a42. Extract the data fields in the retrieved ConfigMap resource; among them, the form of the data field is key-value;

[0106] a43. Use a string parsing tool to format the value in the data field;

[0107] a44. Combine the key in the data field and the formatted value to obtain a formatted data field, and determine the formatted ConfigMap resource according to the formatted data field;

[0108] It can be seen that a41-a44 are similar to a21-a24 in the above text.

[0109] a45. Save the formatted ConfigMap resource to the first temporary file;

[0110] a46. Check whether there are any missing format errors in the first temporary file, and if so, repair the missing format errors;

[0111] Here, to prevent the existence of imperceptible trailing spaces or TAB characters in the first temporary file, the sed command can be used to replace and update the first temporary file, delete the trailing spaces, and replace the TAB characters with four space characters. After the replacement, the new content is still saved to the first temporary file.

[0112] It can be seen that by saving the formatted ConfigMap resource to the first temporary file and then removing the TAB characters and trailing spaces through the sed command, the formatting of the content with incorrect formatting in the ConfigMap resource is repaired.

[0113] a47. Save the first temporary file after repairing the missing formatting errors to a preset database so that the repaired ConfigMap resource can be queried through the native standard query method next time.

[0114] Among them, tools such as jq and yq, and the method of converting between json and yaml can be used to process the content with incorrect formatting in the ConfigMap resource with a specified namespace and name.

[0115] For example, execute the kubectl apply–f / tmp / xxx.yaml command to update the first temporary file after repairing the formatting errors to the etcd database. At this time, when directly using the native kubectl get configmap command, the content queried is the already formatted configmap resource.

[0116] It can be seen that in the cloud-edge collaboration environment, the formatting of the content with incorrect formatting in the ConfigMap resource with a specified namespace and name is repaired and the repaired content is saved to a preset database, such as the etcd database.

[0117] It can be seen that in addition to supporting formatted query of ConfigMap resources, the Kubectl plugin also supports directly repairing the content with formatting errors in the specified ConfigMap resource and permanently saving the data to the etcd database. After that, the native kubectl command can be directly used to query, once and for all.

[0118] Similarly, before combining the key in the data field and the formatted value, the method may further include:

[0119] Convert the format of the key and the formatted value to the yaml format;

[0120] Correspondingly, the combination of the key in the data field and the formatted value: combine the key in yaml format and the formatted value to obtain a data field in yaml format; the first temporary file is in yaml format.

[0121] It can be seen that a complete ConfigMap resource in yaml format can be obtained after a44. Export and save this ConfigMap resource to a first temporary file in xxx.yaml format in the / tmp directory.

[0122] In one embodiment, when there is a processing requirement for the disordered format of the ConfigMap in S120, according to the sub-command corresponding to the processing requirement, process the disordered content in the ConfigMap resource within the corresponding processing range according to the corresponding processing method, which may include:

[0123] a5. If the processing requirement is to repair the disordered content in all ConfigMap resources and save the repaired ConfigMap resources to a preset database, determine the corresponding second sub-command;

[0124] a6. Execute the third sub-command to implement the following steps:

[0125] a61. Query all ConfigMap resources through the native standard query method; the ConfigMap resources are in json format;

[0126] a62. Extract the data fields in each of the queried ConfigMap resources; among them, the form of the data field is key-value;

[0127] a63. Use a string parsing tool to format the value in the data field of each ConfigMap resource;

[0128] a64. Combine the key in the data field of each ConfigMap resource and the formatted value to obtain the formatted data field in the ConfigMap resource, and determine the formatted ConfigMap resource according to the formatted data field;

[0129] a65. Save each formatted ConfigMap resource to its corresponding second temporary file respectively;

[0130] a66. Check whether there are any missing format errors in each second temporary file, and if so, repair the missing format errors;

[0131] a67. Save each of the second temporary files after fixing the missing formatting errors to a preset database so that the corresponding ConfigMap resources after the repair can be queried by the native standard query method next time.

[0132] It can be seen that in the cloud-edge collaboration environment, it is possible to support formatting and repairing the content with incorrect formatting in all ConfigMap resources in the cluster and save the repaired content to a preset database. That is, in addition to directly processing the specified ConfigMap resources, the Kubectl plugin also supports formatting and repairing all ConfigMap resources in the Kubernetes cluster and saving them to a preset database. The difference from the method of processing some ConfigMap resources is that since the parameter --all is detected, it indicates that all ConfigMap resources are to be formatted and repaired, so all ConfigMap resources in the cluster need to be traversed and queried. Also, the final result obtained is not a specified ConfigMap resource, but a resource group formed by each ConfigMap resource.

[0133] It can be seen that in the embodiments of the present invention, the user only needs to initiate a processing requirement for the formatting errors in the ConfigMap resources, that is, one-key processing.

[0134] The embodiments of the present invention mainly have the following beneficial effects:

[0135] 1. Using the kubectl command line to process the specified ConfigMap resources with incorrect formatting or all ConfigMap resources is more convenient and realizes one-key processing; moreover, on the basis of not destroying the original command system, additional sub-commands related to formatting repair and viewing are added, which is more efficient and integrated.

[0136] 2. Perform repair and save to a preset database after the repair, that is, realize permanent storage, and then it can be viewed and edited normally.

[0137] In a second aspect, the embodiments of the present invention provide a device for processing ConfigMap formatting errors based on cloud-edge collaboration. Refer to Figure 2 , the device 100 includes:

[0138] A command definition module 110, which is used to utilize the custom features of the kubectl plugin to add subcommands corresponding to different processing scopes and different processing methods respectively; wherein, the processing scope includes the content with incorrect format in all ConfigMap resources and the content with incorrect format in the ConfigMap resources with a specified namespace and a specified name; the processing methods include viewing after temporary format repair and format repair and saving the repaired ConfigMap resources to a preset database.

[0139] A command execution module 120, which is used to, when there is a processing requirement for incorrect ConfigMap format, process the content with incorrect format in the ConfigMap resources within the corresponding processing scope according to the subcommand corresponding to the processing requirement and in the corresponding processing method.

[0140] In one embodiment, the command definition module is specifically used to: implement the kubectl plugin; determine corresponding parameters according to different usage scenarios based on the implementation file of the kubectl plugin; wherein, the parameters include the processing scope and the processing method, and the implementation file is a shell script or an executable binary program file; generate corresponding subcommands according to the parameters; deploy the executable file containing the subcommands on the Kubernetes cluster nodes and grant executable permissions.

[0141] In one embodiment, the command execution module includes:

[0142] A first processing unit, which is used to, if the processing requirement is to view the content with incorrect format in the ConfigMap resources with a specified namespace and a specified name after temporary format repair, determine the corresponding first subcommand; execute the first subcommand to implement the following steps: query the ConfigMap resources with a specified namespace and a specified name through the native standard query method; the ConfigMap resources are in json format; extract the data fields in the queried ConfigMap resources; wherein, the form of the data fields is key-value; use a string parsing tool to format the values in the data fields; combine the keys and the formatted values in the data fields to obtain the formatted data fields, determine the formatted ConfigMap resources according to the formatted data fields, and display the formatted ConfigMap resources.

[0143] Further, before combining the key and the formatted value in the data field, the first processing unit is further configured to: convert the formats of the key and the formatted value into the yaml format; correspondingly, the process of the first processing unit combining the key and the formatted value in the data field includes: combining the key and the formatted value in the yaml format to obtain a data field in the yaml format.

[0144] In one embodiment, the command execution module includes:

[0145] A second processing unit, configured to, if the processing requirement is to repair the content with incorrect format in a ConfigMap resource with a specified namespace and a specified name and save the repaired ConfigMap resource to a preset database, determine a corresponding second sub-command; execute the second sub-command to implement the following steps: query a ConfigMap resource with a specified namespace and a specified name through a native standard query method; the ConfigMap resource is in the json format; extract the data field in the queried ConfigMap resource; wherein, the form of the data field is key-value; use a string parsing tool to format the value in the data field; combine the key and the formatted value in the data field to obtain a formatted data field, determine a formatted ConfigMap resource according to the formatted data field; save the formatted ConfigMap resource to a first temporary file; check whether there are missing format errors in the first temporary file, and if so, repair the missing format errors; save the first temporary file after repairing the missing format errors to a preset database, so that the repaired ConfigMap resource can be queried through the native standard query method next time.

[0146] Further, before combining the key and the formatted value in the data field, the second processing unit is further configured to: convert the formats of the key and the formatted value into the yaml format; correspondingly, the process of the second processing unit combining the key and the formatted value in the data field includes: combining the key and the formatted value in the yaml format to obtain a data field in the yaml format; the first temporary file is in the yaml format.

[0147] In one embodiment, the command execution module includes:

[0148] A third processing unit, configured to determine a corresponding second sub-command if the processing requirement is to repair the format of the content with incorrect format in all ConfigMap resources and save the repaired ConfigMap resources to a preset database; execute the third sub-command to implement the following steps: query all ConfigMap resources through a native standard query method; the ConfigMap resources are in json format; extract the data fields in each of the queried ConfigMap resources; wherein the form of the data fields is key-value; use a string parsing tool to format the values in the data fields in each ConfigMap resource; combine the keys and the formatted values in the data fields in each ConfigMap resource to obtain the formatted data fields in the ConfigMap resource, and determine the formatted ConfigMap resource according to the formatted data fields; save each of the formatted ConfigMap resources to their respective corresponding second temporary files; check whether there are any missing format errors in each second temporary file, and if so, repair the missing format errors; save each of the second temporary files with the repaired missing format errors to a preset database, so that the corresponding ConfigMap resources after repair can be queried through the native standard query method next time.

[0149] It can be understood that for the explanations, specific implementation manners, beneficial effects, examples, etc. of the relevant content in the device provided in the embodiments of the present invention, reference can be made to the corresponding parts in the method provided in the first aspect, which will not be elaborated here.

[0150] In a third aspect, an embodiment of the present invention provides a computer-readable medium, on which computer instructions are stored, and when the computer instructions are executed by a processor, the processor is caused to execute the method provided in the first aspect.

[0151] Specifically, a system or device equipped with a storage medium can be provided, on which software program code for implementing the functions of any one of the above embodiments is stored, and the computer (or CPU or MPU) of the system or device is caused to read and execute the program code stored in the storage medium.

[0152] In this case, the program code read from the storage medium itself can implement the functions of any one of the above embodiments, so the program code and the storage medium storing the program code constitute a part of the present invention.

[0153] Examples of storage media for providing program code include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), magnetic tapes, non-volatile memory cards, and ROMs. Optionally, the program code can be downloaded from a server computer via a communication network.

[0154] In addition, it should be clear that not only can the functions of any one of the above embodiments be realized by executing the program code read by a computer, but also by causing an operating system or the like operating on the computer to perform some or all of the actual operations based on the instructions of the program code.

[0155] Furthermore, it can be understood that the program code read from the storage medium is written into the memory provided in an expansion board inserted into the computer or into the memory provided in an expansion module connected to the computer, and then some or all of the actual operations are performed by a CPU or the like installed on the expansion board or the expansion module based on the instructions of the program code, thereby realizing the functions of any one of the above embodiments.

[0156] It can be understood that for the explanations, specific implementation manners, beneficial effects, examples, etc. of the content in the computer-readable medium provided by the embodiments of the present invention, reference can be made to the corresponding parts in the method provided in the first aspect, and details are not described herein again.

[0157] In a fourth aspect, an embodiment of this specification provides a computing device, including a memory and a processor. An executable code is stored in the memory. When the processor executes the executable code, the method in any one of the embodiments described in this specification is implemented.

[0158] It can be understood that for the explanations, specific implementation manners, beneficial effects, examples, etc. of the content in the computing device provided by the embodiments of the present invention, reference can be made to the corresponding parts in the method provided in the first aspect, and details are not described herein again.

[0159] Each embodiment in this specification is described in a progressive manner. The same or similar parts among the embodiments can be referred to each other, and the differences between each embodiment and other embodiments are emphasized. In particular, for the device embodiments, since they are basically similar to the method embodiments, the descriptions are relatively simple, and the relevant parts can be referred to the partial descriptions of the method embodiments.

[0160] Those skilled in the art should be able to realize that in one or more of the above examples, the functions described in the present invention can be implemented by hardware, software, add-ons, or any combination thereof. When implemented using software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium.

[0161] The specific embodiments described above further elaborate on the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above are only specific embodiments of the present invention and are not used to limit the protection scope of the present invention. Any modifications, equivalent replacements, improvements, etc. made on the basis of the technical solution of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for processing ConfigMap format disorders based on cloud-edge collaboration, characterized in that, The method includes: Using the custom features of the kubectl plugin to add sub-commands corresponding to different processing scopes and different processing methods respectively; wherein, the processing scope includes the content with incorrect format in all ConfigMap resources and the content with incorrect format in the ConfigMap resources with a specified namespace and a specified name; the processing methods include viewing after temporary format repair and format repair and saving the repaired ConfigMap resources to a preset database. When there is a processing requirement for incorrect ConfigMap format, according to the sub-command corresponding to the processing requirement, process the content with incorrect format in the ConfigMap resources within the corresponding processing scope according to the corresponding processing method.

2. The method according to claim 1, wherein The using the custom features of the kubectl plugin to add sub-commands corresponding to different processing scopes and different processing methods respectively includes: Implement the kubectl plugin. Based on the implementation file of the kubectl plugin, determine the corresponding parameters according to different usage scenarios; wherein, the parameters include the processing scope and the processing method, and the implementation file is a shell script or an executable binary program file. Generate the corresponding sub-commands according to the parameters. Deploy the executable file containing the sub-commands on the Kubernetes cluster nodes and grant executable permissions.

3. The method according to claim 1, characterized in that, The when there is a processing requirement for incorrect ConfigMap format, according to the sub-command corresponding to the processing requirement, process the content with incorrect format in the ConfigMap resources within the corresponding processing scope according to the corresponding processing method includes: If the processing requirement is to view the content with incorrect format in the ConfigMap resources with a specified namespace and a specified name after temporary format repair, determine the corresponding first sub-command. Execute the first sub-command to implement the following steps: Query the ConfigMap resources with a specified namespace and a specified name through the native standard query method; the ConfigMap resources are in json format. Extract the data fields in the queried ConfigMap resources; wherein, the form of the data fields is key-value. Use a string parsing tool to format the values in the data fields. Combine the keys and the formatted values in the data fields to obtain the formatted data fields, determine the formatted ConfigMap resources according to the formatted data fields, and display the formatted ConfigMap resources.

4. The method according to claim 3, wherein Before the combining the keys and the formatted values in the data fields, the method further includes: Convert the formats of the keys and the formatted values to yaml format. Correspondingly, the combining the keys and the formatted values in the data fields includes: combining the keys and the formatted values in yaml format to obtain the data fields in yaml format.

5. The method according to claim 1, characterized in that, When there is a need to process the disordered format of ConfigMap, according to the sub-command corresponding to the processing requirement, the disordered content in the ConfigMap resources within the corresponding processing range is processed according to the corresponding processing method, including: If the processing requirement is to repair the disordered content in the ConfigMap resource with a specified namespace and a specified name and save the repaired ConfigMap resource to a preset database, determine the corresponding second sub-command; Execute the second sub-command to implement the following steps: Query the ConfigMap resource with a specified namespace and a specified name through the native standard query method; the ConfigMap resource is in json format; Extract the data fields in the queried ConfigMap resource; among them, the form of the data field is key-value; Use a string parsing tool to format the values in the data fields; Combine the keys and the formatted values in the data fields to obtain the formatted data fields, and determine the formatted ConfigMap resource according to the formatted data fields; Save the formatted ConfigMap resource to a first temporary file; Check whether there are any missing format errors in the first temporary file, and if so, repair the missing format errors; Save the first temporary file after repairing the missing format errors to a preset database so that the repaired ConfigMap resource can be queried through the native standard query method next time.

6. The method according to claim 5, wherein Before combining the keys and the formatted values in the data fields, the method further includes: Convert the formats of the keys and the formatted values to yaml format; Correspondingly, combining the keys and the formatted values in the data fields includes: combining the keys and the formatted values in yaml format to obtain data fields in yaml format; Correspondingly, the first temporary file is in yaml format.

7. The method according to claim 1, wherein When there is a need to process the disordered format of ConfigMap, according to the sub-command corresponding to the processing requirement, the disordered content in the ConfigMap resources within the corresponding processing range is processed according to the corresponding processing method, including: If the processing requirement is to repair the disordered content in all ConfigMap resources and save the repaired ConfigMap resources to a preset database, determine the corresponding second sub-command; Execute the third sub-command to implement the following steps: Query all ConfigMap resources through the native standard query method; the ConfigMap resources are in json format; Extract the data fields in each of the queried ConfigMap resources; among them, the form of the data field is key-value; Use a string parsing tool to format the values in the data fields in each ConfigMap resource; Combine the key and the formatted value in the data field of each ConfigMap resource to obtain a formatted data field in the ConfigMap resource, and determine a formatted ConfigMap resource according to the formatted data field; Save each formatted ConfigMap resource to its corresponding second temporary file; Check whether there is any missing format error in each second temporary file, and if so, repair the missing format error; Each second temporary file after repairing the missed format errors is saved in the preset database, so that the corresponding ConfigMap resource that has been repaired can be queried by the native standardized query method next time.

8. A device for processing ConfigMap format disorder based on cloud-edge collaboration, characterized in that, The device comprises: A command definition module, which is used to use the custom features of the kubectl plug-in to add subcommands corresponding to different processing scopes and different processing methods; wherein the processing scope includes format disordered content in all ConfigMap resources and format disordered content in ConfigMap resources with a specified namespace and a specified name; the processing methods include viewing after temporary format repair and format repair and saving the repaired ConfigMap resources to a preset database; The command execution module is used to process the disordered format content in the ConfigMap resources within the corresponding processing range according to the subcommand corresponding to the processing requirement and the corresponding processing method when there is a processing requirement for the disordered format of the ConfigMap.

9. A computer-readable storage medium, characterized in that, A computer program is stored thereon, and when the computer program is executed in a computer, the computer is caused to execute the method according to any one of claims 1 to 7.

10. A computing device, characterized in that, The method comprises a memory and a processor, wherein the memory stores executable codes, and when the processor executes the executable codes, the method according to any one of claims 1 to 7 is implemented.