Complete CI/CD Pipeline with AWS EKS and ECR
Nathan Ojieabu
Complete CI/CD Pipeline with AWS EKS and ECR
A fully automated CI/CD pipeline using Jenkins to deploy Java applications to Amazon EKS with a private ECR registry.
Table of Contents
Introduction
This project implements a complete CI/CD workflow that automatically builds a Java Maven application, packages it into a Docker container, pushes it to Amazon ECR, and deploys it to EKS. The pipeline includes version management, automated testing, and deployment verification.
Technologies Used
- Kubernetes/EKS: Container orchestration
- Jenkins: CI/CD automation
- Docker/ECR: Container management
- Maven: Java build tool
- Spring Boot: Java application framework
- GitLab: Source control
Prerequisites
- AWS Account with EKS cluster
- Jenkins server with following tools:
aws-iam-authenticator
kubectl
Docker
Maven
- ECR repository named "java-maven-app"
- Required Jenkins credentials:
aws-ecr
gitlab-access
jenkins-aws-access-key-id
jenkins-aws-secret-access-key
Setup Instructions
-
Configure Jenkins Server:
# Install kubectl curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" chmod +x kubectl mv kubectl /usr/local/bin/ # Install aws-iam-authenticator curl -o aws-iam-authenticator https://amazon-eks.s3.us-west-2.amazonaws.com/1.21.2/2021-07-05/bin/linux/amd64/aws-iam-authenticator chmod +x aws-iam-authenticator mv aws-iam-authenticator /usr/local/bin/
-
Configure Kubernetes Access:
# Create .kube directory mkdir -p ~/.kube # Create and configure kubeconfig file # Add your cluster details to ~/.kube/config with: # - Cluster endpoint # - Certificate authority data # - Cluster name # - AWS region
-
Add Kubernetes Secrets:
kubectl create secret docker-registry aws-ecr-registry-credentials \ --docker-server=$AWS_ACCOUNT.dkr.ecr.$REGION.amazonaws.com \ --docker-username=AWS \ --docker-password=$(aws ecr get-login-password) \
-
Configure Jenkins Credentials:
- Add ECR credentials as "aws-ecr"
- Add AWS credentials for EKS access
- Add GitLab credentials for version commits
Pipeline Flow
- Increments application version
- Builds Java application with Maven
- Creates Docker image
- Pushes image to private ECR
- Deploys to EKS cluster
- Updates version in repository
Screenshot: Jenkins Pipeline Execution
Screenshot: ECR Repository with Images
Screenshot: EKS Cluster Dashboard
Screenshot: EKS Cluster Pods
Access Application
Once deployed, access the application at:
kubectl get svc java-maven-app-service -o wide