Container resource management method, device, electronic device, medium and product

By determining and allocating distributed storage resources in container management requests, the problem of stateless containers requiring reconfiguration of data during restart is solved, improving the efficiency of container operation and ensuring data durability.

CN119759504APending Publication Date: 2025-04-04DAWNING INT INFORMATION IND CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411978914.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

In the prior art, stateless containers require users to reconfigure data during restart, resulting in low efficiency in container operation.

Method used

By receiving container management requests, the distributed storage resources are determined based on the target storage information, and the container is allocated and saved accordingly when it is started or stopped, ensuring that the data is still saved when the container stops or fails.

Benefits of technology

This avoids users' need to reconfigure data when container restarts, improves container operation efficiency, and ensures data persistence and consistency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119759504A_ABST
    Figure CN119759504A_ABST
Patent Text Reader

Abstract

The present application provides a resource management method, device, electronic device, medium and product for a container. The method includes: receiving a container management request, the container management request includes target storage information of a target persistent container, and a target state, the target state being a startup state or a stop state; if the target state is a startup state, determining a first distributed storage resource according to the target storage information, and allocating the first distributed storage resource to the target persistent container; if the target state is a stop state, determining a second distributed storage resource currently allocated to the target persistent container, and saving the second distributed storage resource. The above scheme, through a distributed storage resource independent of the container, can persist the data of the storage container, and the data is still saved when the container stops or fails, avoiding the user from reconfiguring the data, thereby improving the operation efficiency of the container.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of containerization technology, and in particular to a container resource management method, device, electronic device, medium and product. Background Art

[0002] By using containerization technology to package applications and their dependencies into an independent operating environment, a lightweight virtualization solution is provided that can be effectively applied to large-scale computing business scenarios.

[0003] In the related art, for a stateless container, the container saves a persistent state, and each time the container is restarted, there is no historical data or context information in the container.

[0004] However, this solution requires the user to reconfigure the container data when the container is restarted, and the container can be run only after the configuration is completed, resulting in low container operation efficiency. Summary of the invention

[0005] The present application provides a container resource management method, device, electronic device, medium and product to improve the container operation efficiency.

[0006] In a first aspect, the present application provides a resource management method for a container, comprising: receiving a container management request, the container management request comprising target storage information of a target persistent container, and a target state, the target state being a start state or a stop state; if the target state is a start state, determining a first distributed storage resource according to the target storage information, and allocating the first distributed storage resource to the target persistent container; if the target state is a stop state, determining a second distributed storage resource currently allocated to the target persistent container, and saving the second distributed storage resource.

[0007] Optionally, the method as described above determines the first distributed storage resource based on the target storage information, including: determining the target annotation information of the target persistent container; determining whether the target annotation information includes a target storage resource identifier; if so, determining the first distributed storage resource based on the target storage resource identifier; if not, determining the target storage requirement information of the target persistent container based on the target storage information, and determining the first distributed storage resource corresponding to the target storage requirement information.

[0008] Optionally, according to the method as described above, allocating the first distributed storage resource to the target persistent container includes: creating a first container group, and associating the target persistent container with the first container group to obtain a first association relationship, the first container group being used to carry the storage resources of the target persistent container; mounting the first distributed storage resource to the first container group, thereby allocating the first distributed storage resource to the target persistent container through the first association relationship.

[0009] Optionally, the method as described above also includes: determining multiple available nodes, and determining a target node from the multiple available nodes, the target node being used to run the target persistent container; mounting the first distributed storage resource to the target node, and determining the path where the first distributed storage resource is mounted on the target node as the target writable layer corresponding to the target persistent container; determining a container image of the target persistent container, and building a target read-only layer based on the container image; and building a root file system of the target persistent container based on the target writable layer and the target read-only layer, the root file system being used to provide files and dependencies required for the operation of the target persistent container.

[0010] Optionally, the method as described above further includes: if the target state is a stopped state, determining a second container group associated with the target persistent container; associating the target persistent container with the second container group to obtain a second association relationship, and saving the second association relationship; and deleting the second container group.

[0011] Optionally, the method as described above further includes: monitoring a deletion state of the target persistent container, where the deletion state includes a deleted state or a non-deleted state; if the deletion state of the target persistent container is a deleted state, determining a third container group associated with the target persistent container and a third distributed storage resource mounted with the third container group; and deleting the third container group and the third distributed storage resource.

[0012] In a second aspect, the present application provides a resource management device for a container, comprising: a receiving module, used to receive a container management request, the container management request comprising target storage information of a target persistent container, and a target state, the target state being a start state or a stop state; an allocation module, used to determine a first distributed storage resource according to the target storage information if the target state is a start state, and allocate the first distributed storage resource to the target persistent container; a saving module, used to determine a second distributed storage resource currently allocated to the target persistent container if the target state is a stop state, and save the second distributed storage resource.

[0013] Optionally, in the device as described above, the allocation module is specifically used to determine the target annotation information of the target persistent container; the allocation module is also specifically used to determine whether the target annotation information includes a target storage resource identifier; the allocation module is also specifically used to, if so, determine the first distributed storage resource according to the target storage resource identifier; the allocation module is also specifically used to, if not, determine the target storage requirement information of the target persistent container according to the target storage information, and determine the first distributed storage resource corresponding to the target storage requirement information.

[0014] Optionally, the device as described above further includes: an execution module, used to create a first container group, and associate the target persistent container with the first container group to obtain a first association relationship, the first container group being used to carry the storage resources of the target persistent container; the execution module is also used to mount the first distributed storage resource to the first container group, thereby allocating the first distributed storage resource to the target persistent container through the first association relationship.

[0015] Optionally, the device as described above further includes: a construction module, used to determine multiple available nodes, and determine a target node from the multiple available nodes, wherein the target node is used to run the target persistent container; the construction module is also used to mount the first distributed storage resource to the target node, and determine the path where the first distributed storage resource is mounted on the target node as the target writable layer corresponding to the target persistent container; the construction module is also used to determine the container image of the target persistent container, and build a target read-only layer based on the container image; the construction module is also used to build a root file system of the target persistent container based on the target writable layer and the target read-only layer, and the root file system is used to provide files and dependencies required for the operation of the target persistent container.

[0016] Optionally, the device as described above further includes: a processing module, used to determine a second container group associated with the target persistent container if the target state is a stopped state; the processing module is further used to associate the target persistent container with the second container group to obtain a second association relationship, and save the second association relationship; the processing module is further used to delete the second container group.

[0017] Optionally, the device as described above further includes: a monitoring module, used to monitor the deletion status of the target persistent container, the deletion status including a deleted state or a non-deleted state; the monitoring module is further used to determine a third container group associated with the target persistent container and a third distributed storage resource mounted with the third container group if the deletion status of the target persistent container is a deleted state; the monitoring module is further used to delete the third container group and the third distributed storage resource.

[0018] In a third aspect, the present application provides an electronic device comprising: a processor, and a memory communicatively connected to the processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory to implement any method described in any one of the first aspects.

[0019] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are executed by a processor as described in any one of the methods in the first aspect.

[0020] In a fifth aspect, the present application provides a computer program product, comprising a computer program, wherein the computer program is executed by a processor as in any one of the methods in the first aspect.

[0021] The resource management method, device, electronic device, medium and product of the container provided by the present application include: receiving a container management request, the container management request includes the target storage information of the target persistent container and the target state, the target state is the start state or the stop state; if the target state is the start state, determining the first distributed storage resource according to the target storage information, and allocating the first distributed storage resource to the target persistent container; if the target state is the stop state, determining the second distributed storage resource currently allocated to the target persistent container, and saving the second distributed storage resource. The above scheme can persist the data of the storage container through the distributed storage resources independent of the container, and the data is still saved when the container stops or fails, avoiding the user to reconfigure the data, thereby improving the operation efficiency of the container. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0023] Figure 1 A schematic diagram of an application scenario of a container resource management method provided in an embodiment of the present application;

[0024] Figure 2A schematic diagram of a process flow of a container resource management method provided in an embodiment of the present application;

[0025] Figure 3 A schematic diagram of a process flow of a container resource management method provided in an embodiment of the present application;

[0026] Figure 4 A schematic diagram of determining a first distributed resource provided in an embodiment of the present application;

