Method and Application for Local Container Image Management Based on Openstack

By establishing master-slave mirror correspondence in Openstack cluster and using Docker image management system, the problem that mirrors can only be used on a single node is solved, and efficient image management and optimized resource utilization are achieved.

CN114416299BActive Publication Date: 2025-07-08SHANGHAI ANCHAOYUN SOFTWARE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210060863.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-19
Publication Date
2025-07-08
Estimated Expiration
2042-01-19

AI Technical Summary

Technical Problem

The existing local mirror storage solution causes the mirror to be able to be used in a certain node, network bandwidth resources are wasted, and the waiting time of the queue at the tail container is too long when the container is created concurrently, and other physical nodes are not effectively utilized.

Method used

By establishing the correspondence between the primary and slave images in the Openstack cluster database, the image upload and multiple reuse between nodes are realized, the MD5 algorithm is used to ensure data consistency and recovery, and the Docker image management system is used for automated management of the image.

Benefits of technology

It realizes efficient management and utilization of mirrors, reduces network bandwidth resource waste, improves container creation efficiency, avoids duplicate uploads, and optimizes resource allocation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114416299B_ABST
    Figure CN114416299B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and application for local container image management based on Openstack. The method includes the following steps: a first node creates a slave image and establishes a corresponding relationship between the master image and the slave image; the first node downloads available image files to local storage and establishes a corresponding relationship between the available image files and the slave image; and the first node uploads the data of the slave image to the Docker image. This method can associate the same images on different nodes in the Openstack cluster by establishing a corresponding relationship between the master image and the slave image in the database, facilitating image management; and can also achieve one-time upload of images and multiple reuse among nodes according to the corresponding relationship between the master image and the slave image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of cloud computing, and particularly to a method and application for local container image management based on Openstack. Background Art

[0002] In the process of creating a container in a distributed cluster, it is necessary to obtain an image for creating the image, and the image can be stored locally or in an image repository.

[0003] The existing local image storage solution is that after uploading an image from a certain physical node, the image can only be used on that node. When other nodes need this image, it needs to be manually uploaded again. The above scheduling method will cause the containers to be concentrated on a certain node for creation when resources are relatively sufficient, resulting in a waste of network bandwidth resources. When a large number of containers are created concurrently, the containers at the end of the queue wait too long, and at the same time, other physical nodes are not effectively utilized.

[0004] The information disclosed in this background art section is only intended to enhance the overall understanding of the present invention and should not be regarded as an admission or any form of suggestion that this information constitutes prior art already known to those of ordinary skill in the art. Summary of the Invention

[0005] The purpose of the present invention is to provide a method and application for local container image management based on Openstack, which solves the problems that the same image needs to be manually uploaded to different nodes and a large number of duplicate images lead to ineffective management of the images.

[0006] To achieve the above purpose, an embodiment of the present invention provides a method for local container image management based on Openstack.

[0007] In one or more embodiments of the present invention, the method includes: a first node creates a slave image and establishes a corresponding relationship between the master image and the slave image; the first node downloads an available image file to local storage and establishes a corresponding relationship between the available image file and the slave image; and the first node uploads the data of the slave image to the Docker image.

[0008] In one or more embodiments of the present invention, the first node downloads an available image file to local storage and establishes a corresponding relationship between the available image file and the slave image, including: the first node searches for a node having the available image file under the master image; and copies the available image file in the node to the slave image.

[0009] In one or more embodiments of the present invention, the method further includes: when the slave mirror of the first node fails, the first node performs data recovery according to the states of other slave mirrors under the master mirror corresponding to the slave mirror.

[0010] In one or more embodiments of the present invention, the first node performing data recovery according to the states of other slave mirrors under the master mirror corresponding to the slave mirror includes: querying the states of other slave mirrors under the master mirror corresponding to the slave mirror; and copying the data of the other slave mirrors with the same MD5 value into the slave mirror.

[0011] In another aspect of the present invention, there is provided a device for local container image management based on Openstack, which includes a creation module, a download module, and an upload module.

[0012] The creation module is used for the first node to create a slave mirror and establish a corresponding relationship between the master mirror and the slave mirror.

[0013] The download module is used for the first node to download an available image file to local storage and establish a corresponding relationship between the available image file and the slave mirror.

