A transaction control method and device for k8s declarative resources

By setting timers, resource monitors and reverse operation pools on the cloud management platform, the status of Kubernetes resources is monitored and controlled in real time, and the problem that transactions of Kubernetes declarative resources cannot be directly managed and controlled through the cloud management platform is solved, and operations that are more in line with the design principles of cloud management platform and higher resource integration capabilities are achieved.

CN114138592BActive Publication Date: 2025-05-16JINAN INSPUR DATA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111265683.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-28
Publication Date
2025-05-16
Estimated Expiration
2041-10-28

AI Technical Summary

Technical Problem

The transactions of existing Kubernetes declarative resources cannot be directly managed and controlled through the cloud management platform, resulting in the Kubernetes cluster being in the middle of the tuner for a long time in some cases, which violates the design principles of the cloud management platform.

Method used

Provide a transaction control method and device for k8s declarative resources, obtain Kubernetes resources that require operation control through the cloud management platform, and set a timer, resource monitor and reverse operation pool. The monitor monitors resource changes in real time to determine whether the resource reaches the expected state. If it is reached, the timer task will be terminated; if it is not reached, the reverse operation control task of the reverse operation pool will be triggered, and the resource will be restored to the original state.

Benefits of technology

This makes the cloud management platform's operation of Kubernetes container cluster more in line with the design principles of the cloud management platform, and users can obtain operation results more clearly, improving the resource integration capabilities of the cloud resource management platform.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114138592B_ABST
    Figure CN114138592B_ABST
Patent Text Reader

Abstract

The present invention provides a transaction control method and device for k8s declarative resources, belonging to the technical field of cluster management of cloud platforms, and the method steps are as follows: a cloud management platform obtains k8s resources that need operation control, and sets a timer, a resource monitor, and a reverse operation pool according to the type of operation control; the cloud management platform monitors resource changes in the k8s cluster through the resource monitor, and identifies resource changes caused by operation control; the cloud management platform determines whether the k8s resources reach an expected state within the cycle of the timer according to the resource changes, and ends the timer task when the expected state is reached, and triggers the reverse operation control task of the reverse operation pool when the expected state is still not reached at the end of the timer cycle, and restores the original state of the k8s resources. The present invention makes the cloud management platform's operation on the k8s container cluster more in line with the design principles of the cloud management platform, so that users can obtain the results of the operation more clearly and concisely.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of cluster management of cloud platforms, and specifically relates to a transaction control method and device for k8s declarative resources. Background Art

[0002] Kubernetes, referred to as k8s, is an open source container cluster management system from Google. It provides a series of complete functions such as deployment and operation, resource scheduling, service discovery and dynamic scaling for containerized applications, which improves the convenience of large-scale container cluster management. A core feature of Kubernetes is that it can manage containers autonomously to ensure that containers in the cloud platform run according to the user's expectations. For example, if the user wants the web service software apache to run all the time, the user does not need to worry about how to do it. Kubernetes will automatically monitor, restart, and create a new one. In short, let apache always provide services. This is also a manifestation of Kubernetes based on declarative API. API objects are management and operation units in K8s clusters. Each API object has three categories of attributes: metadata, specifications, and status. Metadata is used to identify API objects. Each object has at least three metadata: namespace, name, and unified number; in addition, there are various tags to identify and match different objects. The specification describes the ideal state that users expect the distributed system in the Kubernetes cluster to achieve. For example, users can set the expected number of Pod replicas to 3 through the replication controller. The state describes the actual current state of the system. For example, the current actual number of Pod replicas in the system is 2. Then the current program logic of the replication controller is to automatically start a new Pod and strive to achieve 3 replicas. All configurations in Kubernetes are set through the specification of API objects, that is, users change the system by configuring the ideal state of the system. This is one of the important design concepts of Kubernetes, that is, all operations are declarative rather than imperative. The benefit of declarative operations in distributed systems is stability, and there is no fear of losing operations or running multiple times. For example, the operation of setting the number of replicas to 3 will still have the same result after running multiple times, while the operation of adding 1 to the number of replicas is not declarative, and the result will be wrong after running multiple times. Pod is a container. In essence, we can create containers, add containers to Pods, and use them as an "API" for others to use. This API is different from the normal Web API and is more like an abstract API that other Pods can use.

