Container virtualization method and device based on edge computing, equipment and storage medium
By mounting the target storage device on the host and using the IO virtual block data transmission protocol, it is used as the writable layer of the container virtual machine, the problem of insufficient performance of the IO virtual file system is solved, and data reading and writing of the container virtual machine is improved efficiency.
Patent Information
- Application Number
- CN202411170467.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2024-12-03
AI Technical Summary
The existing IO virtual file system is less efficient when reading and writing data in the writable layer of the container, resulting in performance bottlenecks.
By mounting the target storage device on the host and passing it through to the virtual machine using the IO virtual block data transfer protocol, the file system of the target storage device is generated and used as a writable layer of the root file system of the container, and merged Handle the writable layer and the read-only layer to improve the read and write efficiency of data.
It improves the writable layer data reading and writing efficiency of container virtual machines, and realizes efficient data transmission through the IO virtual block data transmission protocol, solving the problem of insufficient performance of the IO virtual file system.
Smart Images

Figure CN119065792A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data processing, and in particular to a container virtualization method, device, equipment and storage medium based on edge computing. Background Art
[0002] Currently, commonly used container runtime tools pass the host's file system to the container in the virtual machine through the IO virtual file system (virtio-fs), so that the container's read-only layer and writable layer can share the host's local storage space through the IO virtual file system. However, due to the poor read and write performance of the IO virtual file system, when implementing data read and write operations on the writable layer based on the IO virtual file system, there may be a problem of low data read and write efficiency on the writable layer. Summary of the invention
[0003] In order to solve the above technical problems, the present disclosure provides a container virtualization method, device, equipment and storage medium.
[0004] In a first aspect, the present disclosure provides a container virtualization method, the method comprising:
[0005] In response to a virtual machine startup instruction, a target storage device is mounted on the host machine, and the target storage device is transparently transmitted to the virtual machine through an input and output IO virtual block data transmission protocol;
[0006] Generate a file system of the target storage device, and mount the file system of the target storage device to the root file system of the target container in the virtual machine;
[0007] In response to a startup instruction of the target container, the file system of the target storage device is used as a writable layer of a root file system of the target container, and the writable layer is merged with a read-only layer of the root file system of the target container; wherein the writable layer is used to process data read and write requests of the target container by accessing the target storage device.
[0008] In an optional implementation manner, the method further includes:
[0009] Creating a mirror root file system of the host machine, and transparently transmitting the mirror root file system to the virtual machine through the IO virtual file system;
[0010] Mounting the mirrored root file system onto the root file system of the target container in the virtual machine;
[0011] Accordingly, in response to the startup instruction of the target container, using the file system of the target storage device as the writable layer of the root file system of the target container, and merging the writable layer with the read-only layer of the root file system of the target container, includes:
[0012] In response to a startup instruction of the target container, the proxy module is called to overlay the file system of the target storage device onto the mirror root file system by stacking a file system, so as to use the file system of the target storage device as a writable layer of the root file system of the target container, and use the mirror root file system as a read-only layer of the root file system of the target container; wherein the read-only layer is used to process a read request of the target container by accessing a local storage space of the host machine.
[0013] In an optional implementation, in response to the virtual machine startup instruction, mounting the target storage device on the host machine, and transparently transmitting the target storage device to the virtual machine through the IO virtual block data transmission protocol includes:
[0014] In response to a virtual machine startup instruction, a block device file of a target storage device is created, the block device file of the target storage device is mounted to a preset path on a host machine, and a virtual machine simulator is called to hot-add the block device file on the preset path to the virtual machine.
[0015] In an optional implementation, in response to the startup instruction of the target container, using the file system of the target storage device as the writable layer of the root file system of the target container, and merging the writable layer with the read-only layer of the root file system of the target container, includes:
[0016] In response to a startup instruction of the target container, a sub-file system is created for the target container under the root file system of the target container in the virtual machine, and the file system of the target storage device under the root file system is overlaid on the read-only layer of the sub-file system as a writable layer of the sub-file system by stacking file systems, so that the target container can access the target storage device through the sub-file system.
[0017] In an optional implementation manner, the method further includes:
[0018] In response to a data write request for the target container, data corresponding to the data write request is written to the target storage device through the file system of the target storage device in the root file system of the target container.
[0019] In an optional implementation manner, in response to the data write request for the target container, writing the data corresponding to the data write request to the target storage device through the file system of the target storage device in the root file system of the target container includes:
[0020] In response to a data write request for the target container, based on the file system of the target storage device in the root file system of the target container, data corresponding to the data write request is written to the target storage device through the IO virtual block data transmission protocol.
[0021] In an optional implementation manner, the method further includes:
[0022] In response to a data read request for the target container, reading data corresponding to the data read request from the target storage device through a file system of the target storage device in a root file system of the target container;
[0023] If the data corresponding to the data read request is not read from the target storage device, the data corresponding to the data read request is read from the local storage space of the host machine through the mirror root file system in the root file system of the target container.
[0024] In an optional implementation manner, in response to the data read request for the target container, reading data corresponding to the data read request from the target storage device through the file system of the target storage device in the root file system of the target container includes:
[0025] In response to a data read request for the target container, based on the file system of the target storage device in the root file system of the target container, data corresponding to the data read request is read from the target storage device through the IO virtual block data transmission protocol.
[0026] In an optional implementation, the target storage device includes a remote block storage device of the host machine.
[0027] In a second aspect, the present disclosure provides a container virtualization device based on edge computing, the device comprising:
[0028] A first mounting module, for mounting a target storage device on a host machine in response to a virtual machine startup instruction, and transparently transmitting the target storage device to the virtual machine through an IO virtual block data transmission protocol;
[0029] A generation module, used to generate a file system of the target storage device, and mount the file system of the target storage device to the root file system of the target container on the virtual machine;
[0030] a merging processing module, configured to respond to a startup instruction of the target container, use the file system of the target storage device as a writable layer of a root file system of the target container, and merge the writable layer with the read-only layer of the root file system of the target container; wherein the writable layer is used to process a data read and write request of the target container by accessing the target storage device.
[0031] In a third aspect, the present disclosure provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above method when executing the computer program.
[0032] In a fourth aspect, the present disclosure provides a computer program product, wherein the computer program product comprises a computer program / instructions, and the computer program / instructions implement the above method when executed by a processor.
[0033] Compared with the prior art, the technical solution provided by the embodiments of the present disclosure has at least the following advantages:
[0034] In the container virtualization method provided by the embodiment of the present disclosure, in response to a virtual machine startup instruction, a target storage device is mounted on a host machine, and the target storage device is transparently transmitted to the virtual machine through an IO virtual block data transmission protocol; a file system of the target storage device is generated, and the file system of the target storage device is mounted on a root file system of a target container in the virtual machine; in response to a target container startup instruction, the file system of the target storage device is used as a writable layer of the root file system of the target container, and the writable layer is merged with a read-only layer of the root file system of the target container.
[0035] It can be seen that the embodiment of the present disclosure can transparently transmit the target storage device mounted on the host machine to the virtual machine through the IO virtual block data transmission protocol during the virtual machine startup process, so as to realize the writable layer of the root file system of the target container on the virtual machine, so that the data reading and writing operations of the writable layer can be processed based on the target storage device subsequently, thereby improving the data reading and writing efficiency of the writable layer. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0037] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0038] Figure 1 A schematic diagram of the architecture of a kata container provided in an embodiment of the present disclosure;
[0039] Figure 2 A flowchart of a container virtualization method provided by an embodiment of the present disclosure;
[0040] Figure 3 A schematic diagram of a container and image layered storage provided in an embodiment of the present disclosure;
[0041] Figure 4 A schematic diagram of the architecture of another kata container provided in an embodiment of the present disclosure;
[0042] Figure 5 A schematic diagram of a process flow of a container virtual machine provided in an embodiment of the present disclosure;
[0043] Figure 6 A schematic diagram of the structure of a container virtualization device provided in an embodiment of the present disclosure;
[0044] Figure 7 A schematic diagram of the structure of a container virtualization device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0045] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0046] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0047] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0048] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0049] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0050] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0051] Some technical concepts or noun concepts involved in this article are explained:
[0052] Edge computing refers to the use of an open platform that integrates network, computing, storage, and application core capabilities to improve the nearest service at the edge of the network, close to the source of objects or data. Edge computing can provide cloud services and IT environment services to application developers and service providers at the edge of the network, with the goal of providing computing, storage, and network bandwidth close to data input or users.
[0053] A physical machine refers to a physical computer, including physical components such as processors, memory, and storage devices. A physical machine is used to provide a hardware environment for virtual machines, so a physical machine is sometimes also called a "host" or "host machine."
[0054] A virtual machine (VM) refers to a logical computer system created on a physical machine through virtualization technology. Multiple virtual machines can be created on a physical machine, and each virtual machine can run an independent operating system and application programs. A virtual machine is usually called a guest machine, and the physical computer where the virtual machine runs is called a host or host.
[0055] Container technology, also known as container virtualization, is a lightweight virtualization technology that allows multiple isolated user space instances (i.e. containers) to run while sharing the same operating system kernel. Container virtualization can save system resources and startup time.
[0056] The following will take Kata containers as an example to introduce the currently commonly used container runtime tools. It is worth noting that the container virtualization method provided by the present disclosure is not limited to the Kata scenario, but can also be applied to other similar virtualization container scenarios. The container virtualization method provided by the present disclosure can also be used to solve similar problems.
[0057] Kata containers (security containers, hereinafter referred to as Kata) is an open source container runtime tool. It creates a secure container runtime in the form of a lightweight virtual machine by using container images. Compared with the traditional runC running container sharing the host kernel, Kata is based on virtual machine implementation, that is, all containers run in separate micro virtual machines, and each container has an independent operating system kernel. Therefore, Kata provides stronger security isolation and performance isolation.
[0058] Kata uses hypervisor technology to virtualize a lightweight virtual machine (VM), and creates one or more containers inside the virtual machine through an agent module (Agent). The operating environments of multiple containers are isolated from each other. Figure 1 As shown, it is a schematic diagram of the architecture of a kata container provided in an embodiment of the present disclosure, and is explained by taking a virtual machine including container A and container B as an example.
[0059] Among them, the root file systems of container A and container B both include a read-only layer and a writable layer. It can be understood that the read-only layer and writable layer of container A and the read-only layer and writable layer of container B share the local storage space of the host machine through the IO virtual file system.
[0060] Specifically, the local storage space of the host machine is formatted through the overlay file system (overlayfs) to obtain the root file system (Rootfs) of the host machine, which can also be called the root directory; then the root file system is transparently transmitted to the container A (or B) in the virtual machine through the IO virtual file system (virtio-fs), so that the container A (or B) can access and use the local storage space of the host machine based on the root file system.
[0061] In the above technology, kata passes the host's file system to the container in the virtual machine through the IO virtual file system (virtio-fs), so that the container's read-only layer and writable layer can share the host's local storage space through the IO virtual file system. However, due to the poor read and write performance of the IO virtual file system, when implementing data read and write operations on the writable layer based on the IO virtual file system, there may be a problem of low data read and write efficiency of the writable layer.
[0062] To this end, an embodiment of the present disclosure provides a container virtualization method based on edge computing. Specifically, in response to a virtual machine startup instruction, a target storage device is mounted on a host machine, and the target storage device is transparently transmitted to the virtual machine through an IO virtual block data transmission protocol; a file system of the target storage device is generated, and the file system of the target storage device is mounted on the root file system of the target container in the virtual machine; in response to the startup instruction of the target container, the file system of the target storage device is used as a writable layer of the root file system of the target container, and the writable layer is merged with the read-only layer of the root file system of the target container.
[0063] It can be seen that the embodiment of the present disclosure can transparently transmit the target storage device mounted on the host machine to the virtual machine through the IO virtual block data transmission protocol during the virtual machine startup process, so as to realize the writable layer of the root file system of the target container on the virtual machine, so that the data reading and writing operations of the writable layer can be processed based on the target storage device subsequently, thereby improving the data reading and writing efficiency of the writable layer.
[0064] Based on this, the present disclosure provides a container virtualization method, referring to Figure 2 , is a flow chart of a container virtualization method provided by an embodiment of the present disclosure, the method comprising:
[0065] S201: In response to a virtual machine startup instruction, a target storage device is mounted on a host machine, and the target storage device is transparently transmitted to the virtual machine through an IO virtual block data transmission protocol.
[0066] The container virtualization method provided in the embodiments of the present disclosure may be applied to a physical machine (also referred to as a host machine), for example, a host machine on which a virtualization system is deployed.
[0067] Specifically, one or more virtual machines can be created on the host machine, and one or more containers can be run on each virtual machine, and the operating environments of multiple containers are isolated from each other. For any container in the same virtual machine, the container virtualization method provided in the embodiment of the present disclosure can be used to build a root file system (i.e., build a writable layer and a read-only layer of the root file system of the container).
[0068] In an optional implementation, the local storage space of the host machine can be transparently transmitted to the container in the virtual machine through the IO virtual file system (virtio-fs), so that the read-only layer and the writable layer of the container can share the local storage space of the host machine through the IO virtual file system. However, due to the poor read and write performance of the IO virtual file system, when implementing the data read and write operations of the writable layer based on the IO virtual file system, there may be a problem of low data read and write efficiency of the writable layer.
[0069] Therefore, in order to improve the data reading and writing efficiency of the writable layer, the embodiment of the present disclosure can create a writable layer of the root file system for the target container in the virtual machine by mounting the target storage device on the host machine and transparently transmitting the target storage device to the virtual machine, so as to subsequently implement data reading and writing operations based on the writable layer, thereby improving the data reading and writing efficiency of the writable layer.
[0070] Specifically, when a virtual machine startup instruction is received, the target storage device is first mounted on the host machine, and the target storage device is transparently transmitted to the virtual machine through the IO virtual block data transmission protocol.
[0071] In the embodiment of the present disclosure, mounting refers to connecting one or more storage devices to a specified location on a physical machine or a host machine so that data in the one or more storage devices can be accessed or operated.
[0072] In the disclosed embodiment, the target storage device is transparently transmitted to the virtual machine so that the virtual machine can see the target storage device mounted on the host machine. For example, after a USB flash drive is plugged into the computer (equivalent to mounting the target storage device to the host machine), the USB flash drive will exist on the computer as a file system, and the user can see the USB flash drive through the computer display.
[0073] In actual applications, the target storage device can also be mounted on the host machine by utilizing the virtual machine management and control deployed on the host machine, wherein the virtual machine management and control component refers to a component used to manage and monitor virtual machines. In the disclosed embodiment, the virtual machine management and control component is also used to mount the target storage device on the host machine when starting the virtual machine, and transparently transmit the target storage device to the virtual machine through the IO virtual block data transmission protocol, so that the agent module on the virtual machine can be aware of the target storage device mounted on the host machine and perform formatting processing.
[0074] In the disclosed embodiment, the target storage device refers to a device that supports the IO virtual block data transmission protocol for data transmission, wherein the IO virtual block data transmission protocol refers to a protocol for block data transmission simulated in the virtual machine simulator (QEMU), which is used to transmit block data between the virtual machine and the host machine, and has the characteristic of high data transmission efficiency. Specifically, when writing a large amount of data to the target storage device, since the target storage device supports writing operations in units of data blocks, the data reading and writing efficiency is improved.
[0075] In an optional implementation, the target storage device may include a remote block storage device of the host machine, such as a remote cloud disk or other block device. In addition, the target storage device may also include a local block storage device of the host machine, such as a local hard disk, optical disk, flash disk or other block device.
[0076] In a preferred implementation, the target storage device may include an external storage device of the host machine, such as a remote block storage device of the host machine, a block storage device connected to the host machine, etc. Since the target storage device is a block storage device external to the host machine, it can meet the needs of data persistence, and therefore the content therein will not be lost when the container is abnormally restarted, thereby realizing the persistence capability of the container writable layer.
[0077] In an optional implementation, in response to a virtual machine startup instruction, the virtual machine management component can be called to create a block device file of the target storage device, and the block device file of the target storage device can be mounted to a preset path on the host machine, and the virtual machine simulator can be called to hot add the block device file on the preset path to the virtual machine.
[0078] For example, the virtual machine control component can be called to create a Ceph RBD block device file and mount the block device file to the host machine's / dev / <poduid>In actual applications, a virtual machine can correspond to a Ceph RBD block device file, or a container can correspond to a Ceph RBD block device file.
[0079] Mount the Ceph RBD block device file to the host's / dev / <poduid>After the path is set, call the virtual machine emulator QEMU to / dev / <poduid>The Ceph RBD block device file on the path is hot added to the virtual machine.
[0080] Among them, hot adding, also known as hot plugging or hotplug, means that when a computer system (such as a virtual machine) is running, hard disks, USB devices, etc. are allowed to be inserted without shutting down the system or stopping the computer, and can be automatically recognized and configured by the computer system to expand the hardware devices or system resources of the computer system.
[0081] It can be seen that the embodiment of the present disclosure mounts the block device file of the target storage device to a preset path on the host machine, and hot adds the block device file on the preset path to the virtual machine, so that the proxy module in the virtual machine can format the block device file to obtain the file system of the target storage device.
[0082] S202: Generate a file system of the target storage device, and mount the file system of the target storage device to a root file system of a target container on the virtual machine.
[0083] In an optional implementation, after the target storage device is transparently transmitted to the virtual machine through the IO virtual block data transmission protocol, the proxy module on the virtual machine can be called to format the target storage device to obtain a file system of the target storage device.
[0084] In the disclosed embodiment, the target storage device is formatted to create a file system for the target storage device, which is also called a directory, so that the container in the virtual machine can read data in the target storage device based on the file system and write data to the target storage device. After obtaining the file system of the target storage device, the file system is mounted to the root file system of the target container on the virtual machine. The target container can be any container in the virtual machine.
[0085] In the embodiment of the present disclosure, the file system of the target storage device is mounted on the root file system of the target container so that when the target container is subsequently started, the writable layer of the root file system of the target container can be obtained based on the file system of the target storage device.
[0086] In actual applications, corresponding target storage devices can be mounted for different containers in the same virtual machine. Therefore, when creating writable layers in the root file system for different containers, different target storage devices can be used to implement writable layers for different containers by creating sub-file systems.
[0087] Specifically, in response to the start instruction of the target container, a sub-file system is created for the target container under the root file system of the target container in the virtual machine, and the file system of the target storage device under the root file system is overwritten as a read-write sub-file system on the read-only layer of the sub-file system by stacking the file system, so that the target container can access the target storage device through the sub-file system.
[0088] In an optional implementation, a corresponding sub-file system may be created for the target container based on the name of the target container under a designated file system of the virtual machine, so that the target container can access the target storage device through the sub-file system.
[0089] In practical applications, for multiple containers belonging to the same business, the mounted storage device can be the same storage device, and for multiple containers belonging to different businesses, different storage devices can be mounted respectively. Through the container virtualization method provided by the present disclosure, corresponding target storage devices can be mounted for different containers in the virtual machine respectively, so as to realize the writable layers of different containers by using different target storage devices.
[0090] S203: In response to the start instruction of the target container, use the file system of the target storage device as the writable layer of the root file system of the target container, and merge the writable layer with the read-only layer of the root file system of the target container.
[0091] The writable layer is used to process data read and write requests of the target container by accessing the target storage device.
[0092] Since the disclosed embodiment has transparently transmitted the target storage device to the virtual machine through the IO virtual block data transmission protocol during the startup process of the virtual machine (i.e. before the target container is started), and the file system of the target storage device is mounted on the root file system of the target container in the virtual machine, the persistent storage of the file system is realized. Therefore, when the target container is started, the file system of the target storage device can be used as the writable layer of the root file system of the target container, i.e. UpperDir. When reading and writing data subsequently, the writable layer can be used to process the data read and write requests of the target container by accessing the target storage device.
[0093] In the disclosed embodiment, in response to a startup instruction of a target container, a file system of a target storage device is used as a writable layer of a root file system of the target container, and the writable layer is merged with a read-only layer of the root file system of the target container.
[0094] In an optional implementation, the writable layer and the read-only layer may be jointly mounted by stacking a file system as the final root file system rootfs of the target container.
[0095] In an optional implementation, the proxy module may be called to overlay the file system of the target storage device onto the read-only layer in the root file system of the target container by stacking the file system to obtain a writable layer of the root file system of the target container.
[0096] The stacking file system is also called overlayfs, which is used to overlay one file system layer on another file system layer to obtain a new file system layer. Specifically, the file system of the target storage device is overlaid on the read-only layer in the root file system of the target container through the stacking file system as the writable layer of the root file system of the target container.
[0097] The writable layer is used to process data read and write requests of the target container by accessing the target storage device. Specifically, the writable layer allows the target container to perform data read operations and data write operations on the target storage device at runtime, wherein the data write operations may include operations such as creating, modifying and deleting files.
[0098] Since the writable layer of the root file system of the target container in the embodiment of the present disclosure is implemented based on the target storage device, the target container can write data to the target storage device based on the IO virtual block data transfer protocol when processing data read and write requests, thereby improving the data read and write efficiency of the writable layer of the target container.
[0099] In the container virtualization method based on edge computing provided by the embodiment of the present disclosure, in response to the virtual machine startup instruction, the target storage device is mounted on the host machine, and the target storage device is transparently transmitted to the virtual machine through the IO virtual block data transmission protocol; a file system of the target storage device is generated, and the file system of the target storage device is mounted on the root file system of the target container in the virtual machine; in response to the startup instruction of the target container, the file system of the target storage device is used as the writable layer of the root file system of the target container, and the writable layer is merged with the read-only layer of the root file system of the target container.
[0100] It can be seen that the embodiment of the present disclosure can transparently transmit the target storage device mounted on the host machine to the virtual machine through the IO virtual block data transmission protocol during the virtual machine startup process, so as to realize the writable layer of the root file system of the target container in the virtual machine, so that the data reading and writing operations of the writable layer can be processed based on the target storage device subsequently, thereby improving the data reading and writing efficiency of the writable layer.
[0101] In practical applications, the read-only layer in the root file system of the target container can be implemented by stacking the file system (overlayfs) and the IO virtual file system (virtiofs).
[0102] Specifically, first, the stacking file system on the host is called to create a mirror root file system of the host, and the mirror root file system is transparently transmitted to the virtual machine through the IO virtual file system. Then, the proxy module on the virtual machine is called to mount the mirror root file system to the root file system of the target container in the virtual machine.
[0103] In the disclosed embodiment, the IO virtual file system is a technology for performing file transfer in a virtualized environment. The IO virtual file system performs data transfer at the granularity of the file system. When writing data of the same size to a storage device, the IO virtual file system may need to request multiple times.
[0104] In actual applications, kata containers and images are based on layered storage. Containers (also known as Containers) are a lightweight, portable software packaging technology that can run in any environment; images (also known as Images) are read-only file system snapshots that contain the files and settings required for application operation. Images can be used to create and run containers.
[0105] like Figure 3 As shown in FIG. 1 , a schematic diagram of a container and image layered storage provided by an embodiment of the present disclosure is shown. Figure 3 As shown in the figure, read-only layer 1, read-only layer 2 and read-only layer 3 are only allowed to read data, and writable layer 4 can be read and written. When starting the container, a new writable layer, namely the container layer, is obtained by decompressing the image layer (read-only layer 1, read-only layer 2 and read-only layer 3). Obviously, after the container is restarted under abnormal circumstances, there is a problem that the data in the writable layer is easily lost.
[0106] Therefore, after mounting the mirrored root file system on the root file system of the target container in the virtual machine and mounting the file system of the target storage device on the root file system, upon receiving the startup instruction of the target container, the proxy module is called to overlay the file system of the target storage device on the mirrored file system by stacking the file system, so as to use the file system of the target storage device as the writable layer of the root file system of the target container, and use the mirrored root file system as the read-only layer of the root file system of the target container. The read-only layer is used to process the read request of the target container by accessing the local storage space of the host machine.
[0107] It can be seen that the embodiment of the present disclosure uses the mirror root file system as the root file system of the target container and the file system of the target storage device as the writable layer of the root file system of the target container, thereby avoiding the problem of easy loss of data in the writable layer due to the need to re-decompress the read-only layer of the container to obtain the writable layer after an abnormal restart.
[0108] like Figure 4 As shown, it is a schematic diagram of the architecture of another kata container provided in an embodiment of the present disclosure.
[0109] Specifically, when a virtual machine startup instruction is received, the stacking file system on the host is first called to create a mirror root file system of the host, and the mirror root file system is transparently transmitted to the virtual machine through the IO virtual file system; then the proxy module on the virtual machine is called to mount the mirror root file system to the root file system of the target container in the virtual machine.
[0110] Furthermore, the virtual machine management and control component is called to mount the target storage device on the host machine, and the target storage device is transparently transmitted to the virtual machine through the IO virtual block data transmission protocol; further, the proxy module on the virtual machine is called to generate a file system of the target storage device, and the file system of the target storage device is mounted on the root file system of the target container in the virtual machine.
[0111] When receiving the startup instruction of the target container, the proxy module is called to overlay the file system of the target storage device on the mirror root file system by stacking the file system, so as to use the file system of the target storage device as the writable layer of the root file system of the target container, and to use the mirror root file system as the read-only layer of the root file system of the target container.
[0112] The read-only layer is used to process the read request of the target container by accessing the local storage space of the host. Specifically, the read request of the target container can be forwarded to the host through the IO virtual file system. The writable layer is used to process the data read and write request of the target container by accessing the target storage device.
[0113] Since the disclosed embodiment has overlaid the file system (i.e., directory) of the target storage device on the image root file by stacking the file system when the target container is started, thereby obtaining a writable layer of the root file system of the target container, and the writable layer allows the target container to perform write operations on the target storage device during runtime. Therefore, when a data write request for the target container is subsequently received, the data corresponding to the data write request can also be written to the target storage device through the file system of the target storage device in the root file system of the target container.
[0114] In an optional implementation, in order to improve the data writing efficiency of the target container, the data can also be written to the target storage device through the IO virtual block data transmission protocol. Specifically, in response to the data writing request for the target container, based on the file system of the target storage device in the root file system of the target container, the data corresponding to the data writing request is written to the target storage device through the IO virtual block data transmission protocol.
[0115] The file system of the target storage device serves as a writable layer in the root file system of the target container, and supports processing data read and write requests for the target container by accessing the target storage device. That is, the address information of the target storage device can be found through the file system of the target storage device or the directory of the target storage device, so that data can be written to the target storage device.
[0116] In addition, since the IO virtual block data transmission protocol transmits data in the form of block data, it has the characteristic of high data transmission efficiency. Therefore, when writing the data corresponding to the data write request to the target storage device, since the target storage device supports data writing in units of data blocks, it can improve the read and write efficiency of the virtualization system.
[0117] Because the embodiment of the present disclosure has transparently transmitted the mirror root file system of the host machine to the virtual machine before the target container is started, and called the proxy module on the virtual machine to mount the mirror root file system on the root file system of the target container, when the container is started, it only needs to use the mirror root file system as the read-only layer of the root file system of the target container, and the read-only layer can be used to process the read request of the target container by accessing the local storage space of the host machine.
[0118] In actual applications, when processing a read request for a target container, since the data corresponding to the read request may be in the target storage device or in the local storage space of the host machine, when a read request for the target container is received, it is also necessary to determine whether the data corresponding to the read request is in the target storage device.
[0119] Specifically, in response to a data read request for a target container, first, the data corresponding to the data read request is read from the target storage device through the file system of the target storage device in the root file system of the target container; if the data corresponding to the data read request is not read from the target storage device, the data corresponding to the data read request is read from the local storage space of the host machine through the mirror root file system in the root file system of the target container.
[0120] In an optional implementation, in order to improve the data reading efficiency of the target container, data can also be read from the target storage device through the IO virtual block data transmission protocol. Specifically, when a data reading request for the target container is received, the file system of the target storage device in the root file system of the target container reads the data corresponding to the data reading request from the target storage device through the IO virtual block data transmission protocol.
[0121] Since the IO virtual block data transmission protocol performs data transmission in the form of block data, it has the characteristic of high data transmission efficiency. Therefore, when reading data corresponding to a data read request from a target storage device in units of data blocks, the read and write efficiency of the virtualization system can be improved.
[0122] like Figure 5 As shown, it is a flow chart of a container virtual machine provided by an embodiment of the present disclosure.
[0123] When a virtual machine startup instruction is received, the virtual machine management component is called to create a block device file of the target storage device, and the block device file of the target storage device is mounted to a preset path on the host machine, and the virtual machine simulator is called to hot add the block device file on the preset path to the virtual machine.
[0124] The proxy module on the virtual machine is called to format the block device file, obtain the file system of the target storage device, and mount the file system of the target storage device to the root file system of the target container.
[0125] When receiving the startup instruction of the target container, the proxy module is called to overlay the file system of the target storage device on the mirror root file system by stacking the file system, so as to use the file system of the target storage device as the writable layer Upper Dir of the root file system of the target container, and use the mirror root file system as the read-only layer Lower Dir of the root file system of the target container.
[0126] After the read-only layer and writable layer of the target container are successfully prepared, when a data write request for the target container is received, the data corresponding to the data write request is written to the target storage device through the IO virtual block data transmission protocol based on the file system of the target storage device in the root file system of the target container.
[0127] When receiving a data read request for a target container, based on the file system of the target storage device in the root file system of the target container, the data corresponding to the data read request is read from the target storage device through the IO virtual block data transfer protocol; if the data corresponding to the data read request is not read from the target storage device, based on the mirror root file system in the root file system of the target container, the data corresponding to the data read request is read from the local storage space of the host machine through the IO virtual file system.
[0128] It can be seen that the embodiment of the present disclosure separates the read-only layer and the writable layer of the target container, the read-only layer reads data through the IO virtual file system, and the writable layer reads and writes data through the IO virtual block data transmission protocol, thereby improving the data reading and writing efficiency of the writable layer of the target container.
[0129] In addition, the read-only layer and the writable layer can be re-mounted in the target container through the stacked file system, so that the data of the writable layer is not easily lost.
[0130] Based on the same inventive concept as the above embodiment, the present disclosure embodiment also provides a container virtualization device, referring to Figure 6 , is a schematic diagram of a structure of a container virtualization device based on edge computing provided by an embodiment of the present disclosure, the device comprising:
[0131] The first mounting module 601 is used to mount the target storage device on the host machine in response to the virtual machine startup instruction, and transparently transmit the target storage device to the virtual machine through the input and output IO virtual block data transmission protocol;
[0132] A generation module 602 is used to generate a file system of the target storage device and mount the file system of the target storage device to a root file system of a target container on the virtual machine;
[0133] The merge processing module 603 is used to respond to the startup instruction of the target container, use the file system of the target storage device as the writable layer of the root file system of the target container, and merge the writable layer with the read-only layer of the root file system of the target container; wherein the writable layer is used to process the data read and write request of the target container by accessing the target storage device.
[0134] In an optional implementation, the device further includes:
[0135] A creation module is used to create a mirror root file system of the host machine, and transparently transmit the mirror root file system to the virtual machine through the IO virtual file system;
[0136] A second mounting module, used to mount the mirror root file system onto the root file system of the target container in the virtual machine;
[0137] Accordingly, the merging processing module includes:
[0138] an overlay submodule, configured to respond to a startup instruction of the target container and call the proxy module to overlay the file system of the target storage device onto the mirror root file system by stacking the file system, so as to use the file system of the target storage device as a writable layer of the root file system of the target container and use the mirror root file system as a read-only layer of the root file system of the target container; wherein the read-only layer is used to process a read request of the target container by accessing a local storage space of the host machine.
[0139] In an optional implementation manner, the first mounting module includes:
[0140] The first creation submodule is used to call the virtual machine management and control component to create a block device file of a target storage device in response to a virtual machine startup instruction, mount the block device file of the target storage device to a preset path on the host machine, and call the virtual machine simulator to hot-add the block device file on the preset path to the virtual machine.
[0141] In an optional implementation manner, the merging processing module includes:
[0142] The second creation submodule is used to create a sub-file system for the target container under the root file system of the target container in the virtual machine in response to the startup instruction of the target container, and call the proxy module to overlay the file system of the target storage device under the root file system as the writable layer of the sub-file system on the read-only layer of the sub-file system through the stacking file system, so that the target container can access the target storage device through the sub-file system.
[0143] In an optional implementation, the device further includes:
[0144] A writing module is used to respond to a data writing request for the target container and write data corresponding to the data writing request into the target storage device through the file system of the target storage device in the root file system of the target container.
[0145] In an optional implementation manner, the writing module includes:
[0146] A writing submodule is used to respond to a data writing request for the target container, based on the file system of the target storage device in the root file system of the target container, and write the data corresponding to the data writing request to the target storage device through the IO virtual block data transmission protocol.
[0147] In an optional implementation, the device further includes:
[0148] A first reading module, configured to respond to a data reading request for the target container and read data corresponding to the data reading request from the target storage device through a file system of the target storage device in a root file system of the target container;
[0149] The second reading module is used to read the data corresponding to the data reading request from the local storage space of the host machine through the mirror root file system in the root file system of the target container if the data corresponding to the data reading request is not read from the target storage device.
[0150] In an optional implementation manner, the second reading module includes:
[0151] A reading submodule is used to respond to a data reading request for the target container, based on the file system of the target storage device in the root file system of the target container, and read the data corresponding to the data reading request from the target storage device through the IO virtual block data transmission protocol.
[0152] In an optional implementation, the target storage device includes a remote block storage device of the host machine.
[0153] In the container virtualization device based on edge computing provided by the embodiment of the present disclosure, in response to the virtual machine startup instruction, the target storage device is mounted on the host machine, and the target storage device is transparently transmitted to the virtual machine through the IO virtual block data transmission protocol; the file system of the target storage device is generated, and the file system of the target storage device is mounted on the root file system of the target container in the virtual machine; in response to the startup instruction of the target container, the file system of the target storage device is used as the writable layer of the root file system of the target container, and the writable layer is merged with the read-only layer of the root file system of the target container, wherein the writable layer is used to process the data read and write requests of the target container by accessing the target storage device.
[0154] It can be seen that the embodiment of the present disclosure can transparently transmit the target storage device mounted on the host machine to the virtual machine through the IO virtual block data transmission protocol during the virtual machine startup process, so as to realize the writable layer of the root file system of the target container on the virtual machine, so that the data reading and writing operations of the writable layer can be processed based on the target storage device subsequently, thereby improving the data reading and writing efficiency of the writable layer.
[0155] In addition to the above-mentioned method and apparatus, the embodiments of the present disclosure further provide a computer-readable storage medium, in which instructions are stored. When the instructions are executed on a terminal device, the terminal device implements the container virtualization method described in the embodiments of the present disclosure.
[0156] The embodiment of the present disclosure further provides a computer program product, which includes a computer program / instructions. When the computer program / instructions are executed by a processor, the container virtualization method described in the embodiment of the present disclosure is implemented.
[0157] In addition, the present disclosure also provides a container virtualization device, see Figure 7 As shown, it may include:
[0158] Processor 701, memory 702, input device 703 and output device 704. The number of processors 701 in the container virtualization device can be one or more. Figure 7 In some embodiments of the present disclosure, the processor 701, the memory 702, the input device 703 and the output device 704 may be connected via a bus or other means, wherein: Figure 7 The example of connecting through bus is taken in the following.
[0159] The memory 702 can be used to store software programs and modules. The processor 701 executes various functional applications and data processing of the container virtualization device by running the software programs and modules stored in the memory 702. The memory 702 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc. In addition, the memory 702 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device. The input device 703 may be used to receive input digital or character information, and to generate signal input related to user settings and function control of the container virtualization device.
[0160] Specifically in this embodiment, the processor 701 will load the executable files corresponding to the processes of one or more applications into the memory 702 according to the following instructions, and the processor 701 will run the applications stored in the memory 702, thereby realizing various functions of the above-mentioned container virtualization device.
[0161] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "includes a..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0162] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.< / poduid> < / poduid> < / poduid>
Claims
1. A container virtualization method based on edge computing, characterized in that: The method comprises: In response to a virtual machine startup instruction, a target storage device is mounted on the host machine, and the target storage device is transparently transmitted to the virtual machine through an input and output IO virtual block data transmission protocol; Generate a file system of the target storage device, and mount the file system of the target storage device to the root file system of the target container on the virtual machine; In response to a startup instruction of the target container, the file system of the target storage device is used as a writable layer of a root file system of the target container, and the writable layer is merged with a read-only layer of the root file system of the target container; wherein the writable layer is used to process data read and write requests of the target container by accessing the target storage device.
2. The method according to claim 1, characterized in that The method further comprises: Creating a mirror root file system of the host machine, and transparently transmitting the mirror root file system to the virtual machine through the IO virtual file system; Mounting the mirrored root file system onto the root file system of the target container in the virtual machine; Accordingly, in response to the startup instruction of the target container, using the file system of the target storage device as the writable layer of the root file system of the target container, and merging the writable layer with the read-only layer of the root file system of the target container, includes: In response to a startup instruction of the target container, the file system of the target storage device is overlaid on the mirror root file system by stacking a file system, so that the file system of the target storage device is used as a writable layer of the root file system of the target container, and the mirror root file system is used as a read-only layer of the root file system of the target container; wherein the read-only layer is used to process a read request of the target container by accessing a local storage space of the host machine.
3. The method according to claim 1, characterized in that The method of mounting the target storage device on the host machine in response to the virtual machine startup instruction and transparently transmitting the target storage device to the virtual machine through the IO virtual block data transmission protocol includes: In response to a virtual machine startup instruction, a block device file of a target storage device is created, the block device file of the target storage device is mounted to a preset path on a host machine, and the block device file on the preset path is hot-added to the virtual machine.
4. The method according to claim 1, characterized in that: The step of responding to the start instruction of the target container, using the file system of the target storage device as a writable layer of the root file system of the target container, and merging the writable layer with the read-only layer of the root file system of the target container includes: In response to a startup instruction of the target container, a sub-file system is created for the target container under the root file system of the target container in the virtual machine, and the file system of the target storage device under the root file system is overlaid on the read-only layer of the sub-file system as a writable layer of the sub-file system by stacking file systems, so that the target container can access the target storage device through the sub-file system.
5. The method according to claim 1, characterized in that The method further comprises: In response to a data write request for the target container, data corresponding to the data write request is written to the target storage device through the file system of the target storage device in the root file system of the target container.
6. The method according to claim 5, characterized in that The step of responding to the data write request for the target container, writing data corresponding to the data write request to the target storage device through the file system of the target storage device in the root file system of the target container, comprises: In response to a data write request for the target container, based on the file system of the target storage device in the root file system of the target container, data corresponding to the data write request is written to the target storage device through the IO virtual block data transmission protocol.
7. The method according to claim 2, characterized in that: The method further comprises: In response to a data read request for the target container, reading data corresponding to the data read request from the target storage device through a file system of the target storage device in a root file system of the target container; If the data corresponding to the data read request is not read from the target storage device, the data corresponding to the data read request is read from the local storage space of the host machine through the mirror root file system in the root file system of the target container.
8. The method according to claim 7, characterized in that The step of responding to the data read request for the target container, reading data corresponding to the data read request from the target storage device through the file system of the target storage device in the root file system of the target container, comprises: In response to a data read request for the target container, based on the file system of the target storage device in the root file system of the target container, data corresponding to the data read request is read from the target storage device through the IO virtual block data transmission protocol.
9. The method according to claim 1, characterized in that: The target storage device includes a remote block storage device of the host machine.
10. A container virtualization device based on edge computing, characterized in that: The device comprises: A first mounting module, for mounting a target storage device on a host machine in response to a virtual machine startup instruction, and transparently transmitting the target storage device to the virtual machine through an input / output IO virtual block data transmission protocol; A generation module, used to generate a file system of the target storage device, and mount the file system of the target storage device to the root file system of the target container on the virtual machine; a merging processing module, configured to respond to a startup instruction of the target container, use the file system of the target storage device as a writable layer of a root file system of the target container, and merge the writable layer with the read-only layer of the root file system of the target container; wherein the writable layer is used to process a data read and write request of the target container by accessing the target storage device.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed on a terminal device, the terminal device implements the method according to any one of claims 1 to 9.
12. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method according to any one of claims 1 to 9 is implemented.
13. A computer program product, characterized in that The computer program product comprises a computer program / instruction, and when the computer program / instruction is executed by a processor, the method according to any one of claims 1 to 9 is implemented.
Citation Information
Cited By
Method and device for trusted virtual machine, medium, electronic equipment and product
CN120744909A
Methods, apparatus, media, electronic devices and products for trusted virtual machines
CN120744909B