[0027] Figure 5 A schematic diagram of building a root file system provided in an embodiment of the present application;

[0028] Figure 6 A schematic diagram of a target persistent container management method provided in an embodiment of the present application;

[0029] Figure 7 A schematic diagram of the structure of a resource management device for a container provided in an embodiment of the present application;

[0030] Figure 8 A schematic diagram of the structure of a resource management device for a container provided in an embodiment of the present application;

[0031] Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.

[0032] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0033] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0034] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, processing, transmission, provision, disclosure and application of the relevant data comply with the relevant laws, regulations and standards of the relevant countries and regions, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0035] It should be noted that the resource management method, device, electronic device, medium and product of the container of the present application can be used in the field of containerization technology, and can also be used in any field other than containerization. The application field of the resource management method, device, electronic device, medium and product of the container of the present application is not limited.

[0036] Figure 1 A schematic diagram of an application scenario of a container resource management method provided in an embodiment of the present application is used as an example in combination with the illustrated scenario: an application and dependencies are packaged into a container, and a calculation result is obtained by running the container.

[0037] Exemplarily, a container can provide a program's operating environment, and the container includes a stateless container and a stateful container. Among them, a stateless container is a container that does not rely on or save any persistent state. Each time it is started, the stateless container is a brand new instance without historical data or context information. A stateful container is a container that saves a persistent state, and the persistent state includes but is not limited to at least one of the following: data in the file system, database records, user session information, etc. The persistent state is retained when the container is restarted or migrated to ensure service continuity and data consistency.

[0038] In cloud computing business scenarios, Kubernetes, as a container orchestration platform, provides powerful resource management and scheduling capabilities. Through dynamic resource allocation, multi-tenant support, or elastic expansion, Kubernetes can effectively support resource management and scheduling in the AI ​​training process.

[0039] In related technologies, the container scheduling provided by Kubernetes is for stateless containers, and the container environment needs to be reconfigured each time it is started. However, AI training requires a complex environment, and reconfiguring the container environment is inefficient, which in turn leads to low container operation efficiency.

[0040] The method for container resource management provided in this application is intended to solve the above technical problems in the prior art.

[0041] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0042] Figure 2 A schematic diagram of a process flow of a container resource management method provided in an embodiment of the present application, the method comprising the following steps:

[0043] S201: Receive a container management request, where the container management request includes target storage information of a target persistent container and a target state, where the target state is a start state or a stop state.

[0044] Among them, the persistent container is a container that can persist data and is suitable for business scenarios with complex container data configuration, such as AI training.

[0045] Optionally, the execution subject of the present application is a persistence container controller (PersistenceContainerController), and the resources of the target persistence container are managed through the persistence container controller.

[0046] Exemplarily, Kubernetes Custom Resource Definition (CRD) allows the creation and management of custom resources. This application adds two definitions to the target persistent container: target storage information and target status.

[0047] Optionally, the target storage information defines the storage service and storage size required by the target persistent container. The target state defines whether the container is enabled.

[0048] S202: If the target state is the startup state, determine a first distributed storage resource according to the target storage information, and allocate the first distributed storage resource to the target persistent container.

[0049] Among them, the life cycle of distributed storage resources is independent of the persistent container. Even if the persistent container is deleted, restarted, or migrated to other nodes, the data in the distributed storage resources still exists, thereby improving the data security of the persistent container.

[0050] In the related art, the data storage location of the persistent container is bound to the specified path of the node. If the data is stored in a non-specified path in actual operation, the data will be lost after the persistent container is closed.

[0051] In this application, for example, distributed storage resources are allowed to migrate on multiple nodes. This means that persistent containers can be started on different nodes, and the same distributed storage resources can be mounted each time they are started to restore the previous data state. This cross-node sharing capability allows you to restart on a normal node and continue to access the same data when the container stops or a node fails, thereby improving data consistency and persistence.

[0052] S203: If the target state is the stopped state, determine the second distributed storage resource currently allocated to the target persistent container, and save the second distributed storage resource.

[0053] The second distributed storage resource is a distributed storage resource currently used by the target persistent container, and the second distributed storage resource is used to store data of the target persistent container.