[0003] The cloud management platform is an integrated product for managing public cloud, private cloud and hybrid cloud environments. Its main functional scope includes the integration of multiple infrastructures and resources, cross-platform orchestration, etc. Users can manage multiple cloud resource clusters, such as Kubernetes clusters, through the cloud management platform. As a traditional IT portal, the cloud management platform's operation requirements meet the four characteristics of transactions: atomicity, consistency, isolation, and permanence. Atomicity requires that all operations in a transaction are either completed or not completed. It will not end and stay in an intermediate link. If an error occurs during the execution of a transaction, it will be rolled back to the state before the transaction started, as if the transaction had never been executed; consistency means that the database must be in a consistent state before and after the execution of a transaction. If the transaction is successfully completed, all changes in the system will be correctly applied and the system will be in a valid state. If an error occurs in the transaction, all changes in the system will be automatically rolled back and the system will return to its original state.

[0004] The core design of k8s is obviously inconsistent with the design principles of the cloud management platform. In some cases, k8s will be in the intermediate state of the tuner for a long time, and the operating principle of the cloud management platform is transactional, successful or failed rollback. Therefore, the existing Kubernetes declarative resource transactions cannot be directly managed and controlled through the cloud management platform.

[0005] This is a shortcoming of the prior art. Therefore, in view of the above-mentioned defects in the prior art, it is very necessary to provide a transaction control method and device for k8s declarative resources. Summary of the invention

[0006] In view of the defect in the prior art that the transactions of the above-mentioned existing Kubernetes declarative resources cannot be directly managed and controlled through the cloud management platform, the present invention provides a transaction control method and device for k8s declarative resources to solve the above-mentioned technical problem.

[0007] In a first aspect, the present invention provides a transaction control method for k8s declarative resources, comprising the following steps:

[0008] S1. The cloud management platform obtains the Kubernetes resources that require operation control, and sets timers, resource monitors, and reverse operation pools according to the type of operation control;

[0009] S2. The cloud management platform monitors resource changes in the Kubernetes cluster through resource monitors and identifies resource changes caused by operational control;

[0010] S3. The cloud management platform determines whether the Kubernetes resources have reached the expected state within the timer period based on the resource changes, and ends the timer task when the expected state is reached. If the expected state is still not reached at the end of the timer period, the reverse operation control task of the reverse operation pool is triggered to restore the original state of the Kubernetes resources.

[0011] Furthermore, the specific steps of step S1 are as follows:

[0012] S11. The cloud management platform obtains the Kubernetes resources that need to be operated and the types of operation control;

[0013] S12. The cloud management platform obtains the successful completion time of the existing operation of the operation control type as sample data according to the type of operation control, and sets the timer period according to the sample data;

[0014] S13. The cloud management platform sets a resource monitor to record the resources in the Kubernetes cluster, and compares the difference between the resources in the Kubernetes cluster recorded this time and the resources in the Kubernetes cluster recorded last time, and identifies the resource changes;

[0015] S14. The cloud management platform obtains the reverse operation set corresponding to the changes in the Kubernetes resources and their sub-resources caused by the operation control, and generates a reverse operation pool. Before the operation control is performed on the Kubernetes resources, a timer cycle, a resource monitor, and a reverse operation pool are set.

[0016] Furthermore, the specific steps of step S12 are as follows:

[0017] S121. The cloud management platform obtains the completion time of each successful operation corresponding to the operation control, and generates sample data;

[0018] S122. The cloud management platform calculates the average value of each completion time and the variance of each completion time in the sample data, and uses the average value as the estimated time and the variance as the allowable deviation time;

[0019] S123. The cloud management platform uses the sum of the estimated time and the allowable deviation time as the cycle of the timer. The successful completion time of the existing operation control is used as a sample to estimate the time to complete the operation control as the cycle of the timer.