[0014] The upload module is used for the first node to upload the data of the slave mirror to the Docker image.

[0015] In one or more embodiments of the present invention, the download module is further used for: the first node to find the node having the available image file under the master mirror; and copying the available image file in the node into the slave mirror.

[0016] In one or more embodiments of the present invention, the download module is further used for: when the slave mirror of the first node fails, the first node performs data recovery according to the states of other slave mirrors under the master mirror corresponding to the slave mirror.

[0017] In one or more embodiments of the present invention, the download module is further used for: querying the states of other slave mirrors under the master mirror corresponding to the slave mirror; and copying the data of the other slave mirrors with the same MD5 value into the slave mirror.

[0018] In another aspect of the present invention, there is provided an electronic device, including: at least one processor; and a memory, where the memory stores instructions, and when the instructions are executed by the at least one processor, the at least one processor executes the method for local container image management based on Openstack as described above.

[0019] In another aspect of the present invention, there is provided a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for local container image management based on Openstack as described are implemented.

[0020] Compared with the prior art, the method and application for local container image management based on Openstack according to the embodiments of the present invention can associate the same images of different nodes in the Openstack cluster by establishing the corresponding relationship between the master image and the slave image in the database, facilitating image management; and can also achieve one-time upload of the image and multiple reuse among various nodes according to the corresponding relationship between the master image and the slave image. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 is a flowchart of the method for local container image management based on Openstack according to an embodiment of the present invention;

[0022] Figure 2 is an image structure diagram of the method for local container image management based on Openstack according to an embodiment of the present invention;

[0023] Figure 3 is a schematic diagram of data transmission of the method for local container image management based on Openstack according to an embodiment of the present invention;

[0024] Figure 4 is an example diagram of the method for local container image management based on Openstack according to an embodiment of the present invention;

[0025] Figure 5 is a flowchart of fault recovery of the method for local container image management based on Openstack according to an embodiment of the present invention;

[0026] Figure 6 is a structure diagram of the device for local container image management based on Openstack according to an embodiment of the present invention;

[0027] Figure 7 is a hardware structure diagram of the computing device for local container image management based on Openstack according to an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0028] The following will describe in detail the specific embodiments of the present invention with reference to the accompanying drawings, but it should be understood that the protection scope of the present invention is not limited by the specific embodiments.

[0029] Unless otherwise expressly stated, throughout the specification and claims, the term "comprising" or variations thereof such as "comprises" or "comprising" shall be understood to include the stated element or component, without excluding other elements or other components.

[0030] The following describes in detail the technical solutions provided by each embodiment of the present invention in conjunction with the accompanying drawings.

[0031] Embodiment 1

[0032] As Figures 1 to 4 shown, a method for local container image management based on Openstack in an embodiment of the present invention is introduced, and the method includes the following steps.

[0033] In step S101, the first node creates a slave image and establishes a corresponding relationship between the master image and the slave image.

[0034] Add the master image information and the slave image information to the Openstack cluster database, and map the slave image to the master image in the database. By establishing the corresponding relationship between the master image and the slave image in the database, the same images on different nodes can be associated, facilitating image management.

[0035] Glance is a module responsible for image management in the Openstack cluster, used for the management and scheduling of container images, and its functions include the search, registration, and retrieval of virtual machine images, etc. Glance can save images to multiple backend storages, such as simple file storage or object storage.

[0036] The Glance service is responsible for managing images and not for image storage. It needs to store the images in a certain directory of the server where the Glance service runs, or interface with different backends. Therefore, the Glance service needs to specify the way to save the images after that.

[0037] The master image is a virtual image object managed by Glance, used to describe the image object. The master image is an abstract image object that saves the common information of the slave images. The common information includes but is not limited to the description of the image type, the size of the image, the type of the image, and does not save the actual image data.

[0038] The slave image is an actual image object, used to create a container, and is stored in the local image resource. Different slave images have independent metadata and save the actual image data.

[0039] In step S102, the first node downloads the available image file to the local storage and establishes a corresponding relationship between the available image file and the slave image.

[0040] The Glance service can obtain the available image file through the corresponding slave image under the master image, and transfer the available image file to the corresponding slave image. Thus, the image can be uploaded once and reused multiple times among different nodes.

[0041] The first node queries the status of other slave images under the master image corresponding to its own slave image, calculates the MD5 values of other slave images respectively according to the MD5 algorithm, obtains the data of other slave images with the same MD5 value, and this data is the available image file. Then copy this image file to the slave image of the first node. When the same image file is used on different nodes, just copy the data of other slave images under its corresponding master image through the MD5 algorithm.

[0042] The image file can contain a complete operating system environment, and the required application programs can be installed in it. The image file can be used to create a container, and the application can be run using the container. The image file is a read-only template and can be regarded as a unified perspective of multiple read-only layers.

[0043] In step S103, the first node uploads the data of the slave image to the Docker image.

[0044] Docker is an open-source application container engine that can package an application and its dependent packages into a portable container, and then publish it to a machine with the Linux or Windows operating system. It can also achieve virtualization. Containers use the sandbox mechanism completely and there will be no interfaces between them.

[0045] When developing or deploying a service, a Docker file needs to be added to the project, so that the packaged service can be built into a Docker image according to the Docker file, and then containers can be generated through the orchestration file of Kubernetes for management.

[0046] The Glance service accesses the Docker API and loads the slave image data into the Docker image. Docker has three types of APIs: Docker Registry API, Docker Hub API, and Docker Remote API. In this embodiment, the Docker Registry API is selected because the Docker Registry API is the API of the Docker image repository. By operating the Docker Registry API, the image repository can be managed freely, automatically, and programmatically.

[0047] With Figure 4For example, the user sends a request to copy from mirror 01 to any node M. The Glance service of node M creates information from mirror 02 to the database and binds the relationship between mirror 02 and the master mirror. The Glance service of node M queries other slave mirrors corresponding to the master mirror of mirror 02 in the database, finds node N with the actual data of mirror 01, and copies the mirror data in node N to node M. The Glance service of node M uploads the data copied from node N to the Docker image through Docker.

[0048] Embodiment 2

[0049] As Figure 5 shown, a method for local container image management based on Openstack in an embodiment of the present invention is introduced. The method includes the following steps.

[0050] In step S201, the first node creates a slave mirror and establishes the corresponding relationship between the master mirror and the slave mirror.

[0051] Add the master mirror information and the slave mirror information to the Openstack cluster database, and map the slave mirror to the master mirror in the database. By establishing the corresponding relationship between the master mirror and the slave mirror in the database, the same mirrors on different nodes can be associated, facilitating the management of the mirrors.

[0052] Glance is a module responsible for mirror management in the Openstack cluster, used for the management and scheduling of container images. Its functions include the search, registration, and retrieval of virtual machine images, etc. Glance can save images to multiple backend storages, such as simple file storage or object storage.

[0053] The Glance service is responsible for managing the mirror and not for storing the mirror. It needs to store the mirror in a certain directory of the server where the Glance service runs, or connect to different backends. Therefore, the Glance service needs to specify the way to save the mirror.

[0054] The master mirror is a virtual mirror object managed by Glance, used to describe the mirror object. The master mirror is an abstract mirror object that saves the common information of the slave mirror. The common information includes but is not limited to the description of the mirror type, the size of the mirror, the type of the mirror, and does not save the actual mirror data.

[0055] The slave mirror is an actual mirror object, used to create a container, and is a local mirror resource. Different slave mirrors have independent metadata and save the actual mirror data.

[0056] In step S202, when the slave image of the first node fails, the first node performs data recovery based on the states of other slave images under the master image corresponding to the slave image.

[0057] Since the Glance service has established the corresponding relationship between the master image and the slave image in the database, when the slave image of a certain node in the cluster fails, it is only necessary to obtain data from other slave images under the master image corresponding to the failed slave image, without uploading data to the slave image again, thus realizing one-time upload of the image and multiple reuse among each node.

[0058] In step S203, copy the data of other slave images with the same MD5 value to the slave image.

[0059] The principle of the MD5 algorithm can be briefly described as follows: The MD5 code processes the input information in 512-bit groups, and each group is further divided into 16 32-bit sub-groups. After processing, the output of the algorithm consists of four 32-bit groups. Concatenating these four 32-bit groups will generate a 128-bit hash value.

