Cluster resource updating method and system and computer readable storage medium
Through the combination of reverse template and forward template, the problem of configuration information coverage in cluster resource update is solved, the standardization and standardization of configuration information is realized, the reliability of the system and the efficiency of configuration management are improved, and it is compatible with traditional resource update methods.
Patent Information
- Application Number
- CN202410708459.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-03
- Publication Date
- 2024-08-27
AI Technical Summary
When the existing technology updates cluster resources, other configuration information other than the configuration information modified by the application developer is easily overwritten, and is not compatible with the traditional resource update method. As a result, the configuration modified by the operation and maintenance personnel in the cluster is overwritten and cannot be effectively perceived. K8S resource changes.
Through the combination of reverse template and forward template, the DSL representation of the configuration field is obtained, rendered into the input configuration file, the intermediate configuration file is obtained, the differences are merged, and the output configuration file is generated to ensure that other configuration information is not overwritten during the update process and is compatible with traditional Cluster resource update method.
It ensures that configuration information modified by application developers will not be overwritten, achieves standardization and standardization, improves system reliability and configuration management efficiency, reduces system failures caused by configuration errors, and is compatible with traditional resource update methods.
Smart Images

Figure CN118550607A
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a cluster resource updating method, system and computer-readable storage medium. Background Art
[0002] At present, Kubernetes (K8S for short) has become the mainstream technology for container orchestration. If application developers deploy resources to the cluster through the cloud platform and update the resources in the cluster, using the traditional cloud platform resource update method, application developers generally submit the YAML file of K8S resources through the front-end page, or edit K8S resources through the front-end graphical interface. Application developers can modify resource attributes at will, that is, application developers edit the entire resource object definition on the front-end page, which poses a security risk. In addition, application developers directly modify resources in the cluster, and cannot perceive the changes of K8S resources through one-way template updates, resulting in the configuration directly modified by application operation and maintenance personnel in the cluster being overwritten. In the traditional cloud platform resource update method, if the application operation and maintenance personnel or cluster administrator modifies a configuration information in the cluster, but the modified configuration information does not appear in the one-way template, when the application developer uses the one-way template to update the resources in the cluster, other configurations other than the configuration information will be overwritten, resulting in the disadvantage of incompatibility with the traditional resource update method. Summary of the invention
[0003] The technical problem to be solved by the present invention is to overcome the shortcomings of the prior art. The first purpose of the present invention is to provide a cluster resource update method. By processing the intermediate configuration file through a reverse template and a forward template, other configuration information other than the configuration field will not be overwritten during the update process; in addition, the first difference between the input configuration file and the bidirectional rendering configuration file is merged into the intermediate configuration file to obtain the output configuration file, which is sent to the cluster for processing. This update method is compatible with the traditional cluster resource update method.
[0004] In order to solve the above technical problems, the basic concept of the technical solution adopted by the present invention is:
[0005] A cluster resource updating method, comprising:
[0006] Get the DSL representation of the configuration fields;
[0007] The DSL representation of the configuration field is the input configuration file obtained through forward template rendering;
[0008] Get the intermediate configuration file from the cluster based on the metadata in the DSL representation of the configuration fields;
[0009] The intermediate configuration file is rendered by reverse template and forward template in turn to obtain a bidirectional rendering configuration file;
[0010] Get the first difference between the input configuration file and the bidirectional rendering configuration file;
[0011] The first difference is merged into the intermediate configuration file to obtain the output configuration file, and the output configuration file is sent to the cluster.
[0012] Preferably, the DSL representation of the configuration field includes data modified by the application developer.
[0013] Preferably, before obtaining the DSL representation of the configuration field, the method further includes:
[0014] Get the DSL representation of the current resource object, and get the DSL representation of the configuration field according to the DSL representation of the current resource object.
[0015] Preferably, obtaining the DSL representation of the configuration field according to the DSL representation of the current resource object specifically includes:
[0016] Obtain the configuration file to be configured from the cluster, render the configuration file to be configured into a DSL representation of the configuration file through a reverse template, modify the data of the DSL representation of the configuration file to be configured, and obtain the DSL representation of the configuration field;
[0017] Among them, modifying the data represented by the DSL of the configuration file to be configured is an operation performed by the application developer.
[0018] Preferably, the DSL representation of the current resource object is obtained by using a client tool.
[0019] Preferably, the client tools include the kubectl command line and the Kubernets API.
[0020] Preferably, the kubectl command line includes a kubectl get command. Preferably, after obtaining the intermediate configuration file from the cluster according to the metadata in the DSL representation of the configuration field, it also includes:
[0021] Compare the fields of the input configuration file and the intermediate configuration file. If the fields of the two are inconsistent, re-acquire the DSL representation of the current resource object until the two are consistent, and then allow the cluster resource update method to be executed. Preferably, the fields of the input configuration file include the first resourceVersion field and the first generation field, and the fields of the intermediate configuration file include the second resourceVersion field and the first generation field;
[0022] By judging whether the first field of resourceVersion corresponds to the second field of resourceVersion or the first field of generation corresponds to the second field of generation, if so, the cluster resource update method is allowed to be executed, if not, the DSL representation of the current resource object is re-acquired.
[0023] Preferably, obtaining a first difference between the input configuration file and the two-way rendering configuration file; specifically, obtaining the first difference by calling a CreateTwoWayMergeMapPatch method in an SDK component of the cluster;
[0024] The above method can be obtained from the k8s.io / apimachinery / pkg / util / strategicpatch library.
[0025] Preferably, merging the first difference into the intermediate configuration file to obtain the output configuration file specifically includes obtaining the output configuration file by calling the StrategicMergePatch method in the SDK component of the cluster;
[0026] The above method can be obtained from the k8s.io / apimachinery / pkg / util / strategicpatch library.
[0027] Preferably, the reverse template converts the YAML file format or JSON file format of the resource object into a DSL representation of the configuration fields of the resource object.
[0028] Preferably, the forward template is used to convert the DSL representation of the configuration fields of the resource object into the YAML file format or the JSON file format of the resource object.
[0029] A second object of the present invention is to provide a system for a cluster resource update method, the system comprising:
[0030] A first acquisition module is used to acquire a DSL representation of a configuration field modified by an application developer;
[0031] The first processing module renders the DSL representation of the configuration field through a forward template to obtain an input configuration file;
[0032] The second processing module obtains the intermediate configuration file from the cluster according to the metadata in the DSL representation of the configuration field;
[0033] The third processing module renders the intermediate configuration file through the reverse template and the forward template in sequence to obtain a bidirectional rendering configuration file;
[0034] A second acquisition module acquires a first difference between the input configuration file and the bidirectional rendering configuration file;
[0035] The fourth processing module merges the first difference into the intermediate configuration file to obtain an output configuration file, and sends the output configuration file to the cluster.
[0036] The third object of the present invention is to provide a computer-readable storage medium, which includes a computer program, and when the computer program is executed by one or more computers, the one or more computers perform the following operations: the operations include the steps of the cluster resource update method.
[0037] After adopting the above technical scheme, the present invention has the following beneficial effects compared with the prior art.
[0038] By processing the input configuration file through reverse templates and forward templates, it is ensured that other configuration information other than the application developer's configuration will not be overwritten during the update process, thereby being compatible with traditional cluster resource update methods such as directly submitting YAML or JSON files; at the same time, through the cooperation of reverse templates and forward templates, it can be ensured that the configuration information modified by the application developer can be standardized and normalized, and is feasible in the enterprise's large-scale multi-cluster deployment architecture.
[0039] By using the reverse template and the forward template together, the configuration process can be tracked and located more easily during the update process. If an error occurs in a certain link, the problem can be located by checking the results of the template conversion, thus speeding up troubleshooting.
[0040] The input configuration file is obtained by rendering the DSL representation of the configuration field through a forward template, and the intermediate configuration file is obtained from the cluster according to the metadata in the DSL representation of the configuration field. The intermediate configuration file is sequentially rendered through a reverse template and a forward template to obtain a bidirectional rendering configuration file; the first difference between the input configuration file and the bidirectional rendering configuration file is obtained, the first difference is merged into the intermediate configuration file to obtain the output configuration file, and the output configuration file is sent to the cluster to ensure that the output configuration file is verified and corrected, which helps to reduce system failures caused by configuration errors and improves system reliability.
[0041] The specific implementation modes of the present invention are further described in detail below in conjunction with the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0043] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0044] Figure 1 It is a flowchart of a cluster resource update method of the present application;
[0045] Figure 2 It is a flowchart of another cluster resource update method of the present application;
[0046] Figure 3 It is a schematic diagram of the structure of a system of a cluster resource updating method of the present application. DETAILED DESCRIPTION
[0047] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0048] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0049] like Figure 1 As shown, according to one aspect of an embodiment of the present application, a cluster resource update method is provided, comprising:
[0050] Get the DSL representation of the configuration fields;
[0051] The DSL representation of the configuration field includes data modified by the application developer.
[0052] Specifically, the configuration fields modified by the application developer are converted into DSL (Domain Specific Language). DSL is a language defined in the cluster. DSL provides a more concise way to express configuration fields, reducing redundancy and complexity. Application developers can use less code and more intuitive syntax to define resource objects. At the same time, DSL usually has clearer semantics and easier-to-understand syntax structure, which makes the configuration file easier to read and understand. Using DSL can ensure the consistency and standardization of configuration fields and reduce the possibility of configuration errors and inconsistencies.
[0053] like Figure 2 As shown, preferably, before obtaining the DSL representation of the configuration field, the method further includes:
[0054] Get the DSL representation of the current resource object, and get the DSL representation of the configuration field according to the DSL representation of the current resource object.
[0055] Preferably, obtaining the DSL representation of the configuration field according to the DSL representation of the current resource object specifically includes:
[0056] The configuration file to be configured is obtained from the cluster, the configuration file to be configured is rendered into a DSL representation of the configuration file through a reverse template, and the data of the DSL representation of the configuration file to be configured is modified to obtain a DSL representation of the configuration field.
[0057] Preferably, the reverse template converts the YAML file format or JSON file format of the resource object into a DSL representation of the configuration fields of the resource object.
[0058] Among them, the resource object mainly includes two parts of data, one is configuration data, and the other is metadata. In order to more effectively manage and maintain resource objects, the present invention divides the configuration data of resource objects into two parts according to the responsibilities of different roles, namely, the configuration fields of application developers and the configuration fields of platform operation and maintenance personnel.
[0059] Furthermore, the configuration fields of the application developer mainly involve configuration items directly related to the application business logic and functions, such as the application's port settings, environment variables, service discovery parameters, etc. The application developer is responsible for setting and modifying these fields according to the application's needs and characteristics to ensure that the application can run correctly and meet business needs.
[0060] The configuration fields of platform operators mainly involve configuration items related to the deployment, monitoring, management, and security of resource objects, such as resource quotas, security policies, log collection, etc. Platform operators are responsible for setting and maintaining these fields to ensure the stable operation and security of resource objects in the cluster. Through this subdivision, not only the responsibilities of different roles in resource object configuration are clarified, but also the efficiency and accuracy of configuration management are improved. Application developers can focus on the implementation of business logic, while platform operators can focus on the deployment, monitoring, and security management of resources. This division of labor makes the entire resource object management process clearer, more efficient, and more controllable.
[0061] Metadata provides descriptive information about configuration data, which is used to describe the attributes, structure, content, source, context, relationships, etc. of configuration data, so as to facilitate the understanding and management of configuration data.
[0062] Preferably, obtaining the DSL representation of the current resource object by using a client tool;
[0063] Preferably, the client tools include the kubectl command line and the Kubernets API;
[0064] Preferably, the kubectl command line includes a kubectl get command.
[0065] Furthermore, you can use the kubectl get command and specify the -o yaml or -o json option to get the DSL representation of the resource object.
[0066] In the cluster resource update method, the DSL representation of the configuration field is rendered through the forward template to obtain the input configuration file;
[0067] Specifically, the forward template is used to convert the DSL representation of the configuration fields of the application developer in the resource object into the YAML file format or JSON file format of the resource object, that is, the format of the input configuration file is in the YAML file format or JSON file format. The DSL representation of the configuration fields of the application developer, after being rendered by the forward template and then rendered by the reverse template again, still obtains the DSL representation of the configuration fields of the application developer before being rendered by the forward and reverse templates.
[0068] Furthermore, the forward template provides a standard structure and format to ensure that each configuration file processed by the forward template complies with the same specifications, and converts the DSL representation of the configuration fields modified by the application developer into an input configuration file in YAML or JSON format that is easy to read, parse, and manage, thereby improving the readability and maintainability of the configuration file processed by the forward template and providing standardized data support for subsequent resource configuration and management.
[0069] In addition, the use of forward templates can significantly improve processing efficiency. Application developers only need to fill in the fields specified in the forward template without having to write the entire file from scratch, which reduces the complexity of the processing process and further simplifies the maintenance process.
[0070] Reverse templates and forward templates can be written according to the Helm specification, that is, both reverse templates and forward templates are rendered through the Render method of helm.sh / helm / v3 / pkg / engine in the Helm SDK (Software Development Kit). Reverse templates and forward templates can also be rendered through the text / template (Software Development Kit) built into the Go language.
[0071] Among them, Helm is the standard for Kubernets service orchestration implementation, mainly used to manage char packages. Helm is the package manager of Kubernets, similar to apt in Ubuntu, yum in CentOS or pip in Python, which can quickly find, download and install software packages. As a command line tool, Helm is mainly used for the creation, packaging, release and management of Kubernets application charts.
[0072] In the cluster resource update method, the intermediate configuration file is obtained from the cluster according to the metadata in the DSL representation of the configuration field;
[0073] Specifically, obtaining the intermediate configuration file includes the following steps:
[0074] Parse the DSL representation of the configuration fields and extract the configuration metadata from it;
[0075] Use these configuration metadata to construct a query request, which will be sent to the cluster's API Server;
[0076] After receiving the query request, the cluster's API Server will parse it and use the query API provided within the cluster to search in the etcd database within the cluster;
[0077] By querying the etcd database, the API Server will find resources that match the query request, including but not limited to specific Pod, Deployment, and Service Kubernets objects.
[0078] Once the API Server finds resources that match the request, it returns information about these resources to the initiator of the query request.
[0079] The etcd database is a distributed key-value storage system that stores configuration data. The API Server of the cluster interacts with etcd to read and update the status information of the cluster. When application developers request to modify the current configuration information, they can write the changed configuration information to etcd through the API Server. Other components in the cluster, such as Kubelet and Controller Manager, can also monitor the data in etcd through the API Server to obtain the current status of the configuration information changed by the application developer. This mechanism ensures that all components in the cluster can maintain a consistent understanding of the configuration information, thereby achieving efficient resource management and scheduling. Preferably, after obtaining the intermediate configuration file from the cluster according to the metadata in the DSL representation of the configuration field, it also includes:
[0080] Compare the fields of the input configuration file and the intermediate configuration file. If the fields of the two are inconsistent, re-obtain the DSL representation of the current resource object until the two are consistent, and then allow the cluster resource update method to be executed.
[0081] Preferably, the fields of the input configuration file include a resourceVersion first field and a generation first field, and the fields of the intermediate configuration file include a resourceVersion second field and a generation second field.
[0082] Further, read the first resourceVersion field of the input configuration file and the second resourceVersion field of the intermediate configuration file, or read the first generation field of the input configuration file and the second generation field of the intermediate configuration file; field comparison: if the first resourceVersion field is not equal to the second resourceVersion field; or the first generation field is not equal to the second generation field, there is a version difference or configuration difference between the input configuration file and the intermediate configuration file, then re-acquire the DSL representation of the current resource object; if there is no field inconsistency between the first resourceVersion field and the second resourceVersion field, or between the first generation field and the second generation field, then allow the cluster resource update method to be executed. Among them, resourceVersion is an important field used to ensure the order and consistency of concurrent operations, and is usually used with an optimistic locking mechanism to detect and avoid conflicts when multiple application developers try to modify the same resource at the same time. ResourceVersion represents the internal version identifier of each object in the cluster. Whenever the configuration of the object changes, the value of the resourceVersion field increases and changes.
[0083] The generation field is a metadata field in Kubernetes, which is used to track the current spec version of the resource object. The generation field is a unique version identifier in some field objects such as Deployment and ReplicaSet. It increases as the spec of the resource definition changes. It is used to track the spec changes of the resource definition for resource objects such as Deployment and ReplicaSet.
[0084] By viewing the generation field, you can understand how many times the resource object's spec has been updated. In addition, for Deployment, the generation field is usually used together with the status.observedGeneration field to ensure that the latest spec is applied. If status.observedGeneration lags behind generation, it means that it is still in the update stage or is not currently being updated.
[0085] In the cluster resource update method, the intermediate configuration file is rendered by the reverse template and the forward template in sequence to obtain a bidirectional rendering configuration file; the forward template is used to recombine the data processed by the reverse template to form a complete bidirectional rendering configuration file.
[0086] Specifically, read the intermediate configuration file, use the reverse template to process the intermediate configuration file, extract key fields from the intermediate configuration file, and remove other fields that are not directly modified during the update process. Other fields that are not directly modified can use special tags or store them in a temporary data structure.
[0087] The intermediate configuration file is processed by the reverse template and the forward template in turn to obtain a bidirectional rendering configuration file. The purpose of processing the intermediate configuration file by the reverse template and the forward template is to ensure that other fields that are not directly modified in the intermediate configuration file are eliminated during the update process, so that the eliminated configuration fields can be retained and will not be overwritten during the update process, providing conditions for the next update step.
[0088] The bidirectional rendering configuration file and the intermediate configuration file are both in YAML format or JSON format.
[0089] In the cluster resource update method, a first difference between the input configuration file and the bidirectional rendering configuration file is obtained;
[0090] Specifically, the first difference is obtained by calling the CreateTwoWayMergeMapPatch method of the library in the SDK component of the cluster. This method can ensure the reliability of the obtained first difference. The above method can be obtained from the k8s.io / apimachinery / pkg / util / strategicpatch library.
[0091] The above method can generate a patch that describes the first difference between the input configuration file and the bidirectional rendering configuration file.
[0092] The first differences between the input profile and the bidirectional rendering profile include,
[0093] Content comparison: The backend server will compare line by line or field by field to check whether there are any differences in the key-value pairs between the input configuration file and the bidirectional rendering configuration file, including checking whether there are any key-value pair differences, newly added, deleted or modified fields, and whether the values of these fields have changed;
[0094] Structural comparison, including but not limited to the format and organizational structure of the files, such as checking whether the formats of the input configuration file and the bidirectional rendering configuration file are consistent; the organizational structure refers to the internal organizational structure between the input configuration file and the bidirectional rendering configuration file, which can be the hierarchical relationship, array, and sorting of the fields between the two;
[0095] Semantic comparison, including instruction parsing, functional comparison, logical consistency comparison, and dependency relationships;
[0096] Instruction parsing: Parse and understand the instructions and configurations of the input configuration file and the bidirectional rendering configuration file to determine whether there is any semantic difference between the two.
[0097] Functional comparison: compare the functional differences between the input profile and the bidirectional rendering profile, such as service binding, rule routing, and permission settings;
[0098] Logical consistency: Verify whether the input configuration file and the bidirectional rendering configuration file are logically consistent, for example, whether there are conflicting or inconsistent configuration items;
[0099] Dependencies: Analyze the dependencies in the input profiles and the dependencies of the bidirectional rendering profiles to ensure that these dependencies are not broken during the update process.
[0100] Once a discrepancy is found, the processor can fully evaluate the differences between the input profile and the bidirectional rendering profile and generate a difference report based on the differences, detailing the differences between the two.
[0101] In order to obtain the first difference between the input configuration file and the bidirectional rendering configuration file more specifically, you can use a text comparison tool to compare the contents of the input configuration file and the bidirectional rendering configuration file. In the Kubernetes environment, since the input configuration file and the bidirectional rendering configuration file are usually in YAML format, the text comparison tool can well display the differences between the input configuration file and the bidirectional rendering configuration file.
[0102] Text comparison tools include but are not limited to diff, Beyond Compare, and DiffMerge.
[0103] In addition, if you use a version control system (such as Git), you can also use the version control system's functions to compare the differences in configuration files between different versions or branches.
[0104] In the cluster resource update method, the first difference is merged into the intermediate configuration file to obtain the output configuration file, and the output configuration file is submitted to the cluster.
[0105] Specifically, the first difference between the input configuration file and the bidirectional rendering configuration file is parsed to obtain the fields and values that need to be merged into the intermediate configuration file; then, the first difference after parsing is merged into the intermediate configuration file through a specific programming method. During the merging process, if a conflict occurs, the conflict is resolved according to the instructions in the difference report. Once the conflict is resolved, an output configuration file is generated. Finally, the output configuration file is obtained by calling the StrategicMergePatch method of the library in the SDK component of the cluster. The above method can be obtained from the k8s.io / apimachinery / pkg / util / strategicpatch library.
[0106] Similarly, the output configuration file is in YAML format or JSON format. Before sending the output configuration file to the cluster, the backend server will verify the generated output configuration file to ensure that the format of the output configuration file is correct and meets the configuration requirements of K8S, verify the integrity and accuracy of the output configuration file, and ensure that there are no unexpected modifications or missing configuration items. After the verification, the output configuration file can be sent to the cluster for processing. After sending the output configuration file, monitor the response and changes of the cluster to verify whether the configuration has been successfully applied and effective. If an error or exception is encountered during the sending process, perform corresponding processing according to the error information, such as retry, rollback, and other operations.
[0107] In addition, you can choose different sending methods to send output configuration files to the cluster according to the environment and toolset. Common sending methods include but are not limited to the kubectl command line tool, Kubernetes client library (such as Kubernetes Python client) or CI / CD process.
[0108] Further, the kubectl command line tool:
[0109] Use kubectl apply -f <output-config-file>The .yaml command applies the output configuration file to the cluster.
[0110] Kubernetes client library: Use programming methods (such as Python and Go) to use the corresponding Kubernetes client library to read the output configuration file and use the API provided by the library to apply the configuration to the cluster.
[0111] Before merging differences and sending configuration files, it is best to test them in a non-production environment to ensure the correctness and reliability of the output configuration files. If the configuration files contain sensitive information (such as passwords, keys, etc.), please ensure that appropriate security measures are taken during the merge and submission process, such as encryption, access control, etc. If the configuration files are large or contain complex structures, it may be more convenient and efficient to use a version control system (such as Git) to manage changes and differences in the configuration files.
[0112] The output configuration file is sent to the cluster. Specifically, the processor submits the obtained output configuration file to the cluster's API Server through the Update API provided by the cluster. After the API Server processes the Update API request, it returns a response to the processor. After the processor receives and parses the response from the API Server, it returns the received response to the application developer.
[0113] Furthermore, the cluster will verify the output configuration file. After the verification, the output configuration file will be parsed into a K8S API object through the K8S API server. After successful parsing, the output configuration file will be stored in etcd. The controller in the K8S cluster will read the resource status of etcd and create or update the corresponding ReplicaSet and Pod.
[0114] For Pod resources, the scheduler of the K8S cluster will select a suitable node to run the Pod based on the resource usage of each node in the cluster, the scheduling strategy of the Pod, etc. After receiving the task assigned by the scheduler, the Kubelet on the node will download the container image defined in the Pod, and create and start the container according to the configuration of the Pod. The content of starting the container is an existing technology and will not be repeated in detail.
[0115] like Figure 3 As shown, the present invention also provides a system for cluster resource update method, the system comprising:
[0116] A first acquisition module 10 is used to acquire a DSL representation of a configuration field modified by an application developer;
[0117] The first processing module 20 renders the DSL representation of the configuration field through a forward template to obtain an input configuration file;
[0118] The second processing module 30 obtains an intermediate configuration file from the cluster according to metadata in the DSL representation of the configuration field;
[0119] The third processing module 40 renders the intermediate configuration file through the reverse template and the forward template in sequence to obtain a bidirectional rendering configuration file;
[0120] A second acquisition module 50 acquires a first difference between the input configuration file and the bidirectional rendering configuration file;
[0121] The fourth processing module 60 merges the first difference into the intermediate configuration file to obtain an output configuration file, and sends the output configuration file to the cluster.
[0122] The present invention also provides a computer-readable storage medium, which includes a computer program. When the computer program is executed by one or more computers, the one or more computers perform the following operations: the operations include the steps of the cluster resource update method.
[0123] The specific implementation of the computer-readable storage medium is substantially the same as the above cluster resource update method, and will not be described in detail herein.
[0124] The present invention processes the input configuration file through reverse templates and forward templates to ensure that other configuration information other than the application developer's configuration will not be overwritten during the update process, thereby being compatible with traditional cluster resource update methods such as directly submitting YAML or JSON files; at the same time, through the cooperation of reverse templates and forward templates, it can ensure that the configuration information modified by the application developer can be standardized and normalized, and is feasible in the enterprise's large-scale multi-cluster deployment architecture.
[0125] The present invention adopts the cooperation of reverse template and forward template, which can more easily track and locate the configuration process during the update process. If an error occurs in a certain link, the problem can be located by checking the result of template conversion, thereby speeding up the troubleshooting.
[0126] The present invention obtains an input configuration file by rendering a DSL representation of a configuration field through a forward template, obtains an intermediate configuration file from a cluster according to metadata in the DSL representation of the configuration field, and successively renders the intermediate configuration file through a reverse template and a forward template to obtain a bidirectional rendering configuration file; obtains a first difference between the input configuration file and the bidirectional rendering configuration file, merges the first difference into the intermediate configuration file, obtains an output configuration file, and sends the output configuration file to the cluster to ensure that the output configuration file is verified and corrected, which helps to reduce system failure problems caused by configuration errors and improves system reliability.
[0127] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A cluster resource update method, It is characterized in that include, Get the DSL representation of the configuration fields; The DSL representation of the configuration field is the input configuration file obtained through forward template rendering; Get the intermediate configuration file from the cluster based on the metadata in the DSL representation of the configuration fields; The intermediate configuration file is rendered by reverse template and forward template in turn to obtain a bidirectional rendering configuration file; Get the first difference between the input configuration file and the bidirectional rendering configuration file; The first difference is merged into the intermediate configuration file to obtain the output configuration file, and the output configuration file is sent to the cluster.
2. The cluster resource updating method according to claim 1, It is characterized in that Before getting the DSL representation of the configuration fields, also include, Get the DSL representation of the current resource object, and get the DSL representation of the configuration field according to the DSL representation of the current resource object.
3. The cluster resource updating method according to claim 2, It is characterized in that Get the DSL representation of the configuration field according to the DSL representation of the current resource object, including: The configuration file to be configured is obtained from the cluster, the configuration file to be configured is rendered into a DSL representation of the configuration file through a reverse template, and the data of the DSL representation of the configuration file to be configured is modified to obtain a DSL representation of the configuration field.
4. The cluster resource updating method according to claim 2, It is characterized in that Get the DSL representation of the current resource object by using the client tool.
5. The cluster resource updating method according to claim 1, It is characterized in that After fetching the intermediate configuration file from the cluster based on the metadata in the DSL representation of the configuration fields, it also includes, Compare the fields of the input configuration file and the intermediate configuration file. If the fields of the two are inconsistent, re-obtain the DSL representation of the current resource object until the two are consistent, and then allow the cluster resource update method to be executed.
6. The cluster resource updating method according to claim 5, It is characterized in that The fields of the input configuration file include the first resourceVersion field and the first generation field, and the fields of the intermediate configuration file include the second resourceVersion field and the first generation field; By judging whether the first field of resourceVersion corresponds to the second field of resourceVersion or the first field of generation corresponds to the second field of generation, if so, the cluster resource update method is allowed to be executed, if not, the DSL representation of the current resource object is re-acquired.
7. The cluster resource updating method according to claim 1, It is characterized in that The reverse template converts the YAML file format or JSON file format of the resource object into a DSL representation of the configuration fields of the resource object.
8. The cluster resource updating method according to claim 1, It is characterized in that The forward template is used to convert the DSL representation of the configuration fields of a resource object into the YAML file format or JSON file format of the resource object.
9. A system for cluster resource update method, It is characterized in that The system comprises, A first acquisition module is used to acquire a DSL representation of a configuration field; The first processing module renders the DSL representation of the configuration field through a forward template to obtain an input configuration file; The second processing module obtains the intermediate configuration file from the cluster according to the metadata in the DSL representation of the configuration field; The third processing module renders the intermediate configuration file through the reverse template and the forward template in sequence to obtain a bidirectional rendering configuration file; A second acquisition module acquires a first difference between the input configuration file and the bidirectional rendering configuration file; The fourth processing module merges the first difference into the intermediate configuration file to obtain an output configuration file, and sends the output configuration file to the cluster.
10. A computer-readable storage medium, the computer-readable storage medium comprising a computer program, It is characterized in that When the computer program is executed by one or more computers, the one or more computers perform the following operations: the operations include the steps of the cluster resource updating method according to any one of claims 1 to 8.
Citation Information
Cited By
Application configuration update comparison method and comparison device based on Helm
CN119829161A