[0020] Furthermore, the specific steps of step S2 are as follows:

[0021] S21. The cloud management platform detects resource changes in the Kubernetes cluster through resource monitors;

[0022] S22. The cloud management platform detects whether the corresponding specification and status of the operation control have changed according to the type of operation control;

[0023] S23. The cloud management platform detects, based on the type of operation control, whether the replica set of the replica controller corresponding to the operation control has changed and whether the number of pods of the sub-resources corresponding to the replica set has changed;

[0024] S24. The cloud management platform records the changed resources in sequence. The cloud management platform monitors the resource changes of the cloud management platform through the changes of the replicas.

[0025] Furthermore, the specific steps of step S3 are as follows:

[0026] S31. The cloud management platform determines whether the state of resources in the Kubernetes cluster reaches the expected state according to resource changes within the timer period;

[0027] If yes, go to step S32;

[0028] If not, proceed to step S33;

[0029] S32. The cloud management platform ends the timer task, determines that the operation control is successful, and records the operation control time, adds the operation control time to the sample data, and ends;

[0030] S33. The cloud management platform determines that the operation control has failed, starts the resource rollback task, finds the corresponding reverse operation set in the reverse operation pool, and rolls back the resources according to the reverse steps until the Kubernetes resources are restored to their original state. If the resources reach the expected state within the timer period, the operation control is determined to be completed, and the operation control time is recorded. If the expected time is not reached, the resource state is rolled back to prevent the operation control from failing and the resource state cannot be restored.

[0031] Furthermore, in step S12, the sample data is the completion time of a set number of successful operations before the current time, or the completion time within a set time period before the current time.

[0032] In a second aspect, the present invention provides a transaction control device for k8s declarative resources, comprising:

[0033] The operation control environment configuration module is used by the cloud management platform to obtain Kubernetes resources that require operation control and set timers, resource monitors, and reverse operation pools according to the type of operation control;

[0034] The resource monitoring module is used by the cloud management platform to monitor resource changes in the Kubernetes cluster through resource monitors and identify resource changes caused by operational control;

[0035] The k8s transaction control module is used by the cloud management platform to determine whether the Kubernetes resources have reached the expected state within the timer cycle based on resource changes, and to end the timer task when the expected state is reached. If the expected state is still not reached at the end of the timer cycle, the reverse operation control task of the reverse operation pool is triggered to restore the original state of the Kubernetes resources.

[0036] Furthermore, the operation control environment configuration module includes:

[0037] The resource and operation acquisition unit is used by the cloud management platform to obtain the Kubernetes resources and types of operation control that need to be controlled;

[0038] A timer cycle setting unit is used for the cloud management platform to obtain the successful completion time of existing operations of the type of operation control as sample data according to the type of operation control, and set the cycle of the timer according to the sample data;

[0039] The resource monitor setting unit is used for the cloud management platform to set the resource monitor to record the resources in the Kubernetes cluster, and compare the difference between the resources in the Kubernetes cluster recorded this time and the resources in the Kubernetes cluster recorded last time, so as to identify the resource changes;

[0040] The reverse operation pool setting unit is used for the cloud management platform to obtain the reverse operation set corresponding to the changes of Kubernetes resources and their sub-resources caused by the operation control, and generate a reverse operation pool.

[0041] Furthermore, the resource monitoring module includes:

[0042] The resource change detection unit is used by the cloud management platform to detect resource changes in the Kubernetes cluster through resource monitors;

[0043] The specification and status detection unit: the cloud management platform detects whether the corresponding specification and status of the operation control have changed according to the type of operation control;

[0044] The replica change detection unit is used by the cloud management platform to detect whether the replica set of the replica controller corresponding to the operation control has changed and whether the number of pods of the sub-resources corresponding to the replica set has changed according to the operation control type;

[0045] The change recording unit is used by the cloud management platform to record the changed resources in sequence.

[0046] Furthermore, the k8s transaction control module includes:

[0047] The resource status judgment unit is used by the cloud management platform to judge whether the status of resources in the Kubernetes cluster reaches the expected status according to resource changes within the timer period;

