Software environment rapid deployment method based on Jenkins and K3S
Through the combination of Jenkins and K3S, rapid deployment and version management of the software environment are achieved, solving the problems of low deployment efficiency and difficult operation and maintenance of small and medium-sized companies, and providing solutions for rapid delivery and version control.
Patent Information
- Application Number
- CN202011393844.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-03
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2040-12-03
AI Technical Summary
Existing software deployment methods occupy a lot of machine resources, are cumbersome to deploy, have low efficiency, and are difficult to operate and maintain. Especially in small and medium-sized companies, it is difficult to achieve rapid delivery and large-scale replication. Version management is chaotic and rollback is difficult.
Adopt a rapid deployment method of software environment based on Jenkins and K3S, deploy K3s and GlusterFS through automated operation and maintenance tools, define yaml scripts, build jenkins docker container images, configure jenkins tasks, realize automated build and version management, and use Kubectl to control containers for service updates .
It achieves rapid deployment and operation and maintenance of small and medium-sized software projects, simplifies the construction process, facilitates version management and rollback, and improves deployment efficiency and the replication capability of the continuous integration environment.
Smart Images

Figure CN112346752B
Abstract
Description
Technical Field
[0001] The invention relates to a rapid deployment method, and in particular to a software environment rapid deployment method based on Jenkins and K3S. Background Art
[0002] From the perspective of the existing software deployment methods, it has gone through several stages of development, as follows:
[0003] Phase 1: Manual code construction and manual deployment. The deployment method is mainly based on physical servers, and the basic software operating environment and business codes need to be installed one by one.
[0004] Phase 2 2. The development of virtualization technology, gradually migrating from physical machines to virtual machines, accompanied by some forms of software automation construction and deployment.
[0005] Phase 3: With the rise of DevOps and the development of container technology, the industry is gradually moving towards automated construction, pipeline orchestration, and containerized deployment. Cloud computing vendors have launched corresponding deployment solutions.
[0006] In the existing software deployment, there are roughly the following shortcomings:
[0007] 1. The traditional software deployment method based on physical machines or virtual machines has a low degree of machine concentration, requires a large number of machine resources and operation and maintenance personnel, and requires a large amount of deployment document support. It cannot meet the requirements of rapid delivery and deployment.
[0008] 2. Deployment based on the container image deployment method of the Kubernetes cluster. The deployment and structure of K8s itself are relatively complex, time-consuming, and difficult to operate and maintain. Each deployment requires building a container image, which takes a long time.
[0009] 3. Implement various software construction and deployment solutions based on Jenkins, and the construction steps are complicated.
[0010] At the same time, combined with the current conventional deployment execution method, it uses physical machines or virtual machines for deployment, which takes up a lot of resources, is cumbersome to deploy, and cannot achieve intensive resource management. The deployment efficiency is low. The use of cluster methods such as Kubernetes for deployment is suitable for ultra-large-scale clusters. The installation and deployment are complex, the later operation and maintenance are difficult, and it takes up a lot of server resources. It is difficult to carry out on a large scale in small and medium-sized companies. The deployment process is complex and time-consuming. The operating environment and build system cannot be replicated on a large scale. The build process and outputs cannot be managed by version number, and the version management is chaotic. It is impossible to specify branches and versions to build, and it is difficult to roll back once a problem occurs. An overall build is required, and it is impossible to implement builds for single or multiple component modules. A docker image must be built for each release and uploaded to the container warehouse. It depends on the image warehouse and is time-consuming.
[0011] In view of the above-mentioned defects, the designer actively conducts research and innovation in order to create a method for rapid deployment of software environment based on Jenkins and K3S, making it more valuable for industrial use. Summary of the invention
[0012] To solve the above technical problems, the purpose of the present invention is to provide a method for rapid deployment of software environment based on Jenkins and K3S.
[0013] The software environment rapid deployment method based on Jenkins and K3S of the present invention comprises the following steps:
[0014] Step 1: Deploy K3s and the distributed script system GlusterFS based on automated operation and maintenance tools.
[0015] Step 2: Use the K3s cluster machine to mount the distributed script system GlusterFS deployed in step 1 and define the YAML script of the software to be deployed.
[0016] Step 3: Build the Jenkins Docker container image to achieve rapid deployment of the Jenkins environment.
[0017] Step 4: Configure the Jenkins task, build the business code repository address, and generate an automatic production management script.
[0018] Step 5: Specify the shell script for software construction in Pipline.
[0019] Step 6: Save the automatic production management version description script in the code directory through the shell script.
[0020] Step 7: Store the previously built business code in the distributed script system GlusterFS deployed in step 1 for shared storage, and restart the corresponding container through K3s Kubectl to update the service.
[0021] Furthermore, in the above-mentioned method for rapid deployment of software environment based on Jenkins and K3S, in step one, ansible is deployed based on the automated operation and maintenance tool, and a deployment script is written to realize rapid deployment of K3s and the distributed script system GlusterFS. The K3s cluster machine is mounted to the deployed distributed script system, the yaml script of the software to be deployed is defined, and the relevant paths of the container components are mapped to the host machine.
[0022] Furthermore, in the above-mentioned software environment rapid deployment method based on Jenkins and K3S, in the step 2, a K3s deployment binary script is prepared, the K3s and GlusterFS deployment IPs are defined, K3s is defined, the command template j2 script for deploying K3sserver and agent initialization is deployed, the K3s server and agent side yaml scripts are defined, and the relevant template scripts are called.
[0023] Define the glusterfs yum source and define the yum installation command in the yaml script. Define the glusterfs client script and use the mount command to mount the client to the glusterfs server.
[0024] Define the Service type in the YAML script and specify the name.
[0025] Define the Deployment type in the YAML script and specify the name.
[0026] Define relevant specifications in the Deployment type, including replicas, selector, template and other related configuration parameters.
[0027] Define the container name parameter, image parameter, and ports parameter at the Deployment type spec level, and map the container running directory to the host directory through the volumeMounts parameter.
[0028] Furthermore, in the above-mentioned software environment rapid deployment method based on Jenkins and K3S, the implementation process of step three is:
[0029] Write dockerfile to build Jenkins Master image. Write dockerfile to build Jenkins slave image, which contains Java, node and other environments required for software construction. Run the Jenkins master image, and automatically start the Jenkins slave when the task is running. After the construction is completed, the slave is destroyed to ensure that the environment is the same every time.
[0030] Furthermore, in the above-mentioned software environment rapid deployment method based on Jenkins and K3S, the configuration construction in step 4 is composed of a Pipline script written in groovy language to drive the construction process, Pipline is hosted in Gitea, and Jenkins is obtained from Gitea.
[0031] Set the Jenkins task to parameterized and configure the development, test, and production environments of the "choice parameter".
[0032] Configure the Jenkins task "Choose Source for Value" and define it as Component. Configure all component names that need to be deployed here.
[0033] Configure "String Parameter", define the name as RepoAddr, and the value as the business code repository address. Configure the Pipeline source as Git, and configure the Pipeline script code repository address.
[0034] During the execution of Pipeline, the input parameter RepoAddr is obtained and the corresponding business code is pulled.
[0035] Furthermore, in the above-mentioned software environment rapid deployment method based on Jenkins and K3S, in step four, the name and business code repository address are defined through the Jenkins task configuration "list Git Branches" configuration. When the user builds the task, the Jenkins task displays the branch and version tag information of the configured repository, and the user selects the corresponding version when building.
[0036] Furthermore, in the above-mentioned software environment rapid deployment method based on jenkins and K3S, in step 5, the git repository address of the shell script is specified in Pipline, and the branch information of the repository address in step 4 is obtained. Component (custom name) is used as the input parameter of the shell build script. The maven tool is called through the shell to build a binary script according to the specified input.
[0037] Furthermore, in the above-mentioned software environment rapid deployment method based on Jenkins and K3S, the processing process of step six is to obtain the branch information of the warehouse address in step four.
[0038] Use the shell script to list all branch information through git tag, sort the branch information through sort--sort version, and get the previous version name as $CURR_BRANCH according to the current input version name. Create a version description script VERSION.md script in the output script directory, write the current build version as the version number, and write the current time as the build time.
[0039] Get the commit record of this version in git as version description information and write it into VERSION.md.
[0040] Furthermore, in the above-mentioned software environment rapid deployment method based on Jenkins and K3S, the processing process in step seven is:
[0041] Step 1) In Pipline, based on ssh Publisher (plug-in), find the old script directory on the distributed storage according to the input component name, and execute the command to delete the corresponding business code.
[0042] Step 2) In Pipline, based on ssh Publisher, the binary package is transferred to the distributed script system GlusterFS.
[0043] Step 3) Get all pod information on the K3s cluster node, such as the command line: Kubectl get pods-A.
[0044] Step 4) Get detailed information of all pods in the cluster and output them in JSON format, as shown in Kubectl getpods -n <namespace> <pod-name>-o json.
[0045] Step 5) Use the jq command to format the returned results and obtain the namespace, pod name, and corresponding business component name of each container as needed.
[0046] Step 6) Select the pod whose business component name is consistent with the Component parameter input by Jenkins, restart the corresponding pod, and implement the specified build, which is represented by Kubectl delete pod-nn <namespace> <pod-name>.
[0047] By means of the above scheme, the present invention has at least the following advantages:
[0048] 1. Facilitate the delivery and deployment of small and medium-sized software projects, with fast deployment and convenient subsequent operation and maintenance.
[0049] 2. It can simplify the construction time in the software development process and can be built on demand.
[0050] 3. Facilitate the replication and reconstruction of the continuous integration environment for software development.
[0051] 4. Convenient version management and version rollback.
[0052] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention and implement it according to the contents of the specification, the following is a detailed description of the preferred embodiments of the present invention in conjunction with the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 It is a flow chart of the overall task construction during the implementation of the present invention.
[0054] Figure 2 It is a schematic diagram of the overall deployment process during the implementation of the present invention.
[0055] Figure 3 It is a schematic diagram of the implementation sequence deployed during the implementation of the present invention. DETAILED DESCRIPTION
[0056] The specific implementation of the present invention is further described in detail below in conjunction with the accompanying drawings and examples. The following examples are used to illustrate the present invention, but are not intended to limit the scope of the present invention.
[0057] like Figures 1 to 3 The software environment rapid deployment method based on Jenkins and K3S is characterized by comprising the following steps:
[0058] Step 1: Based on the automated operation and maintenance tools, K3s and the distributed script system GlusterFS are deployed. During the implementation, ansible is deployed based on the automated operation and maintenance tools, and deployment scripts are written to quickly deploy K3s and the distributed script system GlusterFS. At the same time, the K3s cluster machine is mounted to the deployed distributed script system, the yaml script of the software to be deployed is defined, and the relevant paths of the container components are mapped to the host machine.
[0059] Step 2: Use the K3s cluster machine to mount to the distributed script system GlusterFS deployed in step 1, and define the yaml script of the software to be deployed in the following way:
[0060] First, prepare the K3s deployment binary script, define the K3s and GlusterFS deployment IP, and define K3s. After that, deploy the command template j2 script for K3s server and agent initialization, define the K3s server and agent-side yaml scripts, and call the relevant template scripts. During the implementation of the present invention, it is also necessary to define the glusterfs yum source, and define the yum installation command in the yaml script. Define the glusterfs client script and use the mount command to mount the client to the glusterfs server. Subsequently, define the Service type in the yaml script and specify the name. Define the Deployment type in the yaml script and specify the name. Then, define the relevant specifications in the Deployment type, including replicas, selector, and template. At the same time, define the container name parameter, image parameter, and ports parameter under the Deployment type spec level, and map the container running directory to the host machine's directory through the volumeMounts parameter.
[0061] Step 3: Build the jenkins docker container image to achieve rapid deployment of the jenkins environment. During this period, write the dockerfile to build the Jenkins Master image. At the same time, write the dockerfile to build the Jenkins slave image, which contains the Java, node and other environments required for software construction. After that, run the jenkins master image, and when the task is run, automatically start the jenkins slave, and destroy the slave after the build is completed, to ensure that the environment is the same every time.
[0062] Step 4, configure the Jenkins task, build the business code repository address, and generate an automatic production management script. During this period, write the Pipline script based on the groovy language to drive the construction process. The Pipline is hosted on Gitea (unified maintenance can be performed), and Jenkins obtains it from Gitea. At the same time, set the Jenkins task to parameterize, and configure the development, test, and production environments of the "choice parameter". In order to better implement the present invention, you can also configure the Jenkins task "Choose Source for Value", define it as the name Component, and configure all component names that need to be deployed here. In addition, configure the "String Parameter", define the name as RepoAddr, and the value as the business code repository address. Configure the Pipeline source to Git, and configure the Pipeline script code repository address. Moreover, during the execution of the Pipeline, obtain the input parameter RepoAddr to pull the corresponding business code.
[0063] At the same time, during the implementation period, you can configure the "list Git Branches" configuration through the Jenkins task to define the name and address of the business code repository. When the user builds the task, the Jenkins task displays the branch and version tag information of the configured repository, and the user selects the corresponding version when building.
[0064] Step 5: Specify the shell script for software construction in Pipline. This script supports building corresponding components according to Jenkins input parameters. During implementation, specify the git repository address of the shell script in Pipline, obtain the branch information of the repository address in step 4, and use Component as the input parameter of the shell construction script. After that, call the Maven tool through the shell to build a binary script according to the specified input.
[0065] Step six, save the automatic production management version description script in the code directory through the shell script. The implementation process is as follows: First, obtain the branch information of the warehouse address in step four. After that, use the shell script to list all branch information through git tag, sort the branch information through sort--sort version, and obtain the previous version name as $CURR_BRANCH according to the current input version name. Next, create a version description script VERSION.md script in the output script directory, write the current build version as the version number, and write the current time as the build time. Finally, obtain the submission record of this version of git as the version description information and write it into VERSION.md. In addition, it can be executed through the command git log--pretty=oneline^$PRE_BRANCE$CURR_BRANCH.
[0066] Step 7: Share the business code that was previously built in the distributed script system GlusterFS deployed in step 1 for storage, and restart the corresponding container through K3s Kubectl to update the service. Specifically, the processing process is as follows:
[0067] Step 1) In Pipline, based on ssh Publisher, find the old script directory on the distributed storage according to the input component name and execute the command to delete the corresponding business code.
[0068] Step 2) In Pipline, based on ssh Publisher, the binary package is transferred to the distributed script system GlusterFS.
[0069] Step 3) Get all pod information on the K3s cluster node using Kubectl get pods-A.
[0070] Step 4) Get detailed information of all pods in the cluster and output them in JSON format, as shown in Kubectl getpods -n <namespace> <pod-name>-o json.
[0071] Step 5) Use the jq command to format the returned results and obtain the namespace, pod name, and corresponding business component name of each container as needed.
[0072] Step 6) Select the pod whose business component name is consistent with the Component parameter input by Jenkins, restart the corresponding pod, and implement the specified build, which is represented by Kubectl delete pod-nn <namespace> <pod-name>.
[0073] In order to better facilitate those skilled in the art to understand the concept of the present invention, the names used in this application are all conventional names in the industry, which are roughly explained as follows:
[0074] Jenkins: Jenkins is an open source continuous integration tool written in Java.
[0075] K3S: K3s is a highly available, CNCF-certified Kubernetes distribution designed for production workloads that are unattended, resource-constrained, in remote areas, or inside IoT devices. K3s is packaged into a single binary script of less than 60MB, reducing the dependencies and steps required to run, install, run, and automatically update production Kubernetes clusters.
[0076] Gluster: Gluster is a large-scale script system. It is a combination of various storage servers, which are connected by Ethernet or Infiniband technology and remote direct memory access RDMA, and finally form a large parallel script system network.
[0077] Getea: Gitea is an open source community-driven lightweight code hosting solution with a backend written in Go and licensed under the MIT license.
[0078] Ansible: Ansible is a new automated operation and maintenance tool developed based on Python. It combines the advantages of many operation and maintenance tools and realizes functions such as batch system configuration, batch program deployment, and batch command execution.
[0079] Docker: Docker is an open source application container engine that allows developers to package their applications and dependent packages into a portable image and then publish them to any popular Linux or Windows machine. It can also achieve virtualization. Containers use a complete sandbox mechanism and there is no interface between them.
[0080] Combined with the actual implementation, the execution process is as follows:
[0081] 1. Prepare the machine for the first time and automatically install the k3s operating environment and jenkins server through the ansible automation script.
[0082] 2. For example, a system involves three components, named DataMgtService DataApAdapterServiceDataTpAdapterService, and the k3s startup script is defined as datamgt.yaml.
[0083] 3. Configure datamgt.yaml.
[0084] The host address / opt / comm / DataManagement / DataMgtService is mapped to the container workspace directory / opt / DataMgtService.
[0085] The pod name is defined as datamgt-service.
[0086] Specify the run file name as DataMgtService.jar.
[0087] Example file:
[0088]
[0089]
[0090]
[0091] 4. In the system Jenkins task, set the Component parameter to "Choose Source for Value" with values of DataMgtService, DataApAdapterService, DataTpAdapterService separated by commas.
[0092] Configure the Pipeline address to the Pipeline script hosting address, such as:
[0093] ssh: / / git@prod-git.example.com:1022 / Prod-CI.git, the Pipeline script specifies the build script build.sh.
[0094] Configure the system code repository, for example:
[0095] ssh: / / git@prod-git.example.com:1022 / Common / Common-DataMgtSystem.git.
[0096] 5. Sometimes you need to build the v1.1.0 version of the DataMgtService component separately. When building the component, select v1.1.0 as the version number and DataMgtService as the component.
[0097] 6. Pull the code from the code repository, switch to version v1.1.0, build the DataMgtService component separately, and the production files include DataMgtService.jar and VERSION.MD.
[0098] 7. Delete the old DataMgtService binary code DataMgtService.jar and VERSION.MD in the shared storage, the directory is / opt / comm / DataManagement / DataMgtService.
[0099] 8. Transfer the new version of DataMgtService component DataMgtService.jar and VERSION.MD to the shared storage directory / opt / comm / DataManagement / DataMgtService.
[0100] 9. According to the definition in the Pipeline script, associate the component name DataMgtService with the pod name datamgt-service in k3s.
[0101] Use the "Kubectl delete datamgt-servic" command to delete the old pod. The system automatically starts a new pod and runs the new code.
[0102] It can be seen that during the implementation period, the present invention can realize the rapid deployment of K3s and GlusterFS based on ansible. At the same time, GlusterFS is used as the distributed storage of K3s, and all hosts of K3s share storage. The binary package generated when the business code is built is mounted to the container, and there is no need to build a separate image for each business component. The rapid deployment image of jenkins is built based on the docker container to achieve the rapid construction of the software construction environment. When building, a new container is started for construction to ensure that the environment is pure each time and the consistency of the source code is guaranteed. Jenkins parameterization and Kubectl command return information can be used to find the corresponding code and pod, and the old code can be deleted and the pod restarted. The maintenance of the version description script can be realized using git and shell. Version maintenance is automatically completed during construction to avoid the problem of unclear version number and unclear source of code in the operation and maintenance process.
[0103] It can be seen from the above textual description and the accompanying drawings that the present invention has the following advantages:
[0104] 1. Facilitate the delivery and deployment of small and medium-sized software projects, with fast deployment and convenient subsequent operation and maintenance.
[0105] 2. It can simplify the construction time in the software development process and can be built on demand.
[0106] 3. Facilitate the replication and reconstruction of the continuous integration environment for software development.
[0107] 4. Convenient version management and version rollback.
[0108] In addition, the indicated orientations or positional relationships described in the present invention are all based on the orientations or positional relationships shown in the accompanying drawings and are only for the convenience of describing the present invention and simplifying the description. They do not indicate or imply that the device or structure referred to must have a specific orientation or be operated with a specific orientation structure. Therefore, they cannot be understood as limitations on the present invention.
[0109] The terms "primary" and "secondary" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, features defined as "primary" and "secondary" may explicitly or implicitly include one or more of the features. In the description of the present invention, "several" means two or more, unless otherwise clearly and specifically defined.
[0110] Likewise, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, "plurality" means two or more, unless otherwise clearly and specifically defined.
[0111] In the present invention, unless otherwise clearly specified and limited, the terms "connected", "set" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral one; it can be a mechanical connection or an electrical connection; it can be directly connected or indirectly connected through an intermediate medium, it can be the internal connection of two components or the interaction relationship between two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to the specific circumstances. And it can be directly on another component or indirectly on the other component. When a component is said to be "connected to" another component, it can be directly connected to the other component or indirectly connected to the other component.
[0112] It should be understood that the terms "length", "width", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating the orientation or position relationship, are based on the orientation or position relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or component referred to must have a specific orientation, be constructed and operate in a specific orientation, and therefore should not be understood as a limitation on the present invention.
[0113] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the technical principles of the present invention, and these improvements and modifications should also be regarded as within the scope of protection of the present invention. < / namespace> < / namespace> < / namespace> < / namespace>
Claims
1. A software environment rapid deployment method based on Jenkins and K3S, characterized by The following steps are involved: Step 1: Based on the automated operation and maintenance tools, K3s and the distributed script system GlusterFS are deployed. Ansible is deployed based on the automated operation and maintenance tools, and deployment scripts are written to quickly deploy K3s and the distributed script system GlusterFS. The K3s cluster machine is mounted to the deployed distributed script system, the yaml script of the software to be deployed is defined, and the relevant paths of the container components are mapped to the host machine. Step 2: Mount the distributed script system GlusterFS deployed in step 1 through the K3s cluster machine, define the yaml script of the software to be deployed; prepare the K3s deployment binary script, define the K3s and GlusterFS deployment IP, define K3s, deploy the command template j2 script for K3s server and agent initialization, define the K3s server and agent yaml scripts, and call the relevant template scripts; define the glusterfs yum source, define the yum installation command in the yaml script; define the glusterfs client script, and use the mount command to mount the client to the glusterfs server; define the Service type in the yaml script and specify the name; define the Deployment type in the yaml script and specify the name; define the relevant specifications in the Deployment type, including replicas, selector, and template; define the container name parameter, image parameter, and ports parameter under the Deployment type spec level, and map the container running directory to the host directory through the volumeMounts parameter; Step 3: Build a Jenkins docker container image to achieve rapid deployment of the Jenkins environment. The implementation process is: write a dockerfile to build a Jenkins Master image; write a dockerfile to build a Jenkins slave image, which contains the Java and node environments required for software construction; run the Jenkins master image, and automatically start the Jenkins slave when the task is running. After the construction is completed, the slave is destroyed to ensure that the environment is the same each time. Step 4: Configure the Jenkins task, build the business code repository address, and generate an automatic production management script: Write a Pipline script based on the groovy language to drive the build process. The Pipline is hosted on Gitea, and Jenkins obtains it from Gitea; Set the Jenkins task to parameterize, and configure the development, test, and production environments of the "choice parameter"; Configure the Jenkins task "Choose Source for Value", define it as the name Component, and configure all component names that need to be deployed here; Configure "String Parameter", define the name as RepoAddr, and the value as the business code repository address; Configure the Pipeline source as Git, and configure the Pipeline script code repository address; Get the input parameter RepoAddr during the Pipeline execution process to pull the corresponding business code; Configure the "list Git Branches" configuration of the Jenkins task, define the name and business code repository address, and when the user builds the task, the Jenkins task displays the branch and version tag information of the configured repository, and the user selects the corresponding version when building; Step 5. Specify the shell script for software construction in Pipline: Specify the git repository address of the shell script in Pipline, obtain the branch information of the repository address in step 4, use Component as the input parameter of the shell construction script, call the Maven tool through the shell, and build a binary script according to the specified input; Step 6: Save the automatic production management version description script in the code directory through the shell script; the processing process is to obtain the branch information of the warehouse address in step 4; use the git tag in the shell script to list all branch information, sort the branch information through sort --sort version, and obtain the previous version name as $CURR_BRANCH according to the current input version name; create a version description script VERSION.md script in the output script directory, write the current build version as the version number, and write the current time as the build time; obtain the commit record of this version of git as the version description information, and write it into VERSION.md; Step 7: Share the previously built business code in the distributed script system GlusterFS deployed in step 1, and restart the corresponding container through K3s Kubectl to update the service. The processing process is to find the old script directory on the distributed storage based on the input component name based on ssh Publisher in Pipline, and execute the command to delete the corresponding business code; based on ssh Publisher in Pipline, transfer the binary package to the distributed script system GlusterFS, and obtain all pod information Kubectl get pods –A on the K3s cluster node; obtain detailed information of all pods on the cluster and output them in json format, expressed as Kubectl get pods -n <namespace> <pod-name>-o json; Use the jq command to format the returned results, and obtain the namespace, pod name, and corresponding business component name of each container as needed; Select the pod whose business component name is consistent with the jenkins input parameter Component, restart the corresponding pod, and implement the specified build, expressed as Kubectl delete pod -n -n <namespace> <pod-name> 。< / pod-name> < / namespace> < / namespace>
