This project demonstrates a complete end-to-end DevOps workflow — deploying a full three-tier web application (React + Node.js + MongoDB) on Google Cloud Platform (GCP) using Kubernetes (GKE).
This application is designed using a Three-Tier Architecture:
- Frontend: ReactJS application (served via Node container)
- Backend: Node.js + Express API (handles business logic)
- Database: MongoDB (stores persistent data)
Each layer runs in independent containers managed by Kubernetes Deployments. They communicate internally using ClusterIP services and are exposed externally using a Google Cloud Load Balancer (GCLB) created automatically via Ingress.
flowchart TD
A[User Browser] --> B[GCP Load Balancer]
B --> C[Frontend Service - NodePort]
B --> D[Backend Service - ClusterIP]
D --> E[MongoDB Service - ClusterIP]
E --> F[Persistent Volume]
| Layer | Technology |
|---|---|
| Frontend | ReactJS |
| Backend | Node.js + Express |
| Database | MongoDB |
| Containerization | Docker |
| Orchestration | Kubernetes (GKE) |
| Cloud Provider | Google Cloud Platform (GCP) |
| Load Balancing | GCP HTTP(S) Load Balancer (Ingress) |
k8s/
├── database/
│ ├── deployment.yml
│ ├── pvc.yml
│ ├── secret.yml
│ └── service.yml
│
├── backend/
│ ├── deployment.yml
│ └── service.yml
│
├── frontend/
│ ├── deployment.yml
│ └── service.yml
│
└── ingress/
└── ingress.yaml
gcloud container clusters create three-tier-cluster \
--zone us-west1-a \
--machine-type e2-medium \
--num-nodes 2gcloud container clusters get-credentials three-tier-cluster --zone us-west1-a
kubectl create namespace three-tierPath: k8s/database/
Features:
- Uses PersistentVolumeClaim for data storage
- Credentials stored securely via Kubernetes Secret
- Internal ClusterIP Service for backend access
Commands:
kubectl apply -f k8s/database/ -n three-tierSecret Example:
apiVersion: v1
kind: Secret
metadata:
namespace: three-tier
name: mongo-sec
type: Opaque
data:
username: c2hpc2hpcg== # shishir
password: ZGV2b3BzMTIz # devops123Path: k8s/backend/
Features:
- Handles API logic and connects to MongoDB
- Reads credentials from Secrets
- Internal-only ClusterIP Service
Commands:
kubectl apply -f k8s/backend/ -n three-tierService Example:
apiVersion: v1
kind: Service
metadata:
name: api-svc
namespace: three-tier
spec:
type: ClusterIP
selector:
role: api
ports:
- port: 3500
targetPort: 3500
protocol: TCPPath: k8s/frontend/
Features:
- React app containerized and served via Node.js
- Publicly accessible through NodePort Service
- Connects to backend using internal ClusterIP
Commands:
kubectl apply -f k8s/frontend/ -n three-tierService Example:
apiVersion: v1
kind: Service
metadata:
name: frontend-svc
namespace: three-tier
spec:
type: NodePort
selector:
role: frontend
ports:
- port: 80
targetPort: 3000
protocol: TCPPath: k8s/ingress/ingress.yaml
Purpose: Creates a GCP HTTP Load Balancer that routes:
/→ frontend-svc/api→ api-svc
Ingress Example:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: mainlb
namespace: three-tier
annotations:
kubernetes.io/ingress.class: "gce"
kubernetes.io/ingress.allow-http: "true"
spec:
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: frontend-svc
port:
number: 80
- path: /api
pathType: Prefix
backend:
service:
name: api-svc
port:
number: 3500Command:
kubectl apply -f k8s/ingress/ -n three-tierCheck Ingress:
kubectl get ingress -n three-tier✅ Output:
NAME CLASS HOSTS ADDRESS PORTS AGE
mainlb gce * 34.122.155.98 80 3m
Access app at:
http://34.122.155.98/
flowchart LR
A[User Request] --> B[GCP Load Balancer]
B --> C[Frontend Service - NodePort]
B --> D[Backend Service - ClusterIP]
D --> E[MongoDB Service - ClusterIP]
✅ GKE automatically:
- Creates Load Balancer
- Configures firewall rules
- Handles target proxies and backend health checks
MongoDB uses PersistentVolume and PersistentVolumeClaim for data retention:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mongo-volume-claim
namespace: three-tier
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1GiSecrets store database credentials securely using base64 encoding:
echo -n "shishir" | base64
echo -n "devops123" | base64Applied with:
kubectl apply -f k8s/database/secret.yml -n three-tier# Create cluster & namespace
gcloud container clusters create three-tier-cluster --zone us-west1-a --machine-type e2-medium --num-nodes 2
kubectl create namespace three-tier
# Apply manifests
kubectl apply -f k8s/database/ -n three-tier
kubectl apply -f k8s/backend/ -n three-tier
kubectl apply -f k8s/frontend/ -n three-tier
kubectl apply -f k8s/ingress/ -n three-tier
# Verify
kubectl get pods,svc,ingress -n three-tier| Component | Type | Exposed via | Purpose |
|---|---|---|---|
| Frontend | Deployment + NodePort | Ingress/GCLB | React UI |
| Backend | Deployment + ClusterIP | Internal | API Logic |
| MongoDB | Deployment + PVC + ClusterIP | Internal | Data Layer |
| Ingress | Ingress (GCE) | Public IP | Routes Traffic |
| Action | Command |
|---|---|
| Check all resources | kubectl get all -n three-tier |
| Restart deployment | kubectl rollout restart deployment/<name> -n three-tier |
| Check pod logs | kubectl logs <pod-name> -n three-tier |
| Exec into MongoDB | kubectl exec -it <mongodb-pod> -n three-tier -- /bin/bash |
| Check Ingress IP | kubectl get ingress -n three-tier |
| Service | Purpose |
|---|---|
| GKE (Google Kubernetes Engine) | Kubernetes cluster hosting |
| Google Cloud Load Balancer | HTTP/HTTPS routing (Ingress) |
| Compute Engine | Node instances for pods |
| Docker Hub | Container image registry |
flowchart TD
U[User Browser] --> A[GCP Load Balancer]
A --> B[Frontend Service - NodePort]
A --> C[Backend Service - ClusterIP]
C --> D[MongoDB - PVC + ClusterIP]
D --> E[Persistent Volume]
Shishir Shetty Cloud & DevOps Engineer | GCP ☁️ | Kubernetes ☸️ | Docker 🐳 | CI/CD ⚙️ 📦 GitHub
This project demonstrates:
- ✅ Full three-tier architecture deployment
- ✅ Persistent storage setup
- ✅ Secrets management
- ✅ Ingress-based load balancing
- ✅ Real-world GKE automation
The app is fully containerized, portable, and production-ready. It can easily be replicated on AWS EKS or Azure AKS with minor changes.
⭐ If you liked this project — don’t forget to star the repo!