[0060] Specifically, (1) Padding: First, pad the length (bit) of the input information so that the remainder when divided by 512 is equal to 448. The padding method is to pad a 1 and n 0s. (2) Record the information length: Use 64 bits to store the information length before padding. These 64 bits are added after the padding result, and at this time the information length becomes N * 512 + 448 + 64 = (N + 1) * 512 bits. (3) Load the standard magic numbers: The standard magic numbers are (A = (01234567)16, B = (89ABCDEF)16, C = (FEDCBA98)16, D = (76543210)16). If defined in the program, it is (A = 0X67452301L, B = 0XEFCDAB89L, C = 0X98BADCFEL, D = 0X10325476L). (4) Four rounds of loop operations: The number of loop times is the number of groups (N + 1).

[0061] When the slave image of the first node fails, query the states of other slave images under the master image corresponding to the slave image of the first node, calculate the MD5 values of other slave images respectively according to the MD5 algorithm, and copy the data of other slave images with the same MD5 value to the first node.

[0062] In step S204, the first node uploads the data of the slave image to the Docker image.

[0063] Docker is an open-source application container engine that can package applications and their dependent packages into a portable container, and then publish it to machines with Linux or Windows operating systems. It can also achieve virtualization. Containers use a sandbox mechanism completely and have no interfaces with each other.

[0064] When developing or deploying services, a Docker file needs to be added to the project, so that the packaged service can be built into a Docker image according to the Docker file, and then containers can be generated and managed through the orchestration file of Kubernetes.

[0065] The Glance service accesses the Docker API and loads image data into the Docker image. Docker has three types of APIs: Docker Registry API, Docker Hub API, and Docker Remote API. In this embodiment, Docker Registry API is selected because Docker Registry API is the API of the Docker image repository. By operating Docker Registry API, the image repository can be freely and automatically managed programmatically.

[0066] As Figure 6 shown, a device for local container image management based on Openstack according to the specific embodiment of the present invention is introduced.

[0067] In the embodiment of the present invention, the device for local container image management based on Openstack includes a creation module 601, a download module 602, and an upload module 603.

[0068] The creation module 601 is used for the first node to create a slave image and establish the corresponding relationship between the master image and the slave image.

[0069] The download module 602 is used for the first node to download available image files to local storage and establish the corresponding relationship between the available image files and the slave image.

[0070] The upload module 603 is used for the first node to upload the data of the slave image to the Docker image.

[0071] The download module 602 is further used for: the first node to find the node with available image files under the master image; and copy the available image files in the node to the slave image.

[0072] The download module 602 is further used for: when the slave image of the first node fails, the first node performs data recovery according to the status of other slave images under the master image corresponding to the slave image.

[0073] The download module 602 is further configured to: query the status of other slave images under the master image corresponding to the mirror; and copy the data of other slave images with the same MD5 value to the slave image.

[0074] Figure 7 FIG. shows a hardware structure diagram of a computing device 70 for local container image management based on Openstack according to an embodiment of the present specification. As Figure 7 shown, the computing device 70 may include at least one processor 701, a memory 702 (e.g., a non-volatile memory), a memory 703, and a communication interface 704, and at least one processor 701, the memory 702, the memory 703, and the communication interface 704 are connected together via a bus 705. The at least one processor 701 executes at least one computer-readable instruction stored or encoded in the memory 702.

[0075] It should be understood that the computer-executable instructions stored in the memory 702, when executed, cause the at least one processor 701 to perform the various operations and functions described above in the various embodiments of the present specification in combination with Figures 1-7 the description.

[0076] In the embodiments of the present specification, the computing device 70 may include, but is not limited to: a personal computer, a server computer, a workstation, a desktop computer, a laptop computer, a notebook computer, a mobile computing device, a smart phone, a tablet computer, a cellular phone, a personal digital assistant (PDA), a handheld device, a messaging device, a wearable computing device, a consumer electronic device, and the like.

[0077] According to one embodiment, a program product such as a machine-readable medium is provided. The machine-readable medium may have instructions (i.e., the elements implemented in the form of software described above), which when executed by the machine, cause the machine to perform the various operations and functions described above in the various embodiments of the present specification in combination with Figures 1-7 the description. Specifically, a system or device equipped with a readable storage medium may be provided, on which software program code for implementing the functions of any one of the above embodiments is stored, and the computer or processor of the system or device reads and executes the instructions stored in the readable storage medium.

