Jenkins CI/CD pipelines for Kubernetes Appilication: Continuously Build and Deliver to Amazon EKS Cluster
End-to-End Jenkins CI/CD pipelines for Kubernetes application. Use blue/green deployment strategy to deliver/deploy to a cluster on Amazon Elastic Kubernetes Service.
Helpful Files
bin/setup_jenkins_ubuntu.sh
- All the commands to setup an EKS-ready Jenkins.
- This file is for reference only. DON'T RUN!
bin/create_cluster_eks.sh
- Automatically create/update the roles & network used by EKS, and then create/update the cluster & its node group.
- Same code is used in Jenkinsfile.
bin/deploy_k8s_app.sh
- Deploy the Kubernetes application using
kubectl
. - Same code is used in Jenkinsfile.
- Deploy the Kubernetes application using
How to Roll out a New Version
In the develop
branch:
- Commit the changes for the new version.
- Update the
VERSION
variable in Jenkinsfile and commit. - Push
develop
to trigger CI stages in pipeline.
In the staging
branch:
- Pull and merge the latest
develop
branch. - Push
staging
to trigger CD stages in pipeline (will be deployed to a copy of production environment).
If everything is ready for production:
- Checkout a
release/**
branch fromstaging
branch. - Push and merge the branch to
master
- Push
master
to trigger CI+CD stages in pipeline (will be deployed to the ACTUAL production environment).
An Example for CI
-
Assume that you already have an app running at version
1.0
. -
And you make the following changes for a newer version
1.1
.sed -i "s/World/New World" app/app.py sed -i "s/World/New World" tests/test_app.py
-
Update the version from
1.0
to1.1
in Jenkinsfile.Otherwise the existing version will be OVERWRITTEN after running the pipeline.
sed -i "s/VERSION = '1.0'/VERSION = '1.1'/" Jenkinsfile
-
Commit changes to
develop
, push to trigger the pipeline for CI.