[0054] Exemplarily, after the target persistent container stops, by saving the second distributed storage resource, after the target persistent container is subsequently restarted, the data of the target persistent container can be restored through the saved second distributed storage resource, thereby avoiding the user from reconfiguring the data.

[0055] Optionally, the target persistent container is monitored in real time, and when it is monitored that the target persistent container is switched to a stopped state, the second distributed storage resource is triggered to be saved in real time to ensure that data is not lost in time.

[0056] For example, if the container is scheduled to run on another node after restart, the container can still correctly mount the same storage resource on the new node based on the saved second distributed storage resource. This cross-node sharing capability ensures that the data of the target persistent container remains consistent and available.

[0057] It should be noted that the first distributed storage resource and the second distributed storage resource in the present application are only used to distinguish different application scenarios, and do not mean that the first distributed storage resource and the second distributed storage resource corresponding to the same target persistent container are different distributed storage resources, which will not be repeated below.

[0058] The container resource management method provided in the embodiment of the present application receives a container management request, which includes the target storage information of the target persistent container and the target state, where the target state is the start state or the stop state; if the target state is the start state, the first distributed storage resource is determined according to the target storage information, and the first distributed storage resource is allocated to the target persistent container; if the target state is the stop state, the second distributed storage resource currently allocated to the target persistent container is determined, and the second distributed storage resource is saved. The above scheme can persist the data of the storage container through the distributed storage resources independent of the container, and the data is still saved when the container stops or fails, avoiding the user to reconfigure the data, thereby improving the operation efficiency of the container.

[0059] Based on any of the above embodiments, Figure 3 , which explains the detailed process of container resource management.

[0060] Figure 3 A flowchart of a container resource management method provided in an embodiment of the present application. Figure 3 As shown, the method includes:

[0061] S301: Receive a container management request, where the container management request includes target storage information of a target persistent container and a target state, where the target state is a start state or a stop state.

[0062] It should be noted that the execution process of S301 refers to S201 and will not be repeated here.

[0063] S302: Determine target annotation information of the target persistent container.

[0064] The target annotation information is used to provide non-identifiable, readable information and is used to describe the configuration, status or other related information of the resource.

[0065] Optionally, the target annotation information is metadata in the form of a key-value pair.

[0066] Optionally, obtain target annotation information through logs or interfaces.

[0067] S303: Determine whether the target annotation information includes a target storage resource identifier.

[0068] Optionally, the target storage resource identifier is a unique identifier of the target storage resource.

[0069] The target resource is a resource that stores data of the target persistent container.

[0070] In combination with the scenario example, if the target persistent container is started for the first time, the target resource has not been allocated to the target persistent container, and the target annotation information does not include the target storage resource identifier. If the target persistent container is restarted, the target resource has been allocated to the target persistent container, and the target annotation information does not include the target storage resource identifier corresponding to the allocated target resource.

[0071] If yes, execute S304.

[0072] If not, execute S305.

[0073] S304: Determine a first distributed storage resource according to the target storage resource identifier.

[0074] Exemplarily, if the target annotation information includes a target storage resource identifier, it indicates that the distributed storage resource corresponding to the target persistent container has been determined when the target persistent container is created. Then, the first distributed storage resource corresponding to the target resource identifier is the target resource allocated to the target persistent container.

[0075] In conjunction with the scenario example, the first distributed storage resource stores the data of the target persistent container. By determining the first distributed resource, reconfiguration of the data of the target persistent container can be avoided.

[0076] S305: Determine target storage requirement information of the target persistent container according to the target storage information, and determine a first distributed storage resource corresponding to the target storage requirement information.

[0077] Next, combine Figure 4 Determining the first distributed resource is described.

[0078] Figure 4 A schematic diagram of determining a first distributed resource provided in an embodiment of the present application. Figure 4 As shown, the target storage information and target state of the target persistent container are defined through the custom resource definition. If the target state is the startup state, the target annotation information of the target persistent container is determined. If the target annotation information includes the target storage identifier, the allocated first distributed storage resource is determined according to the target storage resource identifier. If the target annotation information does not include the target storage resource identifier, the first distributed storage resource is applied for according to the target storage information.

