Skip to content

Latest commit

Β 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Student App – Docker & Kubernetes DevOps Project

A small React + Node.js application created to practice real-world DevOps concepts step by step.

The main goal of this project is not application development. It is to understand how a developer's application moves from source code β†’ Docker β†’ Kubernetes β†’ user.


πŸ—οΈ Architecture

                         User
                          β”‚
                          β–Ό
                       Ingress
                          β”‚
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β–Ό                 β–Ό
          Frontend Service    Backend Service
                 β”‚                 β”‚
                 β–Ό                 β–Ό
            React Pods         Node.js Pods
                                   β”‚
                                   β–Ό
                           MongoDB Service
                                   β”‚
                                   β–Ό
                             MongoDB Pod
                                   β”‚
                                   β–Ό
                                  PVC
                                   β”‚
                                   β–Ό
                                  PV

πŸ“ Project Structure

student-app/
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ Dockerfile
β”‚   └── .dockerignore
β”‚
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app.js
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ Dockerfile
β”‚   └── .dockerignore
β”‚
β”œβ”€β”€ k8s/
β”‚   β”œβ”€β”€ namespace.yaml
β”‚   β”œβ”€β”€ backend-deployment.yaml
β”‚   β”œβ”€β”€ backend-service.yaml
β”‚   β”œβ”€β”€ frontend-deployment.yaml
β”‚   β”œβ”€β”€ frontend-service.yaml
β”‚   β”œβ”€β”€ mongodb-deployment.yaml
β”‚   β”œβ”€β”€ mongodb-service.yaml
β”‚   β”œβ”€β”€ mongodb-secret.yaml
β”‚   β”œβ”€β”€ configmap.yaml
β”‚   β”œβ”€β”€ secret.yaml
β”‚   β”œβ”€β”€ ingress.yaml
β”‚   β”œβ”€β”€ persistentvolume.yaml
β”‚   └── persistentvolumeclaim.yaml
β”‚
β”œβ”€β”€ docker-compose.yml
└── README.md

πŸ› οΈ Technologies Used

  • React.js
  • Node.js
  • Express.js
  • Docker
  • Docker Compose
  • Kubernetes
  • Minikube
  • MongoDB
  • Kubernetes Ingress
  • ConfigMap
  • Secret
  • PersistentVolume
  • PersistentVolumeClaim

🎯 Project Learning Goals

This project is designed to practice:

Docker

  • Writing Dockerfiles
  • Building Docker images
  • Running containers
  • Port mapping
  • Container networking
  • .dockerignore
  • Docker Compose

Kubernetes

  • Namespace
  • Deployment
  • ReplicaSet
  • Pods
  • Services
  • ClusterIP
  • Ingress
  • ConfigMap
  • Secret
  • PersistentVolume
  • PersistentVolumeClaim
  • MongoDB deployment
  • Kubernetes networking

Troubleshooting

Practice diagnosing:

  • CrashLoopBackOff
  • ImagePullBackOff
  • Pending Pods
  • Service connectivity problems
  • Ingress problems
  • YAML syntax errors
  • Wrong labels/selectors
  • Wrong ports
  • PVC/PV problems
  • Container startup failures

πŸ”„ DevOps Flow

Application Code
       β”‚
       β–Ό
    Dockerfile
       β”‚
       β–Ό
   Docker Image
       β”‚
       β–Ό
 Docker Container
       β”‚
       β–Ό
 Docker Compose
       β”‚
       β–Ό
 Kubernetes
       β”‚
       β”œβ”€β”€ Namespace
       β”‚
       β”œβ”€β”€ Deployment
       β”‚       β”‚
       β”‚       β–Ό
       β”‚      Pods
       β”‚
       β”œβ”€β”€ Service
       β”‚
       β”œβ”€β”€ ConfigMap
       β”‚
       β”œβ”€β”€ Secret
       β”‚
       β”œβ”€β”€ Ingress
       β”‚
       └── PV/PVC
               β”‚
               β–Ό
            Storage

🐳 Docker

Backend Image

cd backend

docker build -t student-backend:v1 .

Run:

docker run -it \
  --name backend-container \
  -p 5000:5000 \
  student-backend:v1

Test:

http://localhost:5000/students

Frontend Image

cd frontend

docker build -t student-frontend:v1 .

Run:

docker run -it \
  --name frontend-container \
  -p 3000:3000 \
  student-frontend:v1

Open:

http://localhost:3000

🐳 Docker Compose

From the project root:

docker compose up --build

Stop:

docker compose down

Compose allows the React and Node.js containers to run together.

Container-to-container communication uses the Docker service name:

backend:5000

instead of:

localhost:5000

☸️ Kubernetes

Start Minikube:

minikube start

Enable Ingress:

minikube addons enable ingress

Create the namespace:

kubectl apply -f k8s/namespace.yaml

Deploy the application resources:

kubectl apply -f k8s/

Check resources:

kubectl get all -n student-app

Check Pods:

kubectl get pods -n student-app

Check Services:

kubectl get svc -n student-app

Check Ingress:

kubectl get ingress -n student-app

πŸ” ConfigMap and Secret

ConfigMap

Used for non-sensitive configuration such as:

PORT
APP_NAME
API_URL

Secret

Used for sensitive values such as:

Database username
Database password
JWT secret
API tokens

Example:

ConfigMap β†’ Normal configuration

Secret β†’ Sensitive configuration

For real production systems, Kubernetes Secrets should be protected with appropriate RBAC, encryption at rest, and preferably an external secret-management solution.


πŸ’Ύ Kubernetes Storage

The project also practices:

Pod
 ↓
PVC
 ↓
PV
 ↓
Storage

PersistentVolume

Provides storage.

PersistentVolumeClaim

Requests storage for an application.

The goal is to understand how stateful applications such as MongoDB can keep data when Pods are recreated.


🌐 Kubernetes Networking

The application uses Kubernetes Services for internal communication.

React
  β”‚
  β–Ό
backend-service
  β”‚
  β–Ό
Node.js Pods
  β”‚
  β–Ό
mongodb-service
  β”‚
  β–Ό
MongoDB Pod

Ingress provides the external HTTP entry point:

User
 β”‚
 β–Ό
Ingress
 β”œβ”€β”€ /       β†’ frontend-service
 └── /api    β†’ backend-service

πŸ§ͺ Useful Troubleshooting Commands

Check everything:

kubectl get all -n student-app

Check Pods:

kubectl get pods -n student-app

Detailed Pod information:

kubectl describe pod <pod-name> -n student-app

View logs:

kubectl logs <pod-name> -n student-app

Check Services:

kubectl get svc -n student-app

Check Ingress:

kubectl get ingress -n student-app

Check PVC:

kubectl get pvc -n student-app

Check PV:

kubectl get pv

Check Kubernetes events:

kubectl get events -n student-app

Enter a running container:

kubectl exec -it <pod-name> -n student-app -- sh

🚨 Problems Practiced

During development, several real-world issues were intentionally/debugged, including:

  • Docker Engine connection problems
  • Incorrect Dockerfile commands
  • Docker port mapping
  • Container networking
  • React-to-backend communication
  • Kubernetes YAML case sensitivity
  • Missing Kubernetes resource names
  • Ingress port configuration errors
  • PersistentVolume spelling errors
  • PersistentVolume storage quantity errors
  • Kubernetes Service selectors

These troubleshooting exercises are an important part of the project.


πŸ“š What I Learned

Through this project I practiced:

React
  ↓
Node.js
  ↓
Dockerfile
  ↓
Docker Image
  ↓
Docker Container
  ↓
Docker Compose
  ↓
Kubernetes
  ↓
Deployment
  ↓
Pod
  ↓
Service
  ↓
Ingress
  ↓
ConfigMap
  ↓
Secret
  ↓
PV/PVC

The main focus was understanding how each DevOps component connects to the next one, rather than memorizing YAML files.


πŸš€ Future Improvements

  • Add MongoDB CRUD operations
  • Add Kubernetes readiness and liveness probes
  • Add CPU/memory requests and limits
  • Add Horizontal Pod Autoscaler
  • Add NetworkPolicy
  • Add Kubernetes Jobs/CronJobs
  • Add GitHub Actions CI/CD
  • Push images to Docker Hub
  • Add Helm charts
  • Add Prometheus and Grafana monitoring
  • Deploy to a cloud Kubernetes cluster

πŸ‘¨β€πŸ’» Author

Aman Kumar Gupta

DevOps / Linux / Cloud Learning Project

GitHub: aman9039


⭐ Project Goal

This project is a hands-on DevOps learning project designed to understand how a simple full-stack application can be containerized, connected, deployed, configured, exposed, and troubleshot using Docker and Kubernetes.

About

A beginner-friendly React + Node.js application deployed with Docker and Kubernetes. Practicing Dockerfiles, Docker Compose, Deployments, Services, Ingress, ConfigMaps, Secrets, PV/PVC, and Kubernetes troubleshooting.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages