CN118170500A - Method and system for constructing container mirror image and dynamically injecting container mirror image - Google Patents
Method and system for constructing container mirror image and dynamically injecting container mirror image Download PDFInfo
- Publication number
- CN118170500A CN118170500A CN202410585945.8A CN202410585945A CN118170500A CN 118170500 A CN118170500 A CN 118170500A CN 202410585945 A CN202410585945 A CN 202410585945A CN 118170500 A CN118170500 A CN 118170500A
- Authority
- CN
- China
- Prior art keywords
- image
- file
- container
- runtime
- index
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 38
- 238000002347 injection Methods 0.000 claims abstract description 28
- 239000007924 injection Substances 0.000 claims abstract description 28
- 238000010276 construction Methods 0.000 claims abstract description 15
- 239000010410 layer Substances 0.000 claims description 37
- 238000004364 calculation method Methods 0.000 claims description 4
- 230000007246 mechanism Effects 0.000 claims description 4
- 238000005192 partition Methods 0.000 claims description 3
- 239000002356 single layer Substances 0.000 claims description 3
- 238000000638 solvent extraction Methods 0.000 claims description 3
- 230000001960 triggered effect Effects 0.000 claims description 3
- 238000005516 engineering process Methods 0.000 abstract description 8
- 230000008569 process Effects 0.000 description 12
- 238000010586 diagram Methods 0.000 description 6
- 238000004806 packaging method and process Methods 0.000 description 5
- 230000006870 function Effects 0.000 description 4
- 238000012423 maintenance Methods 0.000 description 4
- 239000000243 solution Substances 0.000 description 4
- 230000005540 biological transmission Effects 0.000 description 3
- 239000002699 waste material Substances 0.000 description 3
- 101001121408 Homo sapiens L-amino-acid oxidase Proteins 0.000 description 2
- 102100026388 L-amino-acid oxidase Human genes 0.000 description 2
- 238000007726 management method Methods 0.000 description 2
- 239000000203 mixture Substances 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 101000827703 Homo sapiens Polyphosphoinositide phosphatase Proteins 0.000 description 1
- 102100023591 Polyphosphoinositide phosphatase Human genes 0.000 description 1
- 101100012902 Saccharomyces cerevisiae (strain ATCC 204508 / S288c) FIG2 gene Proteins 0.000 description 1
- 230000009471 action Effects 0.000 description 1
- 230000015556 catabolic process Effects 0.000 description 1
- 230000007812 deficiency Effects 0.000 description 1
- 238000006731 degradation reaction Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 238000012544 monitoring process Methods 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 230000004043 responsiveness Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/64—Protecting data integrity, e.g. using checksums, certificates or signatures
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/61—Installation
- G06F8/63—Image based installation; Cloning; Build to order
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/71—Version control; Configuration management
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44521—Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Health & Medical Sciences (AREA)
- Bioethics (AREA)
- General Health & Medical Sciences (AREA)
- Computer Hardware Design (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本发明涉及一种容器镜像构建与动态注入的方法及系统,属于云计算技术领域,包括:将传统标准镜像解耦划分为基础支撑镜像、运行时镜像和应用程序镜像;基于索引阈值构建文件签名索引,并上传到云上文件存储系统;通过文件实体注入形式或文件索引拉取形式分别从基础支撑镜像、运行时镜像或应用程序镜像中动态地加载及注入文件至容器的相应层中。本申请提供的方法及系统,有利于镜像的高效存储、快速分发;在构建新镜像时可以快速完成,加快了部署的速度;可以根据实际需求在容器运行时动态地向容器中注入额外的组件、配置信息或文件,从而提高了容器应用的灵活性和适应性;可实现基础支撑镜像、运行时镜像和应用程序镜像之间的文件级共享。
The present invention relates to a method and system for container image construction and dynamic injection, which belongs to the field of cloud computing technology, including: decoupling the traditional standard image into a basic support image, a runtime image and an application image; building a file signature index based on an index threshold, and uploading it to a file storage system on the cloud; dynamically loading and injecting files from the basic support image, the runtime image or the application image into the corresponding layer of the container in the form of file entity injection or file index pull. The method and system provided by the present application are conducive to the efficient storage and rapid distribution of images; the construction of a new image can be completed quickly, which speeds up the deployment speed; additional components, configuration information or files can be dynamically injected into the container when the container is running according to actual needs, thereby improving the flexibility and adaptability of container applications; file-level sharing between the basic support image, the runtime image and the application image can be achieved.
Description
技术领域Technical Field
本发明涉及云计算技术领域,尤其涉及一种容器镜像构建与动态注入的方法及系统。The present invention relates to the field of cloud computing technology, and in particular to a method and system for container image construction and dynamic injection.
背景技术Background technique
容器镜像是一种轻量级、独立的软件打包形式,将应用程序及其所有依赖项打包在一起,以确保应用程序在不同环境中具有一致的运行方式,容器镜像的基础是联合文件系统(Union File System)技术,联合文件系统允许将多个文件系统挂载到同一个目录下,形成一个统一的文件系统视图,在容器镜像中,不同的层可以通过联合文件系统技术整合在一起,为容器提供一个统一的文件系统,这种机制使得容器能够共享相同的基础文件系统,并且实现了容器镜像的分层存储结构。A container image is a lightweight, independent form of software packaging that packages an application and all its dependencies together to ensure that the application runs consistently in different environments. The basis of container images is the Union File System technology, which allows multiple file systems to be mounted to the same directory to form a unified file system view. In a container image, different layers can be integrated together through the Union File System technology to provide a unified file system for the container. This mechanism enables containers to share the same basic file system and implements the hierarchical storage structure of container images.
容器镜像技术借助联合文件系统、写时复制等底层技术实现了高效的应用程序打包和分发方式,为软件开发和部署带来了革命性的变革,容器镜像的出现使得应用程序能够更加轻松地实现跨平台部署、快速迭代和持续交付,极大地提升了开发团队的生产力和效率。Container image technology uses underlying technologies such as joint file systems and copy-on-write to achieve efficient application packaging and distribution, bringing revolutionary changes to software development and deployment. The emergence of container images makes it easier for applications to be deployed across platforms, iterate quickly, and deliver continuously, greatly improving the productivity and efficiency of development teams.
随着容器化技术的普及和应用,容器在软件镜像包中整体载入操作系统等运行环境数据,在提供快速便捷“开箱即用”特性的同时,容器镜像包含了服务所需的全部运行环境,导致镜像规模不断增大,当将通用容器镜像构建技术应用于相应信息系统领域时,因容器镜像大体积引发了诸多问题,如镜像构建耗时增加、存储空间需求增长、镜像传输或分发时间延长等挑战;特别值得关注的是,容器镜像实际有效程序内容可能只占整个镜像的一小部分,有效内容占比过低,造成资源浪费和性能下降;同时,信息系统为适应多变的任务和应用场景,面临软件需求变更、快速迭代需求,使得软件每次更新都需“一体式”打包镜像,花费大量时间用于构建容器镜像,导致更新时效性低、更新效率低。With the popularization and application of containerization technology, the container loads the operating environment data such as the operating system as a whole in the software image package. While providing a fast and convenient "out-of-the-box" feature, the container image contains all the operating environment required for the service, resulting in the continuous increase in the scale of the image. When the general container image construction technology is applied to the corresponding information system field, the large volume of the container image causes many problems, such as increased image construction time, increased storage space requirements, and longer image transmission or distribution time. It is particularly noteworthy that the actual effective program content of the container image may only account for a small part of the entire image, and the proportion of effective content is too low, resulting in resource waste and performance degradation. At the same time, in order to adapt to changing tasks and application scenarios, information systems face changes in software requirements and rapid iteration requirements, so that each software update needs to be "all-in-one" packaged image, and a lot of time is spent on building container images, resulting in low update timeliness and low update efficiency.
发明内容Summary of the invention
本发明意在提供一种容器镜像构建与动态注入的方法及系统,以解决现有技术中存在的不足,本发明要解决的技术问题通过以下技术方案来实现。The present invention intends to provide a method and system for container image construction and dynamic injection to solve the deficiencies in the prior art. The technical problem to be solved by the present invention is achieved through the following technical solutions.
本发明提供的容器镜像构建与动态注入的方法,包括:The method for building and dynamically injecting a container image provided by the present invention includes:
将传统标准镜像解耦划分为基础支撑镜像、运行时镜像和应用程序镜像;Decouple the traditional standard image into basic support image, runtime image and application image;
基于索引阈值构建基础支撑镜像、运行时镜像和应用程序镜像分别对应的文件签名索引,并将文件签名索引对应的文件实体上传到云上文件存储系统;Build file signature indexes corresponding to the basic support image, runtime image, and application image based on the index threshold, and upload the file entities corresponding to the file signature indexes to the cloud file storage system;
通过文件实体注入形式或文件索引拉取形式分别从基础支撑镜像、运行时镜像或应用程序镜像中动态地加载及注入文件至容器的相应层中。Files are dynamically loaded and injected into the corresponding layer of the container from the base support image, runtime image or application image through file entity injection or file index pull.
在上述的方案中,基于索引阈值构建基础支撑镜像、运行时镜像和应用程序镜像分别对应的文件签名索引包括:In the above scheme, the file signature indexes corresponding to the basic support image, the runtime image and the application image are constructed based on the index threshold, including:
对基础支撑镜像、运行时镜像和应用程序镜像中大小大于索引阈值的文件建立相应文件签名索引。Create corresponding file signature indexes for files in the basic support image, runtime image, and application image whose sizes are greater than the index threshold.
在上述的方案中,索引阈值的计算公式为:In the above scheme, the calculation formula of the index threshold is:
; ;
其中,S为索引阈值,xi∈X,X为通过扫描云上文件存储系统,记录每个文件的大小得到的文件大小列表,表示所有文件大小的平均值,/>表示根据磁盘空间限制确定的阈值,Dmax是磁盘空间的最大可用量,α是一个调节系数,确保索引后的大文件不会占用过多的磁盘空间,/>表示根据建立索引的时间复杂度和系统性能需求确定的阈值,Tmax是云上文件存储系统允许的最大索引建立时间,O(f)是Blake2b算法在单位文件上建立索引的时间复杂度。Where S is the index threshold, x i ∈ X, and X is the file size list obtained by scanning the cloud file storage system and recording the size of each file. Indicates the average size of all files, /> Indicates the threshold determined according to the disk space limit, D max is the maximum available disk space, α is an adjustment factor to ensure that large files after indexing do not occupy too much disk space,/> It represents the threshold value determined according to the time complexity of indexing and system performance requirements. T max is the maximum indexing time allowed by the cloud file storage system. O(f) is the time complexity of the Blake2b algorithm for indexing a unit file.
在上述的方案中,在通过文件实体注入形式在容器的相应层中分别从基础支撑镜像、运行时镜像或应用程序镜像中动态地加载及注入文件至容器的相应层中时,在容器启动时或在运行过程中,根据传统标准镜像的解耦划分规则,触发基础支撑镜像、运行时镜像或应用程序镜像,并通过文件复制的注入机制直接从基础支撑镜像、运行时镜像或应用程序镜像中加载并注入相应的文件至容器的相应层中。In the above scheme, when files are dynamically loaded and injected from the basic support image, runtime image or application image into the corresponding layers of the container in the form of file entity injection, when the container is started or during operation, the basic support image, runtime image or application image is triggered according to the decoupling division rules of the traditional standard image, and the corresponding files are directly loaded and injected from the basic support image, runtime image or application image into the corresponding layers of the container through the file copying injection mechanism.
在上述的方案中,在通过文件索引拉取形式分别从基础支撑镜像、运行时镜像或应用程序镜像中动态地加载及注入文件至容器的相应层中时,从云上文件存储系统拉取文件签名索引对应的文件实体并共享至容器的相应层中或通过文件挂载方式共享文件至容器的相应层中。In the above scheme, when files are dynamically loaded and injected into the corresponding layers of the container from the basic support image, runtime image or application image respectively through file index pulling, the file entity corresponding to the file signature index is pulled from the cloud file storage system and shared to the corresponding layer of the container or the file is shared to the corresponding layer of the container through file mounting.
在上述的方案中,在文件签名索引在本地文件共享池中存在文件实体时,通过文件挂载方式共享文件至容器的相应层中。In the above solution, when the file signature index has a file entity in the local file sharing pool, the file is shared to the corresponding layer of the container by file mounting.
在上述的方案中,在文件签名索引在本地文件共享池中不存在文件实体时,在本地文件共享池依据文件签名索引从云上文件存储系拉取对应的文件实体,并通过文件挂载方式共享文件至容器的相应层中。In the above scheme, when the file entity does not exist in the local file sharing pool according to the file signature index, the local file sharing pool pulls the corresponding file entity from the cloud file storage system based on the file signature index, and shares the file to the corresponding layer of the container through file mounting.
在上述的方案中,经过构建文件签名索引后的基础支撑镜像、运行时镜像和应用程序镜像均包括文件实体和文件签名索引。In the above solution, after the file signature index is constructed, the basic support image, runtime image and application image all include the file entity and the file signature index.
在上述的方案中,基础支撑镜像、运行时镜像和应用程序镜像均采用单层或多层结构。In the above solutions, the basic support image, runtime image and application image all adopt a single-layer or multi-layer structure.
本发明提供的容器镜像构建与动态注入的系统,采用如上所述的容器镜像构建与动态注入的方法进行容器镜像的构建与动态注入,所述系统包括:The system for building and dynamically injecting container images provided by the present invention adopts the method for building and dynamically injecting container images as described above to build and dynamically inject container images, and the system includes:
解耦划分模块,用于将传统标准镜像解耦划分为基础支撑镜像、运行时镜像和应用程序镜像;Decoupling and partitioning module, used to decouple and partition the traditional standard image into basic support image, runtime image and application image;
文件签名索引构建模块,用于基于索引阈值构建基础支撑镜像、运行时镜像和应用程序镜像分别对应的文件签名索引,并将文件签名索引对应的文件实体上传到云上文件存储系统;A file signature index building module is used to build file signature indexes corresponding to the basic support image, runtime image, and application image respectively based on the index threshold, and upload the file entity corresponding to the file signature index to the cloud file storage system;
加载注入模块,用于通过文件实体注入形式或文件索引拉取形式分别从基础支撑镜像、运行时镜像或应用程序镜像中动态地加载及注入文件至容器的相应层中。The loading and injection module is used to dynamically load and inject files from the basic support image, runtime image or application image into the corresponding layer of the container through file entity injection or file index pull.
本发明实施例包括以下优点:The embodiments of the present invention include the following advantages:
本发明实施例提供的容器镜像构建与动态注入的方法及系统,将传统标准镜像解耦划分为基础支撑镜像、运行时镜像和应用程序镜像,不同组件或功能按照独立的逻辑单元划分,打包出的镜像体积相对较小,有利于镜像的高效存储、快速分发;将传统标准镜像解耦划分为基础支撑镜像、运行时镜像和应用程序镜像,基础支撑镜像、运行时镜像和应用程序镜像可以独立快速构建和部署,实现了镜像分层打包,由于镜像分层打包可以复用已有的镜像层,因此在构建新镜像时可以快速完成,加快了部署的速度,其中在某一组件需要更新时,也不需要全部重新打包,只需更新某一组件的镜像即可,运行维护更加灵活;可以根据实际需求在容器运行时动态地向容器中注入额外的组件、配置信息或文件,从而提高了容器应用的灵活性和适应性,在容器运行中,更新某一组件或者扩展某一功能不需要重新上传重启容器镜像,只需更新部分组件镜像即可;可实现基础支撑镜像、运行时镜像和应用程序镜像之间的文件级共享,基础支撑镜像、运行时镜像和应用程序镜像之间的文件级共享明显减少了分发传输的数据量,还能显著提升整体系统的效率和性能;通过文件级共享,相同文件在不同容器部署过程中可以直接共享,避免重复下载和存储相同的数据,减少了网络带宽的占用和存储资源的浪费;同时,基础支撑镜像、运行时镜像和应用程序镜像之间的文件级共享还有利于统一管理和更新共享文件,确保文件的一致性和完整性,通过维护一个集中的文件共享池,可以更加有效地管理和控制文件的版本和权限,简化系统维护和升级的流程;此外,文件级共享也为容器部署提供了更灵活的部署选项,使得容器应用程序能够更快速地启动和扩展,进一步提升了系统的响应速度和可伸缩性。The method and system for container image construction and dynamic injection provided by the embodiment of the present invention decouple the traditional standard image and divide it into a basic support image, a runtime image and an application image. Different components or functions are divided according to independent logical units, and the packaged image volume is relatively small, which is conducive to efficient storage and rapid distribution of the image; the traditional standard image is decoupled and divided into a basic support image, a runtime image and an application image. The basic support image, the runtime image and the application image can be independently and quickly constructed and deployed, thereby realizing layered image packaging. Since the layered image packaging can reuse the existing image layer, it can be completed quickly when a new image is constructed, which speeds up the deployment. When a component needs to be updated, it does not need to be completely repackaged, but only the image of a component needs to be updated, and the operation and maintenance are more flexible. According to actual needs, additional components, configuration information or files can be dynamically injected into the container when the container is running, thereby improving the flexibility and adaptability of the container application. During the operation of the container, updating a component or expanding a function does not require To re-upload and restart the container image, you only need to update some component images; file-level sharing can be achieved between the basic support image, runtime image and application image. File-level sharing between the basic support image, runtime image and application image significantly reduces the amount of data distributed and transmitted, and can also significantly improve the efficiency and performance of the overall system; through file-level sharing, the same file can be directly shared during different container deployment processes, avoiding repeated downloading and storage of the same data, reducing network bandwidth usage and storage resource waste; at the same time, file-level sharing between the basic support image, runtime image and application image is also conducive to unified management and updating of shared files, ensuring file consistency and integrity. By maintaining a centralized file sharing pool, file versions and permissions can be more effectively managed and controlled, simplifying the system maintenance and upgrade process; in addition, file-level sharing also provides more flexible deployment options for container deployment, allowing container applications to start and expand more quickly, further improving the system's responsiveness and scalability.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
图1是本发明的实施例一种容器镜像构建与动态注入的方法的流程示意图;FIG1 is a schematic diagram of a process of a method for building and dynamically injecting a container image according to an embodiment of the present invention;
图2是本发明的实施例对传统标准镜像进行拆分的流程示意图;FIG2 is a schematic diagram of a process of splitting a traditional standard image according to an embodiment of the present invention;
图3是本发明的实施例对服务目录软件的完整镜像进行拆分的流程示意图;3 is a schematic diagram of a process of splitting a complete image of a service catalog software according to an embodiment of the present invention;
图4是本发明的一个实施例构建各个镜像对应的文件签名索引的流程示意图;FIG4 is a schematic diagram of a process of constructing a file signature index corresponding to each image according to an embodiment of the present invention;
图5是本发明的实施例通过文件索引拉取形式动态地加载及注入文件的流程示意图;5 is a schematic diagram of a process of dynamically loading and injecting files by pulling files through a file index according to an embodiment of the present invention;
图6是本发明的实施例一种容器镜像构建与动态注入的系统的组成示意图。FIG6 is a schematic diagram of the composition of a system for building and dynamically injecting container images according to an embodiment of the present invention.
具体实施方式Detailed ways
需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。下面将参考附图并结合实施例来详细说明本发明。It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present invention will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
如图1所示,本发明提供一种容器镜像构建与动态注入的方法,该方法包括以下步骤:As shown in FIG1 , the present invention provides a method for building and dynamically injecting a container image, the method comprising the following steps:
步骤S1:将传统标准镜像解耦划分为基础支撑镜像、运行时镜像和应用程序镜像;Step S1: Decouple the traditional standard image into a basic support image, a runtime image, and an application image;
具体地,在对传统标准镜像进行拆分的过程中,依据软件结构以及运行特点,将传统标准镜像解耦划分为基础支撑镜像、运行时镜像和应用程序镜像,具体可参阅图1;其中基础支撑镜像指软件运行底层依赖的根文件系统roofs,运行时镜像指程序执行所需的基础运行时环境,如Java环境、Python环境等,应用程序镜像指面向最终用户研发的可执行程序包,如联合筹划、综合态势、行动监控等软件的程序包;例如服务目录软件由Java语言开发,按上述拆分规则即可将服务目录软件的完整镜像解耦划分为Kylin操作系统镜像、Java运行环境镜像和服务目录Jar包镜像,具体可参阅图3;Specifically, in the process of splitting the traditional standard image, the traditional standard image is decoupled and divided into the basic support image, the runtime image and the application image according to the software structure and operation characteristics, as shown in Figure 1; the basic support image refers to the root file system roofs that the software depends on at the bottom of the operation, the runtime image refers to the basic runtime environment required for program execution, such as the Java environment, Python environment, etc., and the application image refers to the executable program package developed for end users, such as the program packages of joint planning, comprehensive situation, action monitoring and other software; for example, the service catalog software is developed in Java language, and the complete image of the service catalog software can be decoupled and divided into the Kylin operating system image, the Java runtime environment image and the service catalog Jar package image according to the above splitting rules, as shown in Figure 3;
具体地:将传统标准镜像解耦划分为基础支撑镜像、运行时镜像和应用程序镜像,当系统业务需求更新时,通常情况下仅需重新构建应用程序类镜像即可,能够有效缩短镜像构建时间;同时,将传统标准镜像解耦划分为基础支撑镜像、运行时镜像和应用程序镜像,不同组件或功能按照独立的逻辑单元划分,打包出的镜像体积相对较小,有利于镜像的高效存储、快速分发;此外,将传统标准镜像解耦划分为基础支撑镜像、运行时镜像和应用程序镜像,基础支撑镜像、运行时镜像和应用程序镜像可以独立快速构建和部署,实现了镜像分层打包,由于镜像分层打包可以复用已有的镜像层,因此在构建新镜像时可以快速完成,加快了部署的速度,其中在某一组件需要更新时,也不需要全部重新打包,只需更新某一组件的镜像即可,运行维护更加灵活;Specifically: the traditional standard image is decoupled and divided into basic support image, runtime image and application image. When the system business requirements are updated, usually only the application class image needs to be rebuilt, which can effectively shorten the image building time; at the same time, the traditional standard image is decoupled and divided into basic support image, runtime image and application image. Different components or functions are divided according to independent logical units, and the packaged image size is relatively small, which is conducive to efficient storage and rapid distribution of images; in addition, the traditional standard image is decoupled and divided into basic support image, runtime image and application image. The basic support image, runtime image and application image can be independently and quickly built and deployed, realizing layered image packaging. Since the layered image packaging can reuse the existing image layer, it can be completed quickly when building a new image, which speeds up the deployment. When a component needs to be updated, it does not need to be completely repackaged. It is only necessary to update the image of a component, which makes operation and maintenance more flexible.
步骤S2:基于索引阈值构建基础支撑镜像、运行时镜像和应用程序镜像分别对应的文件签名索引,并将文件签名索引对应的文件实体上传到云上文件存储系统;Step S2: constructing file signature indexes corresponding to the basic support image, the runtime image, and the application image respectively based on the index threshold, and uploading the file entities corresponding to the file signature indexes to the cloud file storage system;
具体地,文件签名索引是通过Blake2b算法依据基础支撑镜像、运行时镜像或应用程序镜像中的文件内容进行哈希运算,生成的能够唯一标识相应文件的数字签名;Specifically, the file signature index is a digital signature that can uniquely identify the corresponding file, generated by performing a hash operation based on the file content in the basic support image, runtime image, or application image using the Blake2b algorithm;
具体地,文件以文件实体形式还是索引形式存在于基础支撑镜像、运行时镜像或应用程序镜像中,由索引阈值S决定,由于形成文件签名索引需要花费时间,因此需要建立签名索引的文件越多,计算时间越长,为了平衡镜像大小和建立文件签名索引所需的时间,设置索引阈值S,当文件的大小大于索引阈值S时,建立文件签名索引,反之不建立文件签名索引,从而,使得基础支撑镜像、运行时镜像和应用程序镜像由文件索引和文件混合组成,大幅压缩了镜像体积;此外,针对基础支撑镜像、运行时镜像和应用程序镜像,配套相应的云上文件存储系统,将文件签名索引对应的文件实体上传到云上文件存储系统,用于后续动态按需下载;Specifically, whether the file exists in the basic support image, runtime image or application image in the form of a file entity or an index is determined by the index threshold S. Since it takes time to form a file signature index, the more files need to establish a signature index, the longer the calculation time. In order to balance the image size and the time required to establish a file signature index, the index threshold S is set. When the size of the file is greater than the index threshold S, a file signature index is established, otherwise no file signature index is established. As a result, the basic support image, runtime image and application image are composed of a mixture of file indexes and files, which greatly compresses the image size. In addition, for the basic support image, runtime image and application image, a corresponding cloud file storage system is provided, and the file entity corresponding to the file signature index is uploaded to the cloud file storage system for subsequent dynamic on-demand download.
具体地,综合考虑文件大小分布、系统资源限制、建立索引的时间复杂度和性能需求,设计索引阈值S,以确保系统能够快速建立索引并保持高效的性能,索引阈值S的计算公式为:Specifically, considering file size distribution, system resource limitations, time complexity of indexing, and performance requirements, the index threshold S is designed to ensure that the system can quickly build indexes and maintain efficient performance. The calculation formula of the index threshold S is:
; ;
其中,xi∈X,X为通过扫描云上文件存储系统,记录每个文件的大小得到的文件大小列表,表示所有文件大小的平均值,/>表示根据磁盘空间限制确定的阈值,Dmax是磁盘空间的最大可用量,α是一个调节系数,确保索引后的大文件不会占用过多的磁盘空间,/>表示根据建立索引的时间复杂度和系统性能需求确定的阈值, Tmax是云上文件存储系统允许的最大索引建立时间,O(f)是Blake2b算法在单位文件上建立索引的时间复杂度;Where, x i ∈ X, X is the file size list obtained by scanning the cloud file storage system and recording the size of each file. Indicates the average size of all files, /> Indicates the threshold determined according to the disk space limit, D max is the maximum available disk space, α is an adjustment factor to ensure that large files after indexing do not occupy too much disk space,/> represents the threshold value determined according to the time complexity of indexing and system performance requirements. T max is the maximum indexing time allowed by the cloud file storage system. O(f) is the time complexity of the Blake2b algorithm for indexing a unit file.
具体地,经过基于索引阈值构建基础支撑镜像、运行时镜像和应用程序镜像分别对应的文件签名索引后,基础支撑镜像、运行时镜像和应用程序镜像均包括文件实体和文件签名索引,从而压缩了镜像的体积,当镜像体积减小时,带来传输和存储的效率提升,如,同样的带宽,体积越小,耗费的传输时间也越少,带宽占用越少,同样的存储空间,可以存放更多的镜像;Specifically, after constructing the file signature indexes corresponding to the basic support image, runtime image and application image respectively based on the index threshold, the basic support image, runtime image and application image all include the file entity and the file signature index, thereby compressing the image size. When the image size is reduced, the transmission and storage efficiency is improved. For example, with the same bandwidth, the smaller the size, the less transmission time is consumed, the less bandwidth is occupied, and more images can be stored in the same storage space.
具体地,将文件签名索引对应的文件实体上传到云上文件存储系统,可解决文件实体获取的问题,实现云上存储,全网共享;Specifically, uploading the file entity corresponding to the file signature index to the cloud file storage system can solve the problem of obtaining the file entity, realize cloud storage, and share it across the entire network;
具体地,基础支撑镜像、运行时镜像和应用程序镜像均采用单层或多层结构;Specifically, the basic support image, runtime image, and application image all adopt a single-layer or multi-layer structure;
在本发明的一个实施例中,基础支撑镜像、运行时镜像和应用程序镜像采用两层结构,基础支撑镜像、运行时镜像和应用程序镜像的第一层和第二层均包括多个文件实体和多个文件签名索引,将文件签名索引对应的文件实体上传到云上文件存储系统,在后续需要获取文件签名索引对应的文件实体时,依据文件签名索引从云上文件存储系拉取对应的文件实体,具体可参阅图4;In one embodiment of the present invention, the basic support image, the runtime image and the application image adopt a two-layer structure. The first layer and the second layer of the basic support image, the runtime image and the application image each include multiple file entities and multiple file signature indexes. The file entity corresponding to the file signature index is uploaded to the cloud file storage system. When the file entity corresponding to the file signature index needs to be obtained later, the corresponding file entity is pulled from the cloud file storage system according to the file signature index. For details, please refer to Figure 4;
步骤S3:通过文件实体注入形式或文件索引拉取形式分别从基础支撑镜像、运行时镜像或应用程序镜像中动态地加载及注入文件至容器的相应层中;Step S3: dynamically loading and injecting files from the basic support image, the runtime image or the application image into the corresponding layer of the container by means of file entity injection or file index pull;
具体地,在通过文件实体注入形式在容器的相应层中分别从基础支撑镜像、运行时镜像或应用程序镜像中动态地加载及注入文件至容器的相应层中时,在容器启动时或在运行过程中,根据传统标准镜像的解耦划分规则,触发基础支撑镜像、运行时镜像或应用程序镜像,并通过文件复制的注入机制直接从基础支撑镜像、运行时镜像或应用程序镜像中加载并注入相应的文件至容器的相应层中;Specifically, when files are dynamically loaded and injected from a basic support image, a runtime image or an application image into corresponding layers of a container respectively in the form of file entity injection, when the container is started or during operation, the basic support image, the runtime image or the application image is triggered according to the decoupling division rule of the traditional standard image, and the corresponding files are directly loaded and injected from the basic support image, the runtime image or the application image into the corresponding layers of the container through the injection mechanism of file copying;
具体地,在通过文件索引拉取形式分别从基础支撑镜像、运行时镜像或应用程序镜像中动态地加载及注入文件至容器的相应层中时,从云上文件存储系统拉取文件签名索引对应的文件实体并共享至容器的相应层中或通过文件挂载方式共享文件至容器的相应层中,具体可参阅图5;Specifically, when files are dynamically loaded and injected into the corresponding layer of the container from the basic support image, the runtime image or the application image respectively by pulling the file index, the file entity corresponding to the file signature index is pulled from the cloud file storage system and shared to the corresponding layer of the container or the file is shared to the corresponding layer of the container by file mounting, as shown in FIG5 ;
具体地,在文件签名索引在本地文件共享池中存在文件实体时,通过文件挂载方式共享文件至容器的相应层中;在文件签名索引在本地文件共享池中不存在文件实体时,在本地文件共享池依据文件签名索引从云上文件存储系拉取对应的文件实体,并通过文件挂载方式共享文件至容器的相应层中,因此对于在同一物理节点容器部署过程中存在相同文件签名索引时,通过本地文件共享池可以共享文件,能够有效防止相同文件重复拉取,进一步减少数据的下载量并提高资源利用率;Specifically, when the file signature index exists in the local file sharing pool, the file is shared to the corresponding layer of the container by means of file mounting; when the file signature index does not exist in the local file sharing pool, the local file sharing pool pulls the corresponding file entity from the cloud file storage system based on the file signature index, and shares the file to the corresponding layer of the container by means of file mounting. Therefore, when the same file signature index exists in the container deployment process of the same physical node, the file can be shared through the local file sharing pool, which can effectively prevent the repeated pulling of the same file, further reduce the amount of data downloaded and improve resource utilization.
具体地,通过文件索引拉取形式分别从基础支撑镜像、运行时镜像或应用程序镜像中动态地加载及注入文件至容器的相应层中可实现基础支撑镜像、运行时镜像和应用程序镜像之间的文件级共享,基础支撑镜像、运行时镜像和应用程序镜像之间的文件级共享明显减少了分发传输的数据量,还能显著提升整体系统的效率和性能;通过文件级共享,相同文件在不同容器部署过程中可以直接共享,避免重复下载和存储相同的数据,减少了网络带宽的占用和存储资源的浪费;同时,基础支撑镜像、运行时镜像和应用程序镜像之间的文件级共享还有利于统一管理和更新共享文件,确保文件的一致性和完整性,通过维护一个集中的文件共享池,可以更加有效地管理和控制文件的版本和权限,简化系统维护和升级的流程;此外,文件级共享也为容器部署提供了更灵活的部署选项,使得容器应用程序能够更快速地启动和扩展,进一步提升了系统的响应速度和可伸缩性;Specifically, by dynamically loading and injecting files from the basic support image, runtime image or application image into the corresponding layer of the container in the form of file index pulling, file-level sharing between the basic support image, runtime image and application image can be achieved. File-level sharing between the basic support image, runtime image and application image significantly reduces the amount of data distributed and transmitted, and can also significantly improve the efficiency and performance of the overall system. Through file-level sharing, the same file can be directly shared during the deployment of different containers, avoiding repeated downloading and storage of the same data, reducing network bandwidth usage and storage resource waste. At the same time, file-level sharing between the basic support image, runtime image and application image is also conducive to unified management and updating of shared files, ensuring the consistency and integrity of files. By maintaining a centralized file sharing pool, file versions and permissions can be more effectively managed and controlled, simplifying the system maintenance and upgrade process. In addition, file-level sharing also provides more flexible deployment options for container deployment, allowing container applications to start and expand more quickly, further improving the system's response speed and scalability.
具体地,步骤S3可以根据实际需求在容器运行时动态地向容器中注入额外的组件、配置信息或文件,从而提高了容器应用的灵活性和适应性,在容器运行中,更新某一组件或者扩展某一功能不需要重新上传重启容器镜像,只需更新部分组件镜像即可。Specifically, step S3 can dynamically inject additional components, configuration information or files into the container according to actual needs when the container is running, thereby improving the flexibility and adaptability of container applications. When the container is running, updating a component or expanding a function does not require re-uploading and restarting the container image, but only needs to update some component images.
如图6所示,本发明提供一种容器镜像构建与动态注入的系统,采用如上所述的容器镜像构建与动态注入的方法进行容器镜像构建与动态注入,该系统包括:As shown in FIG6 , the present invention provides a system for building and dynamically injecting container images, which uses the method for building and dynamically injecting container images as described above to build and dynamically inject container images. The system includes:
解耦划分模块,用于将传统标准镜像解耦划分为基础支撑镜像、运行时镜像和应用程序镜像;Decoupling and partitioning module, used to decouple and partition the traditional standard image into basic support image, runtime image and application image;
文件签名索引构建模块,用于基于索引阈值构建基础支撑镜像、运行时镜像和应用程序镜像分别对应的文件签名索引,并将文件签名索引对应的文件实体上传到云上文件存储系统;A file signature index building module is used to build file signature indexes corresponding to the basic support image, runtime image, and application image respectively based on the index threshold, and upload the file entity corresponding to the file signature index to the cloud file storage system;
加载注入模块,用于通过文件实体注入形式或文件索引拉取形式分别从基础支撑镜像、运行时镜像或应用程序镜像中动态地加载及注入文件至容器的相应层中。The loading and injection module is used to dynamically load and inject files from the basic support image, runtime image or application image into the corresponding layer of the container through file entity injection or file index pull.
应该指出,上述详细说明都是示例性的,旨在对本申请提供进一步的说明。除非另有指明,本文使用的所有技术和科学术语均具有与本申请所属技术领域的普通技术人员的通常理解所相同的含义。It should be noted that the above detailed description is exemplary and is intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the art to which the present application belongs.
需要注意的是,这里所使用的术语仅是为了描述具体实施方式,而非意图限制根据本申请的示例性实施方式。如在这里所使用的,除非上下文另外明确指出,否则单数形式也意图包括复数形式。此外,还应当理解的是,当在本说明书中使用术语“包含”和/或“包括”时,其指明存在特征、步骤、操作、器件、组件和/或它们的组合。It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should also be understood that when the terms "comprise" and/or "include" are used in this specification, it indicates the presence of features, steps, operations, devices, components and/or combinations thereof.
需要说明的是,本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的术语在适当情况下可以互换,以便这里描述的本申请的实施方式能够以除了在这里图示或描述的那些以外的顺序实施。It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein.
此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含。例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units that are not explicitly listed or inherent to these processes, methods, products, or apparatuses.
为了便于描述,在这里可以使用空间相对术语,如“在……之上”、“在……上方”、“在……上表面”、“上面的”等,用来描述如在图中所示的一个器件或特征与其他器件或特征的空间位置关系。应当理解的是,空间相对术语旨在包含除了器件在图中所描述的方位之外的在使用或操作中的不同方位。例如,如果附图中的器件被倒置,则描述为“在其他器件或构造上方”或“在其他器件或构造之上”的器件之后将被定位为“在其他器件或构造下方”或“在其他器件或构造之下”。因而,示例性术语“在……上方”可以包括“在……上方”和“在……下方”两种方位。该器件也可以其他不同方式定位,如旋转90度或处于其他方位,并且对这里所使用的空间相对描述作出相应解释。For ease of description, spatially relative terms, such as "above", "above", "on the upper surface of", "above", etc., may be used herein to describe the spatial positional relationship between a device or feature and other devices or features as shown in the figure. It should be understood that spatially relative terms are intended to include different orientations of the device in use or operation in addition to the orientation described in the figure. For example, if the device in the accompanying drawings is inverted, the device described as "above other devices or structures" or "above other devices or structures" will be positioned as "below other devices or structures" or "below other devices or structures". Thus, the exemplary term "above" may include both "above" and "below". The device may also be positioned in other different ways, such as rotated 90 degrees or in other orientations, and the spatially relative descriptions used herein are interpreted accordingly.
在上面详细的说明中,参考了附图,附图形成本文的一部分。在附图中,类似的符号典型地确定类似的部件,除非上下文以其他方式指明。在详细的说明书、附图及权利要求书中所描述的图示说明的实施方案不意味是限制性的。在不脱离本文所呈现的主题的精神或范围下,其他实施方案可以被使用,并且可以作其他改变。In the above detailed description, reference is made to the accompanying drawings, which form a part of this document. In the accompanying drawings, similar symbols typically identify similar components unless the context indicates otherwise. The illustrated embodiments described in the detailed description, drawings, and claims are not meant to be limiting. Other embodiments may be used, and other changes may be made, without departing from the spirit or scope of the subject matter presented herein.
以上所述仅为本发明的优选实施例而已,并不用于限制本发明,对于本领域的技术人员来说,本发明可以有各种更改和变化。凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410585945.8A CN118170500B (en) | 2024-05-13 | 2024-05-13 | A method and system for container image construction and dynamic injection |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410585945.8A CN118170500B (en) | 2024-05-13 | 2024-05-13 | A method and system for container image construction and dynamic injection |
Publications (2)
Publication Number | Publication Date |
---|---|
CN118170500A true CN118170500A (en) | 2024-06-11 |
CN118170500B CN118170500B (en) | 2024-12-03 |
Family
ID=91350868
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202410585945.8A Active CN118170500B (en) | 2024-05-13 | 2024-05-13 | A method and system for container image construction and dynamic injection |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN118170500B (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20100287338A1 (en) * | 2009-05-06 | 2010-11-11 | An Yonghyun | Selective mirroring method |
CN110704162A (en) * | 2019-09-27 | 2020-01-17 | 北京百度网讯科技有限公司 | Method, device and equipment for sharing container mirror image by physical machine and storage medium |
CN112685134A (en) * | 2020-12-31 | 2021-04-20 | 中科星图股份有限公司 | Mirror image construction and loading method based on mirror image loading in container environment |
CN114924845A (en) * | 2022-07-21 | 2022-08-19 | 合肥中科类脑智能技术有限公司 | Mirror image delay loading method and system suitable for edge AI scene |
-
2024
- 2024-05-13 CN CN202410585945.8A patent/CN118170500B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20100287338A1 (en) * | 2009-05-06 | 2010-11-11 | An Yonghyun | Selective mirroring method |
CN110704162A (en) * | 2019-09-27 | 2020-01-17 | 北京百度网讯科技有限公司 | Method, device and equipment for sharing container mirror image by physical machine and storage medium |
CN112685134A (en) * | 2020-12-31 | 2021-04-20 | 中科星图股份有限公司 | Mirror image construction and loading method based on mirror image loading in container environment |
CN114924845A (en) * | 2022-07-21 | 2022-08-19 | 合肥中科类脑智能技术有限公司 | Mirror image delay loading method and system suitable for edge AI scene |
Also Published As
Publication number | Publication date |
---|---|
CN118170500B (en) | 2024-12-03 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN102185928B (en) | Method for creating virtual machine in cloud computing system and cloud computing system | |
CN107729020B (en) | Method for realizing rapid deployment of large-scale container | |
US8606886B2 (en) | System for conversion between physical machines, virtual machines and machine images | |
CN108667904B (en) | Docker container remote memory volume management method and system | |
US20160205541A1 (en) | Apparatus For End-User Transparent Utilization of Computational, Storage, and Network Capacity of Mobile Devices, and Associated Methods | |
US20100287280A1 (en) | System and method for cloud computing based on multiple providers | |
KR20140100504A (en) | Data transmission and reception system | |
WO2018196462A1 (en) | Resource scheduling apparatus, resource scheduling system and resource scheduling method | |
CN113760453B (en) | Container mirror image distribution system and container mirror image pushing, pulling and deleting method | |
CN115827008B (en) | Cloud primary big data component management system based on cloud primary platform Kubernetes | |
CN112835524A (en) | Storage resource configuration method, storage resource controller and scheduling system | |
US20210055938A1 (en) | Hydration in virtual machines | |
JP2013516711A (en) | System and method for controlling power in an electronic device | |
CN111385325A (en) | P2P-based file distribution system and method | |
CN116192872A (en) | Edge environment container acceleration provisioning method, system, electronic device and storage medium | |
CN112883006B (en) | Enterprise-level container mirror image acceleration method and device, electronic equipment and storage medium | |
US8442939B2 (en) | File sharing method, computer system, and job scheduler | |
CN118170500A (en) | Method and system for constructing container mirror image and dynamically injecting container mirror image | |
US11475022B2 (en) | System and method for constructing a compound object in a distributed object storage system | |
CN114153525A (en) | AI model service sharing method and system for power grid regulation and control business | |
WO2024208214A1 (en) | Container starting method, and device, storage medium and system | |
CN118214641A (en) | Business container management method, system, computer equipment, medium and product | |
CN115904416A (en) | Deployment method, device, equipment and storage medium of whole network data monitoring system | |
CN113641641A (en) | Switching method, switching system, equipment and storage medium of file storage service | |
US11520781B2 (en) | Efficient bulk loading multiple rows or partitions for a single target table |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |