0% found this document useful (0 votes)
20 views7 pages

RA2211027010116

Uploaded by

studylets138
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views7 pages

RA2211027010116

Uploaded by

studylets138
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Virtual Lab Experiment – 6

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.

🛠️ Tools & Technologies Used

 Terraform (IaC)

 Ansible (Configuration Management)

 Docker (Containerization)

 Jenkins (CI/CD)

 GitHub (Source Control)

 Maven (Build Automation)

 Kubernetes (Orchestration)

 AWS (Cloud Infrastructure)

📋 Step-by-Step Procedure

🔹 STEP 1: Clone Java Application from GitHub

1. Use a sample Maven-based Java web app (e.g., Spring Boot).

2. Fork or clone it from GitHub:

git clone https://github.com/your-username/sample-java-app.git


🔹 STEP 2: Provision Infrastructure Using Terraform

1. Install Terraform:

sudo apt-get install terraform

2. Create Terraform scripts to:

o Provision an EC2 instance for Jenkins

o Create an EKS (Elastic Kubernetes Service) cluster

o Set up IAM roles, security groups, and networking (VPC, Subnets)

3. Initialize & Apply Terraform:

terraform init
terraform plan

terraform apply

🔹 STEP 3: Configure Jenkins Server Using Ansible

1. Install Ansible:

sudo apt install ansible

2. Create Inventory File with Jenkins EC2 IP.


3. Write Ansible Playbook to:

o Install Java, Jenkins, Docker, kubectl, and Maven

o Start and enable Jenkins service

o Add Jenkins user to Docker group

4. Run Playbook:

ansible-playbook install-jenkins.yml -i inventory

🔹 STEP 4: Configure Jenkins for CI/CD

1. Access Jenkins via browser: http://<jenkins-ec2-ip>:8080

2. Install required plugins:

o GitHub, Maven Integration, Docker, Kubernetes CLI

3. Create Jenkins Credentials for:

o GitHub

o Docker Hub

o AWS IAM Access

4. Create a new Jenkins Pipeline Job.


🔹 STEP 5: Write Jenkinsfile for CI/CD Pipeline

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'
}
}
}
}

🔹 STEP 6: Create Kubernetes Deployment Files

1. Write YAML files for:

o Deployment

o Service (NodePort/LoadBalancer)

2. Deploy manually once:

kubectl apply -f deployment.yaml

kubectl apply -f service.yaml

🔹 STEP 7: Verify CI/CD Pipeline Execution

1. Make a code change in GitHub (e.g., update a string in the Java app).

2. Jenkins will:

o Pull code

o Build with Maven

o Build and push Docker image

o Deploy new version to Kubernetes

3. Access the app via:

http://<LoadBalancer-DNS or NodePort-IP>
✅ Expected Outcome:

 Fully functional CI/CD pipeline

 Automatic code build, Docker packaging, and deployment to Kubernetes on AWS

Rubric (Total: 6 Marks)

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy