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