[0079] Exemplarily, the storage service and storage size required by the target persistent container are determined according to the target storage requirement information, and the distributed storage resource that meets the storage service and storage size requirements is determined as the first distributed storage resource.

[0080] Optionally, the storage service includes but is not limited to at least one of the following: storage performance information (such as storage bandwidth information), storage geographic location information, or storage security information, etc. The storage size identifies how much storage space the target persistent container requires.

[0081] Combined with the scenario example description, according to the target storage information, the first distributed storage resource that meets the requirements of the target persistent container can be accurately determined, thereby improving the accuracy of resource allocation.

[0082] Optionally, among multiple distributed storage resources that meet the conditions, the optimal first distributed storage resource is selected according to the current load situation. For example, the system may select the first distributed storage resource on a node with a lower load to avoid overloading certain nodes.

[0083] It should be noted that the present application does not limit the execution order of S304 and S305.

[0084] S306: Create a first container group, and associate the target persistent container with the first container group to obtain a first association relationship, where the first container group is used to carry storage resources of the target persistent container.

[0085] Among them, the container group (Pod) is the smallest deployable unit in Kubernetes.

[0086] Exemplarily, the first container group provides the target persistent container with the ability to access distributed storage resources. By mounting the distributed storage resources to a specific path in the first container group, the target persistent container can read and write these distributed storage resources at runtime.

[0087] Optionally, use label selectors (Labels and Selectors) to associate the target persistent container with the first container group. For example, add specific labels to the YAML file of the first container group, and then select the target persistent container by using these labels.

[0088] S307: Mount the first distributed storage resource to the first container group, thereby allocating the first distributed storage resource to the target persistent container through the first association relationship.

[0089] Exemplarily, through the first association relationship, the first container group transmits the information of the mounted first distributed storage resource to the target persistent container, which means that the target persistent container can automatically access the first distributed storage resource and use the storage space provided by it.

[0090] Optionally, the usage of the first distributed storage resource is continuously monitored to ensure its performance and availability. If the load of the first distributed storage resource is found to be too high or a fault occurs, optimization or fault recovery can be automatically performed to ensure the normal operation of the target persistent container.

[0091] Optionally, if the storage requirement of the target persistent container changes (for example, insufficient storage capacity), the first container group can dynamically adjust the allocated first distributed storage resource, for example, by expanding the capacity of the first distributed storage resource or migrating the target persistent container to other more suitable storage resources.

[0092] A feasible implementation method, the resource management method of the container also includes: determining multiple available nodes, and determining a target node from the multiple available nodes, the target node is used to run the target persistent container; mounting the first distributed storage resource to the target node, and determining the path where the first distributed storage resource is mounted on the target node as the target writable layer corresponding to the target persistent container; determining the container image of the target persistent container, and building a target read-only layer based on the container image; building a root file system of the target persistent container based on the target writable layer and the target read-only layer, the root file system is used to provide files and dependencies required for the operation of the target persistent container.

[0093] Optionally, the multiple available nodes are all healthy nodes, the multiple available nodes are all nodes with idle resources, and the multiple available nodes are all nodes with normal network connection status.

[0094] Optionally, query the node list through the interface and determine the available nodes from the node list.

[0095] Optionally, multiple available nodes are evaluated based on factors such as performance, health status, resource quantity, network connectivity, security, or geographical location of the multiple available nodes, and the target node is determined based on the evaluation results.

[0096] Among them, the root file system RootFs is a complete file system used by the target persistent container, which provides the target persistent container with all the files and dependencies required to run the application.

[0097] In the related art, a temporary directory is created on the host's file system for storing data, and the data in the temporary directory will be lost when the container stops. This application creates a root file system that does not rely on the host for storing data, which can improve data security.

[0098] Next, combine Figure 5 Describes how to build a root file system.

[0099] Figure 5 This is a schematic diagram of building a root file system provided in an embodiment of the present application. Figure 5 As shown, specify a mount path for the first distributed storage resource and ensure that the path is available on the target node. Mount the distributed storage resource to the specified path on the target node and use it as the target writable layer. When the target persistent container is started, specify a directory that will be mapped to the target persistent container, allowing the target persistent container to perform write operations at runtime. The container image is a file that contains the files required for the application to run. Download the container image to the target node, decompress the container image to obtain the target read-only layer, and the target persistent container reads the files in the target read-only layer to automatically configure the data. Build the root file system based on the target writable layer and the target read-only layer.

