Micro-service application deployment method and device
By hashing and deduplication of the mirrored hierarchical files of microservice applications in a private deployment environment, the problem of repeated hierarchical files occupies bandwidth and storage in the image files is solved, and a more efficient deployment process is achieved.
Patent Information
- Application Number
- CN202411677307.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-21
- Publication Date
- 2025-04-11
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In a private deployment environment, multiple microservice applications are built on similar basic images, resulting in a large number of duplicate mirror layered files in the image files, occupying valuable transmission bandwidth and storage space, and affecting deployment efficiency.
By obtaining the offline image package of the microservice application of the application container engine of the privatized environment, extracting the mirror layered files and mirror information collection of the mirror file according to the preset product file format, performing hash calculations to remove duplicate mirror layered files, updating the mirror information collection, and saving it as an application deployment file, so that the microservice application is deployed in the application container engine.
The redundant mirrored layered files in multiple microservice application image files are removed, which reduces the size of application deployment files, reduces the use of transmission bandwidth, improves deployment efficiency, and reduces waste of storage space.
Smart Images

Figure CN119806556A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of computer technology, and in particular, to a microservice application deployment method, a microservice application deployment device, an electronic device, and a computer-readable storage medium. Background Art
[0002] Docker (Application Container Engine) is an open source platform for developing, delivering, and running applications. Docker can run on computers with many operating systems, such as Windows, macOS, and Linux, and package an application and its dependencies into a container, which can run in any environment that supports Docker. Containers are isolated from each other and can pass information to each other through specific channels.
[0003] With the popularity of containerization technology, Docker has become the preferred platform for enterprises to build, distribute and run microservice applications. In a private deployment environment, multiple microservice applications are often built based on similar basic images, resulting in a large number of duplicate image layered files in the image files (images) corresponding to each microservice application. These duplicate image layered files occupy valuable transmission bandwidth and storage space, affecting the deployment efficiency of microservice applications in a private environment. Summary of the invention
[0004] The purpose of the embodiment of the present invention is to provide a microservice application deployment method, which is used to solve the problem that duplicate image layered files occupy valuable transmission bandwidth and storage space of the privatized environment, affecting the deployment efficiency of the microservice application in the privatized environment. The specific technical solution is as follows:
[0005] In a first aspect of the implementation of the present invention, a microservice application deployment method is first provided, the method comprising:
[0006] Obtain the offline image package of the microservice application of the application container engine in the privatized environment;
[0007] Obtaining an image layer file and an image information set of an image file from the offline image package according to a preset product file format;
[0008] Performing hash calculations on the image layered files respectively to obtain hash identifiers;
[0009] Removing duplicate image layered files according to the hash identifier to obtain updated image layered files;
[0010] Update the image information set according to the updated image layered file to obtain an updated image information set;
[0011] The updated image information set is saved as an application deployment file, where the application deployment file is used to deploy the microservice application in the application container engine of the privatized environment.
[0012] Optionally, removing duplicate image layered files according to the hash identifier includes:
[0013] When the same hash identifier exists, it is determined that there is a duplicate image layered file;
[0014] The duplicated image layered files are deleted from the image layered files.
[0015] Optionally, the image information set includes an image description file set, a hierarchical file sharing pool, an image manifest, an image index file, image runtime information, and image repository information, and updating the image information set according to the updated image hierarchical file includes:
[0016] Saving the updated image layered file to the layered file sharing pool;
[0017] The hash identifier corresponding to the updated image layered file is stored in the image manifest file;
[0018] The image manifest file, the image index file, the image runtime information and the image repository information are moved to the image description file set.
[0019] Optionally, the image information set includes a product manifest file, and updating the image information set according to the updated image layer file includes:
[0020] The image information corresponding to the image file of the microservice application is recorded in the product manifest file; wherein the image information at least includes an image name.
[0021] Optionally, after saving the update image information set as an application deployment file, which is used to deploy the microservice application in the application container engine of the privatized environment, the method further includes:
[0022] Obtaining the application deployment file;
[0023] Extracting and updating the image information set from the application deployment file according to a preset product file format;
[0024] The microservice application is deployed in the application container engine of the privatized environment according to the updated image information set.
[0025] Optionally, updating the image information set includes a product manifest file, a hierarchical file sharing pool, and an image description file set, and deploying the microservice application in the application container engine of the privatized environment according to the updated image information set includes:
[0026] Create a file directory corresponding to each of the image files according to the image information of the image in the product list file;
[0027] Move the image description file set corresponding to each of the image files to the file directory of the image;
[0028] Read the image manifest file corresponding to each of the image files to obtain a hash identifier corresponding to each of the image files;
[0029] Acquire the updated image layered files corresponding to each of the image files from the layered file sharing pool according to the hash identifiers corresponding to each of the image files, and save them in the file directories corresponding to each of the image files;
[0030] Compress the file directories corresponding to the respective image files to obtain an updated offline image package;
[0031] The updated offline image package is loaded into the application container engine of the privatized environment to deploy the microservice application.
[0032] Optionally, the application container engine includes at least Docker.
[0033] The embodiment of the present invention further discloses a microservice application deployment device, the device comprising:
[0034] An offline image package acquisition module is used to obtain an offline image package of a microservice application of an application container engine in a privatized environment;
[0035] An offline image package processing module, used to obtain an image layer file and an image information set of an image file from the offline image package according to a preset product file format;
[0036] The image layered file calculation module is used to perform hash calculations on the image layered files to obtain hash identifiers;
[0037] An image layered file deduplication module, used to remove duplicate image layered files according to the hash identifier to obtain updated image layered files;
[0038] An image information set updating module, used to update the image information set according to the updated image layered file to obtain an updated image information set;
[0039] A microservice application deployment module is used to save the update image information set as an application deployment file, and the application deployment file is used to deploy the microservice application in the application container engine of the privatized environment.
[0040] In another aspect of the implementation of the present invention, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is run on a computer, the computer executes any of the microservice application deployment methods described above.
[0041] In another aspect of the implementation of the present invention, a computer program product comprising instructions is also provided, which, when executed on a computer, enables the computer to execute any of the microservice application deployment methods described above.
[0042] Compared with the related art, the embodiments of the present invention have at least the following advantages:
[0043] In an embodiment of the present invention, an offline image package of a microservice application of an application container engine of a privatized environment is obtained, an image layered file and an image information set of the image file are obtained from the offline image package according to a preset product file format, hash calculations are performed on the image layered files to obtain hash identifiers to remove duplicate image layered files according to the hash identifiers to obtain updated image layered files, and then, the image information set is updated according to the updated image layered files to obtain an updated image information set, and the updated image information set is saved as an application deployment file, and the microservice application can be deployed in the application container engine of the privatized environment by downloading the application deployment file. The embodiment of the present invention removes redundant image layered files in the image files of multiple microservice applications, reduces the volume of application deployment files of privatized deployed microservice applications, reduces the bandwidth occupied by application deployment files of microservice applications during transmission, improves the transmission efficiency of application deployment files of microservice applications, and reduces the waste of storage space required for microservice applications, thereby improving the deployment efficiency of microservice applications in a privatized environment. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art.
[0045] Figure 1 A flowchart of a method for deploying a microservice application provided in an embodiment of the present invention;
[0046] Figure 2 A method for constructing an application deployment file of a microservice application provided in an embodiment of the present invention;
[0047] Figure 3A method for deploying an application deployment file of a microservice application provided in an embodiment of the present invention;
[0048] Figure 4 A structural block diagram of a microservice application deployment device provided in an embodiment of the present invention;
[0049] Figure 5 The present invention is a block diagram of an electronic device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0050] The technical solutions in the embodiments of the present invention will be described below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0051] Reference Figure 1 , is a flowchart of a microservice application deployment method provided in an embodiment of the present invention, such as Figure 1 As shown, the method may specifically include the following steps:
[0052] Step 101: Obtain an offline image package of a microservice application of an application container engine in a privatized environment.
[0053] In specific implementation, a privatized environment refers to deploying services or resources (such as microservice applications) in the internal private network of an organization or enterprise to meet the specific needs and security requirements of the organization or enterprise. This deployment method allows users to manage resources and services in their own network environment, providing higher security, flexibility and controllability.
[0054] In some specific examples, the application container engine may include at least Docker. Specifically, a Docker image (image) is a read-only template for creating a Docker container. A Docker image contains all the content required to run an application (such as a microservice application), including code, runtime environment, libraries, environment variables, and configuration files. Docker images are the basis for building and distributing applications, ensuring the consistency and portability of applications. In Docker, image files are layered, which means that each image file is built on top of another image file, usually starting from a base image (such as Ubuntu, Alpine Linux, etc.), and then adding the dependencies and configurations required by the application, that is, the image file has corresponding multiple image layered files, and the image layered files corresponding to the image file will have duplicate image layered files, and usually only a few image layered files in the upper layer are different.
[0055] Among them, the microservice application includes one or more image files (images). An image file is a lightweight, independent, executable software package that contains all the content required to run a microservice application, including code, runtime environment, system tools, system libraries, and settings.
[0056] In an embodiment of the present invention, the online image files of the privatization environment of multiple microservice applications are downloaded and saved as an offline image package, which is a compressed file organized in tar format. After all the image files used for the privatization environment deployment are downloaded, all the materials for construction are ready.
[0057] Step 102: Obtain an image layer file and an image information set of the image file from the offline image package according to a preset product file format.
[0058] In an embodiment of the present invention, in order to standardize the artifact file (application deployment file of a microservice application) proposed in an embodiment of the present invention, a new file format DLSA is defined, that is, a preset artifact file format. The Chinese name of DLSA is Docker layered shared artifact, and the English name is Docker Layout Share Archive.
[0059] Exemplarily, the structure of the DLSA file format is shown in the following table:
[0060]
[0061] In an embodiment of the present invention, the image layered file and the image information set of the image file can be obtained from the offline image package according to the preset product file format (DLSA), wherein the image layered file is the core component of the Docker image, and the Docker image is composed of multiple read-only layers (layers), each layer represents a step or modification in the image file construction process, and these layers are superimposed through a joint file system to form a corresponding image file. The image information set is the relevant information corresponding to each image file extracted from the offline image package according to the preset product file format (DLSA), for example, the image information set may include information such as the image manifest file, the image index file, the image runtime information, and the image repository information, wherein the image manifest file is used to store the hash identifier of the image layered file.
[0062] In the process of deploying the image file of the microservice application with the Docker image, the image index file, image runtime information, and image repository information provide the necessary metadata and configuration information to ensure that the image file can be deployed and run correctly. The image index file is usually a file in JSON (JavaScript Object Notation, a lightweight data exchange format) format, which describes the configuration information of the image file, including the architecture of the image, the operating system, the reference of the image manifest, etc. The image runtime information is used to describe the runtime configuration of the image, which can ensure that the image file has consistent behavior in different container runtime environments. The image repository information is used to describe the location and reference of the image file in the repository, and can contain information about the image file such as the name of the image, the tag, and the corresponding manifest summary.
[0063] Step 103: Perform hash calculations on the image layered files to obtain hash identifiers.
[0064] Step 104: Remove duplicate image layered files according to the hash identifier to obtain updated image layered files.
[0065] In an embodiment of the present invention, for the image layered files corresponding to each image file, a hash algorithm can be used to perform hash calculation on the image layered files to obtain a hash identifier (hash value). Based on the hash identifier, it can be determined whether the image layered files are duplicate image layered files, that is, whether they are the same image layered files. If it is determined according to the hash identifier that there are duplicate image layered files, the duplicate image layered files can be removed and only one can be retained, thereby obtaining an updated image layered file after removing the duplicate image layered files. In this way, the size of the application deployment file used when deploying microservice applications can be reduced. In some specific examples, hash algorithms such as sha256 and MD5 can be used to perform hash calculation on the image layered files to obtain hash identifiers corresponding to each image layered file.
[0066] Step 105: Update the image information set according to the updated image layered file to obtain an updated image information set.
[0067] In the embodiment of the present invention, after the update of the image layer file is completed to obtain the updated image layer file, the image information set is updated based on the updated image layer file to obtain the updated image information set.
[0068] Step 106: Save the updated image information set as an application deployment file, where the application deployment file is used to deploy the microservice application in the application container engine of the privatized environment.
[0069] In an embodiment of the present invention, after obtaining the update image information, the application deployment file can be obtained by compressing the update image information. For example, gunzip can be used to compress all DLSA materials (i.e., update image information) to form a DLSA file (application deployment file). The file suffix of the application deployment file can be dlsa.
[0070] In one example, a sample product (application deployment file) name may be: application.dlsa.
[0071] In some specific applications, the application deployment files of the microservice application can be pushed to the artifact library. Subsequently, after the operation and maintenance deployment personnel download the application deployment files from the artifact library, they can deploy and run the application deployment files of the microservice application in the application container engine of the privatized environment.
[0072] In an embodiment of the present invention, an offline image package of a microservice application of an application container engine of a privatized environment is obtained, an image layered file and an image information set of the image file are obtained from the offline image package according to a preset product file format, hash calculations are performed on the image layered files to obtain hash identifiers to remove duplicate image layered files according to the hash identifiers to obtain updated image layered files, and then, the image information set is updated according to the updated image layered files to obtain an updated image information set, and the updated image information set is saved as an application deployment file, and the microservice application can be deployed in the application container engine of the privatized environment by downloading the application deployment file. The embodiment of the present invention removes redundant image layered files in the image files of multiple microservice applications, reduces the volume of application deployment files of privatized deployed microservice applications, reduces the bandwidth occupied by application deployment files of microservice applications during transmission, improves the transmission efficiency of application deployment files of microservice applications, and reduces the waste of storage space required for microservice applications, thereby improving the deployment efficiency of microservice applications in a privatized environment.
[0073] In an embodiment of the present invention, removing duplicate image layered files according to the hash identifier includes:
[0074] When the same hash identifier exists, it is determined that there is a duplicate image layered file;
[0075] The duplicated image layered files are deleted from the image layered files.
[0076] In the specific implementation, hash algorithms such as sha256 and MD5 are algorithms that map data of any length to fixed-length output. By processing the image layered file through the hash algorithm, a unique hash identifier can be generated for the image layered file. Specifically, the hash identifier is a string of fixed length, for example, the hash identifier calculated by the MD5 hash algorithm is 32 characters, and the hash identifier calculated by the SHA-256 hash algorithm is 64 characters.
[0077] In an embodiment of the present invention, a hash identifier (hash value) can uniquely identify each image layered file. By calculating the hash identifier of each image layered file, the uniqueness of each image layered file can be ensured. Therefore, when multiple image layered files have the same hash identifier, it can be determined that the image layered files with the same hash identifier are duplicated, that is, the contents of these image layered files are exactly the same. Therefore, in order to reduce the size of the application deployment file of the microservice application, these duplicate image layered files can be deleted and only one copy is retained. This can reduce the storage space (disk) occupied by the application deployment file in a privatized environment, improve the transmission efficiency of the application deployment file, and then improve the deployment efficiency of the application deployment file.
[0078] In one embodiment of the present invention, the image information set includes an image description file set, a hierarchical file sharing pool, an image manifest file, an image index file, image runtime information, and image repository information. Updating the image information set according to the updated image hierarchical file includes:
[0079] Saving the updated image layered file to the layered file sharing pool;
[0080] The hash identifier corresponding to the updated image layered file is stored in the image manifest file;
[0081] The image manifest file, the image index file, the image runtime information and the image repository information are moved to the image description file set.
[0082] The image information set is obtained from the offline image package according to the preset artifact file format (DLSA), which may include at least an image description file set, a hierarchical file sharing pool, an image list, an image index file, image runtime information and image repository information.
[0083] In an embodiment of the present invention, after deleting duplicate image layered files, an updated image layered file can be obtained. Then, the processed updated image layered file can be moved to a layered file sharing pool for storage, and a hash identifier corresponding to the updated image layered file can be stored in an image manifest file (of course, it can also be stored in the image manifest file when the hash identifier of the image layered file is generated), and the image manifest file, image index file, image runtime information, and image repository information can be moved to a DLSA image description file collection.
[0084] In an embodiment of the present invention, the image information set includes a product manifest file, and updating the image information set according to the updated image layer file includes:
[0085] The image information corresponding to the image file of the microservice application is recorded in the product manifest file; wherein the image information at least includes an image name.
[0086] In an embodiment of the present invention, the image information set may also include a product list file. After the image layered file processing of all acquired image files is completed, the image information of all image files may be recorded in the product list file, so as to facilitate the corresponding processing of each image file when deploying the microservice application.
[0087] For example, refer to Figure 2 , is a method for constructing an application deployment file (product) of a microservice application provided in an embodiment of the present invention, and specific steps may include: preparing all offline image packages; decompressing the offline image packages (the offline image packages may include image layered files and image manifest files, image index files, image runtime information, image warehouse information and other information); calculating the hash identifier of the image layered files; deduplicating and moving them to a layered file sharing pool; collecting image manifest files, image index files, image runtime information and image warehouse information; summarizing an image description file set; compressing the image description file set and the layered file sharing pool using the gunzip algorithm; calibrating the file suffix to form a product file (application deployment file); and pushing it to the product library.
[0088] In one embodiment of the present invention, after saving the update image information set as an application deployment file, which is used to deploy the microservice application in the application container engine of the privatized environment, the method may further include:
[0089] Obtaining the application deployment file;
[0090] Extracting and updating the image information set from the application deployment file according to a preset product file format;
[0091] The microservice application is deployed in the application container engine of the privatized environment according to the updated image information set.
[0092] In one embodiment of the present invention, the updating of the image information set includes a product manifest file, a hierarchical file sharing pool, and an image description file set, and deploying the microservice application in the application container engine of the privatized environment according to the updated image information set includes:
[0093] Create a file directory corresponding to each of the image files according to the image information of the image in the product list file;
[0094] Move the image description file set corresponding to each of the image files to the file directory of the image;
[0095] Read the image manifest file corresponding to each of the image files to obtain a hash identifier corresponding to each of the image files;
[0096] Acquire the updated image layered files corresponding to each of the image files from the layered file sharing pool according to the hash identifiers corresponding to each of the image files, and save them in the file directories corresponding to each of the image files;
[0097] Compress the file directories corresponding to the respective image files to obtain an updated offline image package;
[0098] The updated offline image package is loaded into the application container engine of the privatized environment to deploy the microservice application.
[0099] In an embodiment of the present invention, before deploying a privatized service (deploying a microservice application), an artifact file (application deployment file) of the microservice application can be obtained from the artifact library and transmitted to the privatized environment. On the server of the privatized environment, the application deployment file is first decompressed using the gunzip algorithm. The application deployment file may include an artifact list file, a hierarchical file sharing pool, and an image description file set. The decompressed directory is stored according to the organizational structure of a preset artifact file format (DLSA).
[0100] Read and analyze the artifact list file in the preset artifact file format (DLSA). The artifact list file records the image information (image list) of all image files in the microservice application. For example, the image file can create the file directory (image directory) corresponding to each image file in sequence with the image name. Move the image list file, image index file, image runtime information, and image warehouse information corresponding to each image file in the DLSA image description file set to the file directory corresponding to the newly created image file.
[0101] The image manifest file of each image file is read in sequence. The image manifest file records the hash identifier corresponding to the image layered file used by the image file. According to the hash identifier of each image layered file, the image layered file required by each image file can be obtained from the layered file sharing pool. The image layered file can be placed in the blobs / sha256 / directory in the file directory corresponding to the image file. It should be noted that the layered file sharing pool in the embodiment of the present invention can store the image layered files of one or more microservice applications, so multiple microservice applications can share the image layered files of the layered file sharing pool, thereby further reducing the duplicate image layered files occupying the precious transmission bandwidth and storage space of the privatized environment, and providing users with better service effects of microservice applications.
[0102] Compress the file directories corresponding to each image file in tar format and restore them to the original image offline package (update image offline package) of the application container engine (such as docker). The updated image offline package can be loaded into the context of the application container engine, and used by container orchestration components such as docker or k8s to start containers using images, completing the deployment of microservice applications in a private environment.
[0103] In an optional example of the present invention, the hierarchical file sharing pool can be saved in the application deployment file together with the image description file and the product list file, and the microservice application can be deployed in the privatized environment together. Alternatively, the image description file and the product list file can be sent to the privatized environment first, and then the corresponding image hierarchical file can be obtained from the hierarchical file sharing pool according to the image description file and the product list file, and then the microservice application can be deployed in the privatized environment. Different microservice applications can share the same image hierarchical file through the hierarchical file sharing pool, making the deployment of microservice applications in the privatized environment more flexible, and operation and maintenance personnel can selectively obtain and deploy image hierarchical files according to actual needs.
[0104] For example, refer to Figure 3 , is a method for deploying an application deployment file of a microservice application provided in an embodiment of the present invention. The specific steps for deploying a microservice application in a privatized environment may include: downloading a DLSA artifact (application deployment file) from a product library; decompressing the DLSA artifact using a gunzip algorithm; reading an artifact manifest file from the decompressed DLSA artifact, wherein the artifact manifest file includes image information corresponding to each image file; creating each image directory in turn; reading an image manifest file; distributing image layered files in the image directory; distributing image index files and image runtime information in the image directory; tar compressing the image directory of each image file to obtain an updated offline image package; loading the updated offline image into the docker image to complete the deployment of the microservice application in the privatized environment.
[0105] By applying the embodiment of the present invention, offline image packages of 7 microservice applications were obtained for testing. After the offline image packages were used to form application deployment files corresponding to the microservice applications in a preset product file format (DLSA), the material volume required for deploying the microservice applications in a privatized environment was reduced by 64.3%.
[0106] It can be seen that the preset product file format (DLSA) proposed in the embodiment of the present invention is applied. The product format can reduce the size of the application deployment file deployed in the privatization environment, reduce the bandwidth occupied by the application deployment file during the transmission process, and reduce the waste of storage space. In addition, the preset product file format (DLSA) proposed in the embodiment of the present invention can effectively reduce the disk occupancy of the privatization environment, and improve the deployment efficiency by loading the image files of all microservice applications in one deployment.
[0107] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0108] Reference Figure 4 , is a structural block diagram of a microservice application deployment device provided in an embodiment of the present invention, such as Figure 4 As shown, the device may specifically include the following modules:
[0109] The offline image package acquisition module 401 is used to acquire the offline image package of the microservice application of the application container engine of the privatized environment;
[0110] The offline image package processing module 402 is used to obtain the image layer file and the image information set of the image file from the offline image package according to the preset product file format;
[0111] The image layered file calculation module 403 is used to perform hash calculations on the image layered files to obtain hash identifiers;
[0112] An image layered file deduplication module 404 is used to remove duplicate image layered files according to the hash identifier to obtain an updated image layered file;
[0113] An image information set updating module 405 is used to update the image information set according to the updated image layered file to obtain an updated image information set;
[0114] The microservice application deployment module 406 is used to save the update image information set as an application deployment file, and the application deployment file is used to deploy the microservice application in the application container engine of the privatized environment.
[0115] In one embodiment of the present invention, the image layered file deduplication module 404 is used to:
[0116] When the same hash identifier exists, it is determined that there is a duplicate image layered file;
[0117] The duplicated image layered files are deleted from the image layered files.
[0118] In one embodiment of the present invention, the image information set includes an image description file set, a hierarchical file sharing pool, an image list, an image index file, image runtime information and image repository information, and the image information set update module 405 is used to:
[0119] Saving the updated image layered file to the layered file sharing pool;
[0120] The hash identifier corresponding to the updated image layered file is stored in the image manifest file;
[0121] The image manifest file, the image index file, the image runtime information and the image repository information are moved to the image description file set.
[0122] In one embodiment of the present invention, the image information set includes a product list file, and the image information set update module 405 is used to:
[0123] The image information corresponding to the image file of the microservice application is recorded in the product manifest file; wherein the image information at least includes an image name.
[0124] In one embodiment of the present invention, the device further includes: a microservice application deployment module, which is used to:
[0125] Obtaining the application deployment file;
[0126] Extracting and updating the image information set from the application deployment file according to a preset product file format;
[0127] The microservice application is deployed in the application container engine of the privatized environment according to the updated image information set.
[0128] In one embodiment of the present invention, the updating of the image information set includes a product list file, a hierarchical file sharing pool and an image description file set, and the microservice application deployment module is used to:
[0129] Create a file directory corresponding to each of the image files according to the image information of the image in the product list file;
[0130] Move the image description file set corresponding to each of the image files to the file directory of the image;
[0131] Read the image manifest file corresponding to each of the image files to obtain a hash identifier corresponding to each of the image files;
[0132] Acquire the updated image layered files corresponding to each of the image files from the layered file sharing pool according to the hash identifiers corresponding to each of the image files, and save them in the file directories corresponding to each of the image files;
[0133] Compress the file directories corresponding to the respective image files to obtain an updated offline image package;
[0134] The updated offline image package is loaded into the application container engine of the privatized environment to deploy the microservice application.
[0135] In one embodiment of the present invention, the application container engine includes at least Docker.
[0136] In an embodiment of the present invention, an offline image package of a microservice application of an application container engine of a privatized environment is obtained, an image layered file and an image information set of the image file are obtained from the offline image package according to a preset product file format, hash calculations are performed on the image layered files to obtain hash identifiers to remove duplicate image layered files according to the hash identifiers to obtain updated image layered files, and then, the image information set is updated according to the updated image layered files to obtain an updated image information set, and the updated image information set is saved as an application deployment file, and the microservice application can be deployed in the application container engine of the privatized environment by downloading the application deployment file. The embodiment of the present invention removes redundant image layered files in the image files of multiple microservice applications, reduces the volume of application deployment files of privatized deployed microservice applications, reduces the bandwidth occupied by application deployment files of microservice applications during transmission, improves the transmission efficiency of application deployment files of microservice applications, and reduces the waste of storage space required for microservice applications, thereby improving the deployment efficiency of microservice applications in a privatized environment.
[0137] As for the above-mentioned device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0138] It should be noted that the embodiments of the present invention may involve the use of user data. In actual applications, user-specific personal data can be used in the scheme described herein within the scope permitted by applicable laws and regulations, subject to the requirements of applicable laws and regulations of the country where the user is located (for example, with the user's explicit consent, effective notification to the user, etc.).
[0139] The embodiment of the present invention further provides an electronic device, such as Figure 5 As shown, it includes a processor 501, a communication interface 502, a memory 503 and a communication bus 504, wherein the processor 501, the communication interface 502, and the memory 503 communicate with each other through the communication bus 504.
[0140] Memory 503, used for storing computer programs;
[0141] The processor 501 is used to implement the microservice application deployment method described in any of the above embodiments when executing the program stored in the memory 503:
[0142] Obtain the offline image package of the microservice application of the application container engine in the privatized environment;
[0143] Obtaining an image layer file and an image information set of an image file from the offline image package according to a preset product file format;
[0144] Performing hash calculations on the image layered files respectively to obtain hash identifiers;
[0145] Removing duplicate image layered files according to the hash identifier to obtain updated image layered files;
[0146] Update the image information set according to the updated image layered file to obtain an updated image information set;
[0147] The updated image information set is saved as an application deployment file, where the application deployment file is used to deploy the microservice application in the application container engine of the privatized environment.
[0148] In an embodiment of the present invention, removing duplicate image layered files according to the hash identifier includes:
[0149] When the same hash identifier exists, it is determined that there is a duplicate image layered file;
[0150] The duplicated image layered files are deleted from the image layered files.
[0151] In one embodiment of the present invention, the image information set includes an image description file set, a hierarchical file sharing pool, an image list, an image index file, image runtime information, and image repository information. Updating the image information set according to the updated image hierarchical file includes:
[0152] Saving the updated image layered file to the layered file sharing pool;
[0153] The hash identifier corresponding to the updated image layered file is stored in the image manifest file;
[0154] The image manifest file, the image index file, the image runtime information and the image repository information are moved to the image description file set.
[0155] In an embodiment of the present invention, the image information set includes a product manifest file, and updating the image information set according to the updated image layer file includes:
[0156] The image information corresponding to the image file of the microservice application is recorded in the product manifest file; wherein the image information at least includes an image name.
[0157] In one embodiment of the present invention, after saving the update image information set as an application deployment file, which is used to deploy the microservice application in the application container engine of the privatized environment, the method further includes:
[0158] Obtaining the application deployment file;
[0159] Extracting and updating the image information set from the application deployment file according to a preset product file format;
[0160] The microservice application is deployed in the application container engine of the privatized environment according to the updated image information set.
[0161] In one embodiment of the present invention, the updating of the image information set includes a product manifest file, a hierarchical file sharing pool, and an image description file set, and deploying the microservice application in the application container engine of the privatized environment according to the updated image information set includes:
[0162] Create a file directory corresponding to each of the image files according to the image information of the image in the product list file;
[0163] Move the image description file set corresponding to each of the image files to the file directory of the image;
[0164] Read the image manifest file corresponding to each of the image files to obtain a hash identifier corresponding to each of the image files;
[0165] Acquire the updated image layered files corresponding to each of the image files from the layered file sharing pool according to the hash identifiers corresponding to each of the image files, and save them in the file directories corresponding to each of the image files;
[0166] Compress the file directories corresponding to the respective image files to obtain an updated offline image package;
[0167] The updated offline image package is loaded into the application container engine of the privatized environment to deploy the microservice application.
[0168] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0169] The communication interface is used for communication between the above terminal and other devices.
[0170] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0171] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0172] In another embodiment provided by the present invention, a computer-readable storage medium is also provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the microservice application deployment method described in any of the above embodiments.
[0173] In another embodiment provided by the present invention, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the microservice application deployment method described in any one of the above embodiments.
[0174] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.
[0175] It should be noted that, in this article, relational terms such as first and second, etc. 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 still includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0176] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0177] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A microservice application deployment method, characterized in that: The method comprises: Obtain the offline image package of the microservice application of the application container engine in the privatized environment; Obtaining an image layer file and an image information set of an image file from the offline image package according to a preset product file format; Performing hash calculations on the image layered files respectively to obtain hash identifiers; Remove duplicate image layered files according to the hash identifier to obtain updated image layered files; Update the image information set according to the updated image layered file to obtain an updated image information set; The updated image information set is saved as an application deployment file, where the application deployment file is used to deploy the microservice application in the application container engine of the privatized environment.
2. The method according to claim 1, characterized in that Removing duplicate image layered files according to the hash identifiers includes: When the same hash identifier exists, it is determined that there is a duplicate image layered file; The duplicated image layered files are deleted from the image layered files.
3. The method according to claim 2, characterized in that The image information set includes an image description file set, a hierarchical file sharing pool, an image list, an image index file, image runtime information, and image repository information. The image information set is updated according to the updated image hierarchical file, including: Saving the updated image layered file to the layered file sharing pool; The hash identifier corresponding to the updated image layered file is stored in the image manifest file; The image manifest file, the image index file, the image runtime information and the image repository information are moved to the image description file set.
4. The method according to claim 1, characterized in that: The image information set includes a product list file, and updating the image information set according to the updated image layer file includes: The image information corresponding to the image file of the microservice application is recorded in the product manifest file; wherein the image information at least includes an image name.
5. The method according to claim 1, characterized in that After saving the update image information set as an application deployment file, wherein the application deployment file is used to deploy the microservice application in the application container engine of the privatized environment, the method further includes: Obtaining the application deployment file; Extracting and updating the image information set from the application deployment file according to a preset product file format; The microservice application is deployed in the application container engine of the privatized environment according to the updated image information set.
6. The method according to claim 5, characterized in that The updating of the image information set includes a product manifest file, a hierarchical file sharing pool, and an image description file set, and deploying the microservice application in the application container engine of the privatized environment according to the updated image information set, including: Create a file directory corresponding to each of the image files according to the image information of the image in the product list file; Move the image description file set corresponding to each of the image files to the file directory of the image; Read the image manifest file corresponding to each of the image files to obtain a hash identifier corresponding to each of the image files; Acquire the updated image layered files corresponding to each of the image files from the layered file sharing pool according to the hash identifiers corresponding to each of the image files, and save them in the file directories corresponding to each of the image files; Compress the file directories corresponding to the respective image files to obtain an updated offline image package; The updated offline image package is loaded into the application container engine of the privatized environment to deploy the microservice application.
7. The method according to claim 1, characterized in that The application container engine includes at least Docker.
8. A microservice application deployment device, characterized in that: The device comprises: An offline image package acquisition module is used to obtain an offline image package of a microservice application of an application container engine in a privatized environment; An offline image package processing module, used to obtain an image layer file and an image information set of an image file from the offline image package according to a preset product file format; The image layered file calculation module is used to perform hash calculations on the image layered files to obtain hash identifiers; An image layered file deduplication module, used to remove duplicate image layered files according to the hash identifier to obtain updated image layered files; An image information set updating module, used to update the image information set according to the updated image layered file to obtain an updated image information set; A microservice application deployment module is used to save the update image information set as an application deployment file, and the application deployment file is used to deploy the microservice application in the application container engine of the privatized environment.
9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 7 when executing a program stored in a memory.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Container mirror image synchronization method and system
CN114035808A
Container mirror image deployment method and device, terminal and medium
CN116880951A
Container platform offline deployment method supporting heterogeneous and multiple operating systems
CN118838606A
Cited By
Lightweight method and device for data security capability micro-service container
CN121008869A