Container lifecycle management methods, devices, equipment and media

By receiving lifecycle modification requests and monitoring container stop times, the system automatically updates and cleans up the container cluster, solving the problem of inefficient container lifecycle management and achieving highly efficient automated management.

CN117056026BActive Publication Date: 2026-11-10ZHENGZHOU YUNHAI INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311104240.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-30
Publication Date
2026-11-10
Estimated Expiration
2043-08-30

AI Technical Summary

Technical Problem

In existing technologies, container lifecycle management lacks automated processing logic, requiring users to manually intervene to set shutdown commands, resulting in low efficiency and the risk of misoperation.

Method used

By receiving application lifecycle modification requests, modifying the lifecycle parameters of the target application, updating the container cluster based on the modified parameters, monitoring the container's runtime stop time, and automatically managing container cleanup.

Benefits of technology

It automates the management of the container lifecycle, improves management efficiency, reduces manual intervention, avoids misoperation, and supports batch updates and cleanup of container clusters.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117056026B_ABST
    Figure CN117056026B_ABST
Patent Text Reader

Abstract

This application discloses a container lifecycle management method, apparatus, device, and medium, relating to the field of computer technology. The method includes: receiving an application lifecycle modification request, and modifying the previous lifecycle parameters of a target application based on the application lifecycle modification request to obtain modified lifecycle parameters; updating the previous container cluster corresponding to the target application based on the modified lifecycle parameters to obtain the current container cluster; returning the status information of each current container in the current container cluster to the target application, so that the target application runs the corresponding current container based on the status information; monitoring the running stop time of each current container, and determining whether to clean up the current container by comparing the current time and the running stop time of the current container. This solution can improve the efficiency of container lifecycle management.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to container lifecycle management methods, apparatus, equipment and media. Background Technology

[0002] As container applications continue to develop, container application scenarios are also increasing. However, there has been no automatic processing logic for managing the container lifecycle. If a container needs to be shut down at a specific time, users need to manually intervene by adding a fixed shutdown command to the start command or parameters of the function that calls the container. In other words, when the lifecycle of an application needs to be created or modified, the lifecycle of the corresponding container also needs to be set accordingly, that is, the corresponding shutdown command needs to be set in each function that calls the container. However, such processing not only does not conform to user habits, but also wastes a lot of manpower and is also prone to misoperation.

[0003] In summary, improving the efficiency of container lifecycle management is a problem that needs to be solved in this field. Summary of the Invention

[0004] In view of this, the purpose of this invention is to provide a container lifecycle management method, apparatus, device, and medium that can improve the efficiency of container lifecycle management. The specific solution is as follows:

[0005] Firstly, this application discloses a container lifecycle management method, including:

[0006] Receive an application lifecycle modification request, and modify the previous lifecycle parameters of the target application based on the application lifecycle modification request to obtain the modified lifecycle parameters;

[0007] Based on the modified lifecycle parameters, the previous container cluster corresponding to the target application will be updated to obtain the current container cluster;

[0008] The status information of each current container in the current container cluster is returned to the target application so that the target application can run the corresponding current container based on the status information.

[0009] Monitor the running stop time of each of the current containers, and determine whether to clean up the current container by comparing the current time with the running stop time of the current container.

[0010] Optionally, the step of updating the previous container cluster corresponding to the target application based on the modified lifecycle parameters to obtain the current container cluster includes:

[0011] The previous container in the previous container cluster corresponding to the target application is deleted, and the corresponding current container is created in the previous container cluster based on the modified lifecycle parameters to obtain the current container cluster.

[0012] Optionally, before receiving the application lifecycle modification request, the method further includes:

[0013] Based on the application creation request, create the target application in the corresponding namespace, set the initial lifecycle parameters of the target application, create the target workload in the target application according to the application creation request, and determine the initial lifecycle parameters of the target application as the initial lifecycle parameters of the target workload.

[0014] Create several initial containers corresponding to the target application to obtain an initial container cluster. Write the initial lifecycle parameters of the target application into the corresponding initial containers based on a preset association relationship to obtain the status information of each initial container.

[0015] Based on the preset association relationship, each initial container is bound to the computing node of the corresponding target workload, so that the status information of each initial container can be returned to the corresponding target workload.

[0016] The target workload reports the status information of each initial container to the target application, so that the target application can run the initial container based on the status information of each initial container.

[0017] Optionally, determining the initial lifecycle parameters of the target application as the initial lifecycle parameters of the target workload includes:

[0018] Obtain the current lifecycle parameters of the namespace, and determine whether the difference between the running stop time in the initial lifecycle parameters of the target application and the running stop time in the current lifecycle parameters of the namespace satisfies the first preset condition.

