A method for initializing dependent packages based on container images

Through the dependency package initialization method based on container image, the CI technology is used to automatically build the dependent package source code as a mirror, and the judgment is combined with the Chart package and the Job configuration file, the problem of inefficient initialization of the dependency package on the cloud platform is solved, and automated and efficient dependency package management is realized.

CN114675837BActive Publication Date: 2025-08-05SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210421068.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-21
Publication Date
2025-08-05
Estimated Expiration
2042-04-21

AI Technical Summary

Technical Problem

In the prior art, the initialization method of non-open source dependent packages on cloud platforms is inconvenient for update and management, and requires manual operation, resulting in inefficiency.

Method used

Based on container mirroring technology, the source code of the dependent package is automatically built into the container image through CI technology, and the Chart package and Job configuration files are used for scene and version judgment, and the Chart package is deployed and run in combination with Helm to realize the automatic initialization of the dependent package.

Benefits of technology

It improves the efficiency of dependent package initialization, reduces manual operations, improves code reuse and development efficiency, and simplifies the update and management of dependent packages.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114675837B_ABST
    Figure CN114675837B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for initializing a dependency package based on a container image, and relates to the technical field of data packet management. The method includes automatically constructing the source code of a dependency package into a container image based on CI technology, compiling a Chart package for initializing the dependency package according to the requirements of a cloud platform for the dependency package, compiling a values.yaml configuration file and a Job configuration file of the Chart package, setting initialization operations and a baseline version of the dependency package under an initialization scenario using the values.yaml configuration file, performing scenario judgment and / or version judgment using the Job configuration file, initializing the dependency package corresponding to the container image according to the judgment result, and deploying and running the Chart package using Helm.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention discloses a method, which relates to the technical field of data packet management, and in particular to a method for initializing a dependency package based on a container image. Background Art

[0002] Cloud platforms offer numerous service products, each providing a rich set of features to facilitate software development, deployment, and operations. To facilitate integration with these features, some service products provide non-open-source dependency packages. These non-open-source dependency packages must be initialized on the cloud platform before they can be imported and used. Currently, initializing dependency packages on the cloud platform is done manually by R&D and operations personnel, or in conjunction with business processes. However, this current method of initializing dependency packages is still inconvenient for updating and managing them. Summary of the Invention

[0003] In response to the problems of the prior art, the present invention provides a method for initializing dependency packages based on container images, which realizes automatic initialization of dependency packages based on container image technology and dependency package version control in various scenarios, thereby improving initialization efficiency.

[0004] The specific scheme proposed by the present invention is:

[0005] The present invention provides a method for initializing a dependency package based on a container image, which is characterized in that the dependency package source code is automatically constructed into a container image based on CI technology.

[0006] According to the cloud platform's requirements for dependency packages, a Chart package for dependency package initialization is written, including the values.yaml configuration file and the Job configuration file of the Chart package. The values.yaml configuration file is used to set the initialization operation and the baseline version of the dependency package under the initialization scenario. The Job configuration file is used to perform scenario judgment and / or version judgment, and the dependency package corresponding to the container image is initialized according to the judgment results.

[0007] Use Helm to deploy and run the Chart package.

[0008] Furthermore, the method for initializing a dependency package based on a container image uses a job configuration file to perform scenario judgment and / or version judgment, and initializes the corresponding dependency package of the container image according to the judgment result, including:

[0009] When performing scene judgment, it is judged whether the initialization scene is a scene of a newly installed environment. If it is a scene of a newly installed environment, the judgment result is true;

[0010] When performing version judgment, it is judged whether the container image tag is greater than the dependency package baseline version configured in the values.yaml configuration file. If the container image tag is greater than the corresponding dependency package baseline version, the judgment result is true.

[0011] If the judgment result is true, the corresponding dependency package of the container image is initialized.

[0012] Furthermore, in the container image-based dependency package initialization method, the values.yaml configuration file is used to add an action configuration, and different values set in the action configuration represent different initialization operations in different initialization scenarios.

[0013] Furthermore, the method for initializing a dependency package based on a container image uses a Job configuration file to perform scenario judgment, including:

[0014] According to the value of the action configuration, it is judged whether the scenario is a new environment installation scenario. If it is, the judgment result is true, and the corresponding dependency package of the container image is initialized. Otherwise, the version judgment is performed. If the version judgment passes, the corresponding dependency package of the container image is initialized.

[0015] Furthermore, the method for initializing a dependency package based on a container image, wherein the Chart package is deployed and run using Helm, includes:

[0016] The Job configuration file of the Chart package performs scenario judgment and / or version judgment according to the initialization operation and the baseline version of the dependent package under the initialization scenario set in the values.yaml configuration file. If the judgment result meets the conditions, a one-time Job that meets the requirements is created, and a Pod is created through the one-time Job to execute the initialization of the dependent package.

[0017] Furthermore, in the container image-based dependency package initialization method, the completed one-time job and all Pod objects created by the one-time job are automatically cleaned up by activating the TTL mechanism.

[0018] Furthermore, in the container image-based dependency package initialization method, a retry mechanism is established by setting a restart strategy and a retry limit for a one-time job. When the Pod fails to initialize the dependency package, the restart strategy is triggered, the Pod is restarted, and a retry is performed.

[0019] Furthermore, in the container image-based dependency package initialization method, the Pod status that performs the dependency package initialization operation is monitored. If the Pod status is abnormal, an alarm message is generated and the cause of the initialization failure is investigated.

[0020] The present invention also provides a container image-based dependency package initialization device, comprising a generation module and an execution module.

[0021] The generation module automatically builds the dependency package source code into a container image based on CI technology, and writes a Chart package for initializing the dependency package according to the cloud platform's requirements for the dependency package, wherein the values.yaml configuration file and the Job configuration file of the Chart package are written, and the initialization operation and the dependency package baseline version under the initialization scenario are set using the values.yaml configuration file. The Job configuration file is used to perform scenario judgment and / or version judgment, and the dependency package corresponding to the container image is initialized according to the judgment result.

[0022] The execution module uses Helm to deploy and run the Chart package.

[0023] The benefits of the present invention are:

[0024] The present invention provides a dependency package initialization method based on container images. By simply modifying a small amount of Chart package configuration, dependency package initialization can be achieved in different scenarios, thereby improving code reuse, reducing redundant code, reducing manual operations of development and operation and maintenance personnel, and improving development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] 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. 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 any creative work.

[0026] Figure 1 It is a schematic flow chart of the method of the present invention. DETAILED DESCRIPTION

[0027] The present invention will be further described below with reference to the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it. However, the embodiments are not intended to limit the present invention.

[0028] The present invention provides a method for initializing a dependency package based on a container image, which is characterized in that the dependency package source code is automatically constructed into a container image based on CI technology.

[0029] According to the cloud platform's requirements for dependency packages, a Chart package for dependency package initialization is written, including the values.yaml configuration file and the Job configuration file of the Chart package. The values.yaml configuration file is used to set the initialization operation and the baseline version of the dependency package under the initialization scenario. The Job configuration file is used to perform scenario judgment and / or version judgment, and the dependency package corresponding to the container image is initialized according to the judgment results.

[0030] Use Helm to deploy and run the Chart package.

[0031] The method of the present invention is used to realize automatic initialization of dependent packages in various scenarios based on container mirroring technology and dependent package version control, thereby improving initialization efficiency.

[0032] In specific applications, in some embodiments of the method of the present invention, the source code of the dependency package can be hosted on the GitLab private code hosting platform, and the dependency package source code can be automatically built into a container image based on CI technology. A container image name can be set for each dependency package, and the version number of the dependency package can be set as a container image tag, so that different versions of dependency packages can be distinguished and obtained through the container image tag. In this way, each version of each dependency package has an independent image, which is stored separately and has a small volume. At the same time, it is convenient to independently update a version of a dependency package. At the same time, the container images built from all dependency packages can be placed under one image project to facilitate the management of the image.

[0033] After building the dependency package into a container image, write a Chart package to initialize the dependency package based on the cloud platform's requirements for the dependency package. This mainly involves writing the Chart's values.yaml configuration file and a one-time Job configuration file.

[0034] Furthermore, when writing the values.yaml configuration file of the chart package, add action configuration to the values.yaml configuration file. Set different values for action to represent different initialization operations in different initialization scenarios. Also set a dependency package baseline version for each dependency package in the values.yaml configuration file.

[0035] When writing a one-time Job configuration file for a chart package, you can add container images built from all versions of all dependent packages to the spec.template.spec.container configuration item in the configuration file, and add a conditional judgment around each container image. Only when the judgment result is true will the dependent packages corresponding to the container image be initialized. Furthermore, the conditional judgment mainly performs the following two judgments:

[0036] Scene judgment: judge whether the initialization scene is a newly installed scene. If it is a newly installed scene, the judgment result is true;

[0037] Version judgment: Determine whether the tag of the container image is greater than the baseline version of the dependency package configured in the values.yaml configuration file. If the tag of the container image is greater than the corresponding baseline version of the dependency package, the judgment result is true. Version judgment can use Helm's semverCompare function to compare the version size.

[0038] As long as one of the above two judgments is true, the conditional judgment passes.

[0039] For example, in the command of the container image in a one-time job configuration file, the curl command is used to call the interface of the dependency package repository service on the environment to upload the dependency packages in the / usr / lib directory of the container image to the dependency package repository on the environment. The dependency packages are initialized in the following two scenarios:

[0040] Scenario 1: For a newly installed environment, set the action in the values.yaml configuration file to 2. In the conditional judgment of the Job file, first perform a scenario judgment. If the action is equal to 2, it indicates a newly installed environment. In this scenario, all versions of all dependent packages need to be initialized to the repository.

[0041] Scenario 2: Environment upgrade. Set the action in the values.yaml configuration file to 1. In the conditional judgment of the Job file, first perform a scenario judgment. If the judgment result is that the scenario is not a new environment installation scenario, then perform a version judgment. Only the dependent package images that pass the version judgment will perform the dependency package initialization operation, thus implementing version control of the dependent package initialization.

[0042] In the above embodiment, each time a dependency package is initialized in an environment, the action configuration and the dependency package baseline version configuration in the values.yaml configuration file may be modified according to the existing dependency package information of the environment.

[0043] In addition, after the Chart package is written, Helm is used to run the Chart. The Job configuration file of the Chart package performs scenario judgment and / or version judgment based on the initialization operation and the baseline version of the dependent package under the initialization scenario set in the values.yaml configuration file. If the judgment result meets the conditions, a one-time Job that meets the requirements is created. The one-time Job is used to create a Pod to execute the initialization of the dependent package.

[0044] The method of the present invention can also automatically clean up the finished Job by activating the TTL mechanism. The TTL mechanism is provided by the TTL controller. When the TTL controller cleans up the Job, the TTL controller will delete the Job object and all Pod objects created by the Job.

[0045] By setting the Job's restart policy and retry limit, a retry mechanism is established. When a Pod fails to initialize, the restart policy is triggered, the Pod is restarted, and a retry is performed. If the number of retries exceeds the retry limit, the Pod will not be restarted.

[0046] At the same time, the status of the Pod that performs the dependency package initialization operation is monitored. If the Pod status is abnormal, an alarm message is generated to remind R&D and operation and maintenance personnel to investigate the cause of the initialization failure and perform the initialization operation again to ensure successful initialization of the dependency package.

[0047] The present invention also provides a container image-based dependency package initialization device, comprising a generation module and an execution module.

[0048] The generation module automatically builds the dependency package source code into a container image based on CI technology, and writes a Chart package for initializing the dependency package according to the cloud platform's requirements for the dependency package, wherein the values.yaml configuration file and the Job configuration file of the Chart package are written, and the initialization operation and the dependency package baseline version under the initialization scenario are set using the values.yaml configuration file. The Job configuration file is used to perform scenario judgment and / or version judgment, and the dependency package corresponding to the container image is initialized according to the judgment result.

[0049] The execution module uses Helm to deploy and run the Chart package.

[0050] The information interaction, execution process, etc. between the modules in the above-mentioned device are based on the same concept as the embodiment of the method of the present invention. For specific contents, please refer to the description in the embodiment of the method of the present invention and will not be repeated here.

[0051] By using the device of the present invention, only a small amount of Chart package configuration needs to be modified to realize dependency package initialization in different scenarios, thereby improving code reuse, reducing redundant code, reducing manual operations of development and operation and maintenance personnel, and improving development efficiency.

[0052] It should be noted that not all steps and modules in the above-mentioned processes and device structures are required, and certain steps or modules can be omitted according to actual needs. The execution order of each step is not fixed and can be adjusted as needed. The system structure described in the above-mentioned embodiments can be a physical structure or a logical structure, that is, some modules may be implemented by the same physical entity, or some modules may be implemented by multiple physical entities, or may be implemented by certain components in multiple independent devices.

[0053] The above embodiments are merely preferred embodiments for the purpose of fully illustrating the present invention, and the scope of protection of the present invention is not limited thereto. Equivalent substitutions or modifications made by those skilled in the art based on the present invention are within the scope of protection of the present invention. The scope of protection of the present invention shall be subject to the claims.

Claims

1. A method for initializing dependent packages based on container images, characterized by Based on CI technology, the dependent package source code is automatically built into a container image. According to the cloud platform's requirements for dependency packages, a Chart package for dependency package initialization is written, wherein the values.yaml configuration file and the Job configuration file of the Chart package are written, and the initialization operation and the baseline version of the dependency package under the initialization scenario are set using the values.yaml configuration file, and the scenario judgment and / or version judgment are performed using the Job configuration file, including: using the values.yaml configuration file to add an action configuration, wherein different values set in the action configuration represent different initialization operations under different initialization scenarios, and judging whether the scenario is a new environment installation scenario based on the value of the action configuration. If so, the judgment result is true, and the dependency package corresponding to the container image is initialized. Otherwise, a version judgment is performed. If the version judgment passes, the dependency package corresponding to the container image is initialized. Initializing the dependent packages corresponding to the container image according to the judgment result, including: when performing scene judgment, judging whether the initialization scene is a scene of a newly installed environment, and if so, the judgment result is true; When performing version judgment, it is judged whether the container image tag is greater than the dependency package baseline version configured in the values.yaml configuration file. If the container image tag is greater than the corresponding dependency package baseline version, the judgment result is true. If the judgment result is true, the corresponding dependency package of the container image is initialized. Use Helm to deploy and run the Chart package, including: The Job configuration file of the Chart package performs scenario judgment and / or version judgment according to the initialization operation and the baseline version of the dependent package under the initialization scenario set in the values.yaml configuration file. If the judgment result meets the conditions, a one-time Job that meets the requirements is created, and a Pod is created through the one-time Job to execute the initialization of the dependent package.

2. A container image-based dependency package initialization method according to claim 1, characterized in that Automatically clean up completed one-time jobs and all Pod objects created by the one-time jobs by activating the TTL mechanism.

3. The method for initializing a dependency package based on a container image according to claim 1, wherein A retry mechanism is established by setting a restart strategy and retry limit for a one-time job. When the Pod fails to initialize its dependent packages, the restart strategy is triggered, the Pod is restarted, and a retry is performed.

4. The method for initializing a dependency package based on a container image according to claim 1, wherein Monitor the status of the Pod that performs the dependency package initialization operation. If the Pod status is abnormal, generate an alarm message and investigate the cause of the initialization failure.

5. A container image-based dependency package initialization device, characterized by Including generation module and execution module, The generation module automatically builds the dependency package source code into a container image based on CI technology, and writes a Chart package for initializing the dependency package according to the cloud platform's requirements for the dependency package, wherein the values.yaml configuration file and the Job configuration file of the Chart package are written, and the initialization operation and the dependency package baseline version under the initialization scenario are set using the values.yaml configuration file, and the Job configuration file is used to perform scenario judgment and / or version judgment, including: using the values.yaml configuration file to add an action configuration, wherein different values set in the action configuration represent different initialization operations under different initialization scenarios, and judging whether the scenario is a new environment installation scenario according to the value of the action configuration, if so, the judgment result is true, and the dependency package corresponding to the container image is initialized, otherwise, a version judgment is performed, and if the version judgment passes, the dependency package corresponding to the container image is initialized, Initializing the dependent packages corresponding to the container image according to the judgment result, including: when performing scene judgment, judging whether the initialization scene is a scene of a newly installed environment, and if so, the judgment result is true; When performing version judgment, it is judged whether the container image tag is greater than the dependency package baseline version configured in the values.yaml configuration file. If the container image tag is greater than the corresponding dependency package baseline version, the judgment result is true. If the judgment result is true, the corresponding dependency package of the container image is initialized. The execution module uses Helm to deploy and run the Chart package, including: The Job configuration file of the Chart package performs scenario judgment and / or version judgment according to the initialization operation and the baseline version of the dependent package under the initialization scenario set in the values.yaml configuration file. If the judgment result meets the conditions, a one-time Job that meets the requirements is created, and a Pod is created through the one-time Job to execute the initialization of the dependent package.

Citation Information

Patent Citations

  • Information processing method and device

    CN113190326A

  • Method and device for deploying software

    CN113407194A