Installation Procedure for Adding a CD Jenkins Job(3.0)
The installation process for adding a CD Jenkins job includes the following steps:
- Add a new Item as type Freestyle project.
- Click
This project is parameterized
and add the following parameters:Parameter Type Name String parameter ClusterContext
Namespace
dockerRepo
Release
mzcliUser
Password Parameter mzcliPassword
Build selector for Copy Artifact BuildFromCIPipeline
Boolean DEBUG
install_crd Add Source Code Management, select Git and add your Repository URL, credentials, and branch.
Note!
You need to add Git repository only if you are using canary deploy.
Canary deploy
At the time of canary deploy, there is one canary and one production pod. In case of a new installation, both canary and production pods will run the same workflow. After that is deployed, the Git repository is updated with the information about which
package_image
the production pod will use. So the next time you deploy a new version, only the canary pod is updated and then you must verify the canary deploy first by running the canary deploy Jenkins job. When you feel that canary deploy is good, you can switch the canary pod with production pod and then the git repo needs to be updated with the new version of the production pod.- In the Build section:
- Add build step as
Copy artifacts from another project
.
Add your CI pipeline asProject name
.
UnderWhich build
, selectSpecified by a build parameter
and set Parameter Name toBuildFromCIPipeline.
Add build step
Execute shell
with this command:#!/bin/bash if [[ $DEBUG == "true" ]]; then set -x fi set -e cd output ls unzip *.csar echo Switch context to $ClusterContext kubectl config use-context $ClusterContext if [[ $mzcliUser != "" ]]; then MZCLI="-u $mzcliUser -p $mzcliPassword" fi #Usage ./install.sh -r <repo> -s <release> -g <Git Helmchart dir> -m <commit message> -n <namespace> -u <mzcli user> -p <mzcli password> -a <use specific AWS profile name and authenticate> ./install.sh -r $dockerRepo -n $Namespace -s $Release -g <Change to your Git Helmchart dir> -m <Change to your commit message> $MZCLI -a <Change to AWS Profile name if images is on AWS ECR> -i $install_crd tar -cvf Helm.tar Helm mv Helm.tar ../ cd .. rm -rf output
Install.sh script
The
install.sh
script creates a Kubernetes Secret namedmzcli
with two keys, one namedmzcliUser
and one namedmzcliPassword
. The values are set to the values of the -u and -p parameters. When the -u parameter is not provided, a secret namedmzcli
needs to exist in the cluster in advance.Use
-g
and-m
parameters if any of the Helm chart is using canary deploy.Use -a only if images is located on AWS ECR
- Add build step as
- Add two
Post-build Actions
:Archive the artifacts
withFiles to archive
set toHelm.tar
.- A
Git Publisher
. SelectPush Only If Build Succeeds
and add your Branch to push to.Note!
You need to add Git repository only if you are using canary deploy.
- Apply your changes.
- When selecting
Build with Parameters
it should now look like this (the picture contains example field values):