[0048] The operation control success recording unit is used when the resource status in the Kubernetes cluster reaches the expected status. The cloud management platform ends the timer task, determines that the operation control is successful, and records the operation control time, and adds the operation control time to the sample data.

[0049] The operation rollback unit is used when the status of resources in the Kubernetes cluster has not reached the expected state after the timer period. The cloud management platform determines that the operation control has failed, starts the resource rollback task, finds the corresponding reverse operation set in the reverse operation pool, and rolls back the resources according to the reverse steps until the Kubernetes resources are restored to their original state.

[0050] The beneficial effects of the present invention are:

[0051] The transaction control method and device for k8s declarative resources provided by the present invention make the cloud management platform's operation on the Kubernetes container cluster more in line with the design principles of the cloud management platform, allowing users to obtain the results of the operation more clearly and concisely so that users can perform the next operation; through the cloud management platform of the present invention, the operation of the Kubernetes cluster is unified with various resources, thereby improving the resource integration capability of the cloud resource management platform.

[0052] In addition, the invention has a reliable design principle, a simple structure and a very broad application prospect.

[0053] It can be seen that compared with the prior art, the present invention has outstanding substantive features and significant progress, and the beneficial effects of its implementation are also obvious. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] In order to more clearly illustrate the embodiments of the present invention 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 work.

[0055] Figure 1 It is a flow chart of embodiment 1 of the transaction control method for k8s declarative resources of the present invention.

[0056] Figure 2It is a flow chart of embodiment 2 of the transaction control method for k8s declarative resources of the present invention.

[0057] Figure 3 It is a schematic diagram of the transaction control device of the k8s declarative resources of the present invention.

[0058] In the figure, 1-operation control environment configuration module; 1.1-resource and operation acquisition unit; 1.2-timer period setting unit; 1.3-resource monitor setting unit; 1.4-reverse operation pool setting unit; 2-resource monitoring module; 2.1-resource change detection unit; 2.2-specification and status detection unit; 2.3-copy change detection unit; 2.4-change recording unit; 3-k8s transaction control module; 3.1-resource status judgment unit; 3.2-operation control success recording unit; 3.3-operation rollback unit. DETAILED DESCRIPTION

[0059] In order to enable those skilled in the art to better understand the technical solutions in the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0060] Embodiment 1:

[0061] like Figure 1 As shown, the present invention provides a transaction control method for k8s declarative resources, comprising the following steps:

[0062] S1. The cloud management platform obtains the Kubernetes resources that require operation control, and sets timers, resource monitors, and reverse operation pools according to the type of operation control;

[0063] S2. The cloud management platform monitors resource changes in the Kubernetes cluster through resource monitors and identifies resource changes caused by operational control;

[0064] S3. The cloud management platform determines whether the Kubernetes resources have reached the expected state within the timer period based on the resource changes, and ends the timer task when the expected state is reached. If the expected state is still not reached at the end of the timer period, the reverse operation control task of the reverse operation pool is triggered to restore the original state of the Kubernetes resources.

[0065] The transaction control method for k8s declarative resources provided by the present invention makes the operation of the cloud management platform on the Kubernetes container cluster more in line with the design principles of the cloud management platform, allowing users to obtain the results of the operation more clearly and concisely so that users can perform the next operation; through the cloud management platform of the present invention, the operation of the Kubernetes cluster is unified with various resources, thereby improving the resource integration capability of the cloud resource management platform.

[0066] Embodiment 2:

[0067] like Figure 2 As shown, the present invention provides a transaction control method for k8s declarative resources, comprising the following steps:

[0068] S1. The cloud management platform obtains the Kubernetes resources that require operation control, and sets timers, resource monitors, and reverse operation pools according to the type of operation control. The specific steps are as follows:

[0069] S11. The cloud management platform obtains the Kubernetes resources that need to be operated and the types of operation control;

[0070] S12. The cloud management platform obtains the successful completion time of the existing operations of the operation control type as sample data according to the type of operation control, and sets the cycle of the timer according to the sample data; the specific steps are as follows:

