CN115658237A - Container application automatic deployment method, device, apparatus, equipment and medium - Google Patents

Container application automatic deployment method, device, apparatus, equipment and medium Download PDF

Info

Publication number
CN115658237A
CN115658237A CN202211391294.6A CN202211391294A CN115658237A CN 115658237 A CN115658237 A CN 115658237A CN 202211391294 A CN202211391294 A CN 202211391294A CN 115658237 A CN115658237 A CN 115658237A
Authority
CN
China
Prior art keywords
container
mirror image
environment
deployment
mirror
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211391294.6A
Other languages
Chinese (zh)
Inventor
周飒
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
CMB Yunchuang Information Technology Co Ltd
Original Assignee
CMB Yunchuang Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by CMB Yunchuang Information Technology Co Ltd filed Critical CMB Yunchuang Information Technology Co Ltd
Priority to CN202211391294.6A priority Critical patent/CN115658237A/en
Publication of CN115658237A publication Critical patent/CN115658237A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a method, equipment, a device, equipment and a medium for automatically deploying container application, which relate to the technical field of containers, and the method comprises the following steps: compiling and packaging the codes sent to the code warehouse by using a packaging tool to obtain a container mirror image, and sending the container mirror image to a mirror image warehouse of a first environment; the code comprises an application code, a main execution script located in a deployment file directory and a deployment description file meeting the deployment requirement quantity; performing mirror image synchronization operation on a mirror image warehouse of the second environment and a mirror image warehouse of the first environment by using mirror image synchronization triggering logic determined based on a deployment triggering tool so as to facilitate the mirror image warehouse of the second environment to acquire the container mirror image; and executing the main execution script contained in the container mirror image acquired by the second environment by using a deployment execution tool to realize the automatic deployment of the container application in the container cluster. By the scheme, cross-environment interaction is simplified into transmission of the container mirror image file, and isolation and safety are effectively improved.

Description