[0019] If the conditions are met, the initial lifecycle parameters of the target application are determined as the initial lifecycle parameters of the target workload; if not, a corresponding error message is generated.

[0020] Optionally, monitoring the runtime stop time of each of the current containers includes:

[0021] Monitor the current lifecycle parameters of each of the current containers; wherein the current lifecycle parameters of the current container include the running stop time, the stop control strategy after expiration, and the buffer period;

[0022] If the stop control strategy after expiration is an immediate stop strategy, then the running stop time in the current lifecycle parameters of the current container is directly determined as the running stop time of the current container;

[0023] If the termination control strategy is a delayed termination strategy, then the sum of the current lifecycle parameters of the current container and the buffer period is determined as the current container's termination time.

[0024] Optionally, determining whether to clean up the current container by comparing the current time with the current container's stop time includes:

[0025] If the current time is equal to the stop time of the current container, the preset status flag of the current container is adjusted from the default flag to the pending cleanup flag, so that the preset cleanup thread will clean up the current container with the pending cleanup flag at the preset cleanup time.

[0026] Optionally, the container lifecycle management method further includes:

[0027] Obtain the time difference between the runtime stop time and the current time in the current lifecycle parameters of the current container;

[0028] If the time difference meets the second preset condition, then the corresponding early warning information is generated according to the pre-created early warning mechanism.

[0029] Secondly, this application discloses a container lifecycle management device, comprising:

[0030] The lifecycle modification module is used to receive application lifecycle modification requests and modify the previous lifecycle parameters of the target application based on the application lifecycle modification requests to obtain the modified lifecycle parameters.

[0031] The container cluster update module is used to update the previous container cluster corresponding to the target application based on the modified lifecycle parameters to obtain the current container cluster.

[0032] The status information return module is used to return the status information of each current container in the current container cluster to the target application, so that the target application can run the corresponding current container based on the status information.

[0033] The container monitoring and management module is used to monitor the running stop time of each current container and determine whether to clean up the current container by comparing the current time with the running stop time of the current container.

[0034] Thirdly, this application discloses an electronic device, comprising:

[0035] Memory, used to store computer programs;

[0036] A processor for executing the computer program to implement the steps of the aforementioned disclosed container lifecycle management method.

[0037] Fourthly, this application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the steps of the aforementioned disclosed container lifecycle management method.

[0038] The beneficial effects of this application are as follows: It receives an application lifecycle modification request and modifies the previous lifecycle parameters of the target application based on the request to obtain modified lifecycle parameters; it updates the previous container cluster corresponding to the target application based on the modified lifecycle parameters to obtain the current container cluster; it returns the status information of each current container in the current container cluster to the target application so that the target application can run the corresponding current container based on the status information; it monitors the running stop time of each current container and determines whether to clean up the current container by comparing the current time with the running stop time of the current container. Therefore, this application directly modifies the previous lifecycle parameters of the target application based on the application lifecycle modification request. This automatically manages the container cluster corresponding to the target application, i.e., manages the lifecycle of the container cluster, and achieves batch updates of the container cluster, enabling the target application to run the current container. Furthermore, this application continuously monitors the running stop time of each current container to clean up the corresponding current container, i.e., stop its operation. Attached Figure Description

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

[0040] Figure 1 Here is a flowchart of a container lifecycle management method disclosed in this application:

[0041] Figure 2 This is a schematic diagram of a specific container lifecycle management architecture disclosed in this application;

[0042] Figure 3 This is a schematic diagram of a specific workload layer architecture disclosed in this application;

[0043] Figure 4 This application discloses a specific container lifecycle management method flowchart;

[0044] Figure 5 This is a flowchart of another specific container lifecycle management method disclosed in this application;

[0045] Figure 6 This is a schematic diagram of a specific container cleaning process disclosed in this application;

[0046] Figure 7 This is a schematic diagram of the structure of a container lifecycle management device disclosed in this application;

[0047] Figure 8 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation

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

[0049] As container applications continue to develop, container application scenarios are also increasing. However, there has never been an automatic processing logic for managing the container lifecycle. If a container needs to be shut down at a certain time, then users need to manually intervene and add a fixed shutdown command to the startup command or parameters of the function that calls the container. In other words, when the lifecycle of an application needs to be created or modified, the lifecycle of the corresponding container also needs to be set accordingly, that is, the corresponding shutdown command needs to be set in each function that calls the container. However, such processing not only does not conform to the user's usage habits, but also wastes a lot of manpower and is also prone to misoperation.

[0050] Therefore, this application provides a container lifecycle management solution that can improve the efficiency of container lifecycle management.

[0051] See Figure 1 As shown in the figure, this application discloses a container lifecycle management method, including:

[0052] Step S11: Receive an application lifecycle modification request, and modify the previous lifecycle parameters of the target application based on the application lifecycle modification request to obtain the modified lifecycle parameters.

[0053] The implementation logic of this embodiment is based on a K8S (Kubernetes, i.e., application software) cluster. Before receiving an application lifecycle modification request, a namespace needs to be created. Within this namespace, several applications, workloads, and containers are created to form a container cluster. This container cluster is then associated with its corresponding workloads. In other words, one application contains several workloads, one workload is associated with several containers, and one container corresponds to only one workload. It's important to note that in this embodiment, the application's lifecycle parameters are constrained by the namespace. The lifecycle parameters of the application's workloads and containers are consistent with the application's lifecycle parameters. Therefore, when an application lifecycle modification request is received, the previous lifecycle parameters of the target application need to be modified first. For example... Figure 2 The diagram illustrates a specific container lifecycle management architecture, primarily comprising an application layer, a workload layer, and a container layer. The application layer is responsible for creating applications (i.e., creating workloads under those applications), setting corresponding lifecycle parameters, and receiving application lifecycle modification requests to modify the corresponding workload's lifecycle. The workload layer, based on the Kubernetes master (controller node), includes an application controller (ReleaseController), a controller management mechanism (kube-controllermanager), and an admission control mechanism (Webhook). The application controller listens to the lifecycle of cloudRelease (application) resources, creates workloads, and sets lifecycle policies for them. The controller management listens to the workload's lifecycle. The admission control mechanism operates during the pod (container) creation phase, intercepts pod create requests, and verifies and completes pod annotation information by querying parent resource annotations, adding the lifecycle policy to the pod as an annotation. Figure 3 The diagram illustrates a specific workload layer architecture. The api-server (resource operation interface) is responsible for communication between various functional modules in the cluster. The icks-agent (proxy server) integrates the application controller, the RleaseTimeController (lifecycle control) module, and the admission control mechanism. The controller management integrates controllers for different workloads, including the deploymentController (stateless workload controller) and the statefulsetController (stateful workload controller). The container layer is based on Kubernetes nodes and includes the kubelet (container lifecycle maintenance) module, which is responsible for reporting node status and managing the lifecycle of containers.

[0054] Step S12: Based on the modified lifecycle parameters, update the previous container cluster corresponding to the target application to obtain the current container cluster.

[0055] Understandably, during the process of updating the previous container cluster corresponding to the target application based on the modified lifecycle parameters, it is necessary to delete several previous containers contained in the previous container cluster, and then create new containers based on the modified lifecycle parameters, that is, create several current containers to obtain the current container cluster.

[0056] Step S13: Return the status information of each current container in the current container cluster to the target application so that the target application can run the corresponding current container based on the status information.

[0057] In this embodiment, the current container's status information can characterize whether the current container has been successfully created and whether its own lifecycle parameters have been set to be consistent with the target application's lifecycle parameters. In this way, the target application can determine whether the current container can be run based on the status information, that is, it needs to run the corresponding current container based on the status information.

[0058] Step S14: Monitor the running stop time of each current container, and determine whether to clean up the current container by comparing the current time with the running stop time of the current container.

[0059] The lifecycle parameters of a container include the runtime stop time, the stop control policy after expiration, and the buffer period. The stop control policy after expiration is divided into an immediate stop policy (now) and a delayed stop policy (delay). The runtime stop time of the container needs to be determined according to the stop control policy after expiration. For example, if the runtime stop time in the lifecycle parameters is 5 days, that is, it is tentatively scheduled to stop running after 5 days, if the stop control policy after expiration is an immediate stop policy, then the container will stop running after 5 days. If the stop control policy after expiration is a delayed stop policy with a buffer period of 1 day, then the container will stop running after 6 days.

[0060] Understandably, if the current time is not later than the current container's runtime stop time, then the current container should be cleaned up. That is, the current container can be cleaned up using a preset cleanup thread at the preset cleanup time, or the current container can be cleaned up using a preset cleanup thread when the current time is equal to the current container's runtime stop time.

[0061] If the stop control policy after expiration is an immediate stop policy, then the running stop time in the current lifecycle parameters of the current container will be directly determined as the running stop time of the current container;

[0062] If the termination control strategy is a delayed termination strategy, then the sum of the runtime stop time in the current lifecycle parameters of the current container and the buffer period is determined as the runtime stop time of the current container.

[0063] The beneficial effects of this application are as follows: It receives an application lifecycle modification request and modifies the previous lifecycle parameters of the target application based on the request to obtain modified lifecycle parameters; it updates the previous container cluster corresponding to the target application based on the modified lifecycle parameters to obtain the current container cluster; it returns the status information of each current container in the current container cluster to the target application so that the target application can run the corresponding current container based on the status information; it monitors the running stop time of each current container and determines whether to clean up the current container by comparing the current time with the running stop time of the current container. Therefore, this application directly modifies the previous lifecycle parameters of the target application based on the application lifecycle modification request. This automatically manages the container cluster corresponding to the target application, i.e., manages the lifecycle of the container cluster, and achieves batch updates of the container cluster, enabling the target application to run the current container. Furthermore, this application continuously monitors the running stop time of each current container to clean up the corresponding current container, i.e., stop its operation.

[0064] See Figure 4 As shown in the figure, this application discloses a specific container lifecycle management method, including:

[0065] Step S21: Receive an application lifecycle modification request, and modify the previous lifecycle parameters of the target application based on the application lifecycle modification request to obtain the modified lifecycle parameters.

[0066] In this embodiment, before receiving the application lifecycle modification request, the method further includes: creating a target application in the corresponding namespace based on the application creation request, setting the initial lifecycle parameters of the target application, creating a target workload in the target application according to the application creation request, and determining the initial lifecycle parameters of the target application as the initial lifecycle parameters of the target workload; creating a plurality of initial containers corresponding to the target application to obtain an initial container cluster, writing the initial lifecycle parameters of the target application into the corresponding initial containers based on a preset association relationship to obtain the status information of each initial container; binding each initial container to the corresponding compute node of the target workload based on the preset association relationship, so as to return the status information of each initial container to the corresponding target workload; and reporting the status information of each initial container to the target application through the target workload, so that the target application runs the initial containers based on the status information of each initial container.

[0067] Building upon the traditional namespace creation, a stop label named "endTimestamp:xxxx" is added. This primarily serves to uniformly manage the lifecycle of workload applications across the entire namespace. If no lifecycle is specified, it is left blank, meaning there are no lifecycle restrictions. The namespace model definition can be as follows:

[0068]

[0069] Upon receiving an application creation request from a user, the system creates the target application based on the request and sets its initial lifecycle parameters. An example of the created target application is shown below:

[0070]

[0071] The metadata section records basic information about the target application: name, namespace, label, annotations, and spec. The spec contains complete information about the application's workloads. This complete information is used to create, update, and delete corresponding workloads during application creation through the application control layer, and to monitor the status of each workload within the application, enabling real-time updates to the application state. The code corresponding to the lifecycle parameters is as follows:

[0072] "inspur.com / endTimestamp":"2024-01-01 23:59:59"

[0073] "inspur.com / endtimestragetry":"Delay"

[0074] "inspur.com / BufferTime":3

[0075] "inspur.com / endTimestamp" is the runtime stop time in the lifecycle parameters, "inspur.com / endtimestragetry" is the stop control strategy after expiration in the lifecycle parameters, and "inspur.com / BufferTime" is the buffer period in the lifecycle parameters.

[0076] After the application controller detects an application creation request, it creates the target workload corresponding to the target application based on the request and marks the target workload with lifecycle parameters, setting the initial lifecycle parameters of the target application as the initial lifecycle parameters of the target workload. The workload controller listens for the creation request of the target workload and initiates a request to create a pod (container). The admission control mechanism detects the container creation request, finds the corresponding workload based on the container's owner reference (pre-defined association), and distributes the initial lifecycle parameters in the form of container annotations. After the initial containers are created, the target workload is bound to several initial containers, that is, the initial containers are bound to the compute nodes of the target workload. The kubelet (proxy component) corresponding to the compute nodes of the target workload reports the status information of the initial containers to the target application and performs subsequent operations such as container startup.

[0077] In this embodiment, determining the initial lifecycle parameters of the target application as the initial lifecycle parameters of the target workload includes: obtaining the current lifecycle parameters of the namespace, and determining whether the difference between the runtime stop time in the initial lifecycle parameters of the target application and the runtime stop time in the current lifecycle parameters of the namespace satisfies a first preset condition; if satisfied, the initial lifecycle parameters of the target application are determined as the initial lifecycle parameters of the target workload; if not satisfied, corresponding error information is generated. Understandably, if the initial lifecycle parameter is empty, then by default, the target application's runtime stop time is consistent with the namespace's runtime stop time. That is, the target application's initial lifecycle parameter is consistent with the namespace's lifecycle parameter, and it changes as the namespace's lifecycle parameter changes. If the initial lifecycle parameter is not empty, then it is necessary to determine whether the difference between the runtime stop time in the target application's initial lifecycle parameter and the runtime stop time in the namespace's current lifecycle parameter meets the first preset condition. That is, it is necessary to determine whether the runtime stop time in the target application's initial lifecycle parameter is later than the runtime stop time in the namespace's current lifecycle parameter. If it is later, then the first preset condition is not met, and corresponding error information needs to be generated. If it is not later, then the first preset condition is met, and the target application's initial lifecycle parameter is determined as the target workload's initial lifecycle parameter.

[0078] Step S22: Delete the previous container in the previous container cluster corresponding to the target application, and create the corresponding current container in the previous container cluster based on the modified lifecycle parameters to obtain the current container cluster.

[0079] If you need to obtain the container corresponding to the modified lifecycle parameters, you need to delete the old container and then create a new container corresponding to the modified lifecycle parameters. That is, a container can only correspond to one lifecycle parameter and cannot be modified. Therefore, after obtaining the modified lifecycle parameters, you need to delete the previous container in the previous container cluster corresponding to the target application and create the corresponding current container in the previous container cluster based on the modified lifecycle parameters to obtain the current container cluster.

[0080] Step S23: Return the status information of each current container in the current container cluster to the target application so that the target application can run the corresponding current container based on the status information.

[0081] Step S24: Monitor the running stop time of each current container, and determine whether to clean up the current container by comparing the current time with the running stop time of the current container.

[0082] Therefore, when creating a namespace and creating various applications within that namespace, the lifecycle parameters of the applications need to be based on the lifecycle parameters of the namespace. The lifecycle parameters are also marked in each application so that the lifecycle parameters of each container can be set automatically in batches, which speeds up the creation and modification of lifecycle parameters and improves efficiency. In addition, this application will automatically clean up containers that need to be cleaned up, reducing manual costs.

[0083] See Figure 5 As shown in the figure, this application discloses a specific container lifecycle management method, including:

[0084] Step S31: Receive an application lifecycle modification request, and modify the previous lifecycle parameters of the target application based on the application lifecycle modification request to obtain the modified lifecycle parameters.

[0085] The system receives a user-initiated application lifecycle modification request to modify the target application's lifecycle parameters, obtaining the modified lifecycle parameters. Based on these modified lifecycle parameters, it then modifies the lifecycle parameters of the target application's workload, establishing the modified lifecycle parameters as the workload's lifecycle parameters.

[0086] Step S32: Based on the modified lifecycle parameters, update the previous container cluster corresponding to the target application to obtain the current container cluster.

[0087] Delete the previous container in the previous container cluster, and then create a new container based on the modified lifecycle parameters. This results in the current container cluster containing all the current containers. Set the modified lifecycle parameters to the lifecycle parameters of the current container, and bind the current container to the compute node of the corresponding workload.

[0088] Step S33: Return the status information of each current container in the current container cluster to the target application so that the target application can run the corresponding current container based on the status information.

[0089] Step S34: Monitor the current lifecycle parameters of each of the current containers; wherein the current lifecycle parameters of the current containers include the running stop time, the stop control strategy after expiration, and the buffer period.

[0090] Step S35: If the expiration-after-stop control strategy is an immediate stop strategy, then the running stop time in the current lifecycle parameters of the current container is directly determined as the running stop time of the current container; if the expiration-after-stop control strategy is a delayed stop strategy, then the sum of the running stop time in the current lifecycle parameters of the current container and the buffer period is determined as the running stop time of the current container.

[0091] Understandably, the current runtime of a container needs to be determined based on the expiration and stop control policy. For example, if the runtime of container A is "2021-01-01 23:59:59" in its current lifecycle parameters, and the expiration and stop control policy of container A is an immediate stop policy, then the runtime of container A is "2021-01-01 23:59:59". If the expiration and stop control policy of container A is a delayed stop policy with a buffer period of "24 hours", then the runtime of container A is "2021-01-02 23:59:59".

[0092] Step S36: Determine whether to clean up the current container by comparing the current time with the running stop time of the current container.

[0093] In this embodiment, determining whether to clean up the current container by comparing the current time with the current container's stop time includes: if the current time is equal to the current container's stop time, then adjusting the preset status flag of the current container from the default flag to a pending cleanup flag, so that a preset cleanup thread will clean up the current container configured with the pending cleanup flag at a preset cleanup time.

[0094] The container's default status flag (stop_flag) is typically set to the default flag (False), i.e., stop_flag = False. The check_data (date check) thread retrieves the application's expiration-based stop control policy. If the expiration-based stop control policy is immediate stop, it directly reads the runtime stop time from the current lifecycle parameters and compares it with the current time. If the runtime stop time in the current lifecycle parameters is not later than the current time, the default status flag (stop_flag) is adjusted from the default flag (False) to the pending cleanup flag (True), thus setting stop_flag = True. If the runtime stop time in the current lifecycle parameters is later than the current time, no action is taken, i.e., the default status flag remains unchanged. The status flag (stop_flag) remains the default flag (False). If the stop control policy after expiration is a delayed stop policy, the running stop time and buffer period in the current lifecycle parameters are read, and the sum of the running stop time and buffer period in the current lifecycle parameters is used as the running stop parameter of the current container. Then, the running stop parameter of the current container is compared with the current time. If the running stop parameter of the current container is not later than the current time, the preset status flag (stop_flag) is adjusted from the default flag (False) to the pending cleanup flag (True), so that stop_flag = True. If the running stop parameter of the current container is later than the current time, no action is taken, that is, the preset status flag (stop_flag) remains the default flag (False).

[0095] For example Figure 6 The diagram illustrates a specific container cleanup process. The lifecycle control module monitors the application's runtime stop time, which is also the runtime stop time of each container. When the time difference between the container's runtime stop time and the current time is 0, the preset status flag is adjusted from the default flag to the cleanup flag, and the workload controller is called to modify the workload's replica count to 0 so as to delete the corresponding container. Then, the status of the workload and application is updated to "closed," that is, the workload and application stop running, and then the cleanup process ends.

[0096] This embodiment also includes: obtaining the time difference between the running stop time in the current lifecycle parameters of the current container and the current time; if the time difference meets a second preset condition, generating corresponding warning information according to a pre-created warning mechanism. It can also pre-warn users about containers that are about to stop running. For example, a second preset condition can be set: if the time difference is +2 hours, meaning the current time is 2 hours away from matching the running stop time in the current lifecycle parameters of the current container, corresponding warning information can be generated according to the pre-created warning mechanism to inform the user that the current container is about to stop running, allowing the user to take appropriate action based on the warning information. Warning information for the application lifecycle is generated once daily at midnight by default to avoid information redundancy caused by repeated generation times, which could also impact product performance. Users can configure the warning information generation strategy and set different notification methods according to their business needs and different requirements. If users feel that the daily reminder frequency is too high, they can modify the reminder frequency according to their needs. However, to ensure a better user experience and avoid accidental operation leading to failure to receive timely notification messages, the update frequency for the first three days cannot be modified.

[0097] Therefore, this application can automatically modify container lifecycle parameters in batches and automatically shut down workloads in batches, providing unified management. Users only need simple operations to achieve unified lifecycle management at the namespace level, eliminating the need for constant manual monitoring of application usage and reducing manual maintenance costs. It also offers high flexibility, allowing users to configure different lifecycle strategies for different applications to meet diverse needs.

[0098] See Figure 7 As shown in the figure, this application discloses a container lifecycle management device, including:

[0099] The lifecycle modification module 11 is used to receive an application lifecycle modification request and modify the previous lifecycle parameters of the target application based on the application lifecycle modification request to obtain the modified lifecycle parameters.

[0100] The container cluster update module 12 is used to update the previous container cluster corresponding to the target application based on the modified lifecycle parameters to obtain the current container cluster.

[0101] The status information return module 13 is used to return the status information of each current container in the current container cluster to the target application, so that the target application can run the corresponding current container based on the status information.

[0102] The container monitoring and management module 14 is used to monitor the running stop time of each current container and determine whether to clean up the current container by comparing the current time with the running stop time of the current container.

[0103] The beneficial effects of this application are as follows: It receives an application lifecycle modification request and modifies the previous lifecycle parameters of the target application based on the request to obtain modified lifecycle parameters; it updates the previous container cluster corresponding to the target application based on the modified lifecycle parameters to obtain the current container cluster; it returns the status information of each current container in the current container cluster to the target application so that the target application can run the corresponding current container based on the status information; it monitors the running stop time of each current container and determines whether to clean up the current container by comparing the current time with the running stop time of the current container. Therefore, this application directly modifies the previous lifecycle parameters of the target application based on the application lifecycle modification request. This automatically manages the container cluster corresponding to the target application, i.e., manages the lifecycle of the container cluster, and achieves batch updates of the container cluster, enabling the target application to run the current container. Furthermore, this application continuously monitors the running stop time of each current container to clean up the corresponding current container, i.e., stop its operation.

[0104] Furthermore, embodiments of this application also provide an electronic device. Figure 8 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.

[0105] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Specifically, it may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the following steps:

[0106] Receive an application lifecycle modification request, and modify the previous lifecycle parameters of the target application based on the application lifecycle modification request to obtain the modified lifecycle parameters;