[0100] Exemplarily, the target write layer upperdir allows the target persistent container to create, modify or delete files at runtime. The target read-only layer lowerdir contains the basic files, dependent libraries, or configuration files of the application. The target read-only layer is immutable, which means that the target persistent container cannot modify the files in these layers at runtime. It can be understood that the hierarchical structure of read-only layer and writable layer not only improves the startup efficiency of the target persistent container, but also enhances the isolation and security of the target persistent container.

[0101] In this feasible implementation, the layered root file system ensures the security and consistency of data, thereby improving the isolation and flexibility of the target persistent container.

[0102] S308: If the target state is the stopped state, determine the second distributed storage resource currently allocated to the target persistent container, and save the second distributed storage resource.

[0103] It should be noted that the execution process of S308 refers to S203 and will not be repeated here.

[0104] In a feasible implementation, the container resource management method further includes: if the target state is a stopped state, determining a second container group associated with the target persistent container; associating the target persistent container with the second container group to obtain a second association relationship, and saving the second association relationship; and deleting the second container group.

[0105] Exemplarily, when the target persistent container is in a stopped state, the second container group currently associated with the target persistent container is searched, and by establishing a second association relationship, when the target persistent container is restarted, the second container group last associated with the target persistent container can be determined according to the second association relationship.

[0106] Optionally, the second association relationship is saved in a metadata storage, such as an API server of Kubernetes, an external database, or other reliable storage system, to improve the security of the second association relationship.

[0107] Exemplarily, the present application uses distributed storage resources to persist data, that is, the second container group is deleted, the data of the target persistent container is still retained, and deleting the second container group can effectively release resources. The saved second association relationship can be used to quickly rebuild the container group and improve the efficiency of container group configuration.

[0108] In this feasible implementation, by saving the second association relationship, the second container group can be quickly rebuilt, and then the second container group can be deleted when the target persistent container is in a stopped state, thereby reducing unnecessary occupancy and improving the effective utilization of storage resources.

[0109] In a feasible implementation manner, the container resource management method also includes: monitoring the deletion status of the target persistent container, where the deletion status includes a deleted state or a non-deleted state; if the deletion status of the target persistent container is a deleted state, determining a third container group associated with the target persistent container and a third distributed storage resource mounted with the third container group; and deleting the third container group and the third distributed storage resource.

[0110] The deleted state indicates that the target persistent container is no longer used, which is different from the stopped state, which indicates that the target persistent container is temporarily not used.

[0111] Combined with the scenario example, for the target persistent container in the deleted state, the corresponding third container group and the third distributed storage resource are no longer used. By deleting the third container group and the third distributed storage resource, the resources can be effectively released.

[0112] Optionally, the deletion status is monitored in real time, so that when the target persistent container is deleted, the third container group and the third distributed storage resource are deleted in time.

[0113] Next, combine Figure 6 Describes the management method of the target persistent container.

[0114] Figure 6 A schematic diagram of a target persistent container management method provided in an embodiment of the present application. Figure 6 As shown, corresponding management operations are performed according to different states of the target persistent container. If the target persistent container is in the startup state, a corresponding first container group is created for the target persistent container and a first distributed storage resource is allocated to the first container group. If the target persistent container is in the stop state, the second container group corresponding to the target persistent container is deleted, and the second distributed storage resource corresponding to the target persistent container is saved. If the target persistent container is in the deletion state, the third container group corresponding to the target persistent container and the corresponding third distributed storage resource are deleted.

[0115] In this feasible implementation, by deleting the third container group and the third distributed storage resource that are no longer used, resources can be effectively recovered to improve the effective utilization rate of resources.

[0116] Figure 7 This is a schematic diagram of the structure of a container resource management device provided in an embodiment of the present application. Figure 7 As shown, the resource management device 70 of the container may include: a receiving module 71, an allocation module 72, and a storage module 73, wherein:

[0117] The receiving module 71 is used to receive a container management request, where the container management request includes target storage information of a target persistent container and a target state, where the target state is a start state or a stop state.

[0118] The allocation module 72 is configured to determine the first distributed storage resource according to the target storage information and allocate the first distributed storage resource to the target persistent container if the target state is the startup state.

[0119] The saving module 73 is used to determine the second distributed storage resource currently allocated to the target persistent container and save the second distributed storage resource if the target state is the stopped state.

[0120] Optionally, the receiving module 71 may execute Figure 2 S201 in the embodiment.

[0121] Optionally, the allocation module 72 may execute Figure 2 S202 in the embodiment.

[0122] Optionally, the saving module 73 may execute Figure 2 S203 in the embodiment.

[0123] It should be noted that the resource management device for the container shown in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.

[0124] In a possible implementation, the allocation module 72 is specifically configured to:

[0125] Determine the target annotation information of the target persistence container;

[0126] Determining whether the target annotation information includes a target storage resource identifier;

[0127] If yes, determining the first distributed storage resource according to the target storage resource identifier;

[0128] If not, the target storage requirement information of the target persistent container is determined according to the target storage information, and the first distributed storage resource corresponding to the target storage requirement information is determined.

[0129] Figure 8 A schematic diagram of the structure of a resource management device for a container provided in an embodiment of the present application. Figure 7 Based on the embodiment shown, Figure 8 As shown, the resource management device 80 of the container further includes: an execution module 74, a construction module 75, a processing module 76, and a monitoring module 77, wherein:

[0130] The execution module 74 is used to:

[0131] Creating a first container group, and associating the target persistent container with the first container group to obtain a first association relationship, where the first container group is used to carry storage resources of the target persistent container;

[0132] The first distributed storage resource is mounted to the first container group, thereby allocating the first distributed storage resource to the target persistent container through the first association relationship.

[0133] Building block 75 for:

[0134] Determine multiple available nodes, and determine a target node from the multiple available nodes, where the target node is used to run a target persistent container;

[0135] Mounting the first distributed storage resource to the target node, and determining the path where the first distributed storage resource is mounted on the target node as the target writable layer corresponding to the target persistent container;

[0136] Determine the container image of the target persistent container and build the target read-only layer based on the container image;

[0137] The root file system of the target persistent container is constructed based on the target writable layer and the target read-only layer. The root file system is used to provide the files and dependencies required for the target persistent container to run.

[0138] The processing module 76 is used to:

[0139] If the target state is the stopped state, determining a second container group associated with the target persistent container;

[0140] Associating the target persistent container with the second container group to obtain a second association relationship, and saving the second association relationship;

[0141] Delete the second container group.

[0142] The monitoring module 77 is used to:

[0143] Monitor the deletion status of the target persistent container, which includes the deleted state or the undeleted state;

[0144] If the deletion state of the target persistent container is a deleted state, determining a third container group associated with the target persistent container and a third distributed storage resource mounted with the third container group;

[0145] The third container group and the third distributed storage resource are deleted.

[0146] Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Fig. 9 As shown, the electronic device includes:

[0147] The electronic device includes a processor 291 and a memory 292; it may also include a communication interface 293 and a bus 294. The processor 291, the memory 292, and the communication interface 293 may communicate with each other through the bus 294. The communication interface 293 may be used for information transmission. The processor 291 may call the logic instructions in the memory 292 to execute the method of the above embodiment.

[0148] In addition, the logic instructions in the above-mentioned memory 292 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product.

[0149] The memory 292 is a computer-readable storage medium that can be used to store software programs and computer executable programs, such as program instructions / modules corresponding to the methods in the embodiments of the present application. The processor 291 executes functional applications and data processing by running the software programs, instructions, and modules stored in the memory 292, that is, implementing the methods in the above method embodiments.

[0150] The memory 292 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function; the data storage area may store data created according to the use of the terminal device, etc. In addition, the memory 292 may include a high-speed random access memory and may also include a non-volatile memory.

[0151] An embodiment of the present application provides a non-temporary computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the method as described in the above embodiment.

[0152] An embodiment of the present application provides a computer program product, including a computer program, which implements the method of the above embodiment when the computer program is executed by a processor.

[0153] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.

[0154] It should be further noted that, although the various steps in the flowchart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.

