Production-ready 3-tier application deployment showcasing modern container orchestration
๐ฅ Live Demo โข ๐ Documentation โข ๐ ๏ธ Getting Started โข ๐ผ Portfolio
- ๐ฏ Project Overview
- ๐๏ธ Architecture
- ๐งฐ Technology Stack
- โจ Key Features
- ๐ Quick Start
- ๐ Project Structure
- ๐ Deployment Pipeline
- ๐ก Implementation Highlights
- ๐ฏ Challenges & Solutions
- ๐ Monitoring & Observability
- ๐ฎ Future Roadmap
- ๐ค Contributing
- ๐จโ๐ป Author
- ๐ License
This project demonstrates enterprise-grade Kubernetes deployment by building a complete 3-tier application with modern container orchestration practices. The application showcases scalable microservices architecture with proper service mesh, persistent storage, and production-ready configurations.
- ๐ Full Container Orchestration: Complete Kubernetes deployment with service discovery
- ๐๏ธ Scalable Architecture: Independent scaling of frontend, backend, and database tiers
- ๐ Production Ready: Health checks, monitoring, and persistent storage
- ๐ฐ Resource Optimized: Efficient resource allocation with Minikube deployment
Category | Technologies |
---|---|
โธ๏ธ Container Orchestration | Kubernetes, Minikube |
๐ณ Containerization | Docker, Docker Compose |
๐จ Frontend Framework | React.js, Vue.js, Nginx |
โ๏ธ Backend Services | Node.js, Express.js, RESTful APIs |
๐๏ธ Database | MongoDB Altas String |
๐ Monitoring | Prometheus, Grafana, Health Checks |
๐ง Configuration | ConfigMaps, Environment Variables |
- ๐งฉ Microservices Design: Independently deployable and scalable tiers
- ๐ Service Discovery: Native Kubernetes DNS and service networking
- ๐ Auto-healing: Kubernetes controllers ensure desired state
- โก Rolling Updates: Zero-downtime deployments with rolling update strategy
- ๐ณ Multi-Container Pods: Sidecar patterns and init containers
- ๐ก Load Balancing: Built-in service load balancing and traffic distribution
- ๐ Health Monitoring: Comprehensive liveness and readiness probes
- ๐ Secrets Management: Kubernetes secrets for sensitive data
- ๐ Network Security: Network policies and service mesh integration
- ๐ช Access Control: RBAC with service accounts and role bindings
- ๐ Pod Security: Security contexts and non-root containers
- ๐ Metrics Collection: Prometheus integration for custom metrics
- ๐ Dashboard Visualization: Grafana dashboards for monitoring
- ๐ Logging: Centralized logging with structured log formats
- ๐จ Alerting: Alert manager integration for critical events
# Required tools
kubectl version --client # Kubernetes CLI >= 1.25.0
minikube version # Minikube >= 1.28.0
docker --version # Docker >= 20.10.0
git --version # Git
git clone https://github.com/elonerajeev/3-Tier-App-K8s-Deployment.git
cd 3-Tier-App-K8s-Deployment
# Deploy entire 3-tier application
make deploy
# or use the deployment script:
# chmod +x scripts/deploy.sh && ./scripts/deploy.sh
# Verify deployment
kubectl get pods -n mern-app(namespace)
# Get application URL
minikube service -n 3tier-app frontend --url
# or use port forwarding:
# kubectl port-forward -n 3tier-app service/frontend 3000:3000
๐ฆ 3-Tier-App-K8s-Deployment/
โโโ ๐จ frontend/
โ โโโ src/ # React/Vue source code
โ โโโ public/ # Static assets
โ โโโ Dockerfile # Frontend container image
โ โโโ package.json # Dependencies
โ โโโ nginx.conf # Nginx configuration
โโโ โ๏ธ backend/
โ โโโ src/ # Node.js application
โ โ โโโ controllers/ # API controllers
โ โ โโโ models/ # Data models
โ โ โโโ routes/ # API routes
โ โ โโโ middleware/ # Express middleware
โ โโโ Dockerfile # Backend container image
โ โโโ package.json # Dependencies
โ โโโ healthcheck.js # Health check endpoint
| โโโ index.js.js # main check endpoint
|
โโโ โธ๏ธ k8s/
โ โโโ namespace.yaml # Kubernetes namespace
โ โโโ frontend/
โ โ โโโ deployment.yaml # Frontend deployment
โ โ โโโ service.yaml # Frontend service
โ โ โโโ configmap.yaml # Frontend configuration(Optional)
โ โโโ backend/
โ โ โโโ deployment.yaml # Backend deployment
โ โ โโโ service.yaml # Backend service
โ โ โโโ configmap.yaml # Backend configuration(Optional)
โ โ โโโ secret.yaml # Backend secrets(Optional)
โ โโโ ingress/
โ โ โโโ ingress.yaml # Ingress controller(Optional)
โ โโโ monitoring/
โ โโโ prometheus.yaml # Prometheus configuration
โ โโโ grafana.yaml # Grafana dashboards
โโโ ๐ ๏ธ scripts/
โ โโโ setup-minikube.sh # Minikube setup script
โ โโโ deploy.sh # Deployment automation
โ โโโ cleanup.sh # Resource cleanup
โ โโโ port-forward.sh # Port forwarding helper
โโโ ๐ monitoring/
โ โโโ dashboards/ # Grafana dashboards
โ โโโ alerts/ # Alert configurations
โ โโโ prometheus.yml # Prometheus config
โโโ ๐ง configs/
โ โโโ nginx.conf # Nginx configurations
โ โโโ app.conf # Application configurations
โโโ ๐ docs/
โ โโโ DEPLOYMENT.md # Deployment guide
โ โโโ ARCHITECTURE.md # Architecture documentation
โ โโโ TROUBLESHOOTING.md # Troubleshooting guide
โโโ Makefile # Automation commands
โโโ docker-compose.yml # Local development setup
# Automated Deployment Process
stages:
- ๐ validate:
- syntax-check
- security-scan
- ๐๏ธ build:
- docker-build
- image-push
- ๐งช test:
- unit-tests
- integration-tests
- ๐ deploy:
- k8s-deployment
- health-check
Stage | Action | Status |
---|---|---|
๐ Validation | YAML lint and security scan | โ Active |
๐๏ธ Build | Docker image creation | โ Active |
๐งช Test | Unit and integration tests | โ Active |
๐ค Registry | Push to container registry | โ Active |
๐ Deploy | Kubernetes deployment | โ Active |
โ Verify | Health check validation | โ Active |
# Example: Backend Deployment with Health Checks
apiVersion: apps/v1
kind: Deployment
metadata:
name: backend-deployment
namespace: mern-app
labels:
app: myapp
spec:
replicas: 2
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: backend-container
image: elonerajeev/myapp-backend:v1
ports:
- containerPort: 5000
envFrom:
- secretRef:
name: backend-secret
# Frontend Production Build
FROM node:18-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production && npm cache clean --force
COPY . .
RUN npm run build
FROM nginx:alpine AS runtime
COPY --from=builder /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
#!/bin/bash
set -e
set -o pipefail
echo "๐ Starting 3-Tier Kubernetes Deployment..."
# Navigate to k8s manifests directory
if [ ! -d "k8s-deployment/manifest" ]; then
echo "โ Directory 'k8s-deployment/manifest' not found!"
exit 1
fi
cd k8s-deployment/manifest
# ======================
# Create Namespace
# ======================
echo "๐ Creating Namespace..."
if [ -f namespace.yaml ]; then
kubectl apply -f namespace.yaml
else
echo "โ namespace.yaml file not found!"
exit 1
fi
# ======================
# Deploy Backend
# ======================
echo "โ๏ธ Deploying Backend..."
kubectl apply -f backend/deployment.yaml
kubectl apply -f backend/service.yaml
๐ง Kubernetes Challenges
Challenge | Solution | Impact |
---|---|---|
Service Discovery | Kubernetes DNS and service networking | โ Resolved |
Resource Management | Resource requests and limits | โก Performance |
Health Monitoring | Liveness and readiness probes | ๐ Reliability |
๐ Container Challenges
Challenge | Solution | Impact |
---|---|---|
Image Size Optimization | Multi-stage Docker builds | ๐ Performance |
Configuration Management | ConfigMaps and Secrets | ๐ Security |
Inter-service Communication | Service mesh and networking | ๐ Connectivity |
Rolling Updates | Kubernetes deployment strategies | ๐ Zero-downtime |
# Access Prometheus metrics
curl http://localhost:9090/metrics
# Grafana Dashboard
kubectl port-forward -n monitoring service/grafana 3000:3000
# Access: http://localhost:3000
- ๐ฏ Application Performance: Response time, throughput, error rates
- ๐ Resource Utilization: CPU, memory, disk usage per pod
- ๐ Network Metrics: Request/response latency, connection counts
- ๐๏ธ Database Performance: Query performance, connection pools
- ๐ Prometheus: Metrics collection and alerting
- ๐ Grafana: Visualization dashboards
- ๐ Kubernetes Dashboard: Cluster monitoring
- ๐ฑ AlertManager: Alert notifications
- Add network policies
- Integrate Kubernetes secrets management
- Horizontal Pod Autoscaling (HPA)
- Blue-green deployment strategy
- Canary deployments
- Multi-cluster deployment
- GitOps with ArgoCD
- EKS/GKE/AKS deployment
- Terraform for infrastructure
- CI/CD with GitHub Actions
We welcome contributions! Here's how you can help:
# Fork the repository
git clone https://github.com/your-username/3-Tier-App-K8s-Deployment.git
# Create feature branch
git checkout -b feature/your-feature-name
# Make changes and test
make test
# Submit pull request
- Follow Kubernetes best practices
- Write comprehensive tests
- Update documentation
- Use meaningful commit messages
- Ensure security standards
Rajeev Kumar Kubernetes Specialist & DevOps Engineer
"Orchestrating containers and building scalable cloud-native applications"
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License - Feel free to use this project for learning and development!
Made with โค๏ธ and โ by Rajeev Kumar