[0078] According to the method and application for local container image management based on Openstack according to the embodiments of the present invention, it can associate the same images of different nodes in the Openstack cluster by establishing a correspondence between the master image and the slave image in the database, facilitating image management; and can also implement one-time upload of the image and multiple reuse among nodes according to the correspondence between the master image and the slave image.

[0079] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a system, or a computer program product. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memory, CD-ROM, optical memory, etc.) that contain computer-usable program code.

[0080] The present invention is described with reference to the flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present invention. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram, can be realized by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices generate means for realizing the functions specified in Figure 1 one or more of the flows Figure 1 or blocks or combinations of blocks.

[0081] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including instruction means that realize the functions specified in Figure 1 one or more of the flows Figure 1 or blocks or combinations of blocks.

[0082] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for realizing the functions specified in Figure 1 one or more of the flows Figure 1 or blocks or combinations of blocks.

[0083] The foregoing description of the specific exemplary embodiments of the present invention is for purposes of illustration and exemplification. These descriptions are not intended to limit the invention to the precise forms disclosed, and it is apparent that many modifications and variations are possible in light of the above teachings. The purpose of selecting and describing the exemplary embodiments is to explain the specific principles of the invention and its practical applications, so that those skilled in the art can implement and utilize the various different exemplary embodiments of the invention, as well as various different selections and modifications. The scope of the present invention is intended to be defined by the claims and their equivalents.

Claims

1. A method for local container image management based on Openstack, characterized in that, The method includes: The first node creates a slave image and establishes a correspondence between the master image and the slave image. Here, the master image is a virtual image object that stores the common information of the slave image, and the common information includes the description of the image type, the size of the image, and the type of the image. The slave image is an image object that stores the actual image data; The first node downloads the available image file to the local storage and establishes a correspondence between the available image file and the slave image. Here, the available image file is the data of other slave images with the same MD5 value as the first node's slave image among the other slave images under the master image corresponding to the image; and The first node uploads the data of the slave image to the Docker image; where The first node downloads the available image file to the local storage and establishes a correspondence between the available image file and the slave image, including: The first node searches for the node that has the available image file under the master image; and Copies the available image file in the node to the slave image.

2. The method for local container image management based on Openstack according to claim 1, wherein The method further includes: When the slave image of the first node fails, the first node performs data recovery according to the status of other slave images under the master image corresponding to the slave image.

3. The method for local container image management based on Openstack according to claim 2, wherein, The first node performs data recovery according to the status of other slave images under the master image corresponding to the slave image, including: Querying the status of other slave images under the master image corresponding to the slave image; and Copying the data of the other slave images with the same MD5 value to the slave image.

4. An apparatus for local container image management based on Openstack, characterized in that, The device includes: A creation module for the first node to create a slave image and establish a correspondence between the master image and the slave image. Here, the master image is a virtual image object that stores the common information of the slave image, and the common information includes the description of the image type, the size of the image, and the type of the image. The slave image is an image object that stores the actual image data; A download module for the first node to download the available image file to the local storage and establish a correspondence between the available image file and the slave image. Here, the available image file is the data of other slave images with the same MD5 value as the first node's slave image among the other slave images under the master image corresponding to the image; and An upload module for the first node to upload the data of the slave image to the Docker image; Wherein, the download module is further used for: The first node searches for the node that has the available image file under the master image; and Copies the available image file in the node to the slave image.

5. The apparatus for local container image management based on Openstack according to claim 4, wherein, The download module is further used for: When the slave image of the first node fails, the first node performs data recovery according to the status of other slave images under the master image corresponding to the slave image.

6. The apparatus for local container image management based on Openstack according to claim 5, wherein The download module is further used for: Querying the status of other slave images under the master image corresponding to the slave image; and Copying the data of the other slave images with the same MD5 value to the slave image.

7. An electronic device, characterized in that, Includes: At least one processor; And A memory that stores instructions which, when executed by the at least one processor, cause the at least one processor to execute the method for managing local container images based on Openstack according to any one of claims 1 to 3.

8. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method for managing local container images based on Openstack according to any one of claims 1 to 3 are implemented.

Citation Information

Patent Citations

  • Mirror image implementing method and device

    CN102012793A

  • Distributed storage based Docker image downloading method

    CN106506587A