Skip to content

Repository files navigation

EKS Microservices Platform (AWS)

Complete production-ready EKS infrastructure with three Spring Boot microservices, secured frontend, and CI/CD pipeline.

🏗️ Architecture

  • Infrastructure: EKS cluster (3 nodes) on AWS
  • Microservices: Calculator, Weather, Live Traffic (Spring Boot)
  • Frontend: React-based GUI with authentication
  • Deployment: Helm charts
  • CI/CD: AWS CodePipeline + CodeBuild
  • IaC: Terraform
  • Container Registry: Amazon ECR

📁 Project Structure

eks-microservices-project/
├── terraform/               # Infrastructure as Code
│   ├── modules/
│   │   ├── vpc/            # VPC network module
│   │   ├── eks/            # EKS cluster module
│   │   └── ecr/            # ECR repository module
│   ├── main.tf
│   ├── variables.tf
│   ├── outputs.tf
│   └── terraform.tfvars.example
├── microservices/           # Spring Boot applications
│   ├── calculator/
│   ├── weather/
│   └── live-traffic/
├── frontend/                # React frontend with auth
├── helm-charts/             # Helm deployments
│   ├── calculator/
│   ├── weather/
│   ├── live-traffic/
│   └── frontend/
├── kubernetes/              # K8s manifests
├── buildspec/               # AWS CodeBuild specs
├── scripts/                 # Automation scripts
└── docs/                    # Documentation

🚀 Quick Start

Prerequisites

  1. AWS account with Free Tier or credits
  2. Install required tools:
    # Install AWS CLI v2
    curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
    unzip awscliv2.zip
    sudo ./aws/install
    
    # Install Terraform
    wget https://releases.hashicorp.com/terraform/1.6.0/terraform_1.6.0_linux_amd64.zip
    unzip terraform_1.6.0_linux_amd64.zip
    sudo mv terraform /usr/local/bin/
    
    # Install kubectl
    curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
    sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
    
    # Install Helm
    curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
    
    # Install eksctl (optional but useful)
    curl -sLO "https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_Linux_amd64.tar.gz"
    tar -xzf eksctl_Linux_amd64.tar.gz -C /tmp && sudo mv /tmp/eksctl /usr/local/bin

Step 1: Initial Setup

cd eks-microservices-project

# Configure AWS CLI
aws configure
# Enter: Access Key ID, Secret Access Key, Region (us-east-1), Output (json)

# Set environment variables
export AWS_REGION="us-east-1"
export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
export PROJECT_NAME="eks-microservices-rajesh"

Step 2: Deploy Infrastructure

cd terraform

cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars with your details

terraform init
terraform plan
terraform apply -auto-approve

# Update kubeconfig for EKS
aws eks update-kubeconfig \
    --region us-east-1 \
    --name eks-microservices-cluster

Step 3: Build and Push Docker Images

# Login to ECR
aws ecr get-login-password --region us-east-1 | \
    docker login --username AWS --password-stdin ${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com

chmod +x scripts/build-push-all.sh
./scripts/build-push-all.sh

Step 4: Deploy Applications with Helm

chmod +x scripts/deploy-all-helm.sh
./scripts/deploy-all-helm.sh

kubectl get pods -n microservices
kubectl get svc -n microservices

Step 5: Access the Application

kubectl get svc frontend-service -n microservices
# Access at http://<EXTERNAL-IP>
# Default credentials: admin / admin123

🔄 CI/CD with AWS CodePipeline

Setup CodeCommit Repository

# Create repository
aws codecommit create-repository \
    --repository-name eks-microservices-project \
    --repository-description "EKS Microservices Platform"

# Add remote and push
git remote add codecommit https://git-codecommit.us-east-1.amazonaws.com/v1/repos/eks-microservices-project
git push codecommit main

CodePipeline is created via Terraform (see terraform/main.tf)

🗑️ Cleanup/Decommission

Option 1: From Local Machine

cd terraform
terraform destroy -auto-approve

Option 2: Via Script

chmod +x scripts/destroy-all.sh
./scripts/destroy-all.sh

📊 Cost Optimization

  • EKS Cluster: $0.10/hour (~$73/month) for control plane
  • EC2 Nodes: t3.medium (3 nodes) ~$90/month
  • ALB: ~$20/month
  • ECR: Negligible for small images
  • Estimated monthly cost: ~$183/month

Cost Saving Tips

  1. Use Spot Instances:
    # Already configured in terraform/modules/eks/main.tf
    capacity_type = "SPOT"
  2. Scale down nodes when not in use:
    aws eks update-nodegroup-config \
        --cluster-name eks-microservices-cluster \
        --nodegroup-name eks-node-group \
        --scaling-config minSize=0,maxSize=3,desiredSize=0
  3. Delete when not in use:
    terraform destroy -auto-approve

🔐 Security Features

  • Authentication: Username/password on frontend
  • IAM Roles for Service Accounts (IRSA): Fine-grained pod permissions
  • Network Policies: Restricted pod communication via Calico
  • Security Groups: Controlled ingress/egress
  • Secrets Management: AWS Secrets Manager + K8s secrets
  • Private EKS: Optional private endpoint configuration

📞 Support

# CodeBuild logs
aws codebuild batch-get-builds --ids <build-id>

# Application logs
kubectl logs -f deployment/<service-name> -n microservices

# EKS cluster events
kubectl get events -n microservices --sort-by='.lastTimestamp'

About

Microservices on AWS EKS — Terraform IaC covering VPC, managed node groups, and IRSA, with Helm-packaged workloads and CI/CD

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages