A resource management method and device for a container
Patent Information
- Application Number
- CN202211425763.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-15
- Publication Date
- 2026-10-23
- Estimated Expiration
- 2042-11-15
AI Technical Summary
[0003]然而,Kata Containers为容器添加资源的方法只适用于容器启动的过程中,若在容器启动的过程中配置的资源大小不合适,Kata Containers也无法调整资源大小,可能导致Kata Containers为容器配置的资源无法满足实际的资源需求,或者导致KataContainers为容器配置的资源过大,造成资源浪费
[0025]第五方面,本申请实施例提供一种包含指令的计算机程序产品,当计算机程序产品在计算机上运行时,使得计算机执行如第一方面和第一方面的任一种可能的实现方式中所描述的容器的资源管理方法。
Smart Images

Figure CN115794303B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of cloud computing, and more particularly to a container resource management method and apparatus. Background Technology
[0002] In recent years, Kata Containers has become increasingly widely used due to its advantages of combining the lightweight nature of traditional containers with the security of traditional virtual machines. To improve container startup speed, Kata Containers typically uses fewer resources at startup and adds additional resources as startup progresses. For example, a central processing unit (CPU) resource is defined at container startup, and more CPU resources can be added to the container during startup when more are needed.
[0003] However, Kata Containers' method of adding resources to containers only applies during container startup. If the resource size configured during container startup is inappropriate, Kata Containers cannot adjust the resource size, which may result in Kata Containers configuring resources that do not meet the actual resource requirements, or Kata Containers configuring resources that are too large, resulting in resource waste. Summary of the Invention
[0004] This application provides a container resource management method and apparatus, which can adjust the container resources according to actual needs so that the container resources meet the actual requirements.
[0005] To achieve the above objectives, this application adopts the following technical solution:
[0006] In a first aspect, this application provides a resource management method for a container, applied to a first node. The method includes: creating a user resource object, the user resource object including a namespace of a scheduling unit, an identifier of the scheduling unit, an operation type of the resource, and information about the resource, the operation type of the resource including unloading the resource or mounting the resource; generating a request body based on the user resource object, the request body including an identifier of a sandbox and information about the resource, the identifier of the sandbox being obtained based on the namespace of the scheduling unit and the identifier of the scheduling unit; and mounting the resource to the sandbox or unloading the resource from the sandbox based on the request body.
[0007] Based on the above technical solution, the first node can create user resource objects, generate request bodies based on these objects, and mount or unmount resources from the sandbox according to the request bodies. This allows the first node to configure appropriately sized resources for the container, avoiding both situations where the resources configured by the first node are insufficient to meet actual resource needs and situations where the resources configured by the first node are excessive, resulting in resource waste.
[0008] One possible implementation involves generating a request body based on a user resource object, including: obtaining the address of the first node; obtaining the address of the node where the scheduling unit is located; and generating a request body based on the user resource object if the address of the first node is the same as the address of the node where the scheduling unit is located.
[0009] Based on the above method, when the address of the first node is the same as the address of the node where the scheduling unit is located, it can be determined that the scheduling unit belongs to the first node, ensuring that the first node performs resource management on the scheduling unit.
[0010] One possible implementation is that the request body also includes a boolean type of the user resource and an identifier of the container, the identifier of which is obtained based on the namespace of the scheduling unit and the identifier of the scheduling unit.
[0011] Based on the above method, the first node can determine whether to operate on the sandbox or on a container within the sandbox based on the Boolean type of the user resource in the request body. The first node can also determine which container needs to mount / unmount the resource based on the container's identifier in the request body.
[0012] One possible implementation is that the boolean value of the user resource is false, and the resource is mounted to or unmounted from the sandbox according to the request body, including: mounting the resource to or unmounting the resource from a container in the sandbox according to the request body.
[0013] Based on the above method, when the boolean value of the user resource is false, the first node can mount the resource to a container in the sandbox or unload the resource from a container in the sandbox according to the request body.
[0014] One possible implementation is that the user resource object also includes a boolean type for the user resource.
[0015] Based on the above method, the user resource object also includes a boolean type of user resources, which allows the request body generated by the first node based on the user resource object to contain the boolean type of user resources.
[0016] One possible implementation is that the resource information includes at least one of the following: the type of the resource, the path through which the resource is mounted / unmounted into the container, or the source path of the resource.
[0017] Based on the above method, the first node can mount resources to the sandbox or unmount resources from the sandbox according to the resource type, the path of the resource being mounted / unmounted into the container, or the source path of the resource.
[0018] One possible implementation for unloading resources from the sandbox includes: generating unloading information based on the request body; and invoking the corresponding service based on the unloading information to unload the resources from the sandbox.
[0019] Based on the above method, if resources are unloaded from the sandbox, the first node can generate unloading information based on the request body, call the corresponding service based on the unloading information, unload the resources from the sandbox, and remove the resources on the container to adapt to the actual resource requirements.
[0020] One possible implementation involves mounting resources to a sandbox, including: generating mounting information based on the request body; and invoking the corresponding service based on the mounting information to mount the resources to the sandbox.
[0021] Based on the above method, if resources are mounted to the sandbox, the first node generates mounting information based on the request body, calls the corresponding service based on the mounting information, and mounts the resources to the sandbox, so that resources are added to the container to adapt to the actual resource requirements.
[0022] Secondly, this application provides a container resource management device, which includes a processing module. The processing module is used to create user resource objects, which include a scheduling unit's namespace, a scheduling unit's identifier, a resource's operation type, and resource information. The resource operation type includes unloading or mounting a resource. The processing module is also used to generate a request body based on the user resource object. The request body includes a sandbox identifier and the resource information. The sandbox identifier is obtained based on the scheduling unit's namespace and the scheduling unit's identifier. The processing module is further used to mount resources to the sandbox or unload resources from the sandbox based on the request body.
[0023] Thirdly, this application provides a container resource management apparatus, the apparatus including a processor coupled to a memory, the processor being configured to run computer programs or instructions to implement the container resource management method as described in the first aspect and any possible implementation thereof.
[0024] Fourthly, this application provides a computer-readable storage medium storing instructions that, when executed on a terminal, cause a computer to perform a container resource management method as described in the first aspect and any possible implementation thereof.
[0025] Fifthly, embodiments of this application provide a computer program product containing instructions that, when run on a computer, cause the computer to perform a container resource management method as described in the first aspect and any possible implementation thereof.
[0026] In a sixth aspect, embodiments of this application provide a chip including a processor coupled to a memory, the processor being configured to run computer programs or instructions to implement a container resource management method as described in the first aspect and any possible implementation thereof.
[0027] The technical effects of any possible implementation of aspects two through six can be found in the first aspect or the technical effects of different possible implementations of aspect one, and will not be repeated here. Attached Figure Description
[0028] Figure 1 A schematic diagram of a node provided in an embodiment of this application;
[0029] Figure 2 A flowchart illustrating a container resource management method provided in an embodiment of this application;
[0030] Figure 3 A schematic diagram of the structure of a container resource management device provided in an embodiment of this application;
[0031] Figure 4 A schematic diagram of the structure of another container resource management device provided in an embodiment of this application;
[0032] Figure 5 This is a schematic diagram of the structure of a chip provided in an embodiment of this application. Detailed Implementation
[0033] The resource management method and apparatus for containers provided in the embodiments of this application will be described in detail below with reference to the accompanying drawings.
[0034] In this article, the term "and / or" is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone.
[0035] The terms "first" and "second," etc., used in the specification and drawings of this application are used to distinguish different objects or to distinguish different treatments of the same object, rather than to describe a specific order of objects.
[0036] Furthermore, the terms "comprising" and "having," and any variations thereof, used in the description of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the steps or units listed, but may optionally include other steps or units not listed, or may optionally include other steps or units inherent to such process, method, product, or apparatus.
[0037] It should be noted that in the embodiments of this application, the words "exemplary" or "for example" are used to indicate examples, illustrations, or explanations. Any embodiment or design scheme described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of the words "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.
[0038] To avoid Kata Containers configuring resources that fail to meet actual resource needs, or to prevent Kata Containers from configuring excessive resources that lead to resource waste, this application provides a container resource management method. The apparatus for executing this method can be any device with computing capabilities, such as a portable computer, laptop computer, personal computer (PC), or server, etc.
[0039] As an example, the device could be Figure 1 Node 10 is shown. Figure 1 In this configuration, node 10 may include a hotplug-Operator module 101 and a dm-proxy module 102. The hotplug-Operator module 101 includes a hotplug custom module 1011 and a controller module 1012.
[0040] Specifically, the Hotplug module 1011 can be used to create user resource objects, the Controller module 1012 can be used to generate request bodies based on user resource objects, and the dm-proxy module 102 can be used to mount resources to or unmount resources from the sandbox based on the request bodies. In this way, node 10 can adjust the container's resources according to actual needs, solving the problem of the container's configured resources not meeting actual resource requirements, while also avoiding excessively large container configurations that lead to resource waste.
[0041] Understandably, Kata Containers technology can be applied on node 10. This can avoid the situation where the resources configured for containers by Kata Containers cannot meet the actual resource requirements, and it can also avoid the situation where the resources configured for containers by Kata Containers are too large, resulting in resource waste.
[0042] Figure 1 The node 10 shown is for illustrative purposes only and is not intended to limit the technical solutions of this application. Those skilled in the art should understand that in specific implementations, node 10 may also include other devices, and the number of Hotplug-Operator module 101 and dm-proxy module 102 can be determined according to specific needs without limitation.
[0043] The methods provided in the embodiments of this application will be described in detail below.
[0044] like Figure 2 As shown in the figure, a container resource management method is provided in an embodiment of this application. The container resource management method includes the following steps:
[0045] S201: The first node creates a user resource object.
[0046] In this embodiment of the application, the first node may be Figure 1 Node 10 is shown. That is, the first node may include the Hotplug module 1011, the Controller module 1012, and the dm-proxy module 102.
[0047] One possible implementation is that the Hotplug module 1011 in the first node creates a user resource object. For example, the Hotplug module 1011 in the first node defines and instantiates the user resource object. In this embodiment, the user resource object may include the namespace of the scheduling unit (pod), the identifier of the pod, the operation type of the resource, and information about the resource. Optionally, the user resource object may also include a boolean type of the user resource.
[0048] The pod identifier can be the pod name (podName). Resource operation types include detaching and attaching. Detaching a resource can be understood as removing it from the sandbox, while attaching it can be understood as adding it to the sandbox. When the boolean value of the user resource is true (TRUE), the first node operates on the sandbox; for example, the first node attaches the resource to the sandbox or detaches it from the sandbox. When the boolean value of the user resource is false (FALSE), the first node operates on the container within the sandbox; for example, the first node attaches the resource to a container within the sandbox or detaches it from a container within the sandbox.
[0049] One possible design is that the resource information includes at least one of the following: the resource type, the path to which the resource is mounted / unmounted into the container, or the source path of the resource. The resource type includes block type and rbd type. Understandably, when the resource type is rbd, the Controller module 1012 can create an rbd image of a specified size based on the Ceph storage pool specified by the rbd and map it as a block resource.
[0050] S202: The first node generates a request body based on the user resource object.
[0051] The request body includes the sandbox identifier (id) and resource information. Optionally, the request body may also include the boolean type of the user resource and the identifier (id) of the containers.
[0052] The sandbox ID and container ID are obtained by the first node through a query interface based on the pod's namespace and pod name.
[0053] One possible implementation is that the Controller module 1012 in node 10 generates a request body based on the user resource object sent by the Hotplug module 1011.
[0054] Optionally, the Controller module 1012 in node 10 sends the request body to the dm-proxy module 102. Correspondingly, the dm-proxy module 102 receives the request body.
[0055] Optionally, after creating the user resource object, the Hotplug module 1011 triggers the dm-proxy module 102 to start the dm-proxy service. After starting the dm-proxy service, the dm-proxy module 102 sets the listening address of the dm-proxy service, generates dm-proxy service logs, and maintains a listening state to listen for request bodies sent by the Controller module 1012.
[0056] One possible implementation is that, before S202, the first node, for example, the controller module 1012 of the first node, obtains the address of the first node and the address of the node where the scheduling unit is located. If the address of the first node and the address of the node where the scheduling unit is located are the same, a request body is generated based on the user resource object.
[0057] Understandably, when the address of the first node is the same as the address of the node where the scheduling unit is located, it means that the scheduling unit is on the first node, ensuring that the first node performs resource management for the scheduling unit.
[0058] For example, taking a user resource object that includes the pod's namespace, pod's podName, resource operation type, resource information, and the user resource's boolean type, Controller module 1012 retrieves the sandbox's ID based on the podName and podName, retrieves the containers' ID based on the podName and podName, and retrieves the resource's operation type and resource type. Controller module 1012 then constructs a request body that conforms to the dm-proxy service requirements within the operation function corresponding to the resource's operation type.
[0059] S203: The first node mounts the resource to the sandbox or unmounts the resource from the sandbox according to the request body.
[0060] One possible implementation is that the dm-proxy module 102 in node 10 mounts the resource to the sandbox or unmounts the resource from the sandbox according to the request body.
[0061] One possible implementation is that the boolean value of the user resource is false, and the first node mounts the resource to the sandbox or unmounts the resource from the sandbox according to the request body, including: the first node mounts the resource to a container in the sandbox or unmounts the resource from a container in the sandbox according to the request body.
[0062] Understandably, the operations performed by the first node will differ depending on the type of operation performed on the resource. For example, if the operation type of the resource includes unloading the resource, the first node will unload the resource from the sandbox according to the request body; if the operation type of the resource includes mounting the resource, the first node will mount the resource to the sandbox according to the request body.
[0063] One possible implementation is that after the dm-proxy module 102 listens to the request body, if the resource operation type included in the request body is "mount resource," then the first node, such as the dm-proxy module 102 of the first node, generates mounting information based on the request body and calls the corresponding service based on the mounting information to mount the resource from the sandbox. If the resource operation type included in the request body is "unmount resource," then the first node, such as the dm-proxy module 102 of the first node, generates unmount information based on the request body and calls the corresponding service based on the unmount information to unmount the resource from the sandbox. This will be elaborated on below.
[0064] In scenario 1, the operation type of the resource is to mount the resource. The dm-proxy module 102 generates mounting information based on the request body and calls the corresponding service based on the mounting information to mount the resource from the sandbox.
[0065] For example, the dm-proxy module 102 generates mounting information based on the request body. The dm-proxy module 102 then calls the `attachDevice` function to distribute this mounting information to the shimv2 service. The shimv2 service mounts the resource in the sandbox using the socket address of the management service. The mounting information includes sandbox information, default timeout time, and resource information. The sandbox information includes the sandbox identifier.
[0066] The following examples illustrate this: Example 1 (the first node mounts a block device to the sandbox) and Example 2 (the first node mounts an RBD device to the containers).
[0067] Example 1: In the first node, the Hotplug module 1011 creates a user resource object. This user resource object includes the pod's namespace, podName, resource operation type (attach in Example 1), resource type (block in Example 1), the path where the resource is mounted in the container, the resource's source path, and the user resource's boolean type (true in Example 1). The Controller module 1012 in the first node generates a request body based on the user resource object. This request body includes the sandbox's id, containers' id, resource operation type (attach in Example 1), resource type (block in Example 1), the path where the resource is mounted in the container, the resource's source path, and the user resource's boolean type (true in Example 1).
[0068] Since the boolean type of the user resource is true, the dm-proxy module 102 in the first node mounts the resource to the sandbox. For example, the shimv2 service in the dm-proxy module 102 calls the attachDevice function, passing the request body to attachBlock. It then adds the resource to the sandbox by calling addDevice, and finally mounts the resource to the container through the Kata agent, returning the result. Optionally, the dm-proxy module 102 saves the result in the dm-proxy service log.
[0069] Example 2: In the first node, the Hotplug module 1011 creates a user resource object. This user resource object includes the pod's namespace, podName, resource operation type (attach in Example 2), resource type (rbd in Example 2), path where the resource is mounted in the container, source path of the resource, and boolean type of the user resource (false in Example 2). The Controller module 1012 in the first node generates a request body based on the user resource object. This request body includes the sandbox's id, containers' id, resource operation type (attach in Example 2), resource type (rbd in Example 2), path where the resource is mounted in the container, source path of the resource, and boolean type of the user resource (false in Example 2). Since the resource type in Example 2 is rbd, the Controller module 1012 can create an rbd image of a specified size based on the Ceph storage pool specified by rbd and map it as a block resource.
[0070] Since the boolean type of the user resource is false, the dm-proxy module 102 in the first node mounts the resource to the containers. For example, the shimv2 service in the dm-proxy module 102 calls the attachDevice function, which passes the request body to HotplugDevices. First, it adds the resource to the sandbox by calling addDevice, then mounts the resource to the container through the Kata agent, and finally returns the result of the resource. Optionally, the dm-proxy module 102 saves the result in the log of the dm-proxy service.
[0071] In scenario 2, the operation type for the resource is to unload the resource. The dm-proxy module 102 generates unloading information based on the request body and calls the corresponding service based on the unloading information to unload the resource from the sandbox.
[0072] For example, the dm-proxy module 102 generates unloading information based on the request body. The dm-proxy module 102 calls the function detachDevice to distribute this mounting information to the shimv2 service. The shimv2 service mounts resources in the sandbox through the socket address of the management service. The unloading information includes sandbox information, default timeout time, and resource information.
[0073] It should be understood that Examples 1 and 2 above are merely examples of first-node resource management. In specific applications, examples of first-node resource management can include more than those shown in Examples 1 and 2. For example, the first node may attach an RBD device to the sandbox, the first node may unload a block device from the sandbox, the first node may attach a block device to containers, and the first node may unload an RBD device from containers, etc., which will not be elaborated here.
[0074] based on Figure 2 The method shown allows the first node to create a user resource object, generate a request body based on the user resource object, and then mount the resource onto the sandbox or a container within the sandbox based on the request body, or unload the resource from the sandbox or a container within the sandbox. This allows the first node to adjust the container's resources according to actual needs, solving the problem of insufficient resource configuration in the container to meet actual resource requirements, while also avoiding excessively large resource configurations that lead to resource waste.
[0075] like Figure 3 The diagram shown is a structural schematic of a container resource management device 30 provided in an embodiment of this application. The device includes a processing module 301.
[0076] The processing module 301 is used to create user resource objects, which include the namespace of the scheduling unit, the identifier of the scheduling unit, the operation type of the resource, and the information of the resource. The operation type of the resource includes unloading the resource or mounting the resource. The processing module 301 is also used to generate a request body based on the user resource object. The request body includes the identifier of the sandbox and the information of the resource. The identifier of the sandbox is obtained based on the namespace of the scheduling unit and the identifier of the scheduling unit. The processing module 301 is also used to mount the resource to the sandbox or unload the resource from the sandbox based on the request body.
[0077] One possible design is that the processing module 301 is specifically used to obtain the address of the first node; the processing module 301 is also specifically used to obtain the address of the node where the scheduling unit is located; the processing module 301 is also specifically used to generate a request body based on the user resource object if the address of the first node is the same as the address of the node where the scheduling unit is located.
[0078] One possible design includes a request body that also includes a boolean type for the user resource and an identifier for the container, the identifier of which is derived from the namespace of the scheduling unit and the identifier of the scheduling unit.
[0079] One possible design is that the processing module 301 is also specifically used to mount resources onto or unload resources from containers in the sandbox based on the request body.
[0080] One possible design is that the user resource object also includes a boolean type for the user resource.
[0081] One possible design is that the resource information includes at least one of the following: the type of the resource, the path through which the resource is mounted / unmounted into the container, or the source path of the resource.
[0082] In one possible design, the processing module 301 is further specifically used to generate unloading information based on the request body, and the processing module 301 is further specifically used to call the corresponding service based on the unloading information to unload resources from the sandbox.
[0083] In one possible design, the processing module 301 is further specifically used to generate mounting information based on the request body. The processing module 301 is further specifically used to call the corresponding service based on the mounting information to mount the resource to the sandbox.
[0084] When implemented in hardware, the processing module 301 in this embodiment can be integrated onto the communication interface or onto the processor. Specific implementation methods are as follows: Figure 4 As shown.
[0085] Figure 4A schematic diagram of a possible hardware structure of the container resource management device involved in the above embodiments is shown. The resource management device includes a processor 402. Optionally, the switching device further includes a communication interface 403, a memory 401, and a bus 404.
[0086] Processor 402 is used to control and manage the operation of the container's resource management device, for example, executing the steps performed by processing module 301, and / or other processes for performing the techniques described herein. Processor 402 may implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor may be a central processing unit, a general-purpose processor, a digital signal processor, an application-specific integrated circuit, a field-programmable gate array, or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It may implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor may also be a combination that implements computing functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.
[0087] The communication interface 403 is used to support communication between the container's resource management device and other network entities, for example, to perform the steps executed by the processing module 301 described above.
[0088] The memory 401 is used to store program code and data of the container's resource management device. For example, the memory 401 may be the memory in the container's resource management device, and the memory may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as read-only memory, flash memory, hard disk or solid-state drive; the memory may also include a combination of the above types of memory.
[0089] Bus 404 can be an Extended Industry Standard Architecture (EISA) bus, etc. Bus 404 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 4 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0090] Figure 5 This is a schematic diagram of the structure of chip 50 provided in an embodiment of this application. Chip 50 includes one or more (including two) processors 501. Optionally, chip 50 also includes a communication interface 503, a bus 502, and a memory 504.
[0091] The processor 501 described above can implement or execute various exemplary logic blocks, units, and circuits described in conjunction with the disclosure of this application. The processor can be a central processing unit, a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute various exemplary logic blocks, units, and circuits described in conjunction with the disclosure of this application. The processor can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.
[0092] Memory 504 may include read-only memory and random access memory, and provides operation instructions and data to processor 501. A portion of memory 504 may also include non-volatile random access memory (NVRAM).
[0093] In some implementations, memory 504 stores elements such as execution modules or data structures, or subsets thereof, or extended sets thereof.
[0094] In this embodiment of the application, the corresponding operation is executed by calling the operation instructions stored in the memory 504 (which may be stored in the operating system).
[0095] The memory 504 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as read-only memory, flash memory, hard disk or solid-state drive; the memory may also include combinations of the above types of memory.
[0096] Bus 502 can be an Extended Industry Standard Architecture (EISA) bus, etc. Bus 502 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 5 The symbol is represented by only one line, but this does not mean that there is only one bus or one type of bus.
[0097] Through the above description of the embodiments, those skilled in the art will clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. The specific working process of the system, device, and unit described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0098] This application provides a computer program product containing instructions that, when run on a computer, cause the computer to execute the switching method described in the above method embodiments.
[0099] This application also provides a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the switching method in the method flow shown in the above method embodiments.
[0100] The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: electrical connections having one or more wires; portable computer disks; hard disks; random access memory (RAM); read-only memory (ROM); erasable programmable read-only memory (EPROM); registers; hard disks; optical fibers; portable compact disc read-only memory (CD-ROM); optical storage devices; magnetic storage devices; or any suitable combination thereof; or any other form of computer-readable storage medium known in the art. An exemplary storage medium is coupled to a processor, enabling the processor to read information from and write information to the storage medium. Of course, the storage medium may also be a component of the processor. The processor and the storage medium may reside in an application-specific integrated circuit (ASIC). In the embodiments of this application, the computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0101] Since the switching device, computer-readable storage medium, and computer program product in the embodiments of this application can be applied to the above method, the technical effects that can be obtained can also be referred to the above method embodiments. The embodiments of this application will not be repeated here.
[0102] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0103] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0104] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0105] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A resource management method for containers, characterized in that, Applied to the first node, the method includes: A user resource object is created, which includes the namespace of the scheduling unit, the identifier of the scheduling unit, the operation type of the resource, and the information of the resource. The operation type of the resource includes unloading the resource or mounting the resource. The information of the resource includes: the type of the resource, the path to which the resource is mounted / unloaded into the container, or the source path of the resource. The type of the resource includes block type and RBD type. When the type of the resource is RBD type, an RBD image of a specified size is created according to the Ceph storage pool specified by the RBD, and the RBD image is mapped to the block resource. A request body is generated based on the user resource object. The request body includes the sandbox identifier and the resource information. The sandbox identifier is obtained based on the namespace of the scheduling unit and the identifier of the scheduling unit. The resource is mounted to or unmounted from the sandbox according to the request body.
2. The method according to claim 1, characterized in that, The step of generating a request body based on the user resource object includes: Obtain the address of the first node; Obtain the address of the node where the scheduling unit is located; If the address of the first node is the same as the address of the node where the scheduling unit is located, a request body is generated based on the user resource object.
3. The method according to claim 1 or 2, characterized in that, The request body also includes the boolean type of the user resource and the identifier of the container, wherein the identifier of the container is obtained based on the namespace of the scheduling unit and the identifier of the scheduling unit.
4. The method according to claim 3, characterized in that, When the boolean value of the user resource is false, the step of mounting the resource to the sandbox or unmounting the resource from the sandbox according to the request body includes: The resource is attached to the container in the sandbox or unloaded from the container in the sandbox according to the request body.
5. The method according to claim 3, characterized in that, The user resource object also includes the boolean type of the user resource.
6. The method according to claim 1, 2, or 5, characterized in that, Unloading the resources from the sandbox includes: Generate uninstallation information based on the request body; Based on the uninstallation information, the corresponding service is invoked to uninstall the resource from the sandbox.
7. The method according to claim 1, 2, or 5, characterized in that, The resources are mounted to the sandbox, including: Generate mount information based on the request body; The corresponding service is invoked based on the mounting information to mount the resource to the sandbox.
8. A resource management device for a container, characterized in that, The device includes a processing module; The processing module is used to create user resource objects, which include the namespace of the scheduling unit, the identifier of the scheduling unit, the operation type of the resource, and the information of the resource. The operation type of the resource includes unloading the resource or mounting the resource. The information of the resource includes: the type of the resource, the path to which the resource is mounted / unmounted into the container or the source path of the resource; the type of the resource includes block type and rbd type; when the type of the resource is rbd type, an rbd image of a specified size is created according to the ceph storage pool specified by the rbd, and the rbd image is mapped to the block resource; The processing module is further configured to generate a request body based on the user resource object, the request body including the sandbox identifier and the resource information, the sandbox identifier being obtained based on the namespace of the scheduling unit and the identifier of the scheduling unit; The processing module is further configured to mount the resource to the sandbox or unload the resource from the sandbox according to the request body.
9. A resource management device for a container, characterized in that, include: processor; The processor is coupled to a memory for storing programs or instructions that, when executed by the processor, cause the apparatus to perform the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing instructions, characterized in that, When the computer executes the instructions, the computer performs the method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Jenkins-based equipment management method, device, storage medium and electronic equipment
CN110472413A
Safe container operation method and device, mirror image data downloading method and device and storage medium
CN113886004A