This project demonstrates how to set up a complete CI/CD pipeline for deploying a simple NGINX web app into an Amazon EKS cluster using Jenkins.
π CI/CD Pipeline Implementation Guide (GitHub β Jenkins β Docker Hub β Amazon EKS)
This document explains the steps to set up and implement a CI/CD pipeline that deploys a simple NGINX web app into Amazon EKS using Jenkins, Docker Hub, and Kubernetes.
Before starting, ensure the following are installed and configured:
AWS Account with IAM user or IAM role (with EKS and ECR/Docker permissions).
Amazon EKS Cluster created and running.
EC2 Instance (for Jenkins setup).
Docker Hub account.
Tools on Jenkins server:
Terraform
Docker
AWS CLI v2
Kubectl
eksctl
Git
1οΈβ£ Update System
sudo apt update && sudo apt upgrade -y
2οΈβ£ Install Git
sudo apt install git -y
git --version
3οΈβ£ Install Java (required for Jenkins)
sudo apt install openjdk-11-jdk -y
java -version
4οΈβ£ Install Jenkins
# Add Jenkins key and repo
curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
/usr/share/keyrings/jenkins-keyring.asc > /dev/null
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
# Install Jenkins
sudo apt update
sudo apt install jenkins -y
# Enable & start Jenkins
sudo systemctl enable jenkins
sudo systemctl start jenkins
sudo systemctl status jenkins
Access Jenkins at:
π http://<your-server-ip>:8080
5οΈβ£ Install Terraform
sudo apt install wget unzip -y
wget https://releases.hashicorp.com/terraform/1.9.8/terraform_1.9.8_linux_amd64.zip
unzip terraform_1.9.8_linux_amd64.zip
sudo mv terraform /usr/local/bin/
terraform -version
6οΈβ£ Install kubectl
curl -LO "https://dl.k8s.io/release/$(curl -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/
kubectl version --client
7οΈβ£ Install Docker
# Remove old versions if any
sudo apt remove docker docker-engine docker.io containerd runc -y
# Install packages
sudo apt update
sudo apt install ca-certificates curl gnupg lsb-release -y
# Add Docker GPG key
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
# Add repo
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Install Docker Engine
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
# Add user to docker group (no sudo needed for docker)
sudo usermod -aG docker jenkins
# Verify
docker --version
8οΈβ£ Install AWS CLI v2
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
# Verify
aws --version
aws configure
Enter:
AWS Access Key ID
AWS Secret Access Key
Default region (e.g., us-east-1)
Output format (json recommended)
β Verification Checklist
Run these to confirm:
git --version
java -version
jenkins --version # or check service
terraform -version
kubectl version --client
docker --version
aws --version
1.Initialize Terraform
terraform init
Downloads required provider plugins (AWS, Kubernetes, etc).
Prepares .terraform working directory.
- Validate Configuration
terraform validate
Checks syntax and configuration correctness.
- Review the Execution Plan
terraform plan
Shows what resources will be created.
- Apply to Provision Resources
terraform apply
Provisions the EKS cluster, VPC, and Node Groups.
- Update kubeconfig
aws eks --region <your-region> update-kubeconfig --name <your-cluster-name>
Example:
aws eks --region us-east-1 update-kubeconfig --name Vishnu-demo
Create a new GitHub repository.
Add the following files:
index.html β Your application code.
Dockerfile β Instructions to build a custom Docker image.
Kubernetes manifests (deployment.yaml, service.yaml) β Define how the app runs on EKS.
README.md β Documentation.
Install Jenkins on an EC2 instance (Ubuntu recommended).
Install required plugins:
Docker
Kubernetes CLI
AWS Credentials
Git
Create credentials in Jenkins:
dockerhub-creds β Docker Hub username/password or token.
aws-creds β AWS IAM userβs access key and secret.
The pipeline will have these stages:
Clone Repository
Pulls the application code and manifests from GitHub.
Build Docker Image
Uses the Dockerfile to build a custom NGINX image containing index.html.
Push to Docker Hub
Pushes the built image to your Docker Hub repository.
Update Deployment Manifest
Replaces the image tag in the Kubernetes manifest with the new build version.
Deploy to Amazon EKS
Uses AWS CLI and kubectl to apply the updated deployment and service YAML files to the cluster.
β Update kubeconfig for EKS
aws eks --region us-east-1 update-kubeconfig --name Vishnu-demo
Jenkins updates the kubeconfig dynamically using:
AWS CLI + update-kubeconfig.
The Kubernetes deployment and service are applied.
A LoadBalancer service is created in AWS.
AWS assigns an external IP or DNS.
Run:
kubectl get svc nginx-service
Note the EXTERNAL-IP.
Open it in a browser β Youβll see the custom NGINX page.
Developer pushes code β GitHub.
Jenkins pipeline triggers automatically.
Docker image is built β pushed to Docker Hub.
Kubernetes manifests updated.
Jenkins deploys app to Amazon EKS.
Application becomes accessible via LoadBalancer IP.
π The pipeline flow:
Terraform | GitHub β Jenkins β Docker Hub β Amazon EKS β LoadBalancer β User