[0107] Based on the modified lifecycle parameters, the previous container cluster corresponding to the target application will be updated to obtain the current container cluster;

[0108] The status information of each current container in the current container cluster is returned to the target application so that the target application can run the corresponding current container based on the status information.

[0109] Monitor the running stop time of each of the current containers, and determine whether to clean up the current container by comparing the current time with the running stop time of the current container.

[0110] In some specific embodiments, the processor executes a computer program stored in the memory, specifically implementing the following steps:

[0111] The previous container in the previous container cluster corresponding to the target application is deleted, and the corresponding current container is created in the previous container cluster based on the modified lifecycle parameters to obtain the current container cluster.

[0112] In some specific embodiments, the processor executes a computer program stored in the memory, specifically implementing the following steps:

[0113] Based on the application creation request, create the target application in the corresponding namespace, set the initial lifecycle parameters of the target application, create the target workload in the target application according to the application creation request, and determine the initial lifecycle parameters of the target application as the initial lifecycle parameters of the target workload.

[0114] Create several initial containers corresponding to the target application to obtain an initial container cluster. Write the initial lifecycle parameters of the target application into the corresponding initial containers based on a preset association relationship to obtain the status information of each initial container.

[0115] Based on the preset association relationship, each initial container is bound to the computing node of the corresponding target workload, so that the status information of each initial container can be returned to the corresponding target workload.

[0116] The target workload reports the status information of each initial container to the target application, so that the target application can run the initial container based on the status information of each initial container.

[0117] In some specific embodiments, the processor executes a computer program stored in the memory, specifically implementing the following steps:

[0118] Obtain the current lifecycle parameters of the namespace, and determine whether the difference between the running stop time in the initial lifecycle parameters of the target application and the running stop time in the current lifecycle parameters of the namespace satisfies the first preset condition.

[0119] If the conditions are met, the initial lifecycle parameters of the target application are determined as the initial lifecycle parameters of the target workload; if not, a corresponding error message is generated.

[0120] In some specific embodiments, the processor executes a computer program stored in the memory, specifically implementing the following steps:

[0121] Monitor the current lifecycle parameters of each of the current containers; wherein the current lifecycle parameters of the current container include the running stop time, the stop control strategy after expiration, and the buffer period;

[0122] If the stop control strategy after expiration is an immediate stop strategy, then the running stop time in the current lifecycle parameters of the current container is directly determined as the running stop time of the current container;

[0123] If the termination control strategy is a delayed termination strategy, then the sum of the current lifecycle parameters of the current container and the buffer period is determined as the current container's termination time.

[0124] In some specific embodiments, the processor executes a computer program stored in the memory, specifically implementing the following steps:

[0125] If the current time is equal to the stop time of the current container, the preset status flag of the current container is adjusted from the default flag to the pending cleanup flag, so that the preset cleanup thread will clean up the current container with the pending cleanup flag at the preset cleanup time.

[0126] In some specific embodiments, the processor, by executing a computer program stored in the memory, may further include the following steps:

[0127] Obtain the time difference between the runtime stop time and the current time in the current lifecycle parameters of the current container;

[0128] If the time difference meets the second preset condition, then the corresponding early warning information is generated according to the pre-created early warning mechanism.

[0129] In this embodiment, the power supply 23 is used to provide operating voltage for various hardware devices on the electronic device; the communication interface 24 can create a data transmission channel between the electronic device and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.

[0130] The processor 21 may include one or more processing cores, such as a quad-core processor or an octa-core processor. The processor 21 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 21 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 21 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, the processor 21 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.

[0131] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored on it include operating system 221, computer program 222 and data 223, etc., and the storage method can be temporary storage or permanent storage.

[0132] The operating system 221 manages and controls the various hardware devices and computer programs 222 on the electronic device to enable the processor 21 to perform calculations and processing on the massive amounts of data 223 in the memory 22. The operating system can be Windows, Unix, Linux, etc. The computer program 222, in addition to including a computer program capable of performing the container lifecycle management method executed by the electronic device as disclosed in any of the foregoing embodiments, may further include computer programs capable of performing other specific tasks. The data 223 may include data received by the electronic device from external devices, as well as data collected by its own input / output interface 25.

[0133] Furthermore, embodiments of this application also disclose a computer-readable storage medium storing a computer program. When the computer program is loaded and executed by a processor, it implements the method steps performed during the container lifecycle management process disclosed in any of the foregoing embodiments.