[0071] S121. The cloud management platform obtains the completion time of each successful operation corresponding to the operation control, and generates sample data;

[0072] S122. The cloud management platform calculates the average value of each completion time and the variance of each completion time in the sample data, and uses the average value as the estimated time and the variance as the allowable deviation time;

[0073] S123. The cloud management platform uses the sum of the estimated time and the allowable deviation time as the timer cycle;

[0074] S13. The cloud management platform sets a resource monitor to record the resources in the Kubernetes cluster, and compares the difference between the resources in the Kubernetes cluster recorded this time and the resources in the Kubernetes cluster recorded last time, and identifies the resource changes;

[0075] S14. The cloud management platform obtains a reverse operation set corresponding to changes in Kubernetes resources and their sub-resources caused by the operation control, and generates a reverse operation pool;

[0076] S2. The cloud management platform monitors resource changes in the Kubernetes cluster through resource monitors and identifies resource changes caused by operational control. The specific steps are as follows:

[0077] S21. The cloud management platform detects resource changes in the Kubernetes cluster through resource monitors;

[0078] S22. The cloud management platform detects whether the corresponding specification and status of the operation control have changed according to the type of operation control;

[0079] S23. The cloud management platform detects, based on the type of operation control, whether the replica set of the replica controller corresponding to the operation control has changed and whether the number of pods of the sub-resources corresponding to the replica set has changed;

[0080] S24. The cloud management platform records the changed resources in sequence;

[0081] S3. The cloud management platform determines whether the Kubernetes resources have reached the expected state within the timer period according to the resource changes, and ends the timer task when the expected state is reached. If the expected state is still not reached at the end of the timer period, the reverse operation control task of the reverse operation pool is triggered to restore the original state of the Kubernetes resources. The specific steps are as follows:

[0082] S31. The cloud management platform determines whether the state of resources in the Kubernetes cluster reaches the expected state according to resource changes within the timer period;

[0083] If yes, go to step S32;

[0084] If not, proceed to step S33;

[0085] S32. The cloud management platform ends the timer task, determines that the operation control is successful, and records the operation control time, adds the operation control time to the sample data, and ends;

[0086] S33. The cloud management platform determines that the operation control has failed, starts the resource rollback task, finds the corresponding reverse operation set in the reverse operation pool, and rolls back the resources according to the reverse steps until the Kubernetes resources are restored to their original state.

[0087] In the above-mentioned embodiment 2, in step S12, the sample data is the completion time of a set number of successful operations before the current time, or the completion time within a set time period before the current time.

[0088] Embodiment 3:

[0089] Taking the cluster expansion of Cluster API as an example, this article describes in detail the transaction control method of k8s declarative resources. ClusterAPI is a Kubernetes project that uses declarative Kubernetes-style APIs for cluster creation, configuration, and management. It provides optional additional functions on top of core Kubernetes to manage the life cycle of Kubernetes clusters.

[0090] In the Cluster API, the worker resources in the workload cluster are defined through MachineDeployment, where the number of replicas of the replica identifier worker in the specification is the number of worker nodes. When the workload cluster is expanded, we need to change the value of the replica identifier in the specification. After MachineDeployment detects the change in the replica identifier, it creates a Machine object to create a real worker node. Before the number of machines reaches the target of the replica identifier, the phase in the state is always in the scaling state, and then it changes to running. When the number of machines cannot reach the target of the replica identifier due to insufficient resources or other reasons at the bottom layer, if there is no operation to interrupt and restore it, the cluster will always be in scaling, and the cluster status seen from the management cluster will always be busy. For this purpose, transaction control is added. The detailed operations are as follows:

[0091] Through a set of experiments, we observed the mean value M and variance s2 of the time required for the expansion operation to complete successfully, and used M+s as the timer duration.

[0092] Add the operation identifier and operation result fields to the custom resource of MachineDeployment. The operation identifier indicates the operation type, such as scaleup and scaledown. The operation result field indicates the operation progress and result.