Container application automatic deployment method, device, apparatus, equipment and medium
Technical Field
The invention relates to the technical field of containers, in particular to a container application automatic deployment method, equipment, a device, equipment and a medium.
Background
The development of the container technology enables the deployment mode of the application to be changed greatly, the container technology represented by Docker (open source application container engine) encapsulates the running environment of the application into a mirror image, the difference of external environments is shielded, and the deployment efficiency of the application in multiple environments (such as development, test and production) is greatly improved. With the increase of the container scale, a container arrangement management tool represented by kubernets (hereinafter referred to as K8S) is created, which describes a deployment form of a plurality of complex container applications through a declarative YAML (Markup Language) file (hereinafter referred to as a deployment description file), and the deployment description file defines various information of application deployment, such as the number of copies of the application deployment, a container specification, a mirror image version, a start parameter, a health check mode, and the like. Therefore, based on technologies such as container (e.g., docker) and container orchestration management (e.g., K8S), rapid deployment of applications can be achieved in the containerization era. However, there are often a plurality of environments (such as development, testing, and production) for application deployment, especially in the financial industry, these environments have isolation requirements or security control, and how to implement unified management and simplified deployment among the plurality of environments is a problem worth studying.
Disclosure of Invention
In view of this, an object of the present invention is to provide a method, a device, an apparatus, a device, and a medium for automatically deploying a container application, which can implement unified management and simplified deployment among multiple environments, simplify interaction between environments into transmission of a container image file, effectively improve isolation and security, and reduce deployment risk. The specific scheme is as follows:
in a first aspect, the present application discloses a method for automatically deploying a container application, including:
compiling and packaging the codes sent to the code warehouse by using a packaging tool to obtain a container mirror image, and sending the container mirror image to a mirror image warehouse of a first environment; the code comprises application code, a main execution script located in a deployment file directory and a deployment description file meeting the deployment requirement quantity;
performing mirror synchronization operation on a mirror warehouse of a second environment and a mirror warehouse of the first environment by using mirror synchronization trigger logic determined based on a deployment trigger tool so that the mirror warehouse of the second environment can obtain the container mirror pushed by the mirror warehouse of the first environment;
and executing the main execution script contained in the container image acquired by the second environment by using a deployment execution tool so as to realize automatic deployment of the container application in the container cluster.
Optionally, the compiling and packaging the code sent to the code repository by using a packaging tool to obtain a container mirror image includes:
compiling and packaging the codes sent to the code warehouse by using a packaging tool to obtain corresponding products, and generating container images corresponding to the products by using a preset container image definition file template deployed in the packaging tool.
Optionally, the compiling and packaging the code sent to the code warehouse by using a packaging tool to obtain a corresponding product, and generating a container mirror image corresponding to the product by using a preset container mirror image definition file template deployed in the packaging tool, further includes:
compiling and packaging the application code by using a packaging tool to obtain a product of the application code, and packaging the obtained product of the application code and the deployment file directory by using a preset container image definition file template deployed in the packaging tool to obtain the container image.
Optionally, the performing, by using the mirror synchronization triggering logic determined based on the deployment triggering tool, mirror synchronization operation on the mirror warehouse of the second environment and the mirror warehouse of the first environment, so that the mirror warehouse of the second environment obtains the container mirror image pushed by the mirror warehouse of the first environment, includes:
determining whether to trigger a mirror synchronization operation between a mirror repository of the second environment and a mirror repository of the first environment based on mirror information; the image information is the image information of the container application which needs to be deployed currently and is input by a user in a page provided by the deployment triggering tool, and comprises the image name and the version number.
Optionally, the determining whether to trigger a mirror synchronization operation between the mirror repository of the second environment and the mirror repository of the first environment based on the mirror information includes:
judging whether mirror image information of the container application which is input by a user in a page provided by the deployment triggering tool and needs to be deployed currently exists in a mirror image warehouse of the second environment;
if the container mirror image pushed by the mirror image warehouse of the first environment does not exist, triggering mirror image synchronous operation between the mirror image warehouse of the second environment and the mirror image warehouse of the first environment, so that the mirror image warehouse of the second environment can obtain the container mirror image pushed by the mirror image warehouse of the first environment.
Optionally, after the mirror image warehouse of the second environment obtains the container mirror image pushed by the mirror image warehouse of the first environment, the method further includes:
and copying the deployment file directory in the container mirror image through the second environment by using a temporary container operated based on a preset container operation instruction, and pushing the deployment file directory obtained by copying to a mirror image warehouse of the second environment.
Optionally, the executing, by using a deployment execution tool, the main execution script included in the container image acquired by the second environment to implement automatic deployment of the container application in the container cluster includes:
determining a current environment based on the value of the environment variable added in the deployment execution tool, and executing the main execution script in the deployment file directory corresponding to the current environment, so as to realize automatic deployment of the container application in the container cluster.
In a second aspect, the present application discloses an automatic deployment apparatus for a container application, comprising
The container mirror image sending module is used for compiling and packaging the codes sent to the code warehouse by using a packaging tool to obtain a container mirror image, and sending the container mirror image to a mirror image warehouse of a first environment; the code comprises application code, a main execution script located in a deployment file directory and a deployment description file meeting the deployment requirement quantity;
a container mirror image acquisition module, configured to perform mirror image synchronization operation on a mirror image warehouse of a second environment and a mirror image warehouse of the first environment by using a mirror image synchronization trigger logic determined based on a deployment trigger tool, so that the mirror image warehouse of the second environment acquires the container mirror image pushed by the mirror image warehouse of the first environment;
and the automatic deployment implementation module is used for executing the main execution script contained in the container mirror image acquired by the second environment by using a deployment execution tool so as to implement automatic deployment of the container application in the container cluster.
In a third aspect, the present application discloses an electronic device, comprising:
a memory for storing a computer program;
a processor for executing the computer program to implement the steps of the container application automatic deployment method disclosed in the foregoing.
In a fourth aspect, the present application discloses a computer readable storage medium for storing a computer program; wherein the computer program when executed by a processor implements the steps of the container application automatic deployment method disclosed in the foregoing.
When the container application is automatically deployed, firstly, compiling and packaging codes sent to a code warehouse by using a packaging tool to obtain a container mirror image, and sending the container mirror image to a mirror image warehouse of a first environment; the code comprises an application code, a main execution script located in a deployment file directory and a deployment description file meeting the deployment requirement quantity; then, performing mirror image synchronization operation on a mirror image warehouse of a second environment and a mirror image warehouse of the first environment by using a mirror image synchronization triggering logic determined based on a deployment triggering tool, so that the mirror image warehouse of the second environment can obtain the container mirror image pushed by the mirror image warehouse of the first environment; and finally, executing the main execution script contained in the container image acquired by the second environment by using a deployment execution tool so as to realize automatic deployment of the container application in the container cluster. Therefore, the deployment files in different environments and the application codes are put together, so that the code and deployment unified version management is achieved; and packaging the deployment file and the code into a mirror image by using the characteristics of the container mirror image to realize mirror image deployment. And then, the deployment triggering tool and the deployment executing tool are utilized to operate the container cluster in the same environment, so that the cross-environment calling of an application programming interface is avoided, the cross-environment interaction is simplified into the transmission of a container mirror image file, the isolation and the safety are effectively improved, and the deployment risk is reduced.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
Fig. 1 is a flowchart of a method for automatically deploying a container application according to the present application;
FIG. 2 is a diagram illustrating details contained in code sent to a code repository as provided herein;
FIG. 3 is a flowchart of a specific method for automatically deploying a container application provided herein;
FIG. 4 is a flowchart of a specific method for automatically deploying a container application provided herein;
FIG. 5 is a flowchart of a method for automatically deploying a container application according to the present application;
fig. 6 is a schematic structural diagram of an automatic deployment apparatus for a container application according to the present application;
fig. 7 is a block diagram of an electronic device provided in the present application.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be obtained by a person skilled in the art without making any creative effort based on the embodiments in the present invention, belong to the protection scope of the present invention.
In the prior art, solutions for automated deployment of container applications among multiple environments are generally implemented by using a continuous integration and continuous deployment pipeline (abbreviated as CI/CD pipeline). However, it is relatively unsafe to make the CI/CD pipeline call the K8S application programming interfaces of different environments to implement the deployment of the application, and the deployment description files of different environments are different, so that the container application cannot automatically implement the deployment of multiple environments. Therefore, the application provides an automatic deployment method for the container application, which can realize the automatic deployment of the container application among a plurality of environments.
Referring to fig. 1, an embodiment of the present invention discloses a container application automatic deployment method, including:
s11, compiling and packaging the codes sent to the code warehouse by using a packaging tool to obtain a container mirror image, and sending the container mirror image to a mirror image warehouse of a first environment; the code comprises application code, a main execution script located in a deployment file directory and a deployment description file meeting the deployment requirement quantity.
In this embodiment, the code sent to the code repository includes two parts, one part is a code file of the application itself, and the other part is a deployment file directory, so that the deployment file and the application code can be put together for management. The configuration file directory contains a main execution script and deployment description files of various environments. Each environment is a separate directory, such as a DEV (Development environment) environment and a PROD (Production environment) environment, and the deployment description files corresponding to the environment are stored in the directory. In a specific embodiment, the resource object files supported in the K8S environment are shown in fig. 2, where there may be only one or multiple resource object files according to actual deployment requirements. It should be noted that the main execution script is the use order and use method of these files, which defines how to call the container orchestration management tool to complete deployment, and a typical example is as follows:
#!/bin/bash
kubectl apply-f 1.yaml
kubectl apply-f 2.yaml
in this way, the application codes and the deployment file directories are sent to the code warehouse together, so that unified management of codes and deployment is realized, and the method is the basis of automatic deployment of subsequent container applications.
In this embodiment, after the code is sent to the code warehouse, the packaging tool is used to compile and package the code in the code warehouse, the mirror image construction tool is used to package the compiled and packaged product into a container mirror image, and finally the container mirror image is pushed to the mirror image warehouse of the first environment. In this way, the container image also includes the application operating file and the deployment file.
And S12, carrying out mirror image synchronous operation on a mirror image warehouse of a second environment and a mirror image warehouse of the first environment by using mirror image synchronous trigger logic determined based on a deployment trigger tool so as to enable the mirror image warehouse of the second environment to obtain the container mirror image pushed by the mirror image warehouse of the first environment.
In this embodiment, a mirror warehouse is respectively deployed in each environment, the mirror warehouse only stores static container mirrors, and if mirror synchronization can be performed across mirror warehouses between the environments, it can be understood that this is a similar manner to file transfer. The trigger logic for mirror synchronization is determined by the deployment trigger tool in the second environment, which uses a "pull" approach. The specific implementation steps comprise: determining whether to trigger a mirror synchronization operation between a mirror repository of the second environment and a mirror repository of the first environment based on mirror information; the image information is the image information of the container application which needs to be deployed currently and is input by a user in a page provided by the deployment triggering tool, and comprises the image name and the version number. The deployment triggering tool provides a webpage interface, and a user inputs the mirror name and the version number of the application to be deployed into the interface; and then if the mirror image information does not exist in the second environment mirror image warehouse, pulling a container mirror image from the first environment mirror image warehouse and pushing the container mirror image to the second environment mirror image warehouse, so that the mirror image synchronization between the second environment mirror image warehouse and the first environment mirror image warehouse is realized, and the second environment mirror image warehouse acquires the container mirror image pushed by the first environment mirror image warehouse.
And S13, executing the main execution script contained in the container mirror image acquired by the second environment by using a deployment execution tool so as to realize automatic deployment of the container application in the container cluster.
In this embodiment, after the image warehouse of the second environment acquires the container image pushed by the image warehouse of the first environment, the container image may be pulled locally and pushed to the image warehouse of the target environment by using the deployment execution tool, wherein the main execution script included in the container image acquired by the second environment is mainly used, so that which deployment files are used by the deployment execution tool can be known through the main execution script, and thus the automatic deployment of the container application in the container cluster is realized.
Therefore, when the container application is automatically deployed, the packaging tool is used for compiling and packaging the codes sent to the code warehouse to obtain a container mirror image, and the container mirror image is sent to the mirror image warehouse of the first environment; the code comprises an application code, a main execution script located in a deployment file directory and a deployment description file meeting the deployment requirement quantity; then, mirror image synchronous operation is carried out on a mirror image warehouse of a second environment and a mirror image warehouse of the first environment by using mirror image synchronous triggering logic determined based on a deployment triggering tool, so that the mirror image warehouse of the second environment can obtain the container mirror image pushed by the mirror image warehouse of the first environment; and finally, executing the main execution script contained in the container image acquired by the second environment by using a deployment execution tool so as to realize automatic deployment of the container application in the container cluster. In conclusion, the code and deployment unified version management is achieved by putting the deployment files and the application codes in different environments together; and packaging the deployment file and the code into a mirror image by using the characteristics of the container mirror image to realize mirror image deployment. And then, the deployment triggering tool and the deployment executing tool are utilized to operate the container cluster in the same environment, so that the cross-environment calling of an application programming interface is avoided, the cross-environment interaction is simplified into the transmission of a container mirror image file, the isolation and the safety are effectively improved, and the deployment risk is reduced.
Referring to fig. 3, the embodiment of the present invention discloses a specific automatic container application deployment method, and compared with the previous embodiment, the present embodiment further describes and optimizes the technical solution.
And S21, compiling and packaging the codes sent to the code warehouse by using a packaging tool to obtain corresponding products, and generating container images corresponding to the products by using a preset container image definition file template deployed in the packaging tool.
In this embodiment, a packaging tool is used to compile and package the application code to obtain a product of the application code, and a preset container image definition file template deployed in the packaging tool is used to package the obtained product of the application code and the deployment file directory to obtain the container image. It can be understood that, after the application code and the deployment file are submitted to the code repository, the application code and the deployment file are compiled and packaged by the packaging tool, the packaged product is divided into two parts, one part is a product of the application code, such as a war file of a Java application, and the other part is a product of the deployment file, where the deployment file is directly output as it is. It should be noted that the artifact refers to a binary file generated by compiling and packaging a source code. The artifact is then packaged into a container image according to the container image definition file template configured in the packaging tool. Thus, the container image also comprises an application operation file and a deployment file. And finally pushing the image to an image warehouse of the first environment.
Step S22, determining whether mirror image information of the container application currently needing to be deployed, which is input by the user in the page provided by the deployment triggering tool, exists in the mirror image warehouse of the second environment.
In this embodiment, after the user deploys the image information of the container application that needs to be deployed currently and is input in the page provided by the trigger tool, according to the input image information, that is, the image name and the version number, it is first checked whether the input version number exists in the image repository of the second environment. Therefore, the container mirror image needing to be transmitted can be quickly and accurately known, and the container mirror image can be accurately transmitted.
And S23, if the container mirror image pushed by the mirror image warehouse of the first environment is not present, triggering mirror image synchronous operation between the mirror image warehouse of the second environment and the mirror image warehouse of the first environment, so that the mirror image warehouse of the second environment can obtain the container mirror image pushed by the mirror image warehouse of the first environment.
In this embodiment, if the container image does not exist, the container image is pulled from the first environment image warehouse, and the pulled container image is pushed to the production image warehouse. Namely, the mirror image synchronization operation between the mirror image warehouse of the second environment and the mirror image warehouse of the first environment is triggered, so that the mirror image warehouse of the second environment can obtain the container mirror image pushed by the mirror image warehouse of the first environment. It can be understood that the process from pulling to pushing is equivalent to a file transfer process, that is, the container image in the first environment image warehouse is transferred to the second environment container image, so that the second environment container image also has the container image, thereby implementing image transfer across environments.
And step S24, executing a main execution script contained in the container mirror image acquired by the second environment by using a deployment execution tool so as to realize automatic deployment of the container application in the container cluster.
Therefore, in the embodiment, the container mirror image to be transmitted is accurately positioned by judging whether the mirror image information of the container application to be currently deployed, which is input by the user in the page provided by the deployment triggering tool, exists in the mirror image warehouse of the second environment, so that when the mirror image warehouse of the second environment and the mirror image warehouse of the first environment perform mirror image synchronous operation, the mirror image warehouse of the second environment accurately acquires the container mirror image pushed by the mirror image warehouse of the first environment, and further, the application of the current environment is triggered to be automatically deployed by matching with the related function module.
Referring to fig. 4, the embodiment of the present invention discloses a specific automatic container application deployment method, and compared with the previous embodiment, the present embodiment further describes and optimizes the technical solution.
Step S31, compiling and packaging the codes sent to the code warehouse by using a packaging tool to obtain a container mirror image, and sending the container mirror image to a mirror image warehouse of a first environment; the code comprises application code, a main execution script located in a deployment file directory and a deployment description file meeting the deployment requirement quantity.
Step S32, performing mirror synchronization operation on the mirror warehouse of the second environment and the mirror warehouse of the first environment by using a mirror synchronization trigger logic determined based on the deployment trigger tool, so that the mirror warehouse of the second environment can obtain the container mirror image pushed by the mirror warehouse of the first environment.
And S33, copying the deployment file directory in the container mirror image by using a temporary container operated based on a preset container operation instruction through the second environment, and pushing the deployment file directory obtained by copying to a mirror image warehouse of the second environment.
In this embodiment, the mirror image in the previous step is pulled, so that the container mirror image can be pulled locally and pushed to a target environment mirror image warehouse, and the specific process includes: according to the container mirror image pulled locally, a temporary container is operated through a container operation instruction, such as a docker run, then the deployment file in the container is copied out through a copy instruction, and finally the temporary container is destroyed. After that, the deployment execution tool can directly operate on the container cluster of the current environment, and by executing the master script in the deployment file, automatic deployment of the container application in the container cluster is realized.
And S34, determining a current environment based on the value of the environment variable added into the deployment execution tool, and executing the main execution script in the deployment file directory corresponding to the current environment so as to realize the automatic deployment of the container application in the container cluster.
In this embodiment, since the deployment file includes scripts of multiple environments, and the deployment execution tool needs to know which script under which directory is executed, adding an environment variable, for example, adding a deep _ ENV, to the deployment execution tools of different environments can determine a corresponding environment according to the environment variable. Due to the fact that values of different environments are different, the deployment execution tool can know which deployment files are used by reading the environment variables and execute the main execution script in the deployment file directory corresponding to the current environment, and therefore automatic deployment of the container application in the container cluster can be accurately conducted.
In summary, in the embodiment, a packaging tool is first used to compile and package a code sent to a code repository to obtain a container mirror image, and the container mirror image is sent to a mirror repository of a first environment; the code comprises an application code, a main execution script located in a deployment file directory and a deployment description file meeting the deployment requirement quantity, mirror image synchronization operation is carried out on a mirror image warehouse of a second environment and a mirror image warehouse of a first environment by using a mirror image synchronization triggering logic determined based on a deployment triggering tool, so that the mirror image warehouse of the second environment can obtain a container mirror image pushed by the mirror image warehouse of the first environment, the deployment file directory in the container mirror image is copied by the second environment by using a temporary container operated based on a preset container operation instruction, the copied deployment file directory is pushed to the mirror image warehouse of the second environment, finally, a current environment is determined based on the value of an environment variable added in the deployment execution tool, and the main execution script in the deployment file directory corresponding to the current environment is executed, so that automatic deployment of the container application in a container cluster is realized. Therefore, the deployment files in different environments and the application codes are put together, so that the code and deployment unified version management is achieved; and packaging the deployment file and the code into a mirror image by using the characteristics of the container mirror image to realize mirror image deployment. And then, the deployment triggering tool and the deployment executing tool are utilized to operate the container cluster in the same environment, so that the cross-environment calling of an application programming interface is avoided, the cross-environment interaction is simplified into the transmission of a container mirror image file, the isolation and the safety are effectively improved, and the deployment risk is reduced.
The common solution for automated deployment of container applications among multiple environments is to use a continuous integration and continuous deployment pipeline (abbreviated as CI/CD pipeline), and the landing manner of the CI/CD pipeline in each enterprise varies according to actual situations. For example, but in a K8S environment, a typical implementation is: users submit codes to the code warehouse, then use the relevant tools (such as Jenkins) to pack and compile to form products, and then write the container image definition file (such as Dockerfile). The container mirror image can be constructed by utilizing the container mirror image definition file, and the mirror image needs to be pushed to a mirror image warehouse after the construction is finished, so that the applied version package is provided. And then writing and modifying a deployment description file (YAML file), wherein parameter information of application deployment is defined in the deployment description file, such as image version, resource quota, number of instances, service name and the like. Of course, the deployment profiles required by different environments (development, test, production) are different, so here, the CI/CD pipeline has to deal with the differences of the deployment profiles, and it is general to let the user manually confirm which environment needs to be published before deployment, and then the different environments let the user fill in different parameter information. After the deployment description file exists, the CI/CD pipeline can call a K8S application program interface corresponding to the actual environment to realize the deployment of the container application. However, there are often multiple environments for application deployment, especially in the financial industry, where these environments are isolation-demanding or security-governed. The image transfer between different environments is generally considered to be relatively secure, but it is relatively insecure to enable a CI/CD pipeline to call a K8S application programming interface of different environments to implement deployment of an application, which needs to try to avoid a scenario in which a development environment directly operates an application programming interface of a production environment, and container images are transferred between multiple environments consistently, deployment description files are inconsistent, and container images can shield differences depending on operating environments but cannot shield differences of deployment parameters of different environments, such as different application configuration files of different environments, different container CPUs or memory resources, and the like. After the cross-environment mirror image is transmitted, some extra work is needed to correctly deploy the application, so that after the mirror image is packaged, the deployment of multiple environments cannot be automatically realized.
In order to solve the above problem, the present application explains a specific method for automatically deploying a container application by an embodiment as shown in fig. 5, and particularly uses elements of an application code/deployment file, a deployment trigger tool, and a deployment execution tool, and sends the application code and a plurality of deployment description files to a code warehouse together, and then sends a container image containing the application code and the plurality of deployment description files to an image warehouse of a development environment by using a packaging tool and an image construction tool. And then triggering mirror image synchronization among different environments by using a deployment triggering tool, and finally realizing automatic deployment of the container application in the container cluster by executing the main script in the deployment file by using a deployment execution tool. Therefore, the deployment description file of the container application is embedded in the container mirror image and managed in a unified mode, a cross-environment mirror image synchronization mode is adopted, and each environment is provided with a set of independent mirror image warehouse, so that the mirror images can be synchronized among a plurality of environments. After the mirror image synchronization is successful, the method can be matched with a related function module to trigger the automatic deployment of the application of the current environment, and the API does not need to be called across the environment, so that the deployment efficiency is improved, and the deployment risk is reduced.
Referring to fig. 6, an embodiment of the present application discloses an automatic deployment device for a container application, including:
the container mirror image sending module 11 is configured to compile and package the codes sent to the code warehouse by using a packaging tool to obtain a container mirror image, and send the container mirror image to a mirror image warehouse of the first environment; the code comprises an application code, a main execution script located in a deployment file directory and a deployment description file meeting the deployment requirement quantity;
a container mirror image obtaining module 12, configured to perform mirror image synchronization operation on a mirror image warehouse of a second environment and a mirror image warehouse of the first environment by using a mirror image synchronization trigger logic determined based on a deployment trigger tool, so that the mirror image warehouse of the second environment obtains the container mirror image pushed by the mirror image warehouse of the first environment;
the automatic deployment implementation module 13 is configured to execute, by using a deployment execution tool, the main execution script included in the container image acquired by the second environment, so as to implement automatic deployment of a container application in a container cluster.
Therefore, when the container application is automatically deployed, the packaging tool is used for compiling and packaging the codes sent to the code warehouse to obtain a container mirror image, and the container mirror image is sent to the mirror image warehouse of the first environment; the code comprises application code, a main execution script located in a deployment file directory and a deployment description file meeting the deployment requirement quantity; then, mirror image synchronous operation is carried out on a mirror image warehouse of a second environment and a mirror image warehouse of the first environment by using mirror image synchronous triggering logic determined based on a deployment triggering tool, so that the mirror image warehouse of the second environment can obtain the container mirror image pushed by the mirror image warehouse of the first environment; and finally, executing the main execution script contained in the container mirror image acquired by the second environment by using a deployment execution tool so as to realize automatic deployment of the container application in the container cluster. In conclusion, the code and deployment unified version management is achieved by putting the deployment files and the application codes in different environments together; and packaging the deployment file and the code into a mirror image by using the characteristics of the container mirror image to realize mirror image deployment. And then, the deployment triggering tool and the deployment executing tool are utilized to operate the container cluster in the same environment, so that the cross-environment calling of an application programming interface is avoided, the cross-environment interaction is simplified into the transmission of a container mirror image file, the isolation and the safety are effectively improved, and the deployment risk is reduced.
In some specific embodiments, the container image sending module 11 specifically includes:
and the container mirror image generating unit is used for compiling and packaging the codes sent to the code warehouse by using a packaging tool to obtain corresponding products, and generating container mirror images corresponding to the products by using a preset container mirror image definition file template deployed in the packaging tool.
In some specific embodiments, the container image sending module 11 specifically includes:
and the packaging unit is used for compiling and packaging the application code by using a packaging tool to obtain a product of the application code, and packaging the obtained product of the application code and the deployment file directory by using a preset container image definition file template deployed in the packaging tool to obtain the container image.
In some specific embodiments, the container image obtaining module 12 specifically includes:
a mirror synchronization unit for determining whether to trigger a mirror synchronization operation between a mirror repository of the second environment and a mirror repository of the first environment based on mirror information; the mirror image information is the mirror image information of the container application which needs to be deployed currently and is input by a user in a page provided by the deployment triggering tool, and comprises the mirror image name and the version number;
a determining unit, configured to determine whether mirror image information of the container application that needs to be deployed currently and is input by a user in a page provided by the deployment trigger tool exists in a mirror image warehouse of the second environment;
a container mirror image pushing unit, configured to trigger mirror image synchronization operation between the mirror image warehouse of the second environment and the mirror image warehouse of the first environment if the container mirror image pushing unit does not exist, so that the mirror image warehouse of the second environment obtains the container mirror image pushed by the mirror image warehouse of the first environment;
and the file directory pushing unit is used for copying the deployment file directory in the container mirror image by using a temporary container operated based on a preset container operation instruction through the second environment, and pushing the deployment file directory obtained by copying to the mirror image warehouse of the second environment.
In some specific embodiments, the automatic deployment implementing module 13 specifically includes:
and the environment determining unit is used for determining the current environment based on the value of the environment variable added into the deployment execution tool and executing the main execution script in the deployment file directory corresponding to the current environment so as to realize the automatic deployment of the container application in the container cluster.
Further, an electronic device is disclosed in the embodiments of the present application, and fig. 7 is a block diagram of an electronic device 20 according to an exemplary embodiment, which should not be construed as limiting the scope of the application.
Fig. 7 is a schematic structural diagram of an electronic device 20 according to an embodiment of the present disclosure. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input output interface 25, and a communication bus 26. Wherein, the memory 22 is used for storing a computer program, and the computer program is loaded and executed by the processor 21 to implement the relevant steps in the container application automatic deployment method disclosed in any of the foregoing embodiments. In addition, the electronic device 20 in this embodiment may be specifically an electronic computer.
In this embodiment, the power supply 23 is configured to provide an operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and an external device, and a communication protocol followed by the communication interface is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited herein; the input/output interface 25 is configured to obtain external input data or output data to the outside, and a specific interface type thereof may be selected according to specific application requirements, which is not specifically limited herein.
In addition, the storage 22 is used as a carrier for resource storage, and may be a read-only memory, a random access memory, a magnetic disk or an optical disk, etc., and the resources stored thereon may include an operating system 221, a computer program 222, etc., and the storage manner may be a transient storage or a permanent storage.
The operating system 221 is used for managing and controlling each hardware device on the electronic device 20 and the computer program 222, and may be Windows Server, netware, unix, linux, or the like. The computer programs 222 may further include computer programs that can be used to perform other specific tasks in addition to the computer programs that can be used to perform the container application automatic deployment method performed by the electronic device 20 disclosed in any of the foregoing embodiments.
Further, the present application also discloses a computer-readable storage medium for storing a computer program; wherein the computer program when executed by a processor implements the container application automatic deployment method disclosed above. For the specific steps of the method, reference may be made to the corresponding contents disclosed in the foregoing embodiments, which are not described herein again.
In the present specification, the embodiments are described in a progressive manner, and each embodiment focuses on differences from other embodiments, and the same or similar parts between the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the technical solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
Finally, it should also be noted that, in this document, relational terms such as second and first, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrases "comprising a," "8230," "8230," or "comprising" does not exclude the presence of additional like elements in a process, method, article, or apparatus that comprises the element.
The technical solutions provided by the present application are introduced in detail, and specific examples are applied in the description to explain the principles and embodiments of the present application, and the descriptions of the above examples are only used to help understanding the method and the core ideas of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, the specific implementation manner and the application scope may be changed, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (10)

