Skip to content

swapnilmali101/full-stack-chatapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Full Stack Chat Application

Kubernetes manifests for deploying a Full Stack Chat Application on a local Docker Desktop (Windows) environment with Kubernetes enabled on a single-node cluster.


πŸ“‹ Table of Contents


πŸš€ Overview

This repository contains all the Kubernetes manifest files needed to spin up a full-stack chat application locally. The stack includes:

  • Frontend – Web UI served via a dedicated deployment and service
  • Backend – REST/WebSocket API server
  • MongoDB – Persistent database with a PersistentVolume and PersistentVolumeClaim
  • Ingress – NGINX Ingress Controller to route external traffic to services
  • Secrets – Kubernetes secrets for sensitive configuration (e.g. DB credentials)

All resources are scoped to the k8s-chatapp namespace.


πŸ—οΈ Architecture

                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚           k8s-chatapp Namespace         β”‚
                        β”‚                                         β”‚
  Browser ──► Ingress ──►  Frontend Pod  ──►  Backend Pod         β”‚
                        β”‚                        β”‚                β”‚
                        β”‚               MongoDB Service           β”‚
                        β”‚                    β”‚                    β”‚
                        β”‚               MongoDB Pod               β”‚
                        β”‚            (PV + PVC mounted)           β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

βš™οΈ Prerequisites

Ensure the following are installed and running before deploying:

Tool Version Notes
Docker Desktop Latest Enable Kubernetes in settings
kubectl v1.25+ Kubernetes CLI
NGINX Ingress Controller Latest Required for ingress routing

Enable Kubernetes on Docker Desktop

  1. Open Docker Desktop β†’ Settings β†’ Kubernetes
  2. Check Enable Kubernetes
  3. Click Apply & Restart

Install NGINX Ingress Controller

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.10.0/deploy/static/provider/cloud/deploy.yaml

πŸ“‚ Project Structure

full-stack-chatapp/
β”œβ”€β”€ k8s-manifests/
β”‚   β”œβ”€β”€ namespace.yaml            # Namespace: k8s-chatapp
β”‚   β”œβ”€β”€ secrets.yaml              # Kubernetes Secrets (DB credentials, etc.)
β”‚   β”œβ”€β”€ mongodb-pv.yaml           # PersistentVolume for MongoDB
β”‚   β”œβ”€β”€ mongodb-pvc.yaml          # PersistentVolumeClaim for MongoDB
β”‚   β”œβ”€β”€ mongodb-deployment.yaml   # MongoDB Deployment
β”‚   β”œβ”€β”€ mongodb-service.yaml      # MongoDB ClusterIP Service
β”‚   β”œβ”€β”€ backend-deployment.yaml   # Backend API Deployment
β”‚   β”œβ”€β”€ backend-service.yaml      # Backend ClusterIP Service
β”‚   β”œβ”€β”€ frontend-deployment.yaml  # Frontend Deployment
β”‚   β”œβ”€β”€ frontend-service.yaml     # Frontend ClusterIP Service
β”‚   └── ingress.yaml              # NGINX Ingress rules
β”œβ”€β”€ .env                          # Environment variables (local use only)
β”œβ”€β”€ .gitignore
β”œβ”€β”€ LICENSE
└── README.md

⚑Getting Started

1. Clone the Repository

git clone https://github.com/swapnilmali101/full-stack-chatapp.git
cd full-stack-chatapp

2. Configure Environment Variables

Copy or review the .env file and update any values as needed. Sensitive values should be base64-encoded and placed in secrets.yaml.

# Example: base64 encode a secret value
echo -n "your-password" | base64

πŸ‘·β€β™‚οΈ Deployment

Apply all manifests in the following order from the k8s-manifests/ directory:

cd k8s-manifests

Step 1 – Create Namespace

kubectl create -f namespace.yaml
kubectl get ns

Step 2 – Create Persistent Storage for MongoDB

kubectl apply -f mongodb-pv.yaml
kubectl apply -f mongodb-pvc.yaml
kubectl get pvc,pv -n k8s-chatapp

Step 3 – Deploy MongoDB

kubectl apply -f mongodb-deployment.yaml
kubectl apply -f mongodb-service.yaml

Step 4 – Apply Secrets

kubectl apply -f secrets.yaml

Step 5 – Deploy Backend

kubectl apply -f backend-deployment.yaml
kubectl apply -f backend-service.yaml

Step 6 – Deploy Frontend

kubectl apply -f frontend-deployment.yaml
kubectl apply -f frontend-service.yaml

Step 7 – Apply Ingress

kubectl apply -f ingress.yaml

Verify Everything Is Running

kubectl get pods -n k8s-chatapp
kubectl get svc -n k8s-chatapp
kubectl get ingress -n k8s-chatapp
kubectl get pods -n ingress-nginx
kubectl get svc -n ingress-nginx

All pods should show Running status before proceeding.


🌐 Accessing the Application

Via Ingress (Recommended)

Forward traffic from the NGINX Ingress Controller to your local machine:

kubectl port-forward svc/ingress-nginx-controller -n ingress-nginx 80:80

Then open your browser at: http://localhost:80

Direct Backend Port-Forward (for debugging)

kubectl port-forward svc/backend 5001:5001 -n k8s-chatapp

Backend API available at: http://localhost:5001


⛓️‍πŸ’₯ Teardown

To remove all deployed resources and clean up the namespace:

kubectl delete namespace k8s-chatapp
kubectl get ns

⚠️ This will delete all resources in the k8s-chatapp namespace, including PersistentVolumeClaims and their data.


πŸ“Ÿ Troubleshoots

refer repo β‡’ troubleshooting-plunges


πŸ“„ License

This project is open source and available under the MIT License.


✍️ Author

Swapnil Mali

SWAPNIL MALI.

GitHub Profile

πŸ‘¨πŸ»β€πŸ’»CS Engineer | AWS & DevOps Specialist -🎯focused on building reliable, observable, and scalable systems.


About

Kubernetes manifests for deploying a full-stack chat application on a local Docker Desktop (Windows) environment with Kubernetes enabled on a single-node cluster.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors