An automated publishing method for Helm charts
Through automated publishing methods, cloning sites, processing chart packages and images, it solves the problem of cumbersome Helm chart application deployment and achieves efficient and accurate application migration and deployment, which is suitable for offline and online environments.
Patent Information
- Application Number
- CN202110894717.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-05
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2041-08-05
AI Technical Summary
Helm chart application deployment in a new environment requires manual transmission of chart packages and docker images. The process is cumbersome and time-consuming, and there is a lack of automated solutions.
Provide an automated publishing method, including cloning the site, copying the push script, obtaining basic information of the old and new sites, pulling the basic image, comparing the git_project.yaml file, processing the chart package, and determining the push mode based on the basic component versions of the old and new sites, supporting offline and online mode, which improves efficiency through multi-thread processing and compressed package pushing.
It realizes the automation of application release, reduces labor costs, ensures migration accuracy, adapts to different environments, supports customized packaging, and improves release efficiency and accuracy.
Smart Images

Figure CN113672245B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of automatic application publishing, and specifically provides an automatic publishing method for Helm chart. Background Art
[0002] Helm consists of the client component helm and the server component Tiller. It can package and manage a set of K8S resources in a unified manner. It is the best way to find, share, and use software built for Kubernetes. Helm chart is a collection of files that describe Kubernetes-related resources.
[0003] Service product applications are usually made into chart packages. The installation of the application depends on the chart and Docker image as the installation media. When deploying the application to a new environment, it is usually necessary to transfer the chart package and Docker image to the environment in advance before performing the installation, which is cumbersome. Summary of the invention
[0004] The present invention aims at the deficiencies of the above-mentioned prior art and provides a highly practical automatic publishing method for Helm chart.
[0005] The technical solution adopted by the present invention to solve its technical problem is:
[0006] An automated publishing method for a Helm chart has the following steps:
[0007] S1, cloning site;
[0008] S2. Copy the push script;
[0009] S3, obtain basic information of new and old sites;
[0010] S4. Pull the base image;
[0011] S5. Compare the git_project.yaml file;
[0012] S6, process the chart package;
[0013] S7. Determine the push mode of the push script according to the basic component versions in the new and old sites.
[0014] Furthermore, in step S1, two old and new branches of the site are prepared, and both branches need to be built, cloned locally and stored separately for subsequent comparison.
[0015] Furthermore, in step S2, the push script is prepared for the offline package and is used to push the compressed package of offline data to the actual environment; if it is an online forwarding mode, this step will be skipped.
[0016] Furthermore, in step S3, the basic information obtained includes architecture information, site version, basic component version, variable information, git repository, and mirror repository;
[0017] If there is a difference in the basic component versions, the basic image in the environment needs to be updated in time; if the versions are consistent, the packaging step of the basic image can be skipped;
[0018] The variable information obtained mainly includes the source address of pulling git projects and images, the target push address of git projects and images, the harbor warehouse domain name and account information preset in the environment.
[0019] Furthermore, in step S4, it is determined whether the base image needs to be pulled according to the difference between the new and old versions. For offline packages, they will be output as compressed packages after being pulled. For online forwarding, the image will be tagged with the target repository and pushed.
[0020] Among them, the installation package is pulled by default, and the patch package is not pulled by default.
[0021] Furthermore, in step S5, a comparison is performed based on the git_project.yaml files in the new and old sites. If the versions are different, or the projects have the same version but different commit_id, they will be recorded in the pull list. After the comparison is completed, multi-threading will be enabled to clone all the projects in the list into a local unified folder. After the cloning is completed, all the used projects will be packaged into a compressed package in offline mode, and the site projects will be packaged into another compressed package separately. In online mode, multi-threading will be enabled to forward the projects to the target warehouse at one time.
[0022] Further, in step S6, the imagelist.yaml files in the new and old sites are compared, and if the tags are different, or the items with the same tags but different image_ids are recorded in the pull list;
[0023] Confirm the existing images on the host through the Docker third-party library. If the image_id is the same, remove it and do not pull it again.
[0024] After the removal is completed, multi-threaded image pulling will be enabled. After the pulling is completed, multi-threaded images will be enabled in online mode to re-tag the images and push them to the target warehouse. In offline mode, it is necessary to compare the image_id of the image to be packaged with the image in the cache to see if they are the same. The same image will not be packaged repeatedly, and the different ones will be recorded in the list to be packaged. The packaging is completed by executing the save command through multi-threading;
[0025] The images are packaged into the cache and the target folder is traversed. If the same images exist, they are filtered out and do not need to be copied again. If there are redundant images, they are cleaned up.
[0026] As a preference, image_id can be obtained in two ways:
[0027] The first is the imagelist.yaml file recorded in the site, which is used to determine the image that needs to be pulled;
[0028] The second type is obtained immediately through the Docker third-party library after pulling, which is used to compare with the image in the cache to determine whether the image needs to be saved.
[0029] Furthermore, in step S6, the images in the cache and the target folder are stored in a tarball format, and an image.property file is additionally required to record the image information corresponding to each tarball.
[0030] Furthermore, in step S7, if the versions are consistent, only the chart package and the image package are pushed; if the version is upgraded, the basic components need to be upgraded in addition.
[0031] Compared with the prior art, the automatic publishing method for Helm chart of the present invention has the following outstanding beneficial effects:
[0032] The present invention can reduce the cost of publishing applications. The automated method can batch migrate the installation media of applications, saving manpower while ensuring the accuracy of migration. The offline and online modes are distinguished to better adapt to different environments. For offline environments, the installation media can be automatically pulled into a folder and the migration can be achieved through the hard disk.
[0033] For online environments, that is, environments that can be temporarily connected to the office network, the required mechanisms can be directly sorted out and pushed directly to the target warehouse, saving time and effort. It supports customized packaging content and packages according to actual needs, avoiding redundant content and being more efficient. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0035] Attached Figure 1 It is a flow chart of the automated publishing method for Helm charts;
[0036] Attached Figure 2 It is a schematic diagram of the packaging operation process in the automated release method for Helm chart;
[0037] Attached Figure 3 It is a technical architecture diagram for the automated release method of Helm chart. DETAILED DESCRIPTION
[0038] In order to enable those skilled in the art to better understand the solution of the present invention, the present invention is further described in detail below in conjunction with specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0039] A best embodiment is given below:
[0040] like Figure 1-3 As shown, in this embodiment, an automatic publishing method for Helm chart, for an upgrade package, has the following steps:
[0041] S1. Cloning site:
[0042] Prepare the old and new branches of the site, and make sure both branches have been built. After cloning them locally, store them separately for subsequent comparison.
[0043] S2. Copy the push script:
[0044] The push script is prepared for offline packages and is used to push the compressed package of offline data to the actual environment; if it is in online forwarding mode, this step will be skipped.
[0045] S3. Get basic information of new and old sites:
[0046] It mainly obtains site architecture information, site version, basic component version, variable information, basic information of git repository and mirror repository, which is convenient for comparing new and old sites and locating product data sources.
[0047] in,
[0048] If there is a difference in the basic component version, you need to update the basic image in the environment in time; if the versions are consistent, you can skip the packaging step of the basic image to save packaging time.
[0049] The variable information obtained mainly includes the source address of pulling git projects and images, the target push address of git projects and images, the domain name and account information of the harbor warehouse preset in the environment, etc.
[0050] S4. Pull the base image:
[0051] Determine whether to pull the base image based on the difference between the new and old versions; for offline packages, they will be output as compressed packages after pulling, and for online forwarding, the image will be tagged with the target repository and pushed.
[0052] Among them, the installation package is pulled by default, and the patch package is not pulled by default.
[0053] S5. Compare the git_project.yaml files:
[0054] Compare the git_project.yaml files in the new and old sites. If the versions are different, or if the projects have the same version but different commit_id, they will be recorded in the pull list.
[0055] After the comparison is completed, multi-threading will be enabled to clone all projects in the list into a local unified folder; after the cloning is completed, all projects will be packaged into a compressed package in offline mode, and the site projects will be packaged into another compressed package separately. In online mode, multi-threading will be enabled to forward the projects to the target warehouse at one time.
[0056] in,
[0057] The commit_id is recorded in the git_project.yaml file in the site and depends on the site build. Sites that have not been built or not built immediately may affect the accuracy of the packaging. The old version of the site in the upgrade package is usually deployed and represents the current deployment status in the environment. Building it again will lead to inaccurate information.
[0058] The number of multithreaded threads depends on the performance of the host machine where the packaged image is located. Experiments have shown that in a physical machine environment, 10 threads are usually the most efficient, while in a virtual machine environment, no more than 5 threads should be used, otherwise timeouts or failures will occur.
[0059] S6. Processing chart package:
[0060] Compare the imagelist.yaml files in the new and old sites. If the tags are different, or the items have the same tags but different image_ids, they will be recorded in the pull list.
[0061] Use the Docker third-party library to confirm which images already exist on the host. If the image_id is the same, remove it and do not pull it again. After the removal is completed, multi-threading will be enabled to pull the image. After the pull is completed, multi-threading will be enabled in online mode to re-tag the image and push it to the target warehouse. In offline mode, it is necessary to compare the image_id of the image to be packaged with the cache to see if it is the same. The same image will not be packaged repeatedly, and the different ones will be recorded in the list to be packaged. The packaging is completed by executing the save command through multi-threading.
[0062] The images are packaged into the cache and the target folder is traversed. If the same images exist, they are filtered out and do not need to be copied again. If there are redundant images, they are cleaned up.
[0063] in,
[0064] There are two ways to obtain image_id: the first is recorded in the imagelist.yaml file on the site, which is used to determine which images need to be pulled.
[0065] The second type is obtained immediately through the Docker third-party library after pulling, which is used to compare with the image in the cache to determine whether the image needs to be saved.
[0066] The images in the cache and target folders are stored in tarball format. An additional image.property file is required to record the image information corresponding to each tarball for easy comparison.
[0067] There will be images in the target folder, which usually happens when the package is packed twice, or the last packing fails or is not completed. You need to compare the file size and creation time. If both are the same, skip the processing (that is, reuse this image package); if one is different, you need to pull the image package in the cache and overwrite it.
[0068] S7. Determine the push mode of the push script according to the basic component versions in the new and old sites:
[0069] If the versions are consistent, only the chart package and image package are pushed. If the version is upgraded, the basic components need to be upgraded in addition.
[0070] In the present invention:
[0071] build.yam is used to store the build results and information of each application;
[0072] git_project.yaml is used to store information related to each application git project;
[0073] imagelist.yaml is used to store the image list and information that each application depends on;
[0074] image.property is used to record the information of the image package in the cache, which is convenient for extracting or comparing images during subsequent packaging;
[0075] push_git_projects.yaml is a file used by the push script of the offline package to record git project information.
[0076] push_registry_imagelist.yaml is a file used by the push script of the offline package, which records the image information that needs to be pushed to the registry warehouse.
[0077] push_harbor_imagelist.yaml is a file used by the push script of the offline package, which records the image information that needs to be pushed to the harbor repository.
[0078] Explanation of keywords in this invention:
[0079] Chart: is a collection of files that describe Kubernetes-related resources.
[0080] YAML: is a highly readable format used to express data serialization.
[0081] Image: A mirror is a copy of data in a file system.
[0082] site: A site is a collection of resources and configurations deployed in an environment.
[0083] Build: This usually refers to site building, pulling chart application information into the site, and packaging the required information into key files.
[0084] Packaging: An important part of automated release, divided into online forwarding and offline packaging, forwarding the installation media of all applications involved to the target environment or compressing them into compressed packages.
[0085] Key site files: mainly refer to the three files build.yaml, git_project.yaml, and imagelist.yaml in the site, which are used to provide packaging information.
[0086] Package output files: mainly refer to the four files image.property, push_git_projects.yaml, push_registry_imagelist.yaml, and push_harbor_imagelist.yaml in the site, which are mainly used to record the information of the compressed package for easy packaging and pushing.
[0087] The above-mentioned specific implementations are only specific cases of the present invention. The patent protection scope of the present invention includes but is not limited to the above-mentioned specific implementations. Any appropriate changes or substitutions made by any ordinary technician in the technical field that conform to the claims of the present invention for an automatic publishing method for Helm chart shall fall within the patent protection scope of the present invention.
[0088] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. An automated publishing method for Helm chart, characterized in that: The following steps are involved: S1, cloning site; Prepare the old and new branches of the site, and both branches need to be built. After cloning them locally, store them separately for subsequent comparison; S2. Copy the push script; S3, obtain basic information of new and old sites; The basic information obtained includes architecture information, site version, basic component version, variable information, git repository and mirror repository; If there is a difference in the basic component versions, the basic image in the environment needs to be updated in time; if the versions are consistent, the packaging step of the basic image can be skipped; The variable information obtained includes the source address of pulling the git project and the image, the target push address of the git project and the image, the domain name and account information of the harbor warehouse preset in the environment; S4. Pull the base image; Determine whether to pull the base image based on the difference between the new and old versions. For offline packages, they will be output as compressed packages after pulling. For online forwarding, the image will be tagged with the target repository and pushed; The installation package is pulled by default, while the patch package is not pulled by default; S5. Compare the git_project.yaml file; Compare the git_project.yaml files in the new and old sites. If the versions are different, or the projects with the same version but different commit_id are recorded in the pull list, after the comparison is completed, multi-threading will be enabled to clone all the projects in the list into a local unified folder. After the cloning is completed, all the used projects will be packaged into a compressed package in offline mode, and the site projects will be packaged into another compressed package separately. In online mode, multi-threading will be enabled to forward the projects to the target warehouse at one time; S6, process the chart package; Compare the imagelist.yaml files in the new and old sites. If the tags are different, or if the tags are the same but the image_id is different, the items will be recorded in the pull list. Confirm the existing images on the host through the Docker third-party library. If the image_id is the same, remove it and do not pull it again. After the removal is completed, multi-threaded image pulling will be enabled. After the pulling is completed, multi-threaded images will be enabled in online mode to re-tag the images and push them to the target warehouse. In offline mode, it is necessary to compare the image_id of the image to be packaged with the image in the cache to see if they are the same. The same image will not be packaged repeatedly, and the different ones will be recorded in the list to be packaged. The packaging is completed by executing the save command through multi-threading; The images are packaged into the cache and the target folder is traversed. If the same images exist, they are filtered out and do not need to be copied again. If there are redundant images, they are cleaned up. S7. Determine the push mode of the push script according to the basic component versions in the new and old sites; If the versions are consistent, only the chart package and image package are pushed; if the version is upgraded, the basic components need to be upgraded in addition.
2. According to claim 1, an automatic publishing method for Helm chart is characterized in that: In step S2, the push script is prepared for the offline package and is used to push the compressed package of offline data to the actual environment; if it is an online forwarding mode, this step will be skipped.
3. According to claim 2, the method for automatically publishing a Helm chart is characterized in that: In step S6, image_id is obtained in two ways: The first is the imagelist.yaml file recorded in the site, which is used to determine the image that needs to be pulled; The second type is obtained immediately through the Docker third-party library after pulling, which is used to compare with the image in the cache to determine whether the image needs to be saved.
4. According to claim 3, the method for automatically publishing a Helm chart is characterized in that: In step S6, the images in the cache and target folders are stored in tarball format, and an image.property file is additionally required to record the image information corresponding to each tarball.