1. A container application automatic deployment method is characterized by comprising the following steps:
compiling and packaging the codes sent to the code warehouse by using a packaging tool to obtain a container mirror image, and sending the container mirror image to a mirror image warehouse of a first environment; the code comprises application code, a main execution script located in a deployment file directory and a deployment description file meeting the deployment requirement quantity;
performing mirror image synchronization operation on a mirror image warehouse of a second environment and a mirror image warehouse of the first environment by using mirror image synchronization triggering logic determined based on a deployment triggering tool so that the mirror image warehouse of the second environment can obtain the container mirror image pushed by the mirror image warehouse of the first environment;
and executing the main execution script contained in the container mirror image acquired by the second environment by using a deployment execution tool so as to realize automatic deployment of the container application in the container cluster.
2. The method for automatically deploying the container application according to claim 1, wherein the compiling and packaging the code sent to the code warehouse by using a packaging tool to obtain the container image comprises:
compiling and packaging the codes sent to the code warehouse by using a packaging tool to obtain corresponding products, and generating container images corresponding to the products by using a preset container image definition file template deployed in the packaging tool.
3. The method according to claim 2, wherein the compiling and packaging of the code sent to the code repository by using a packaging tool obtains a corresponding product, and the generating of the container image corresponding to the product by using a preset container image definition file template deployed in the packaging tool further comprises:
compiling and packaging the application code by using a packaging tool to obtain a product of the application code, and packaging the obtained product of the application code and the deployment file directory by using a preset container image definition file template deployed in the packaging tool to obtain the container image.
4. The method according to claim 1, wherein the performing, by using a mirror synchronization trigger logic determined based on a deployment trigger tool, a mirror synchronization operation on a mirror repository of a second environment and a mirror repository of the first environment to facilitate the mirror repository of the second environment to obtain the container mirror pushed by the mirror repository of the first environment includes:
determining whether to trigger a mirror synchronization operation between a mirror repository of the second environment and a mirror repository of the first environment based on mirror information; the image information is the image information of the container application which needs to be deployed currently and is input by a user in a page provided by the deployment triggering tool, and comprises the image name and the version number.
5. The method for automatically deploying container applications according to claim 4, wherein the determining whether to trigger a mirror synchronization operation between the mirror repository of the second environment and the mirror repository of the first environment based on mirror information comprises:
judging whether mirror image information of the container application which needs to be deployed currently and is input by a user in a page provided by the deployment triggering tool exists in a mirror image warehouse of the second environment;
if the container mirror image pushed by the mirror image warehouse of the first environment does not exist, triggering mirror image synchronous operation between the mirror image warehouse of the second environment and the mirror image warehouse of the first environment, so that the mirror image warehouse of the second environment can obtain the container mirror image pushed by the mirror image warehouse of the first environment.
6. The method for automatically deploying the container application according to any one of claims 1 to 5, wherein after the mirror repository of the second environment acquires the container mirror pushed by the mirror repository of the first environment, the method further comprises:
and copying the deployment file directory in the container mirror image through the second environment by using a temporary container operated based on a preset container operation instruction, and pushing the deployment file directory obtained by copying to a mirror image warehouse of the second environment.
7. The method according to claim 1, wherein the executing, by using a deployment execution tool, the main execution script included in the container image acquired by the second environment to implement automatic deployment of the container application in a container cluster comprises:
determining a current environment based on the value of the environment variable added in the deployment execution tool, and executing the main execution script in the deployment file directory corresponding to the current environment, so as to realize automatic deployment of the container application in the container cluster.
8. An automated deployment apparatus for a container application, comprising:
the container mirror image sending module is used for compiling and packaging the codes sent to the code warehouse by using a packaging tool to obtain a container mirror image, and sending the container mirror image to a mirror image warehouse of a first environment; the code comprises application code, a main execution script located in a deployment file directory and a deployment description file meeting the deployment requirement quantity;
the container mirror image acquisition module is used for carrying out mirror image synchronous operation on a mirror image warehouse of a second environment and a mirror image warehouse of the first environment by using mirror image synchronous trigger logic determined based on a deployment trigger tool so as to facilitate the mirror image warehouse of the second environment to acquire the container mirror image pushed by the mirror image warehouse of the first environment;
and the automatic deployment implementation module is used for executing the main execution script contained in the container mirror image acquired by the second environment by using a deployment execution tool so as to implement automatic deployment of the container application in the container cluster.
9. A detection model false drop detection training device is characterized by comprising:
a memory for storing a computer program;
a processor for executing the computer program to implement the container application automatic deployment method of any of claims 1 to 7.
10. A computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the container application automatic deployment method of any of claims 1 to 7.
CN202211391294.6A 2022-11-08 2022-11-08 Container application automatic deployment method, device, apparatus, equipment and medium Pending CN115658237A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211391294.6A CN115658237A (en) 2022-11-08 2022-11-08 Container application automatic deployment method, device, apparatus, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211391294.6A CN115658237A (en) 2022-11-08 2022-11-08 Container application automatic deployment method, device, apparatus, equipment and medium

Publications (1)

Publication Number Publication Date
CN115658237A true CN115658237A (en) 2023-01-31

Family

ID=85016646

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211391294.6A Pending CN115658237A (en) 2022-11-08 2022-11-08 Container application automatic deployment method, device, apparatus, equipment and medium

Country Status (1)

Country Link
CN (1) CN115658237A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116431277A (en) * 2023-03-13 2023-07-14 浙江海规技术有限公司 Multi-place operation and maintenance containerization method and device, computer equipment and storage medium
CN116627446A (en) * 2023-07-25 2023-08-22 华控清交信息科技(北京)有限公司 Method and device for deploying application on k8s container cluster and electronic equipment
CN117519912A (en) * 2024-01-04 2024-02-06 之江实验室 Mirror image warehouse deployment method, device, storage medium and equipment

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116431277A (en) * 2023-03-13 2023-07-14 浙江海规技术有限公司 Multi-place operation and maintenance containerization method and device, computer equipment and storage medium
CN116627446A (en) * 2023-07-25 2023-08-22 华控清交信息科技(北京)有限公司 Method and device for deploying application on k8s container cluster and electronic equipment
CN117519912A (en) * 2024-01-04 2024-02-06 之江实验室 Mirror image warehouse deployment method, device, storage medium and equipment
CN117519912B (en) * 2024-01-04 2024-04-05 之江实验室 Mirror image warehouse deployment method, device, storage medium and equipment

