This project aims to develop a CI/CD pipeline for microservices applications with blue/green deployment. The CI step includes a simple linter, and the CD steps include:
- Pushing the built Docker container(s) to the Docker repository
- Deploying these Docker container(s) to a small Kubernetes cluster using AWS Kubernetes cluster
- Building these steps in Jenkins pipeline
Click to expand
- EC2 Instance with Ubuntu 18.04
- Install Jenkins & plugins
Jenkins plugins:
Amazon Web Services SDK
Ansible plugin
Ant plugin
Blue Ocean
CloudBees AWS Credentials Plugin
Docker Pipeline
GitHub Pipeline for Blue Ocean
Pipeline: AWS Steps
-
Add IAM policy for blue/green deployment
-
Add AWS credentials in Jenkins
-
Add Docker credentials in Jenkins
-
Create AWS keypair for cluster and create cluster using
eksctl
-
Create blue & green branches, each with the following files:
- Dockerfile
- Jenkinsfile
- our "app":
index.html
-
Build Jenkins pipeline
Click here to expand
-
Unable to push to docker using Jenkins, even after adding docker credentials to Jenkins. Finally found a way to have Jenkins use docker credentials with
withDockerRegistry([ credentialsId: "dockerhub", url: "" ])
. -
Installing
kubectl
on Ubuntu user instead of Jenkins user caused issues where Jenkins is unable to runkubectl
commands. My workaround is usingsudo su ubuntu -c
to run it. -
Switching between blue and green app doesn't show at first, but later realized it must be cached. By switching to incognito, I was able to see the switch.