RA2211027010116
RA2211027010116
CI/CD Pipeline to Deploy Dockerized Application on Kubernetes using Jenkins, GitHub, Maven,
Terraform, and Ansible
🎯 Objective:
To build and deploy a Dockerized Java web application to a Kubernetes cluster on AWS using a fully
automated CI/CD pipeline with Jenkins, Maven, GitHub, Terraform, and Ansible.
Terraform (IaC)
Docker (Containerization)
Jenkins (CI/CD)
Kubernetes (Orchestration)
📋 Step-by-Step Procedure
1. Install Terraform:
terraform init
terraform plan
terraform apply
1. Install Ansible:
4. Run Playbook:
o GitHub
o Docker Hub
Jenkinsfile example:
groovy
pipeline {
agent any
tools {
maven 'Maven 3.8.1'
}
environment {
DOCKER_IMAGE = "yourdockerhubusername/sample-java-app:${BUILD_NUMBER}"
}
stages {
stage('Checkout Code') {
steps {
git 'https://github.com/your-username/sample-java-app.git'
}
}
stage('Build with Maven') {
steps {
sh 'mvn clean package'
}
}
stage('Build Docker Image') {
steps {
sh 'docker build -t $DOCKER_IMAGE .'
}
}
stage('Push to Docker Hub') {
steps {
withDockerRegistry([credentialsId: 'docker-hub-creds']) {
sh 'docker push $DOCKER_IMAGE'
}
}
}
stage('Deploy to Kubernetes') {
steps {
sh 'kubectl set image deployment/sample-app-deployment sample-
container=$DOCKER_IMAGE'
}
}
}
}
o Deployment
o Service (NodePort/LoadBalancer)
1. Make a code change in GitHub (e.g., update a string in the Java app).
2. Jenkins will:
o Pull code
http://<LoadBalancer-DNS or NodePort-IP>
✅ Expected Outcome:
Needs Improvement (0
Criteria Excellent (1 Marks) Good (0.5 Mark)
Mark)
1. Infrastructure Fully functional AWS infra with Partially functional infra, Infrastructure not
Provisioning (Terraform) EC2 & EKS minor issues provisioned or fails entirely
2. Configuration Jenkins and dependencies Partial setup; minor Jenkins not installed or
Management (Ansible) correctly installed misconfigurations major errors
3. CI/CD Pipeline in Pipeline works end-to-end with Pipeline executes partially; Pipeline fails or is not
Jenkins all stages minor stage issues configured
4. Dockerization & Image Docker image built and pushed Image built but push or tag Docker image not built or
Management to Docker Hub missing pushed
5. Kubernetes Application deployed and App deployed but not Deployment failed or not
Deployment accessible via service accessible properly attempted
6. Version Control GitHub repo connected and GitHub integrated but manual No GitHub integration or
Integration (GitHub) automated builds work triggers used broken webhook