Similar Documents

Publication Publication Date Title
US11599348B2 (en) Container image building using shared resources
CN110413288B (en) Application deployment method, device, server and storage medium
CN115658237A (en) Container application automatic deployment method, device, apparatus, equipment and medium
US9760343B2 (en) Application builder based on metadata
US9367305B1 (en) Automatic container definition
US11389960B2 (en) Systems and methods for robotic process automation
EP3043258A1 (en) iOS APPLICATION AUTOMATIC COMPILATION METHOD AND SYSTEM
US7818733B2 (en) Improving bundle control in computing environment
WO2015199748A1 (en) Rest service source code generation
CN110750243A (en) Project code development method and system
US10459698B2 (en) Framework for generating adapters in an integrated development environment
CN111651169B (en) Block chain intelligent contract operation method and system based on web container
CN111736810A (en) Method for dynamically creating node of docker container to execute task based on jenkins real-time task
CN116069341A (en) Automatic deployment method, equipment and storage medium for application program
US10896035B1 (en) Methods of converting APIs into objects and uses thereof
CN117112122A (en) Cluster deployment method and device
CN107918543B (en) Installation package generation method and device, computer equipment and storage medium
CN113467790A (en) Software packaging method and device and readable storage medium
CN112231231B (en) Cloud service debugging method, system and device
CN111427770B (en) Resource testing method and related equipment
CN114020285A (en) Industrial APP operation method and device
CN114443065A (en) Platform deployment method, platform deployment device, electronic equipment and storage medium
CN112685051A (en) Method, device, platform and storage medium for automatically executing shell script
CN117093286B (en) Plug-in generation method, device, equipment and computer readable storage medium
Mardan et al. Getting Node. js Apps Production Ready

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination