An open API service indexing awesome lists of open source software.

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

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. |

---


## πŸ“ Appendix: Files

### [deployments.yaml](deployments.yaml)

### [dockerfile](dockerfile)

### [jenkinsfile](jenkinsfile)

---

## πŸ“„ License

This project is open source and available under the [MIT License](LICENSE).

-----

## ✍️ Author



Swapnil Mali


SWAPNIL MALI.




GitHub Profile


πŸ‘¨πŸ»β€πŸ’»CS Engineer | AWS & DevOps Specialist -🎯focused on building reliable, observable, and scalable systems.



---

[πŸ”](#top)