This project demonstrates a production-like deployment of a MedusaJS v2 ecommerce backend using Docker, Jenkins CI/CD, Azure Kubernetes Service (AKS), and PostgreSQL. The backend exposes REST APIs and an admin panel for managing ecommerce operations.
๐ง Tech Stack
- Backend: MedusaJS v2
- Database: PostgreSQL (containerized)
- CI/CD: Jenkins (Pipeline-based deployment)
- Containerization: Docker & Docker Compose
- Orchestration: Kubernetes (AKS)
- Cloud: Microsoft Azure
- Others: Helm (optional), kubectl, Azure CLI
๐ Project Structure
MedusajsV2/
โ
โโโ k8s/ # Kubernetes YAML files
โ โโโ deployment.yaml
โ โโโ service.yaml
โ โโโ postgres.yaml
โ
โโโ jenkins/
โ โโโ Jenkinsfile # Jenkins CI/CD pipeline script
โ
โโโ Dockerfile # Docker image for MedusaJS backend
โโโ docker-compose.yml # Local development setup
โโโ README.md # This file
๐ Features
- CI/CD pipeline triggered via Jenkins
- Deployment on AKS using kubectl
- External LoadBalancer to access Medusa Admin UI
- Logs and service monitoring with
kubectl - Secure PostgreSQL with volume persistence
- Easily scalable & production-ready
๐ ๏ธ Setup & Deployment
1. Clone the Repo
git clone https://github.com/jaspreet237/MedusajsV2.git
cd MedusajsV2
2. Build Docker Images
docker build -t medusa-app . docker-compose up -d
3. Push to Docker Hub
docker tag medusa-app <your-dockerhub-username>/medusa-app docker push <your-dockerhub-username>/medusa-app
4. Create AKS Cluster (Optional: if not already created)
az aks create --resource-group rg-aks-dev --name my-aks-cluster --node-count 1 --generate-ssh-keys az aks get-credentials --resource-group rg-aks-dev --name my-aks-cluster
5. Apply Kubernetes Manifests
kubectl apply -f k8s/postgres.yaml kubectl apply -f k8s/deployment.yaml kubectl apply -f k8s/service.yaml
6. Access Application
Check external IP:
kubectl get svc medusa-service
Visit:
http://<EXTERNAL-IP>:9000/app/login
๐งช Create Admin User (Inside Pod)
kubectl exec -it <medusa-pod-name> -- yarn medusa user -e admin@mail.com -p password
๐งฐ Jenkins CI/CD Setup
- Pipeline includes steps to:
- Clone repo
- Build Docker image
- Push to Docker Hub
- Apply Kubernetes manifests
Example Jenkinsfile is included underย jenkins/.
๐ฐ Azure AKS Cost Estimation (For MedusaJS V2 Deployment)
Deploying MedusaJS v2 on Azure Kubernetes Service (AKS) involves multiple Azure resources that contribute to the total monthly cost. The following breakdown provides an approximate cost structure for running a single production-like MedusaJS backend with PostgreSQL.
โ๏ธ Resource Breakdown (1-Node Setup)
| Component | Resource Type | Estimated Monthly Cost (INR/USD) | Description |
|---|---|---|---|
| AKS Cluster Node | Standard_B2s (2 vCPU, 4 GB RAM) | โน2,000 / $25 | Runs MedusaJS and PostgreSQL pods |
| AKS Control Plane | Managed by Azure | Free | Control plane is free for 1st cluster |
| Azure Container Registry (Optional) | Basic Tier | โน350 / $5 | Stores Docker images for deployment |
| Managed Disk (Persistent Storage) | 20 GB Premium SSD | โน300 / $4 | Persistent volume for PostgreSQL |
| Azure Load Balancer | Standard SKU | โน700 / $9 | Provides external access to MedusaJS API |
| Public IP (Static) | 1 Static IP | โน250 / $3 | Assigned to the LoadBalancer service |
| Bandwidth / Egress Data | ~50 GB outbound/month | โน500 / $6 | Depends on app traffic and usage |
๐ฉ Estimated Monthly Total: ~ โน4,100 โ โน5,000 (~$50 โ $60 USD)
๐ก This estimate assumes 24/7 uptime with low-to-medium traffic. For development or testing environments, cost can be reduced by using Spot instances or scaling down node count.
๐ Scaling Cost for Additional Applications or Pods
If you want to deploy multiple MedusaJS backends or microservices, the cost scales linearly based on pod and node utilization.
| Scenario | Example | Approx. Cost Impact |
|---|---|---|
| 2 MedusaJS Apps | 2 Deployments sharing same AKS Node | +โน1,000 / +$12 |
| 3โ4 MedusaJS Apps | Requires 2nd AKS Node | +โน2,000 / +$25 |
| Horizontal Pod Autoscaler | Scales automatically with load | Based on CPU usage and node addition |
๐น Each new node adds approximately โน2,000โโน2,500 ($25โ$30) per month.
๐น Storage and bandwidth usage also increase proportionally.
๐งฎ How to Estimate Exact Cost
You can calculate your precise AKS expenses using the Azure Pricing Calculator:
๐ https://azure.microsoft.com/en-us/pricing/calculator
To use it:
- Add Azure Kubernetes Service
- Select VM Size (e.g., B2s or D2s_v3) and region
- Include Storage, Bandwidth, and Public IP
- Compare between Dev/Test and Production usage levels
๐ช Cost Optimization Tips
- Use B-series VMs for development (low-cost burstable instances)
- Enable node auto-scaling to reduce idle costs
- Schedule cluster shutdown for non-production workloads
- Store Docker images in Azure Container Registry (Basic tier)
- Monitor and right-size resources using Azure Advisor
๐ Future Enhancements
- Implement Ingress Controller (Nginx or Traefik)
- Enable TLS with Let’s Encrypt
- Add Redis for caching & job queue
- Configure Horizontal Pod Autoscaler
- Enable Role-Based Access Control (RBAC)
- Integrate monitoring (Prometheus + Grafana)
๐ง What You Can Learn From This Project
- Real-world AKS deployment
- End-to-end DevOps pipeline using Jenkins
- Secure and scalable Kubernetes practices
- Practical MedusaJS backend usage
๐ค Contributing
Pull requests and stars are welcome! For major changes, please open an issue first.

Pull requests and stars are welcome! For major changes, please open an issue first.