A production-ready Amazon EKS (Elastic Kubernetes Service) infrastructure deployed using AWS CloudFormation, featuring automated deployment of a scalable microservices architecture with MongoDB persistence, load balancing, and high availability.
This project implements a complete cloud-native infrastructure on AWS with the following components:
- VPC: Custom Virtual Private Cloud with 6 subnets across 3 availability zones
- 3 Public subnets for load balancers and NAT gateways
- 3 Private subnets for application workloads
- Internet Gateway for public connectivity
- 3 NAT Gateways for high availability
- EKS Cluster: Managed Kubernetes cluster (v1.28+)
- Node Group: Auto-scaling group of EC2 instances (t3.medium)
- Min: 2 nodes
- Desired: 3 nodes
- Max: 6 nodes
- EBS CSI Driver: For persistent volume support
- Application Load Balancer: Internet-facing load balancer for external traffic
- MongoDB: StatefulSet with 10GB persistent storage
- Backend Service: 3 replicas with ClusterIP service
- Frontend Service: 3 replicas with LoadBalancer service
- Ingress: Traffic routing for microservices
- AWS CLI configured with appropriate credentials
- kubectl installed
- Docker Desktop (optional, for custom images)
- AWS Account with permissions for:
- EKS
- EC2
- VPC
- CloudFormation
- IAM
- EBS
Upload the CloudFormation templates in this order:
Stack Name: eks-vpc-stack
Template: 1-vpc-stack.yaml
Parameters: Use defaults (all CIDR ranges pre-configured)Stack Name: eks-cluster-stack
Template: 2-eks-cluster-stack.yaml
Parameters:
- EnvironmentName: eks-prod
- KubernetesVersion: 1.28
Capabilities: Check "I acknowledge that AWS CloudFormation might create IAM resources"
Wait Time: ~15 minutesStack Name: eks-nodegroup-stack
Template: 3-eks-nodegroup-stack.yaml
Parameters:
- NodeInstanceType: t3.medium
- NodeAutoScalingGroupMinSize: 2
- NodeAutoScalingGroupDesiredCapacity: 3
- NodeAutoScalingGroupMaxSize: 6
Wait Time: ~5 minutes# Update kubeconfig
aws eks update-kubeconfig --region us-east-1 --name eks-prod --profile default
# Verify connection
kubectl get nodes# Create access entry for your IAM user
aws eks create-access-entry \
--cluster-name eks-prod \
--principal-arn arn:aws:iam::YOUR_ACCOUNT_ID:user/YOUR_USERNAME \
--region us-east-1
# Associate admin policy
aws eks associate-access-policy \
--cluster-name eks-prod \
--principal-arn arn:aws:iam::YOUR_ACCOUNT_ID:user/YOUR_USERNAME \
--access-scope type=cluster \
--policy-arn arn:aws:eks::aws:cluster-access-policy/AmazonEKSClusterAdminPolicy \
--region us-east-1aws eks create-addon \
--cluster-name eks-prod \
--addon-name aws-ebs-csi-driver \
--region us-east-1# Get subnet IDs
aws ec2 describe-subnets --region us-east-1 \
--filters "Name=tag:Name,Values=eks-prod-public-subnet-*" \
--query "Subnets[].SubnetId" --output table
# Tag subnets (replace with your actual subnet IDs)
aws ec2 create-tags \
--resources subnet-XXXXX subnet-YYYYY subnet-ZZZZZ \
--tags Key=kubernetes.io/role/elb,Value=1 \
--region us-east-1
aws ec2 create-tags \
--resources subnet-XXXXX subnet-YYYYY subnet-ZZZZZ \
--tags Key=kubernetes.io/cluster/eks-prod,Value=shared \
--region us-east-1# Deploy all components
kubectl apply -f namespace.yaml
kubectl apply -f mongodb-statefulset.yaml
kubectl apply -f backend-deployment.yaml
kubectl apply -f frontend-deployment.yaml
kubectl apply -f ingress.yaml
# Verify deployments
kubectl get pods -n microservices
kubectl get svc -n microservices# Get LoadBalancer URL
kubectl get svc frontend -n microservices
# Access the application
# http://<EXTERNAL-IP>eks-cft-project/
βββ cloudformation/
β βββ 1-vpc-stack.yaml # VPC and networking
β βββ 2-eks-cluster-stack.yaml # EKS cluster and IAM roles
β βββ 3-eks-nodegroup-stack.yaml # Worker nodes
β βββ namespace.yaml # Kubernetes namespace
β βββ mongodb-statefulset.yaml # MongoDB database
β βββ backend-deployment.yaml # Backend service
β βββ frontend-deployment.yaml # Frontend service
β βββ ingress.yaml # Ingress routing
βββ config.env # Environment configuration
βββ README.md # This file
βββ QUICKSTART.md # Quick reference guide
- VPC CIDR: 10.0.0.0/16
- Public Subnets: 10.0.1.0/24, 10.0.2.0/24, 10.0.3.0/24
- Private Subnets: 10.0.11.0/24, 10.0.12.0/24, 10.0.13.0/24
- Availability Zones: 3 (us-east-1a, us-east-1b, us-east-1c)
- Name: eks-prod
- Kubernetes Version: 1.28+
- Endpoint Access: Public and Private
- Logging: Enabled (API, Audit, Authenticator, Controller Manager, Scheduler)
- Instance Type: t3.medium
- Min Nodes: 2
- Desired Nodes: 3
- Max Nodes: 6
- Volume Size: 50GB (gp3, encrypted)
- AMI: Amazon Linux 2 (EKS optimized)
- MongoDB: 1 replica, 10GB persistent volume
- Backend: 3 replicas, 256Mi-512Mi memory
- Frontend: 3 replicas, 128Mi-256Mi memory
# All resources
kubectl get all -n microservices
# Pods
kubectl get pods -n microservices
# Services
kubectl get svc -n microservices
# Persistent Volumes
kubectl get pvc -n microservices# Backend logs
kubectl logs -f deployment/backend -n microservices
# Frontend logs
kubectl logs -f deployment/frontend -n microservices
# MongoDB logs
kubectl logs mongodb-0 -n microservices# Scale backend
kubectl scale deployment backend --replicas=5 -n microservices
# Scale frontend
kubectl scale deployment frontend --replicas=5 -n microservices# Update backend image
kubectl set image deployment/backend backend=YOUR_REGISTRY/backend:v2 -n microservices
# Update frontend image
kubectl set image deployment/frontend frontend=YOUR_REGISTRY/frontend:v2 -n microservices- IAM Roles for Service Accounts (IRSA): OIDC provider configured
- Network Segmentation: Private subnets for workloads, public for LBs
- Encrypted EBS Volumes: All persistent data encrypted at rest
- Security Groups: Cluster control plane security group
- Private API Endpoint: Available for enhanced security
- IMDSv2: Required on all EC2 instances
Estimated monthly costs (us-east-1):
- EKS Cluster: ~$73/month
- 3x t3.medium nodes: ~$100/month
- 3x NAT Gateways: ~$100/month
- EBS Volumes: ~$5/month
- Load Balancer: ~$20/month
- Data Transfer: Variable
Total: ~$300-350/month
- Use Spot instances for non-critical workloads
- Reduce NAT gateways to 1 for dev/test
- Use smaller instance types for testing
- Enable cluster autoscaler for dynamic scaling
- Delete resources when not in use
To delete all resources and avoid charges:
# Delete Kubernetes resources
kubectl delete namespace microservices
# Delete CloudFormation stacks (in reverse order)
aws cloudformation delete-stack --stack-name eks-nodegroup-stack --region us-east-1
# Wait for completion (~5 minutes)
aws cloudformation delete-stack --stack-name eks-cluster-stack --region us-east-1
# Wait for completion (~10 minutes)
aws cloudformation delete-stack --stack-name eks-vpc-stack --region us-east-1
# Wait for completion (~5 minutes)
# Verify all resources deleted
aws cloudformation list-stacks --region us-east-1 \
--stack-status-filter DELETE_COMPLETE# Describe pod
kubectl describe pod POD_NAME -n microservices
# Check events
kubectl get events -n microservices --sort-by='.lastTimestamp'# Verify subnet tags
aws ec2 describe-subnets --subnet-ids SUBNET_ID
# Required tags:
# - kubernetes.io/role/elb = 1
# - kubernetes.io/cluster/eks-prod = shared# Update kubeconfig
aws eks update-kubeconfig --region us-east-1 --name eks-prod
# Verify IAM permissions
aws sts get-caller-identity
# Check access entry
aws eks list-access-entries --cluster-name eks-prod --region us-east-1# Verify EBS CSI driver
kubectl get pods -n kube-system | grep ebs-csi
# Check PVC status
kubectl get pvc -n microservices- AWS EKS Documentation
- Kubernetes Documentation
- AWS CloudFormation Documentation
- EKS Best Practices Guide
This is a learning/demonstration project. Feel free to:
- Fork and customize for your needs
- Report issues or suggest improvements
- Share your deployment experiences
This project is provided as-is for educational and demonstration purposes.
Created as a demonstration of enterprise-grade AWS EKS infrastructure deployment using Infrastructure as Code (IaC) principles.
β Automated infrastructure deployment with CloudFormation β High availability across 3 availability zones β Auto-scaling node groups (2-6 nodes) β Persistent storage with EBS CSI driver β Production-ready networking with NAT gateways β Secure IAM roles and OIDC integration β Load-balanced, publicly accessible application β Comprehensive monitoring and logging enabled
Status: β Deployed and Operational
Last Updated: February 2026