Skip to content

shimon23/ecommerce-microservices

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

E-Commerce Microservices Platform

Status Azure Python Kubernetes Terraform

Production-ready microservices platform deployed on Azure AKS, demonstrating modern DevOps practices, cloud-native architecture, and infrastructure as code.

🎬 Live Demo | πŸ“– Documentation | πŸš€ Deployment Guide


🎯 Project Overview

A complete end-to-end DevOps implementation showcasing:

  • πŸ—οΈ Infrastructure as Code with Terraform
  • ☁️ Cloud Deployment on Azure AKS
  • 🐳 Containerization with Docker
  • ⎈ Orchestration with Kubernetes & Helm
  • πŸ”„ CI/CD workflows (in progress)
  • πŸ“Š Observability & monitoring (planned)

πŸ—οΈ Architecture

                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚   Azure Cloud       β”‚
                    β”‚                     β”‚
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
    β”‚  Azure Kubernetes Service (AKS)  β”‚  β”‚
    β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚
    β”‚  β”‚   Ingress Controller       β”‚  β”‚  β”‚
    β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚
    β”‚             β”‚                     β”‚  β”‚
    β”‚    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”            β”‚  β”‚
    β”‚    β”‚                 β”‚            β”‚  β”‚
    β”‚  β”Œβ”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚
    β”‚  β”‚  Product   β”‚  β”‚   Order    β”‚  β”‚  β”‚
    β”‚  β”‚  Service   β”‚  β”‚  Service   β”‚  β”‚  β”‚
    β”‚  β”‚  (x2)      β”‚  β”‚   (x2)     β”‚  β”‚  β”‚
    β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚
    β”‚                                   β”‚  β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
    β”‚                                      β”‚
    β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
    β”‚  β”‚ Azure Container Registry     β”‚   β”‚
    β”‚  β”‚ (Docker Images)              β”‚   β”‚
    β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
    β”‚                                      β”‚
    β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
    β”‚  β”‚ Azure Key Vault              β”‚   β”‚
    β”‚  β”‚ (Secrets Management)         β”‚   β”‚
    β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Microservices

  • Product Service (Port 8000): Product catalog management with CRUD operations
  • Order Service (Port 8001): Order processing with product validation via HTTP

πŸ› οΈ Technology Stack

Cloud & Infrastructure

  • Cloud Platform: Microsoft Azure
  • Kubernetes: Azure Kubernetes Service (AKS) - v1.28
  • Container Registry: Azure Container Registry (ACR)
  • Secrets: Azure Key Vault
  • Networking: Azure VNet, NSG, Load Balancer
  • Monitoring: Azure Log Analytics

Infrastructure as Code

  • Terraform: Infrastructure provisioning
  • Helm 3: Kubernetes package management
  • Multi-environment: Dev/Staging/Prod configurations

Application

  • Language: Python 3.11
  • Framework: FastAPI (async)
  • API Docs: Swagger/OpenAPI
  • Containerization: Docker (multi-stage builds)

DevOps Tools

  • Version Control: Git, GitHub
  • Container Orchestration: Kubernetes
  • CI/CD: GitHub Actions (in progress)
  • GitOps: ArgoCD (planned)

πŸš€ Quick Start

Prerequisites

  • Azure Subscription
  • Azure CLI (az)
  • Terraform (>= 1.0)
  • kubectl
  • Helm 3
  • Docker

Deploy to Azure

1. Clone Repository

git clone https://github.com/YOUR_USERNAME/ecommerce-microservices.git
cd ecommerce-microservices

2. Login to Azure

az login
az account set --subscription "YOUR_SUBSCRIPTION_ID"

3. Deploy Infrastructure

cd infrastructure/terraform

# Initialize Terraform
terraform init

# Deploy (10-15 minutes)
terraform apply

# Or use the helper script:
./deploy.ps1  # Windows
./deploy.sh   # Linux/Mac

4. Connect to AKS

# Get AKS credentials
az aks get-credentials \
    --resource-group $(terraform output -raw resource_group_name) \
    --name $(terraform output -raw aks_cluster_name)

# Verify connection
kubectl get nodes

5. Build & Push Images

cd ../..

# Login to ACR
ACR_NAME=$(cd infrastructure/terraform && terraform output -raw acr_name)
az acr login --name $ACR_NAME

# Get ACR login server
ACR_LOGIN_SERVER=$(cd infrastructure/terraform && terraform output -raw acr_login_server)

# Build and push Product Service
cd product-service
docker build -t product-service:v1.0.0 .
docker tag product-service:v1.0.0 $ACR_LOGIN_SERVER/product-service:v1.0.0
docker push $ACR_LOGIN_SERVER/product-service:v1.0.0
cd ..

# Build and push Order Service
cd order-service
docker build -t order-service:v1.0.0 .
docker tag order-service:v1.0.0 $ACR_LOGIN_SERVER/order-service:v1.0.0
docker push $ACR_LOGIN_SERVER/order-service:v1.0.0
cd ..

6. Deploy Services

# Update Helm values with your ACR
# Edit helm/*/values-azure.yaml and set your ACR name

# Deploy with Helm
helm install product-service ./helm/product-service \
    -f ./helm/product-service/values-azure.yaml

helm install order-service ./helm/order-service \
    -f ./helm/order-service/values-azure.yaml

# Check deployment
kubectl get pods
kubectl get svc

7. Access Services

# Port-forward to access locally
kubectl port-forward svc/product-service 8000:8000
kubectl port-forward svc/order-service 8001:8001

# Access Swagger UI
# Product Service: http://localhost:8000/docs
# Order Service: http://localhost:8001/docs

πŸ’° Cost Optimization

The infrastructure includes cost-saving features:

  • Single-node cluster for development (~$30/month if running 24/7)
  • Destroy/Deploy scripts for daily usage (~$0.50/day)
  • Auto-scaling disabled in dev (enable for prod)
  • Basic SKU for ACR and other services

Daily Workflow

# Morning - Start work
cd infrastructure/terraform
./deploy.ps1        # 10 minutes to create

# Evening - End work
./destroy.ps1       # 5 minutes to destroy
# Saves ~$2-4/day!

πŸ“Š Project Features

βœ… Completed

  • Microservices architecture (2 services)
  • FastAPI REST APIs with OpenAPI docs
  • Docker containerization with multi-stage builds
  • Local Kubernetes deployment
  • Helm charts for package management
  • Azure AKS production deployment
  • Terraform infrastructure as code
  • Azure Container Registry integration
  • Azure Key Vault for secrets
  • Health checks (liveness & readiness probes)
  • Resource limits and requests
  • High availability (2 replicas per service)
  • Service discovery and inter-service communication
  • Cost optimization scripts

🚧 In Progress

  • CI/CD pipeline with GitHub Actions
  • GitOps with ArgoCD
  • Prometheus & Grafana monitoring
  • Centralized logging
  • API Gateway / Ingress setup
  • SSL/TLS certificates

πŸŽ“ Key Learning Outcomes

Technical Skills

  • Infrastructure as Code with Terraform
  • Kubernetes orchestration at scale
  • Azure cloud services (AKS, ACR, Key Vault, VNet)
  • Container best practices (multi-stage builds, security)
  • Helm package management
  • Microservices communication patterns
  • DevOps workflows and automation

Production Practices

  • High availability configuration
  • Health monitoring and self-healing
  • Resource optimization
  • Security best practices (secrets management, network isolation)
  • Cost management strategies
  • Multi-environment deployments

πŸ“ Project Structure

ecommerce-microservices/
β”œβ”€β”€ product-service/           # Product microservice
β”‚   β”œβ”€β”€ main.py               # FastAPI application
β”‚   β”œβ”€β”€ requirements.txt      
β”‚   └── Dockerfile            # Multi-stage build
β”œβ”€β”€ order-service/            # Order microservice
β”‚   β”œβ”€β”€ main.py
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── Dockerfile
β”œβ”€β”€ infrastructure/
β”‚   └── terraform/            # Infrastructure as Code
β”‚       β”œβ”€β”€ main.tf           # Resource group, workspace
β”‚       β”œβ”€β”€ aks.tf            # AKS cluster configuration
β”‚       β”œβ”€β”€ acr.tf            # Container registry
β”‚       β”œβ”€β”€ networking.tf     # VNet, subnets, NSG
β”‚       β”œβ”€β”€ keyvault.tf       # Secrets management
β”‚       β”œβ”€β”€ variables.tf      # Input variables
β”‚       β”œβ”€β”€ outputs.tf        # Output values
β”‚       β”œβ”€β”€ deploy.ps1        # Deployment script
β”‚       └── destroy.ps1       # Cleanup script
β”œβ”€β”€ helm/                     # Helm charts
β”‚   β”œβ”€β”€ product-service/
β”‚   β”‚   β”œβ”€β”€ values.yaml       # Default values
β”‚   β”‚   β”œβ”€β”€ values-azure.yaml # Azure-specific
β”‚   β”‚   └── templates/
β”‚   └── order-service/
β”‚       └── ...
β”œβ”€β”€ k8s/                      # Raw K8s manifests (reference)
└── docker-compose.yml        # Local development

πŸ§ͺ Testing

API Testing

Product Service:

# Get all products
curl http://localhost:8000/api/products

# Create product
curl -X POST http://localhost:8000/api/products \
  -H "Content-Type: application/json" \
  -d '{"name": "Laptop", "price": 999.99, "stock": 50}'

Order Service:

# Create order
curl -X POST http://localhost:8001/api/orders \
  -H "Content-Type: application/json" \
  -d '{
    "items": [{"product_id": 1, "quantity": 2}],
    "customer_email": "test@example.com"
  }'

πŸ”§ Troubleshooting

Common Issues

Pods in ImagePullBackOff:

# Check image exists in ACR
az acr repository list --name $ACR_NAME

# Verify AKS can pull from ACR
az aks check-acr --name $AKS_NAME --resource-group $RG_NAME --acr $ACR_NAME.azurecr.io

Service communication fails:

# Test from within cluster
kubectl exec -it <pod-name> -- curl http://product-service:8000/health

# Check service DNS
kubectl exec -it <pod-name> -- nslookup product-service

Terraform state issues:

# Refresh state
terraform refresh

# If corrupted, import resources
terraform import azurerm_resource_group.main /subscriptions/.../resourceGroups/...

πŸ“š Documentation


🀝 Contributing

This is a personal learning project, but feedback and suggestions are welcome!


πŸ“ License

MIT License - feel free to use for learning purposes.


πŸ‘€ Author

DevOps Engineer

  • πŸš€ Building production-ready cloud-native applications
  • ☁️ Azure & AWS certified
  • ⎈ Kubernetes enthusiast (CKA in progress)
  • πŸ“š Learning in public and documenting the journey

Connect:


🎯 Project Status

Current Phase: Production deployment on Azure AKS βœ…
Next Steps: CI/CD automation, monitoring & observability
Last Updated: November 2024

Active Development: This project is being actively developed with regular commits. Check back for updates!


πŸ’‘ Acknowledgments

Built with passion for DevOps and cloud-native technologies. Special thanks to the open-source community for the amazing tools and resources.


⭐ If you find this project helpful, please consider giving it a star!

About

DevOps project - Microservices on Azure AKS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published