[0134] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0135] The present invention has provided a detailed description of a container lifecycle management method, apparatus, device, and medium. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A container lifecycle management method, characterized in that, include: Receive an application lifecycle modification request, and modify the previous lifecycle parameters of the target application based on the application lifecycle modification request to obtain the modified lifecycle parameters; Based on the modified lifecycle parameters, the previous container cluster corresponding to the target application will be updated to obtain the current container cluster; The status information of each current container in the current container cluster is returned to the target application so that the target application can run the corresponding current container based on the status information. Monitor the running stop time of each of the current containers, and determine whether to clean up the current container by comparing the current time with the running stop time of the current container; Prior to receiving the application lifecycle modification request, the process also includes: Based on the application creation request, create the target application in the corresponding namespace, set the initial lifecycle parameters of the target application, create the target workload in the target application according to the application creation request, and determine the initial lifecycle parameters of the target application as the initial lifecycle parameters of the target workload. Create several initial containers corresponding to the target application to obtain an initial container cluster. Write the initial lifecycle parameters of the target application into the corresponding initial containers based on a preset association relationship to obtain the status information of each initial container. Based on the preset association relationship, each initial container is bound to the computing node of the corresponding target workload, so that the status information of each initial container can be returned to the corresponding target workload. The target workload reports the status information of each initial container to the target application, so that the target application can run the initial container based on the status information of each initial container. Furthermore, the container lifecycle management method also includes: Before updating the previous container cluster corresponding to the target application based on the modified lifecycle parameters, the modified lifecycle parameters are determined as the lifecycle parameters of the target workload; After updating the previous container cluster corresponding to the target application based on the modified lifecycle parameters to obtain the current container cluster, each current container in the current container cluster is bound to the corresponding compute node of the target workload.

2. The container lifecycle management method according to claim 1, characterized in that, The step of updating the previous container cluster corresponding to the target application based on the modified lifecycle parameters to obtain the current container cluster includes: The previous container in the previous container cluster corresponding to the target application is deleted, and the corresponding current container is created in the previous container cluster based on the modified lifecycle parameters to obtain the current container cluster.

3. The container lifecycle management method according to claim 2, characterized in that, The step of determining the initial lifecycle parameters of the target application as the initial lifecycle parameters of the target workload includes: Obtain the current lifecycle parameters of the namespace, and determine whether the difference between the running stop time in the initial lifecycle parameters of the target application and the running stop time in the current lifecycle parameters of the namespace satisfies the first preset condition. If the conditions are met, the initial lifecycle parameters of the target application are determined as the initial lifecycle parameters of the target workload; if not, a corresponding error message is generated.

4. The container lifecycle management method according to any one of claims 1 to 3, characterized in that, The monitoring of the running stop time of each of the current containers includes: Monitor the current lifecycle parameters of each of the current containers; wherein the current lifecycle parameters of the current container include the running stop time, the stop control strategy after expiration, and the buffer period; If the stop control strategy after expiration is an immediate stop strategy, then the running stop time in the current lifecycle parameters of the current container is directly determined as the running stop time of the current container; If the termination control strategy is a delayed termination strategy, then the sum of the current lifecycle parameters of the current container and the buffer period is determined as the current container's termination time.

5. The container lifecycle management method according to claim 4, characterized in that, The step of determining whether to clean up the current container by comparing the current time and the current container's stop time includes: If the current time is equal to the stop time of the current container, the preset status flag of the current container is adjusted from the default flag to the pending cleanup flag, so that the preset cleanup thread will clean up the current container with the pending cleanup flag at the preset cleanup time.

6. The container lifecycle management method according to claim 4, characterized in that, Also includes: Obtain the time difference between the runtime stop time and the current time in the current lifecycle parameters of the current container; If the time difference meets the second preset condition, then the corresponding early warning information is generated according to the pre-created early warning mechanism.

7. A container lifecycle management device, characterized in that, The container lifecycle management device is used to implement the container lifecycle management method as described in any one of claims 1 to 6, wherein the container lifecycle management device comprises: The lifecycle modification module is used to receive application lifecycle modification requests and modify the previous lifecycle parameters of the target application based on the application lifecycle modification requests to obtain the modified lifecycle parameters. The container cluster update module is used to update the previous container cluster corresponding to the target application based on the modified lifecycle parameters to obtain the current container cluster. The status information return module is used to return the status information of each current container in the current container cluster to the target application, so that the target application can run the corresponding current container based on the status information. The container monitoring and management module is used to monitor the running stop time of each current container and determine whether to clean up the current container by comparing the current time with the running stop time of the current container.

8. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the container lifecycle management method as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, Used to store computer programs; wherein, when executed by a processor, the computer programs implement the steps of the container lifecycle management method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • A container group lifecycle management method based on Kubernetes system architecture

    CN109542605A

  • Application updating method and device, equipment and medium

    CN113741923A