Storage area creation method, system, electronic device, and computer storage medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-16
- Publication Date
- 2026-08-11
AI Technical Summary
例如,若在一个节点上创建对应于容器的若干个没有I/O隔离的存储区域,若某一个容器发生了大量的I/O请求,会造成该节点上的其他容器的存储资源挤兑,甚至可能影响节点上的宿主机系统出现问题
[0014]根据本申请实施例提供的存储区域创建方案,通过稀疏文件模板以稀疏文件的方式存储容器的格式化数据,降低了获得存储容器的格式化数据的过程中需要操作的数据量,在获得节点获得稀疏文件模板后,可以继续根据所述稀疏文件模板中的格式化数据创建所述容器对应的本地存储空间,并将创建的所述本地存储空间作为块设备挂载至所述容器下,从而实现了容器间的I/O隔离。
Smart Images

Figure CN116301624B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, system, electronic device, and computer storage medium for creating a storage area. Background Technology
[0002] As containers become unified online service clusters capable of orchestration, related container issues have also emerged, especially the I / O (input / output) isolation problem. For example, if several storage areas without I / O isolation are created on a node corresponding to containers, and a large number of I / O requests occur in one container, it will cause storage resource congestion for other containers on that node, and may even affect the host system on the node.
[0003] In view of this, the technical problem that the existing technology urgently needs to solve is to provide an alternative method for creating storage areas. Summary of the Invention
[0004] In view of this, embodiments of this application provide a storage area creation scheme to at least partially solve the above-mentioned problems.
[0005] According to a first aspect of the embodiments of this application, a method for creating a storage region is provided, including:
[0006] In response to a storage space creation instruction for a container, the node used to run the container is instructed to obtain a sparse file template for the local storage of the node, the sparse file template being used to store the formatted data of the container as a sparse file.
[0007] The local storage space corresponding to the container is created based on the formatted data in the sparse file template.
[0008] The created local storage space is mounted as a block device to the container to create a storage area for the container.
[0009] According to a second aspect of the embodiments of this application, a container management system is provided, including: a control component running outside a node and a management component running inside a node;
[0010] The control component is used to receive a storage space creation instruction for the container and send the storage space creation instruction to the management component in the node used to run the container;
[0011] The management component is used to enable the node to obtain a sparse file template to the node's local storage. The sparse file template is used to format data of the sparse file storage container. The component is used to create a local storage space corresponding to the container based on the formatted data in the sparse file template. The component is used to mount the created local storage space as a block device to the container to create a storage area for the container.
[0012] According to a third aspect of the present application, an electronic device is provided, comprising: a processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other via the communication bus; the memory is used to store at least one executable instruction, wherein the executable instruction causes the processor to perform an operation corresponding to the method described in the first aspect.
[0013] According to a fourth aspect of the embodiments of this application, a computer storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the method described in the first aspect.
[0014] According to the storage area creation scheme provided in the embodiments of this application, the formatted data of the container is stored in a sparse file manner using a sparse file template, which reduces the amount of data that needs to be operated in the process of obtaining the formatted data of the storage container. After the node obtains the sparse file template, it can continue to create the local storage space corresponding to the container according to the formatted data in the sparse file template, and mount the created local storage space as a block device under the container, thereby realizing I / O isolation between containers. Attached Figure Description
[0015] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings.
[0016] Figure 1 A schematic diagram of an exemplary system for the storage area creation method applicable to embodiments of this application;
[0017] Figure 2 This is a flowchart illustrating the steps of a storage area creation method according to an embodiment of this application;
[0018] Figure 3 This is a flowchart illustrating the steps of another storage area creation method according to an embodiment of this application;
[0019] Figure 4 This is a schematic diagram illustrating a usage scenario according to an embodiment of this application;
[0020] Figure 5 This is a schematic diagram of a container management system according to an embodiment of this application;
[0021] Figure 6 This is a schematic diagram of another container management system according to an embodiment of this application;
[0022] Figure 7 This is a schematic diagram of the structure of an electronic device according to Embodiment 5 of this application. Detailed Implementation
[0023] To enable those skilled in the art to better understand the technical solutions in the embodiments of this application, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art should fall within the protection scope of the embodiments of this application.
[0024] The specific implementation of the embodiments of this application will be further described below with reference to the accompanying drawings.
[0025] Figure 1 An exemplary system for creating a storage area applicable to embodiments of this application is shown. For example... Figure 1 As shown, the system 100 may include a cloud server 102, a communication network 104, and / or one or more user devices 106. Figure 1 The example in the text shows multiple user devices.
[0026] The cloud server 102 can be any suitable device for storing information, data, programs, and / or any other suitable type of content, including but not limited to distributed storage system devices, server clusters, computing cloud server clusters, etc. In some embodiments, the cloud server 102 can perform any suitable function. For example, in some embodiments, the cloud server 102 may include multiple nodes, which can be used to run containers. As an optional example, in some embodiments, the cloud server 102 can be used to orchestrate and manage containers.
[0027] In some embodiments, the communication network 104 can be any suitable combination of one or more wired and / or wireless networks. For example, the communication network 104 can include any one or more of the following: the Internet, an intranet, a wide area network (WAN), a local area network (LAN), a wireless network, a digital subscriber line (DSL) network, a frame relay network, an asynchronous transfer mode (ATM) network, a virtual private network (VPN), and / or any other suitable communication network. The user equipment 106 can be connected to the communication network 104 via one or more communication links (e.g., communication link 112), and the communication network 104 can be linked to the cloud server 102 via one or more communication links (e.g., communication link 114). The communication link can be any communication link suitable for transmitting data between the user equipment 106 and the cloud server 102, such as a network link, a dial-up link, a wireless link, a hardwired link, any other suitable communication link, or any suitable combination of such links.
[0028] User equipment 106 may include one or more user devices suitable for displaying container orchestration options and receiving container orchestration instructions. In some embodiments, user equipment 106 may include any suitable type of device. For example, in some embodiments, user equipment 106 may include mobile devices, tablet computers, laptop computers, desktop computers, wearable computers, game consoles, media players, vehicle entertainment systems, and / or any other suitable type of user equipment.
[0029] Based on the above system, this application provides a method for creating a storage area, which will be described below through several embodiments.
[0030] Below, we will first explain the technical terms involved in this application.
[0031] Elastic block storage is a low-latency, persistent, and highly reliable block-level random storage provided for cloud servers.
[0032] DeviceMapper is a framework provided by the Linux kernel system for converting physical devices into virtual logical devices.
[0033] Logical Volume Manager (LVM) is a user-space capability provided by the Linux system based on the DeviceMapper framework. It has the ability to dynamically manage hard disks. It can divide a large block device into sub-blocks of arbitrary size for use by different applications.
[0034] A sparse file is a type of computer file that attempts to use file system space more efficiently when the file content is mostly empty. It works by representing empty data blocks with brief information (metadata) instead of occupying actual space on the disk to store them. Only the actual (non-empty) data blocks are written to the disk as is.
[0035] loopdevice: / dev / loop (or vnd (vnode disk), lofi (loop file interface)) is a pseudo-device in Unix-like systems that allows files to be accessed as if they were block devices.
[0036] Kubernetes (often abbreviated as K8s) is an open-source system for automatically deploying, scaling, and managing containerized applications.
[0037] CSI: The standard protocol for using storage within Kubernetes.
[0038] rootfs: The root directory of the container; all files within the container reside in the root directory.
[0039] Below, we will first explain the general approach of creating a root directory with I / O isolation for containers.
[0040] The first approach is to use a separate elastic block storage as the root directory. However, creating the elastic block storage and mounting it to the container takes a long time, which leads to longer startup times for the corresponding container instances and a poor user experience.
[0041] Specifically, users can create an instance pod and declare that they will use a separate elastic block storage as the root directory rootfs. Then, the CSI can call the ECS's open API to create the elastic block storage and use the open API to mount the data disk. After that, the CSI will continue to perform formatting, mounting, and other operations to mount it to a specific directory on the host machine. Once the mounting is complete, the container image is downloaded. The image can start when the container is running and set the root directory of the container to the elastic block storage mount directory when the container is running.
[0042] However, the above solution has the following drawbacks:
[0043] 1. Excessive creation / mounting time for Elastic Block Storage: Elastic Block Storage is created and mounted by calling the ECS OpenAPI, both of which are very time-consuming. This can cause the instance pod to take a very long time to start, affecting the user experience.
[0044] 2. The minimum size for elastic block storage is 20 Gi. This size is somewhat large for applications using containers, which will lead to a waste of resources. Gi is a unit of measurement; 1024B = 1KiB (often abbreviated as 1Ki); 1024KiB = 1MiB (often abbreviated as 1Mi); 1024MiB = 1GiB (often abbreviated as 1Gi).
[0045] 3. A typical ECS instance can only mount a maximum of 16 elastic block storage units; even special models can only mount 64 elastic block storage units. This not only squeezes the space available for users' persistent data disks, but also limits the number of containers that can be deployed on a single machine.
[0046] The second approach utilizes the Logical Volume Manager (LVM) component to create logical volumes corresponding to the containers on the nodes based on Elastic Block Storage, and uses these logical volumes as the root directory of the containers. Compared to the first approach described above:
[0047] 1. By creating the logical volume corresponding to the container locally, there is no need to call the open API, which saves time and improves speed.
[0048] 2. LVM can create logical volumes of any size, improving resource utilization.
[0049] 3. LVM will only use the elastic block storage quota of the physical disks it uses. It can guarantee the corresponding quota for users' persistent storage.
[0050] However, logical volumes still have the following problems:
[0051] 1. The creation and deletion of logical volumes are slow, especially under I / O pressure, which may increase the creation time to the second or 10 seconds, resulting in a poor user experience.
[0052] 2. Maintaining logical volumes consumes CPU resources. As the number of containers increases, the maintenance of logical volumes consumes a large amount of CPU resources.
[0053] 3. When an error occurs in a logical volume, such as failure to create or delete, or a freeze, it will affect the operation of other logical volumes and may even cause errors in the host machine where the container is located.
[0054] In view of this, embodiments of this application provide another solution for creating storage space for containers.
[0055] See Figure 2 The figure illustrates a flowchart of creating storage space for a container according to an embodiment of this application, as shown in the figure, which includes:
[0056] S201. In response to a storage space creation instruction for a container, the node used to run the container is instructed to obtain a sparse file template for local storage of the node, the sparse file template being used to store formatted data of the container via sparse files.
[0057] Specifically, in this embodiment, when creating an instance, the user can declare that the local storage of the node will be used as the root directory of the container corresponding to the instance. After receiving the instance creation request, the server can determine the node where the container is located and send a storage space creation instruction to the node for the container. The storage space creation instruction is used to instruct the node to use local storage to create the root directory for the container.
[0058] After receiving the storage space creation instruction, the node can obtain a sparse file template.
[0059] In this embodiment, the sparse file template uses formatted data from a sparse file storage container. Empty data blocks in the sparse file can be represented by brief information, while the actual data blocks are written to the disk. This allows the sparse file to occupy less storage space than its declared size. By using formatted data from the sparse file storage container, the actual storage space occupied by the container's file template is reduced, making it easier to copy and transfer.
[0060] In this embodiment, it is preferable to store the sparse file template locally on the node, so that the sparse file template can be directly copied from the local machine when performing the above steps. Of course, in other implementations, the sparse file template can also be stored in other locations outside the node, so that the node can obtain the sparse file template when it is needed.
[0061] The formatted data of the containers stored in the sparse file template can be determined by those skilled in the art according to the container orchestration requirements. For example, it may include the directory structure, the content stored in each directory, the preset data size corresponding to the directory, etc. This embodiment does not limit this.
[0062] S202. Create the local storage space corresponding to the container based on the formatted data in the sparse file template;
[0063] Based on the formatted file in the sparse file template, a corresponding local storage space can be created for the container in the node locality. Specifically, the storage content, storage method, read and write method, etc. of the storage space can be defined according to the formatted file. This embodiment does not limit this, as long as it can be used by the container.
[0064] In addition, in this embodiment, the local storage of the node includes at least one of the following: the node's system disk, data disk, or disk array.
[0065] The system disk of a node refers to the data hard drive used to run the host machine, while the data disk refers to the data hard drive used to store data. A redundant array of independent disks (RAID) can specifically be an array composed of several disks. Different RAID structures have different advantages, such as high fault tolerance, and those skilled in the art can configure them according to their needs.
[0066] S203. The created local storage space is mounted as a block device to the container to create a storage area for the container.
[0067] Block devices are a type of I / O device that stores information in fixed-size blocks, each with its own address. They can also read data of a certain length from any location on the device. A key characteristic of block devices is their ability to be read from and written independently of other blocks.
[0068] By mounting local storage space as a block device to a container, the container can operate on the local storage space in the same way as the block device. In addition, for the container, the local storage space is an independent block device, and the feature of block devices being able to be read and written independently of other blocks achieves I / O isolation between containers.
[0069] The solution provided in this embodiment stores the formatted data of the container in a sparse file manner using a sparse file template, which reduces the amount of data that needs to be operated on in the process of obtaining the formatted data of the storage container. After the node obtains the sparse file template, it can continue to create the local storage space corresponding to the container according to the formatted data in the sparse file template, and mount the created local storage space as a block device under the container, thereby realizing I / O isolation between containers.
[0070] Compared with the above-mentioned scheme of creating the root directory of the container through elastic block storage and LVM, the scheme provided in this embodiment has the following advantages:
[0071] 1. LVM is greatly affected by the I / O pressure of the file system, which may result in a long creation time; however, the solution provided in this embodiment creates local storage areas for containers independently and consumes fewer resources. The I / O pressure of the node's file system will not have a significant impact on the process of creating new local storage areas.
[0072] 2. LVM requires management through Device Manager, which consumes a lot of resources. The solution provided in this embodiment does not require Device Manager and consumes fewer resources.
[0073] 3. When LVM makes changes to a logical volume, it needs to acquire a global mutex lock before it can make changes. The existence of a global mutex lock may lead to operational errors for logical volumes that have not acquired a global mutex lock. However, the solution provided in this embodiment can directly read and write to block devices without a global mutex lock, reducing the possibility of errors.
[0074] See Figure 3 The figure illustrates another process for creating storage space for a container according to an embodiment of this application, as shown in the figure, which includes:
[0075] S301. In response to the storage space creation instruction, copy the sparse file template to the target storage area in the local storage of the node.
[0076] In this embodiment, the sparse file template can be pre-stored locally on the node. After receiving the storage space creation instruction, the sparse file template can be copied to the target storage area.
[0077] The target storage area can be the storage area allocated to the container. For specific allocation methods, please refer to relevant technologies, which will not be elaborated here.
[0078] In this embodiment, since different containers have different creation requirements, the sparse file template may not be fully compatible with the container requirements. Therefore, the target storage area can be configured according to the storage space creation instruction. The configuration operation includes expansion or contraction. As a result, containers with some configuration differences can use the same sparse file template, which improves the versatility of the sparse file template.
[0079] Specifically, storage space creation instructions can carry persistent volume (PV) information and persistent volume claim (PVC) information. The PV identifies the size of the available storage area of the container, and the PVC is bound to the PV and used to utilize the PV. The PV represents a resource in the cluster, and the PVC is a request for the PV resource. Based on the PVC / PV, configuration operations can be performed on the target storage area. For example, if the PV corresponding to the sparse file template is inconsistent with the PV carried in the storage space creation instruction, the target storage area can be expanded or shrunk to match it.
[0080] Of course, in other implementations of this application, the sparse file template may not be configured, which is also within the scope of protection of this application.
[0081] S302. Based on the formatted data in the sparse file template, create a virtual block device associated with the target storage area to create the local storage space corresponding to the container.
[0082] In this embodiment, the file corresponding to the target storage area can be simulated as a virtual block device. When the container uses local storage space, it can access the virtual block device, which can then be mapped to access the file corresponding to the target storage area.
[0083] S303. Mount the virtual block device to the container.
[0084] The created virtual block device can be equivalent to an unmounted storage hardware, which can be mounted to the container's access directory and used as the container's storage space.
[0085] For example, when a container operates on stored data, it can access the virtual block device through the node's file system. The virtual block device maps the access to the file corresponding to the target storage area, and then accesses the file corresponding to the target storage area again through the node's file system. Because the access process for the virtual block device involves two file system accesses, this virtual block device is also called a loop device. Different virtual block devices are independent storage devices for containers, thus achieving good I / O isolation. Furthermore, virtual block devices can generally be created directly by the host machine running on the node, without adding the resources required for the storage device creation process.
[0086] In addition, since virtual block devices are actually files mapped from the node's local storage space, they also use the node's file system and can use the convenient functions that already exist in the file system. Thus, the convenient functions already supported by the file system can be applied to the process of creating storage for containers, improving the convenience of the creation process.
[0087] For example, if the file system supports copying data via reference links, then in this embodiment, the method may further include:
[0088] S304. Based on the file system of the node, obtain the image of the container by means of a reference link, and determine the root directory of the container according to the image and the local storage space.
[0089] The dashed line in the figure indicates that step S304 is an optional step.
[0090] Obtaining the container image by referencing links means that the image copying process can be completed by copying the container's inode index, without having to copy all the image data, thus speeding up the container creation process.
[0091] Furthermore, since the common parts of several container images are read-only, the storage of the read-only parts of the image can be optimized through the file system, and the data written by the container can be received and stored through the container's private writable layer, thereby achieving read-write separation and further reducing I / O pressure.
[0092] In addition, since the virtual block device is actually a file mapping of the node's local storage space and uses the node's file system, if multiple containers are running in the node, the multiple containers share the node's cache storage area when performing read and write operations on their corresponding virtual block devices.
[0093] Specifically, when multiple containers perform read and write operations on their respective local storage space virtual block devices, the data to be read or written corresponding to the read and write operations can be stored in the cache storage area of the file system. Different containers but performing read or write operations on the same data can share the data in the cache storage area, which improves cache utilization and achieves high cache density.
[0094] The solution provided in this embodiment stores the formatted data of the container in a sparse file manner using a sparse file template, which reduces the amount of data that needs to be operated on in the process of obtaining the formatted data of the storage container. After the node obtains the sparse file template, it can continue to create the local storage space corresponding to the container according to the formatted data in the sparse file template, and can map the local storage space to a virtual block device and mount it to the container. This allows the creation and use of the container's storage space to utilize the convenient functions already supported by the file system, thereby improving the efficiency of creating and using the storage space corresponding to the container.
[0095] See Figure 4 The illustration shows a usage scenario provided by an embodiment of this application, including a management component, a control component, and a node. The control component may include one component for controlling all container creation processes. The management component may include multiple components, which may run in the node for managing container-related content on the node.
[0096] As shown in the figure, it includes:
[0097] S400. Initialize the management component in the node and create a sparse file template in the node through the management component.
[0098] It should be noted that during the initialization process, the type of available hard disk in the node can be determined, and a sparse file template can be created based on the type.
[0099] S401, User input creates an instance of the application;
[0100] S402. Based on the received instance creation operation, the control component can wait for application scheduling to determine the node where the application is located.
[0101] Specifically, after receiving the instance creation operation, the control component can request the scheduling of relevant nodes for the application and can receive the nodes scheduled to the application.
[0102] S403, the control component can identify the container created for the instance and send a storage space creation instruction to the node for the container, so that the node can create a storage area for the container on the local disk.
[0103] S404. After receiving the storage space creation instruction, the management component in the node can obtain the pre-created sparse file template.
[0104] S405 The management component can expand the obtained sparse file template and copy it to the target storage area based on the metadata such as PVC / PV carried in the storage space creation instruction, thereby creating a local storage area for the container.
[0105] S406. Create a virtual block device loop device and associate the loop device with the files in the target storage area, mapping the files in the target storage area to the virtual block device.
[0106] It should be noted that when a node is initialized, it can determine whether its local storage is the node's system disk, data disk, or disk array, and create a virtual block device according to the determination result.
[0107] S407. After the management component creates and associates the virtual block device, it can report the creation completion information to the control component.
[0108] S408: Receive application startup requests from users via the node.
[0109] Upon receiving the application startup request, the container needs to be started and run on the node. The process of starting and running the container can be seen in steps S409-S413 below. However, it should be noted that the following steps are only illustrative examples, and other processes for starting containers are also within the scope of protection of this application.
[0110] S409. The container storage interface (CSI) of the management component is triggered by the node to run persistent storage initialization.
[0111] S410, The management component mounts the persistently stored virtual block device to the node at the path corresponding to the container.
[0112] S411, The management component received a message indicating successful mounting.
[0113] S412. Inform the user that the mounting is complete and the container can be used.
[0114] See Figure 5 The figure shows a schematic diagram of a container management system according to an embodiment of this application. As shown, the system includes a control component 501 running outside the nodes and a management component 502 running inside the nodes. As shown, there may be multiple nodes, and therefore, there may also be multiple management components 502.
[0115] The control component 501 is configured to receive a storage space creation instruction for a container and send the storage space creation instruction to the management component in the node used to run the container.
[0116] The management component 502 is used to enable the node to obtain a sparse file template to the node's local storage. The sparse file template is used to format data of the sparse file storage container. The component 502 is used to create a local storage space corresponding to the container based on the format data in the sparse file template. The component 502 is used to mount the created local storage space as a block device to the container to create a storage area for the container.
[0117] The specific implementation of each step in the control and management components can be found in the corresponding descriptions of the steps and units in the above method embodiments, which have corresponding beneficial effects, and will not be repeated here. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the devices and modules described above can be referred to the corresponding process descriptions in the foregoing method embodiments, and will not be repeated here.
[0118] See Figure 6 The figure illustrates a schematic diagram of a container system according to this application. As shown, the container system may include multiple instance pods. Two instances are illustrated in the figure. The instance pods define metadata such as PVC / PV pairs. The control component (loopdevice driver controller, also known as loop device control component) running outside the node and the management component (loopdevice manager) running inside the node in the container system belong to the container management system.
[0119] It should be noted that the container system provided in this embodiment uses the Container Storage Interface (CSI) for container orchestration. Therefore, the container mounting service (CSI plugin) and the container provisioning service (CSI provisioner) are both implemented through the CSI standard interface.
[0120] The management component (loopdevice manager) in the container mounting service (CSI plugin) of a node can create a sparse file template in the node during initialization.
[0121] An instance pod can send a trigger to a container provisioning service (CSI provisioner), which may include the control component (loopdevice driver controller, also known as loop device control component) described in the above embodiments.
[0122] The container provisioning service can send a connection request (serconnection) to the node allocated for the instance pod to make remote calls. This connection request can carry metadata such as PVC / PV pairs for creating storage areas for the container. In other words, the storage space creation instruction can carry persistent volume (PV) information and persistent volume claim (PVC) information.
[0123] After receiving a connection request, the Remote Procedure Call Protocol (RPC) server in the node can send it to the loopdevice manager in the container mount service csiplugin. The management component copies the pre-created sparse file template and creates a virtual block device loopdevice based on the copied file. The virtual block device can then be mounted to the pod mountpath directory corresponding to the container in the instance. This directory is the rootfs directory of the container in the instance.
[0124] Reference Figure 7 The diagram shows a structural schematic of an electronic device according to Embodiment 5 of this application. The specific embodiments of this application do not limit the specific implementation of the electronic device.
[0125] like Figure 7 As shown, the electronic device may include: a processor 702, a communication interface 704, a memory 706, and a communication bus 708.
[0126] in:
[0127] The processor 702, communication interface 704, and memory 706 communicate with each other via communication bus 708.
[0128] Communication interface 704 is used to communicate with other electronic devices or servers.
[0129] The processor 702 is used to execute program 710, specifically to execute the relevant steps in the above-described storage area creation method embodiment.
[0130] Specifically, program 710 may include program code that includes computer operation instructions.
[0131] The processor 702 may be a CPU, an ASIC (Application-On Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of this application. The smart device includes one or more processors, which may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.
[0132] Memory 706 is used to store program 710. Memory 706 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.
[0133] Program 710 may include multiple computer instructions. Specifically, program 710 can cause processor 702 to perform the operation corresponding to any of the methods described in the foregoing multiple method embodiments through multiple computer instructions.
[0134] The specific implementation of each step in program 710 can be found in the corresponding steps and units described in the above method embodiments, and has corresponding beneficial effects, which will not be repeated here. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the devices and modules described above can be referred to the corresponding process descriptions in the foregoing method embodiments, and will not be repeated here.
[0135] This application also provides a computer storage medium storing a computer program thereon, which, when executed by a processor, implements the method described in any of the foregoing method embodiments. The computer storage medium includes, but is not limited to, compact disc read-only memory (CD-ROM), random access memory (RAM), floppy disk, hard disk, or magneto-optical disk.
[0136] This application also provides a computer program product, including computer instructions that instruct a computing device to perform an operation corresponding to any of the methods in the above-described multiple method embodiments.
[0137] Furthermore, it should be noted that the user-related information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to sample data used for training the model, data used for analysis, stored data, displayed data, etc.) involved in the embodiments of this application are all information and data authorized by the user or fully authorized by all parties. Moreover, the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0138] It should be noted that, depending on the implementation needs, the various components / steps described in the embodiments of this application can be broken down into more components / steps, or two or more components / steps or parts of the operation of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of this application.
[0139] The methods described in the embodiments of this application can be implemented in hardware, firmware, or as software or computer code that can be stored in a recording medium (such as a CD-ROM, RAM, floppy disk, hard disk, or magneto-optical disk), or as computer code originally stored in a remote recording medium or a non-transitory machine-readable medium and subsequently stored in a local recording medium, downloaded over a network. Thus, the methods described herein can be stored on a recording medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware (such as an Application-On Specific Integrated Circuit (ASIC) or a Field Programmable Gate Array (FPGA)). It is understood that the computer, processor, microprocessor controller, or programmable hardware includes storage components (e.g., Random Access Memory (RAM), Read-Only Memory (ROM), Flash Memory, etc.) capable of storing or receiving software or computer code, which, when accessed and executed by the computer, processor, or hardware, implements the methods described herein. Furthermore, when a general-purpose computer accesses code used to implement the methods shown herein, the execution of the code transforms the general-purpose computer into a dedicated computer for executing the methods shown herein.
[0140] Those skilled in the art will recognize that the units and method steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the embodiments of this application.
[0141] The above embodiments are only used to illustrate the embodiments of this application, and are not intended to limit the embodiments of this application. Those skilled in the art can make various changes and modifications without departing from the spirit and scope of the embodiments of this application. Therefore, all equivalent technical solutions also fall within the scope of the embodiments of this application, and the patent protection scope of the embodiments of this application should be defined by the claims.
Claims
1. A method for creating a storage area, characterized in that, include: Determine the type of hard drive in the node, and create a sparse file template based on the type of hard drive; In response to a storage space creation instruction for a container, the node used to run the container is instructed to obtain a sparse file template for the local storage of the node, the sparse file template being used to store the formatted data of the container as a sparse file. The local storage space corresponding to the container is created based on the formatted data in the sparse file template; wherein, if the persistent storage volume information corresponding to the sparse file template is different from the persistent storage volume information carried by the storage space creation instruction, the target storage area is expanded or shrunk to make it consistent with the persistent storage volume information carried by the storage space creation instruction. The created local storage space is mounted as a block device under the container to create a storage area for the container. The block device will map access to the file corresponding to the target storage area and access the file corresponding to the target storage area through the file system of the node to use the function of copying data by reference link supported by the file system of the node.
2. The method according to claim 1, characterized in that, The step of responding to a storage space creation instruction for a container, causing the node running the container to obtain a sparse file template to the node's local storage, includes: In response to the storage space creation instruction, the sparse file template is copied to the target storage area in the local storage of the node.
3. The method according to claim 2, characterized in that, The step of creating the local storage space corresponding to the container based on the formatted data in the sparse file template includes: Based on the formatted data in the sparse file template, a virtual block device associated with the target storage area is created to create the local storage space corresponding to the container; The step of mounting the created local storage space as a block device to the container to create a storage area for the container includes: The virtual block device is mounted to the container.
4. The method according to claim 3, characterized in that, If multiple containers are running in the node, the multiple containers share the node's cache storage area when performing read and write operations on their corresponding virtual block devices.
5. The method according to claim 2, characterized in that, The method further includes: performing a configuration operation on the target storage area according to the storage space creation instruction, wherein the configuration operation includes: an expansion operation or a reduction operation.
6. The method according to any one of claims 1-4, characterized in that, The local storage includes at least one of the following: the node's system disk, data disk, or disk array.
7. The method according to any one of claims 1-4, characterized in that, The method further includes: Based on the node's file system, the container's image is obtained through a reference link, and the container's root directory is determined based on the image and the local storage space.
8. A container management system, characterized in that, include: Control components that run outside the node, and management components that run inside the node; The management component is used to determine the type of hard disk in the node and to create a sparse file template based on the type of hard disk. The control component is used to receive a storage space creation instruction for the container and send the storage space creation instruction to the management component in the node used to run the container; The management component is used to enable the node to obtain a sparse file template to the node's local storage, and the sparse file template is used to format data through a sparse file storage container; The local storage space corresponding to the container is created based on the formatted data in the sparse file template. If the persistent storage volume information corresponding to the sparse file template is different from the persistent storage volume information carried in the storage space creation instruction, the target storage area is expanded or shrunk to make it consistent with the persistent storage volume information carried in the storage space creation instruction. The created local storage space is mounted as a block device under the container to create a storage area for the container. The block device maps access to the files corresponding to the target storage area and accesses the files corresponding to the target storage area through the file system of the node to use the function of copying data by reference link supported by the file system of the node.
9. An electronic device, characterized in that, include: The processor, memory, communication interface, and communication bus are provided, wherein the processor, memory, and communication interface communicate with each other via the communication bus. The memory is used to store at least one executable instruction that causes the processor to perform the operation corresponding to the method as described in any one of claims 1-7.
10. A computer storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the method as described in any one of claims 1-7.
Citation Information
Patent Citations
Persistent volume allocation method and device, computer equipment and storage medium
CN111966305A
Container creating method and device
CN113190325A
Method for dynamically supplying storage space based on QCOW2 technology under container platform and application
CN114968092A