This project showcases the implementation of a CI/CD pipeline for an e-commerce website composed of 11 microservices. The deployment platform is AWS EKS (Elastic Kubernetes Service).
- Ad Sense Service
- Cart Service
- Checkout Service
- Currency Service
- Email Service
- Frontend Service
- External Frontend (for load balancing)
- Payment Service
- Product Catalogue Service
- Recommendation Service
- Scalability: Independent scaling of services.
- Resilience: Service failures do not impact the entire system.
- Development Speed: Parallel development and quicker releases.
- Technology Diversity: Use of the best-suited technology for each service.
- Isolation and Maintenance: Easier to understand, develop, test, and maintain.
- Jenkinsfiles: Define steps for building, testing, and deploying each service.
- Docker: Containerization for consistent environments.
- AWS EKS: Managed Kubernetes service for deployment.
-
Create AWS IAM User
- Attach necessary policies:
AmazonEC2FullAccess
,AmazonEKS_CNI_Policy
, etc. - Create an inline policy for EKS access.
- Download
credentials.csv
.
- Attach necessary policies:
-
Launch Virtual Machine using AWS EC2
- Instance Type:
t2.large
- AMI: Ubuntu Server 20.04 LTS
- Configure security groups.
- Instance Type:
-
Install AWS CLI, EKSCTL & KUBECTL on VM Server
- AWSCLI:
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" sudo apt install unzip unzip awscliv2.zip sudo ./aws/install aws configure
- KUBECTL:
curl -o kubectl https://amazon-eks.s3.us-west-2.amazonaws.com/1.19.6/2021-01-05/bin/linux/amd64/kubectl chmod +x ./kubectl sudo mv ./kubectl /usr/local/bin kubectl version --short --client
- EKSCTL:
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp sudo mv /tmp/eksctl /usr/local/bin eksctl version
- AWSCLI:
-
Installing Jenkins on Ubuntu
#!/bin/bash sudo apt install openjdk-17-jre-headless -y sudo wget -O /usr/share/keyrings/jenkins-keyring.asc https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key 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 sudo apt-get update sudo apt-get install jenkins -y
-
**Create EKS Cluster **
eksctl create cluster --name=EKS-1 --region=ap-south-1 --zones=ap-south-1a,ap-south-1b --without-nodegroup eksctl utils associate-iam-oidc-provider --region ap-south-1 --cluster EKS-1 --approve eksctl create nodegroup --cluster=EKS-1 --region=ap-south-1 --name=node2 --node-type=t3.medium --nodes=3 --nodes-min=2 --nodes-max=4 --node-volume-size=20 --ssh-access --ssh-public-key=DevOps --managed --asg-access --external-dns-access --full-ecr-access --appmesh-access --alb-ingress-access
- Docker
- Docker Pipeline
- Kubernetes
- Kubernetes CLI
- Multibranch Scan Webhook Trigger
- Docker Credentials:
docker-cred
- GitHub Credentials:
git-cred
- Add repository URL and GitHub credentials.
- Configure webhook trigger with the generated URL.
-
service account
apiVersion: v1 kind: ServiceAccount metadata: name: jenkins namespace: webapps
-
Role
apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: app-role namespace: webapps rules: - apiGroups: [""] resources: ["pods", "services"] verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
-
Role Binding
apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: app-rolebinding namespace: webapps roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: app-role subjects: - kind: ServiceAccount name: jenkins namespace: webapps
-
Secret
apiVersion: v1 kind: Secret metadata: name: mysecretname annotations: kubernetes.io/service-account.name: jenkins
pipeline {
agent any
stages {
stage('Deploy To Kubernetes') {
steps {
withKubeCredentials(kubectlCredentials: [[caCertificate: '', clusterName: 'EKS-1', contextName: '', credentialsId: 'k8-token', namespace: 'webapps', serverUrl: 'https://B7C7C20487B2624AAB0AD54DF1469566.yl4.ap-south-1.eks.amazonaws.com']]) {
sh "kubectl apply -f deployment-service.yml"
}
}
}
stage('Verify Deployment') {
steps {
withKubeCredentials(kubectlCredentials: [[caCertificate: '', clusterName: 'EKS-1', contextName: '', credentialsId: 'k8-token', namespace: 'webapps', serverUrl: 'https://B7C7C20487B2624AAB0AD54DF1469566.yl4.ap-south-1.eks.amazonaws.com']]) {
sh "kubectl get svc -n webapps"
}
}
}
}
}
- Automated CI/CD pipeline for 11 microservices.
- Scalable and resilient e-commerce website on AWS EKS.
- Continuous feedback from Jenkins builds.
- Reduced time and effort for manual deployments.
- Automated testing and deployment for early issue detection.
- Efficient handling of varying loads.
- Simplified maintenance and updates.
The successful deployment of the e-commerce website using a microservices architecture and an automated CI/CD pipeline on AWS EKS exemplifies the advantages of modern software development practices. This project not only achieves the goals of scalability, reliability, and efficiency but also sets a strong foundation for future enhancements and growth. The methodologies and technologies employed in this project can serve as a blueprint for similar projects aiming to leverage microservices and CI/CD pipelines for continuous innovation and delivery.