[0093] When expanding capacity, modify the replica identifier under the specification in MachineDeployment, change the phase to scalingup, set the operation identifier to scalingup, and set the operation result field to scalingup;

[0094] Start the timer;

[0095] The resource monitor detects the state of the phase in the MachineDeployment. If the phase value is running, the operation result field is set to scaleup success, and the timer task ends.

[0096] If the phase value is scalingup and the timer period has not ended, continue to wait; if the timer period has ended, scale down the replica identifier in MachineDeployment to the value before the expansion through the reverse operation of the expansion, set the operation result field to rollback, and modify the node deletion policy to newest, so as to roll back the latest generated node, change the phase value to running, set the operation result field to rollback success, and end the task;

[0097] If the operation is successful, the time consumed by the operation control is recorded, and the accumulated successful time is used as new sample data. The sample data is sorted and the data of the most recent week is taken as the sample data for the next operation control.

[0098] Embodiment 4:

[0099] like Figure 3 As shown, the present invention provides a transaction control device for k8s declarative resources, including:

[0100] Operation control environment configuration module 1 is used by the cloud management platform to obtain Kubernetes resources that require operation control, and to set timers, resource monitors, and reverse operation pools according to the type of operation control;

[0101] Resource monitoring module 2, used by the cloud management platform to monitor resource changes in the Kubernetes cluster through resource monitors and identify resource changes caused by operation control;

[0102] The k8s transaction control module 3 is used by the cloud management platform to determine whether the Kubernetes resources have reached the expected state within the timer period according to the resource changes, and to end the timer task when the expected state is reached. If the expected state is still not reached at the end of the timer period, the reverse operation control task of the reverse operation pool is triggered to restore the original state of the Kubernetes resources.

[0103] The transaction control device for k8s declarative resources provided by the present invention makes the cloud management platform's operation on the Kubernetes container cluster more in line with the design principles of the cloud management platform, allowing users to obtain the results of the operation more clearly and concisely so that users can perform the next operation; through the cloud management platform of the present invention, the operation of the Kubernetes cluster is unified with various resources, thereby improving the resource integration capability of the cloud resource management platform.

[0104] Embodiment 5:

[0105] like Figure 3 As shown, the present invention provides a transaction control device for k8s declarative resources, including:

[0106] The operation control environment configuration module 1 is used by the cloud management platform to obtain Kubernetes resources that require operation control, and to set timers, resource monitors, and reverse operation pools according to the type of operation control; the operation control environment configuration module 1 includes:

[0107] Resource and operation acquisition unit 1.1, used by the cloud management platform to acquire Kubernetes resources and types of operation control that require operation control;

[0108] The timer period setting unit 1.2 is used for the cloud management platform to obtain the successful completion time of the existing operation of the operation control of this type as sample data according to the type of operation control, and set the period of the timer according to the sample data;

[0109] Resource monitor setting unit 1.3 is used for the cloud management platform to set up resource monitors to record resources in the Kubernetes cluster, and compare the difference between the resources recorded in the Kubernetes cluster this time and the resources recorded in the Kubernetes cluster last time, and identify resource changes;

[0110] The reverse operation pool setting unit 1.4 is used for the cloud management platform to obtain the reverse operation set corresponding to the changes of Kubernetes resources and their sub-resources caused by the operation control, and generate a reverse operation pool;

[0111] Resource monitoring module 2 is used for the cloud management platform to monitor resource changes in the Kubernetes cluster through a resource monitor and identify resource changes caused by operation control; resource monitoring module 2 includes:

[0112] Resource change detection unit 2.1, used by the cloud management platform to detect resource changes in the Kubernetes cluster through resource monitors;

[0113] Specification and status detection unit 2.2, the cloud management platform detects whether the corresponding specification and status of the operation control have changed according to the type of operation control;

[0114] The replica change detection unit 2.3 is used by the cloud management platform to detect, according to the operation control type, whether the replica set of the replica controller corresponding to the operation control has changed and whether the number of pods of the sub-resources corresponding to the replica set has changed;

[0115] Change recording unit 2.4, used by the cloud management platform to record the changed resources in sequence;