[0155] It should be understood that the above-mentioned device embodiments are only illustrative, and the device of the present application can also be implemented in other ways. For example, the division of units / modules in the above-mentioned embodiments is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.

[0156] In addition, unless otherwise specified, each functional unit / module in each embodiment of the present application may be integrated into one unit / module, each unit / module may exist physically separately, or two or more units / modules may be integrated together. The above-mentioned integrated unit / module may be implemented in the form of hardware or in the form of a software program module.

[0157] If the integrated unit / module is implemented in the form of hardware, the hardware may be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, memristors, etc. The processor may be any appropriate hardware processor, such as a CPU, a GPU, an FPGA, a DSP, and an ASIC, etc. The storage unit may be any appropriate magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory RRAM (Resistive Random Access Memory), a dynamic random access memory DRAM (Dynamic Random Access Memory), a static random access memory SRAM (Static Random-Access Memory), an enhanced dynamic random access memory EDRAM (Enhanced Dynamic Random Access Memory), a high-bandwidth memory HBM (High-Bandwidth Memory), a hybrid memory cube HMC (Hybrid Memory Cube), etc.

[0158] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a memory and includes several instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.

[0159] In the above embodiments, the description of each embodiment has its own emphasis. For the part not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0160] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0161] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A container resource management method, characterized in that: include: receiving a container management request, wherein the container management request includes target storage information of a target persistent container and a target state, wherein the target state is a start state or a stop state; If the target state is the startup state, determining a first distributed storage resource according to the target storage information, and allocating the first distributed storage resource to the target persistent container; If the target state is a stopped state, the second distributed storage resource currently allocated by the target persistent container is determined, and the second distributed storage resource is saved.

2. The method according to claim 1, characterized in that Determining a first distributed storage resource according to the target storage information includes: Determine target annotation information of the target persistent container; Determining whether the target annotation information includes a target storage resource identifier; If yes, determining the first distributed storage resource according to the target storage resource identifier; If not, the target storage requirement information of the target persistent container is determined according to the target storage information, and the first distributed storage resource corresponding to the target storage requirement information is determined.

3. The method according to claim 1 or 2, characterized in that: Allocating the first distributed storage resource to the target persistent container includes: Creating a first container group, and associating the target persistent container with the first container group to obtain a first association relationship, wherein the first container group is used to carry storage resources of the target persistent container; The first distributed storage resource is mounted to the first container group, thereby allocating the first distributed storage resource to the target persistent container through the first association relationship.

4. The method according to any one of claims 1 to 3, characterized in that The method further comprises: Determine a plurality of available nodes, and determine a target node from the plurality of available nodes, wherein the target node is used to run the target persistent container; Mounting the first distributed storage resource to the target node, and determining the path where the first distributed storage resource is mounted on the target node as the target writable layer corresponding to the target persistent container; Determine a container image of the target persistent container, and build a target read-only layer according to the container image; A root file system of the target persistent container is constructed according to the target writable layer and the target read-only layer, and the root file system is used to provide files and dependencies required for the operation of the target persistent container.

5. The method according to claim 1, characterized in that: The method further comprises: If the target state is a stopped state, determining a second container group associated with the target persistent container; Associating the target persistent container with the second container group to obtain a second association relationship, and saving the second association relationship; Delete the second container group.

6. The method according to any one of claims 1 to 5, characterized in that The method further comprises: Monitoring a deletion state of the target persistent container, where the deletion state includes a deleted state or a non-deleted state; If the deletion state of the target persistent container is a deleted state, determining a third container group associated with the target persistent container and a third distributed storage resource mounted with the third container group; The third container group and the third distributed storage resource are deleted.

7. A container resource management device, characterized in that: include: A receiving module, configured to receive a container management request, wherein the container management request includes target storage information of a target persistent container and a target state, wherein the target state is a start state or a stop state; an allocation module, configured to determine a first distributed storage resource according to the target storage information and allocate the first distributed storage resource to the target persistent container if the target state is a startup state; The saving module is used to determine the second distributed storage resource currently allocated to the target persistent container and save the second distributed storage resource if the target state is the stopped state.

8. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 6 when executed by a processor.

10. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 6 when being executed by a processor.