This project is a SpringBoot application developed to demonstrate a Continuous Integration and Continuous Deployment (CI/CD) pipeline using Docker, Jenkins, ArgoCD, Kubernetes, and SonarQube. The application serves as a template for developers to understand and implement CI/CD practices in their SpringBoot projects. The entire setup is deployed on an AWS EC2 instance, showcasing a cloud-based infrastructure for continuous integration and deployment.
- SpringBoot application template.
- CI/CD pipeline implemented with Docker, Jenkins, ArgoCD, Kubernetes, and SonarQube.
- Docker containers for building, testing, and deploying the application.
- Jenkins for automating build, test, and deployment processes.
- ArgoCD for continuous delivery and GitOps-based deployment.
- Kubernetes for container orchestration and deployment.
- SonarQube for code quality analysis and static code scanning.
- AWS EC2 instance for hosting the entire setup.
- AWS account with EC2 access.
- Basic knowledge of AWS services.
- Docker installed on your EC2 instance.
- Kubernetes cluster configured on PC (e.g., Minikube, Docker Desktop Kubernetes, or any cloud provider).
- Jenkins installed and configured on EC2.
- ArgoCD setup with access to your Kubernetes cluster.
- SonarQube server accessible from your EC2 instance.
- Launch an EC2 instance on AWS with appropriate permissions.
- Go to AWS Console
- Instances
- Launch instances
- EC2 > Instances
- In the bottom tabs -> Click on Security
- Security groups
- Add inbound traffic rules
- Allow TCP port:
8080
(for Jenkins) & port:9000
(for Sonarqube)
- SSH into your EC2 instance.
- Clone this repository to your EC2 instance.
git clone https://github.com/ARUP-G/Java-CICD-Implementation
- Navigate to the project directory.
cd Java-CICD-Implementation/spring-boot-app
- Build the Docker image.
dokcer build -t spring-boot-app .
- Run the Docker container locally for testing.
docker run -d -p 8000:8000 spring-boot-app
- Access the application at
http://your_ec2_public_ip:8000
.
- Update existing packages
sudo apt update
- Download Java (JDK) for Jenkins to run
sudo apt install openjdk-17-jre -y
- Download Jenkins
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins
- Check if Jenkins Running properly
ps -ef | grep jennkins
- Can Access the jenkins in
http://your_ec2_public_ip:8080
- For admin password
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
- Docker install for build and pipeline agent
sudo apt install docker.io
- Grant Jenkins user and Ubuntu user permission to docker deamon
sudo su -
usermod -aG docker jenkins
usermod -aG docker ubuntu
systemctl restart docker
The CI/CD pipeline is implemented with Jenkins and ArgoCD:
- Triggering the pipeline on code commits.
- Building the Docker image.
- Scanning code with SonarQube.
- Pushing the Docker image to the Docker registry.
- Update imageTag in deployment manifest repository .
- ArgoCD continuously monitors the Git repository for changes and automatically deploys the application to Kubernetes clusters.
- Install necessary plugins: Docker Pipeline, Kubernetes Continuous Deploy, SonarQube Scanner, etc.
- Configure Jenkins credentials for Docker registry
'docker-cred'
, Github'github'
, and SonarQube server token'sonarqube'
. - Create a Jenkins pipeline job and configure the pipeline script from Jenkinsfile with proper path
spring-boot-app/Jenkinsfile
.
- Start Minikube cluster on PC (For Minikube Installation "https://minikube.sigs.k8s.io/docs/start/")
minikube start
- Create namespace
kubectl create namespace argocd
- Install ArgoCD
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
- To show all the services of Argocd
kubectl get services -n argocd
- To connect to ArgoCD server
kubectl edit svc argocd-server -n argocd
# in the text/yaml file change the type from ClustreIP to NodePort and save
type: NodePort
- Create tunnel to Argocd-server
minikube service argocd-server -n argocd
- Click any of 2 IP provided by Minikube and open ArgoCD
- Secret to Login & decode it from base64
kubectl get secret -n argocd
kubectl edit secret argocd-initial-admin-secret -n argocd
- Create ArgoCD application
- Check Spring-boot-application
- Install and configure SonarQube server (Docker image).
docker run -d -p 9000:9000 sonarqube:lts-community
- Access SonarQube server
"http://your_ec2_public_ip:9000"
- Set up a SonarQube project for your SpringBoot application and modify
Static Code Analysis
stage and updateSONAR_URL
SONAR_URL = "http://your_ec2_public_ip:9000"
- Obtain SonarQube access token and configure it in Jenkins under credentials.
- Monitor the CI/CD pipeline execution in Jenkins.
- Monitor application health and performance in ArgoCD dashboard.
- Analyze code quality and vulnerabilities in SonarQube.
- Ensure proper security configurations on your AWS EC2 instance, including security groups, IAM roles, and network access control.
This project is licensed under the Apache License.
Arup Das
Special thanks to the developers of Docker, Jenkins, ArgoCD, Kubernetes, and SonarQube for their fantastic tools and contributions to the open-source community.