[0116] The k8s transaction control module 3 is used by the cloud management platform to determine whether the Kubernetes resources have reached the expected state within the timer period according to the resource changes, and to end the timer task when the expected state is reached, and to trigger the reverse operation control task of the reverse operation pool when the expected state is still not reached at the end of the timer period to restore the original state of the Kubernetes resources; the k8s transaction control module 3 includes:

[0117] The resource status judgment unit 3.1 is used for the cloud management platform to judge whether the status of resources in the Kubernetes cluster reaches the expected status according to resource changes within the timer period;

[0118] Operation control success recording unit 3.2 is used when the resource status in the Kubernetes cluster reaches the expected status. The cloud management platform ends the timer task, determines that the operation control is successful, and records the operation control time, and adds the operation control time to the sample data;

[0119] Operation rollback unit 3.3 is used when the status of resources in the Kubernetes cluster has not reached the expected state after the timer period. The cloud management platform determines that the operation control has failed, starts the resource rollback task, finds the corresponding reverse operation set in the reverse operation pool, and rolls back the resources according to the reverse steps until the Kubernetes resources are restored to their original state.

[0120] Although the present invention has been described in detail by referring to the accompanying drawings and in combination with the preferred embodiments, the present invention is not limited thereto. Without departing from the spirit and essence of the present invention, a person of ordinary skill in the art may make various equivalent modifications or substitutions to the embodiments of the present invention, and these modifications or substitutions shall be within the scope of the present invention. Any person of ordinary skill in the art may easily think of changes or substitutions within the technical scope disclosed by the present invention, and these shall be within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the scope of protection of the claims.

Claims

1. A transaction control method for k8s declarative resources, characterized in that: The steps include: S1. The cloud management platform obtains the Kubernetes resources that require operation control, and sets the timer, resource monitor, and reverse operation pool according to the type of operation control; the specific steps of step S1 are as follows: S11. The cloud management platform obtains the Kubernetes resources that need to be operated and the types of operation control; S12. The cloud management platform obtains the successful completion time of the existing operation of the operation control type as sample data according to the type of operation control, and sets the timer cycle according to the sample data; the specific steps of step S12 are as follows: S121. The cloud management platform obtains the completion time of each successful operation corresponding to the operation control, and generates sample data; S122. The cloud management platform calculates the average value of each completion time and the variance of each completion time in the sample data, and uses the average value as the estimated time and the variance as the allowable deviation time; S123. The cloud management platform uses the sum of the estimated time and the allowable deviation time as the timer cycle; S13. The cloud management platform sets a resource monitor to record the resources in the Kubernetes cluster, and compares the difference between the resources in the Kubernetes cluster recorded this time and the resources in the Kubernetes cluster recorded last time, and identifies the resource changes; S14. The cloud management platform obtains a reverse operation set corresponding to changes in Kubernetes resources and their sub-resources caused by the operation control, and generates a reverse operation pool; S2. The cloud management platform monitors resource changes in the Kubernetes cluster through resource monitors and identifies resource changes caused by operational control; S3. The cloud management platform determines whether the Kubernetes resources have reached the expected state within the timer period according to the resource changes, and ends the timer task when the expected state is reached. If the expected state is not reached at the end of the timer period, the reverse operation control task of the reverse operation pool is triggered to restore the original state of the Kubernetes resources. The specific steps of step S3 are as follows: S31. The cloud management platform determines whether the state of resources in the Kubernetes cluster reaches the expected state according to resource changes within the timer period; If yes, go to step S32; If not, proceed to step S33; S32. The cloud management platform ends the timer task, determines that the operation control is successful, and records the operation control time, adds the operation control time to the sample data, and ends; S33. The cloud management platform determines that the operation control has failed, starts the resource rollback task, finds the corresponding reverse operation set in the reverse operation pool, and rolls back the resources according to the reverse steps until the Kubernetes resources are restored to their original state.

