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

Abhijeet MaskeAbhijeet Maske
6 min read

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:

  1. Frontend (UI Layer) โ€“ The user interface, built with React/Angular/HTML-CSS.

  2. Backend (Application Layer) โ€“ The business logic, often built with Node.js, Java, or Python.

  3. 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

  1. Containerize frontend, backend, and database.

  2. Write Kubernetes YAMLs for each tier.

  3. Deploy them using kubectl apply -f.

  4. Expose services (NodePort for external access, ClusterIP for internal).

  5. 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

  1. Get Node IP using:

     kubectl get nodes -o wide
    
  2. Access the frontend in browser:

     http://<node-ip>:30080
    
  3. 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.

0
Subscribe to my newsletter

Read articles from Abhijeet Maske directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Abhijeet Maske
Abhijeet Maske