A production-ready full-stack chat application built using modern DevOps practices.
- Cloud Native Chat App DevOps
- Table of Contents
- Introduction
- Features
- Tech Stack
- Architecture Overview
- Project Structure
- Prerequisites
- Setup
.env - Step 1: Build Docker Images
- Step 2: Apply Kubernetes Manifests
- Step 3: Verify Deployments
- Step 4: Configure Hosts File
- Step 5: Access the App (Important for Ingress)
- CI/CD (Jenkins)
- Step 6: Common Issues & Fixes
- Project Notes
- π€ About the Architect
This is a production-ready cloud-native chat application demonstrating real-world DevOps practices including CI/CD, containerization, and Kubernetes orchestration.
- Real-time messaging using Socket.IO
- User authentication (JWT)
- Profile management
- Online/offline user status
- Dockerized frontend & backend
- Kubernetes deployment with Ingress
- MongoDB persistent storage
- CI/CD pipeline using Jenkins
- Frontend: React, TailwindCSS, Zustand
- Backend: Node.js, Express, Socket.IO
- Database: MongoDB
- Containerization: Docker
- Orchestration: Kubernetes
- CI/CD: Jenkins
- Ingress: NGINX
User β Browser
β
Ingress (NGINX)
β
βββββββββββββββββ
β Frontend β
β React App β
ββββββββ¬βββββββββ
β API Calls
βββββββββββββββββ
β Backend β
β Node + Socket β
ββββββββ¬βββββββββ
β
MongoDB
CI/CD:
GitHub β Jenkins β Docker β Kubernetes
full-stack_chatApp/
βββ backend/ # Node.js backend
βββ frontend/ # React frontend
βββ kubernetes/ # Kubernetes manifests (deployments, services, ingress)
βββ docker-compose.yml # Optional local Docker Compose setup
βββ Jenkinsfile
βββ README.md
- Docker Desktop (Kubernetes enabled)
- kubectl
- Node.js >= 18 (optional)
- Git
- Browser
cd backendCreate .env:
MONGODB_URI=mongodb://mongoadmin:secret@mongodb:27017/dbname?authSource=admin
JWT_SECRET=your_jwt_secret_key
PORT=5001
cd backend
docker build -t your-dockerhub/chatapp-backend:latest .
cd ../frontend
docker build -t your-dockerhub/chatapp-frontend:latest .Push images to Docker Hub:
docker push mayrhatte09/chatapp-backend:latest
docker push mayrhatte09/chatapp-frontend:latest- Apply namespace:
kubectl apply -f kubernetes/namespace.yaml- Apply Persistent Volume & PVC for MongoDB
kubectl apply -f kubernetes/mongodb-pv.yaml
kubectl apply -f kubernetes/mongodb-pvc.yaml- Apply MongoDB deployment & service:
kubectl apply -f kubernetes/mongodb-deployment.yaml
kubectl apply -f kubernetes/mongodb-service.yaml- Apply backend deployment & service:
kubectl apply -f kubernetes/backend-deployment.yaml
kubectl apply -f kubernetes/backend-service.yaml- Apply frontend deployment & service:
kubectl apply -f kubernetes/frontend-deployment.yaml
kubectl apply -f kubernetes/frontend-service.yaml- Apply secrets (JWT secret):
kubectl apply -f kubernetes/secrets.yaml- Apply Ingress to route
chatapp.com:
kubectl apply -f kubernetes/ingress.yaml
Check pods:
kubectl get pods -n kubernetesCheck services:
kubectl get svc -n kubernetesCheck ingress:
kubectl get ingress -n kubernetesEnsure NGINX ingress controller is running:
kubectl get pods -n ingress-nginx
kubectl get svc -n ingress-nginx(Optional) Port-forwarding:
kubectl port-forward service/backend -n kubernetes 5001:5001
kubectl port-forward service/frontend -n kubernetes 80:80Ingress uses a custom host (chatapp.com). You need to map it to localhost.
- Open Notepad as Administrator:
Press Windows Key β type Notepad β Right Click β Run as administrator
- Open the hosts file:
C:\Windows\System32\drivers\etc\hosts
- Add the line:
127.0.0.1 chatapp.com
- Save and flush DNS:
ipconfig /flushdns- Verify:
ping chatapp.com
# Should return 127.0.0.1- Frontend: http://chatapp.com/
- Backend: http://chatapp.com/api/
- Push code to GitHub
- Jenkins pulls code
- Builds Docker images
- Pushes to Docker Hub
- Deploys to Kubernetes
| Issue | Fix |
|---|---|
| chatapp.com not working | Check hosts file and run ipconfig /flushdns |
| Ingress no address | Install ingress controller |
| Backend not running | Check pod logs |
Ingress shows <none> for ADDRESS |
Ensure NGINX ingress controller is installed and running |
| Backend not working | Verify backend service exposes port 5001 and pod is running |
| Frontend not loading | Check frontend service and pod status |
| Secret not found | Apply secrets.yaml before backend deployment |
| MongoDB connection error | Verify MONGODB_URI and MongoDB pod status |
| Pods stuck in Pending | Check PVC/PV and cluster resources |
| ImagePullBackOff | Verify image name and push to Docker Hub |
| CrashLoopBackOff | Check logs and environment variables |
| Port not accessible | Verify service ports and configuration |
| Ingress not routing | Check ingress rules and service names |
| DNS not resolving | Verify hosts file entry |
| Jenkins pipeline failed | Check Jenkins console logs |
| Docker build failed | Check Dockerfile and dependencies |
| Wrong namespace issue | Use -n kubernetes in commands |
| Socket.IO not working | Check backend port and WebSocket config |
| CORS error | Enable CORS in backend |
| Backend API not reachable | Verify backend service and endpoints |
| MongoDB pod restarting | Check storage and logs |
| Deployment not updating | Reapply manifests or check image tag |
| High response time | Check pod resources and scaling |
| Service not found | Verify service name in configs |
| Env variables not working | Check .env or Kubernetes secrets |
| Ingress 502 error | Backend service may be down |
| Permission denied (Docker/Jenkins) | Check Docker socket permissions |
- MongoDB uses Persistent Volume and PVC to persist data.
- JWT secret stored in Kubernetes Secret and injected into backend.
- Frontend communicates with backend via
/api/routed through Ingress. - Docker Desktop Kubernetes is for local development; for production, use cloud K8s.
|
Mayur Hatte
DevOps & Cloud Infrastructure Engineer Focused on building self-healing, automated infrastructure. This playbook is a verified asset of MayurHatte09. |
