https://github.com/swapnilmali101/java-blog-site-cicd-eks-project
This project demonstrates a DevOps pipeline integrating Jenkins, Docker, and AWS EKS (Kubernetes) to achieve Continuous Integration and Continuous Deployment (CI/CD) for a Java web application. The application is containerized using Tomcat, monitored with Prometheus and Grafana, and automatically deployed to EKS
https://github.com/swapnilmali101/java-blog-site-cicd-eks-project
aws aws-ec2 aws-eks aws-eks-cluster docker dockerhub git github jenkins jenkinspipeline kubectl kubernetes kubernetes-cluster kubernetes-deployment
Last synced: 1 day ago
JSON representation
This project demonstrates a DevOps pipeline integrating Jenkins, Docker, and AWS EKS (Kubernetes) to achieve Continuous Integration and Continuous Deployment (CI/CD) for a Java web application. The application is containerized using Tomcat, monitored with Prometheus and Grafana, and automatically deployed to EKS
- Host: GitHub
- URL: https://github.com/swapnilmali101/java-blog-site-cicd-eks-project
- Owner: swapnilmali101
- License: mit
- Created: 2025-11-01T12:51:29.000Z (8 months ago)
- Default Branch: master
- Last Pushed: 2026-06-18T01:59:18.000Z (6 days ago)
- Last Synced: 2026-06-18T03:25:58.632Z (6 days ago)
- Topics: aws, aws-ec2, aws-eks, aws-eks-cluster, docker, dockerhub, git, github, jenkins, jenkinspipeline, kubectl, kubernetes, kubernetes-cluster, kubernetes-deployment
- Language: Java
- Homepage: https://github.com/swapnilmali101/java-blog-site-cicd-eks-project
- Size: 86.9 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# π AWS EKS + Jenkins CI/CD β Project With Workflow Execution.
> **Repository:** [java-blog-site-cicd-eks-project](https://github.com/swapnilmali101/java-blog-site-cicd-eks-project.git)
---
## π§© About the Project
This project demonstrates a **DevOps pipeline** integrating **Jenkins**, **Docker**, and **AWS EKS (Kubernetes)** to achieve **Continuous Integration and Continuous Deployment (CI/CD)** for a Java web application. The application is containerized using **Tomcat**, monitored with **Prometheus** and **Grafana**, and automatically deployed to **EKS** using a Jenkins pipeline.
---
## π Table of Contents
1. [Overview](#overview)
2. [Prerequisites](#prerequisites)
3. [Prepare AWS and IAM](#prepare-aws-and-iam)
4. [Launch EC2 for Jenkins](#launch-ec2-for-jenkins)
5. [Install Required Software](#install-required-software)
6. [Configure Jenkins](#configure-jenkins)
7. [Create IAM Roles for EKS](#create-iam-roles-for-eks)
8. [Create EKS Cluster](#create-eks-cluster)
9. [Jenkins Pipeline Explanation](#jenkins-pipeline-explanation)
10. [Run & Verify Deployment](#verify-deployment)
11. [Troubleshooting](#troubleshooting)
12. [Appendix: Files](#appendix-files)
---
## π§ Overview
- π **Jenkins** automates: Code β Build β Dockerize β Push β Deploy.
- π³ **Docker Hub** hosts the built image (`swapnilmali101/java-blog-site-image`).
- βΈοΈ **AWS EKS** runs the application in Kubernetes pods.
- π **Prometheus** and **Grafana** provide monitoring and visualization.
---
## βοΈ Prerequisites
- β
AWS Account with required permissions (EC2, EKS, IAM).
- β
Docker Hub account: `swapnilmali101`.
- β
GitHub repository: [java-blog-site-cicd-eks-project](https://github.com/swapnilmali101/java-blog-site-cicd-eks-project.git).
- β
Local setup or EC2 instance with AWS CLI and kubectl installed.
---
## π§± 1. Prepare AWS and IAM
1. Go to **AWS Console β IAM**.
2. Create an **IAM User** with *programmatic access*.
3. Save **Access Key ID** and **Secret Key**.
4. Attach permissions for EC2, EKS, and S3.
5. These credentials will later be used for Jenkins configuration.
---
## βοΈ 2. Launch EC2 for Jenkins
| Parameter | Value |
|------------|-------|
| **AMI** | Amazon Linux 2 |
| **Instance Type** | t3.large |
| **Storage** | 30 GiB |
| **Ports** | 22 (SSH), 8080 (Jenkins), 80/443 (optional) |
π Create or select an SSH key pair for EC2 access.
---
## π§° 3. Install Required Software
SSH into EC2 and run:
```bash
sudo yum update -y
sudo yum install -y java-11-amazon-corretto docker maven
# Jenkins setup
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
sudo yum install -y jenkins
sudo systemctl enable --now jenkins
# Docker permissions
sudo systemctl enable --now docker
sudo usermod -aG docker jenkins
# kubectl installation
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo chmod +x kubectl
sudo mv kubectl /usr/bin/
sudo usermod -s /bin/bash jenkins
grep jenkins /etc/passwd
```
π Access Jenkins: `http://:8080`
---
## π§© 4. Configure Jenkins
1. Unlock Jenkins using `/var/lib/jenkins/secrets/initialAdminPassword`.
2. Install **recommended plugins** (Git, Pipeline, Docker Pipeline, Kubernetes).
3. Add credentials:
- π³ **Docker Hub:** Username & password β ID: `dockerhub-pass`
---
## π 5. Create IAM Roles for EKS
1. **Master Role:** Use case β EKS Cluster.
- Attach policies:
- `AmazonEKSClusterPolicy`
3. **Worker Node Role:** Use case β EC2.
- Attach policies:
- `AmazonEKS_CNI_Policy`
- `AmazonEC2ContainerRegistryReadOnly`
- `AmazonEKSWorkerNodePolicy`
---
## βΈοΈ 6. Create EKS Cluster
```bash
eksctl create cluster \
--name moster-node \
--version 1.27 \
--region ap-southeast-1 \
--nodegroup-name worker-nodes \
--node-type t3.medium \
--nodes 2 \
--nodes-min 2 \
--nodes-max 3
```
Then configure:
```bash
aws eks update-kubeconfig --region ap-southeast-1 --name master-node
kubectl get nodes
```
---
## π§© 7. Jenkins Pipeline Explanation
The provided Jenkinsfile stages:
- Git Checkout: clone the repo.
- Maven Build: mvn clean package to produce the WAR.
- Docker Build: build image java-blog-site-image:v${BUILD_NUMBER} .
- Docker Login & Push: login to Docker Hub (credential dockerhub-pass), tag and push.
- Update Deployment File: update deployments.yaml to new tag using sed.
- Kubernetes Deployment: apply deployments.yaml
Important Jenkins credential IDs used in the Jenkinsfile must match those created earlier.
---
## β
8. Run & Verify Deployment
1. Run Jenkins pipeline.
2. Check Docker Hub for image tag `v{BUILD_NUMBER}`.
3. Validate deployment:
```bash
kubectl get pods -o wide
kubectl get svc
```
4. π Access app: `http://:NodePort_Number`
---
## π§ 9. Troubleshooting
| Problem | Fix |
|----------|------|
| **ImagePullBackOff** | Ensure image tag matches Docker Hub tag. |
| **kubectl not found** | Confirm `/usr/bin/kubectl` exists & executable. |
| **Permission denied (Docker)** | Restart Jenkins after `usermod -aG docker jenkins`. |
| **AWS CLI error** | Re-run `aws configure` with correct keys. |
| **Pods stuck pending** | Verify node role and subnet permissions. |
---
### [deployments.yaml](deployments.yaml)
### [dockerfile](dockerfile)
### [jenkinsfile](jenkinsfile)
---
## π License
This project is open source and available under the [MIT License](LICENSE).
-----
## βοΈ Author
SWAPNIL MALI.
π¨π»βπ»CS Engineer | AWS & DevOps Specialist -π―focused on building reliable, observable, and scalable systems.
---
[π](#top)