๐ Deploying a Three-Tier Application on Kubernetes: My Real-Time Project Experience

As part of my DevOps learning journey, I recently worked on deploying a three-tier application on Kubernetes. This project helped me gain hands-on experience with containerization, orchestration, and scaling real-world applications. In this blog, Iโll walk you through how I designed and deployed the setup.
๐น What is a Three-Tier Application?
A three-tier architecture divides an application into three logical layers:
Frontend (UI Layer) โ The user interface, built with React/Angular/HTML-CSS.
Backend (Application Layer) โ The business logic, often built with Node.js, Java, or Python.
Database (Data Layer) โ Stores and retrieves application data (MySQL, MongoDB, PostgreSQL, etc.).
This separation makes the system more scalable, manageable, and fault-tolerant.
๐น Tools & Technologies Used
Docker โ For containerizing the app.
Kubernetes (K8s) โ For deployment, scaling, and service management.
YAML Manifests โ For defining deployments, services, and configs.
NodePort Service โ For exposing the application externally.
Horizontal Pod Autoscaler (HPA) โ For auto-scaling based on load.
๐น Project Setup
1๏ธโฃ Frontend Deployment
Containerized the frontend app using Dockerfile.
Created a Deployment YAML to run multiple replicas.
Exposed it using a NodePort Service so users can access it via browser.
2๏ธโฃ Backend Deployment
Built a backend container image (Node.js API).
Defined a Deployment YAML for backend pods.
Exposed the backend internally with a ClusterIP Service, so only frontend communicates with it.
3๏ธโฃ Database Deployment
Deployed MongoDB/MySQL using a StatefulSet (or Deployment).
Configured PersistentVolume (PV) & PersistentVolumeClaim (PVC) for data persistence.
Connected backend to the database via internal ClusterIP service.
๐น Horizontal Pod Autoscaling (HPA)
To make the system production-ready, I implemented HPA.
The frontend and backend deployments automatically scale pods up/down based on CPU usage.
This ensures the app remains highly available even under heavy traffic.
๐น Accessing the Application
Finally, I accessed the application using the NodePort external IP. The three layers communicated smoothly:
Frontend โ Backend โ Database
Verified that data was stored and retrieved correctly.
๐น Key Learnings
โ
How to design and deploy a real-time multi-tier architecture in Kubernetes.
โ
Using NodePort vs ClusterIP for internal/external communication.
โ
Setting up Persistent Volumes for database storage.
โ
Implementing HPA for automatic scaling.
๐น Final Thoughts
This project gave me real-world exposure to how enterprises deploy scalable applications on Kubernetes. Going forward, I plan to integrate Ingress, CI/CD pipelines, and monitoring (Prometheus + Grafana) to make it even more production-grade.
If youโre starting with Kubernetes, I highly recommend trying out a three-tier app projectโitโs a complete package for learning orchestration.
๐ Hashtags for LinkedIn/Medium:#DevOps #Kubernetes #Docker #CloudComputing #Projects #LearningByDoing
Do you want me to also write YAML snippets (frontend, backend, DB, HPA) inside the blog so it looks more technical and attracts recruiters/learners on LinkedIn?
You said:
make it in detail mentation all the thinks
ChatGPT said:
Perfect ๐ฅ Letโs create a detailed, step-by-step blog for your Three-Tier Application Deployment on Kubernetes, with all the YAMLs, commands, and explanations. This will look professional on LinkedIn / Medium / GitHub and show your DevOps skills clearly.
๐ Step-by-Step Guide: Deploying a Three-Tier Application on Kubernetes
As part of my DevOps learning journey, I recently deployed a three-tier application (Frontend, Backend, Database) on Kubernetes. This project gave me hands-on experience with containerization, orchestration, and autoscaling. In this blog, Iโll explain each step in detail along with YAML manifests.
๐น 1. Understanding the Three-Tier Architecture
A three-tier architecture separates an app into three layers:
Frontend (UI Layer): React / Angular / HTML-CSS app.
Backend (API Layer): Node.js / Java / Python app with business logic.
Database (Data Layer): MySQL / MongoDB storing application data.
This separation ensures scalability, maintainability, and fault tolerance.
๐น 2. Tools & Technologies Used
Docker โ Containerization
Kubernetes โ Deployment & orchestration
kubectl โ Command-line tool to manage clusters
NodePort & ClusterIP Services โ For networking
Persistent Volumes โ For database storage
Horizontal Pod Autoscaler (HPA) โ For autoscaling
๐น 3. Project Workflow
Containerize frontend, backend, and database.
Write Kubernetes YAMLs for each tier.
Deploy them using
kubectl apply -f
.Expose services (NodePort for external access, ClusterIP for internal).
Set up HPA for scaling.
๐น 4. Deployment Manifests
โ 4.1 Frontend Deployment (NodePort Service)
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend-deploy
labels:
app: frontend
spec:
replicas: 2
selector:
matchLabels:
app: frontend
template:
metadata:
labels:
app: frontend
spec:
containers:
- name: frontend
image: your-dockerhub-username/frontend-app:latest
ports:
- containerPort: 3000
---
apiVersion: v1
kind: Service
metadata:
name: frontend-svc
spec:
type: NodePort
selector:
app: frontend
ports:
- port: 3000
targetPort: 3000
nodePort: 30080
๐ The frontend is exposed on NodePort 30080 so users can access it via browser.
โ 4.2 Backend Deployment (ClusterIP Service)
apiVersion: apps/v1
kind: Deployment
metadata:
name: backend-deploy
labels:
app: backend
spec:
replicas: 2
selector:
matchLabels:
app: backend
template:
metadata:
labels:
app: backend
spec:
containers:
- name: backend
image: your-dockerhub-username/backend-app:latest
ports:
- containerPort: 3500
---
apiVersion: v1
kind: Service
metadata:
name: backend-svc
spec:
type: ClusterIP
selector:
app: backend
ports:
- port: 3500
targetPort: 3500
๐ Backend is ClusterIP, so only frontend can talk to it internally.
โ 4.3 Database Deployment (Persistent Storage + ClusterIP)
apiVersion: v1
kind: PersistentVolume
metadata:
name: db-pv
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/data/db"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: db-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: db-deploy
spec:
replicas: 1
selector:
matchLabels:
app: database
template:
metadata:
labels:
app: database
spec:
containers:
- name: mongo
image: mongo:latest
ports:
- containerPort: 27017
volumeMounts:
- name: db-storage
mountPath: /data/db
volumes:
- name: db-storage
persistentVolumeClaim:
claimName: db-pvc
---
apiVersion: v1
kind: Service
metadata:
name: db-svc
spec:
type: ClusterIP
selector:
app: database
ports:
- port: 27017
targetPort: 27017
๐ Database uses PV + PVC to persist data even if the pod restarts.
โ 4.4 Horizontal Pod Autoscaler (HPA)
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: backend-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: backend-deploy
minReplicas: 2
maxReplicas: 5
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50
๐ The backend scales between 2 to 5 replicas depending on CPU usage.
๐น 5. Deployment Commands
# Apply all YAMLs
kubectl apply -f frontend.yml
kubectl apply -f backend.yml
kubectl apply -f database.yml
kubectl apply -f hpa.yml
# Verify pods & services
kubectl get pods
kubectl get svc
kubectl get hpa
๐น 6. Testing the Application
Get Node IP using:
kubectl get nodes -o wide
Access the frontend in browser:
http://<node-ip>:30080
Check connections:
Frontend โ Backend โ Database
Insert and fetch data to confirm.
๐น 7. Key Learnings
โ
Designed and deployed a three-tier application in Kubernetes.
โ
Used NodePort for external access and ClusterIP for internal services.
โ
Implemented Persistent Volumes for database storage.
โ
Enabled HPA for automatic scaling under load.
๐น 8. Future Enhancements
Use Ingress Controller instead of NodePort.
Implement CI/CD with Jenkins + GitHub Actions.
Add Monitoring with Prometheus + Grafana.
Deploy on Cloud (AWS/GCP/Azure) instead of local cluster.
๐ฏ Final Thoughts
This project was a great hands-on DevOps practice. I got real-time experience in handling multi-tier architecture on Kubernetes with scalability and persistence.
If youโre learning DevOps, I highly recommend building and deploying a similar projectโit gives end-to-end exposure to how real applications run in production.
Subscribe to my newsletter
Read articles from Abhijeet Maske directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