2. The transaction control method for k8s declarative resources according to claim 1, characterized in that: The specific steps of step S2 are as follows: S21. The cloud management platform detects resource changes in the Kubernetes cluster through resource monitors; S22. The cloud management platform detects whether the corresponding specification and status of the operation control have changed according to the type of operation control; S23. The cloud management platform detects, based on the type of operation control, whether the replica set of the replica controller corresponding to the operation control has changed and whether the number of pods of the sub-resources corresponding to the replica set has changed; S24. The cloud management platform records the changed resources in sequence.

3. The transaction control method for k8s declarative resources according to claim 2, characterized in that: In step S12, the sample data is the completion time of a set number of successful operations before the current time, or the completion time within a set time period before the current time.

4. A transaction control device for k8s declarative resources, characterized in that: include: The operation control environment configuration module (1) is used by the cloud management platform to obtain Kubernetes resources that require operation control, and to set timers, resource monitors, and reverse operation pools according to the type of operation control; The operation control environment configuration module (1) includes: Resource and operation acquisition unit (1.1), used by the cloud management platform to acquire Kubernetes resources and types of operation control that require operation control; The timer cycle setting unit (1.2) is used for the cloud management platform to obtain the successful completion time of the existing operation of the operation control of this type as sample data according to the type of operation control, and set the cycle of the timer according to the sample data; the specific process is as follows: The cloud management platform obtains the completion time of each successful operation corresponding to the existing operation control and generates sample data; The cloud management platform calculates the average value of each completion time and the variance of each completion time in the sample data, and uses the average value as the estimated time and the variance as the allowable deviation time; The cloud management platform uses the sum of the estimated time and the allowable deviation time as the timer period; The resource monitor setting unit (1.3) is used for the cloud management platform to set the resource monitor to record the resources in the Kubernetes cluster, and compare the difference between the resources in the Kubernetes cluster recorded this time and the resources in the Kubernetes cluster recorded last time, so as to identify the resource changes; A reverse operation pool setting unit (1.4) is used by the cloud management platform to obtain a reverse operation set corresponding to changes in Kubernetes resources and their sub-resources caused by operation control, and generate a reverse operation pool; Resource monitoring module (2), used by the cloud management platform to monitor resource changes in the Kubernetes cluster through a resource monitor and identify resource changes caused by operation control; The k8s transaction control module (3) is used by the cloud management platform to determine whether the Kubernetes resources have reached the expected state within the timer period according to the resource change, and to end the timer task when the expected state is reached, and to trigger the reverse operation control task of the reverse operation pool when the expected state is still not reached at the end of the timer period to restore the original state of the Kubernetes resources; the k8s transaction control module (3) includes: The resource status judgment unit (3.1) is used by the cloud management platform to judge whether the status of resources in the Kubernetes cluster reaches the expected status according to resource changes within the timer period; The operation control success recording unit (3.2) is used when the resource status in the Kubernetes cluster reaches the expected status. The cloud management platform ends the timer task, determines that the operation control is successful, and records the operation control time, and adds the operation control time to the sample data. The operation rollback unit (3.3) is used when the status of resources in the Kubernetes cluster has not reached the expected state after the timer period. The cloud management platform determines that the operation control has failed, starts the resource rollback task, finds the corresponding reverse operation set in the reverse operation pool, and rolls back the resources according to the reverse steps until the Kubernetes resources are restored to their original state.

5. The transaction control device for k8s declarative resources according to claim 4, characterized in that: The resource monitoring module (2) includes: Resource change detection unit (2.1), used by the cloud management platform to detect resource changes in the Kubernetes cluster through resource monitors; The specification and status detection unit (2.2) detects whether the specification and status corresponding to the operation control have changed according to the type of operation control; The replica change detection unit (2.3) is used by the cloud management platform to detect, according to the type of operation control, whether the replica set of the replica controller corresponding to the operation control has changed and whether the number of pods of the sub-resources corresponding to the replica set has changed; The change recording unit (2.4) is used by the cloud management platform to record the changed resources in sequence.

Citation Information

Patent Citations

  • Method for realizing flow control of Pod network in Kubernetes

    CN111371696A

  • Text classification method and device and electronic equipment

    CN111737464A