Update README.md

This commit is contained in:
Joblin John Jeya Rockas 2026-04-27 22:34:15 +00:00
parent 7dbe0d81fa
commit b9ec34979b

258
README.md
View File

@ -1,192 +1,166 @@
# Docker Multi-Service Notes Application # Notes Application - Docker & Kubernetes Deployment
## 1. Introduction ## Overview
This project is a multi-container web application deployed using Docker. This project is a Notes Application deployed using Docker and Kubernetes (MicroK8s).
It demonstrates how multiple services such as frontend, backend, The application allows users to:
database, and file storage can be containerized and orchestrated using
Docker Compose.
The system follows a microservices architecture where each service runs
independently and communicates through a Docker network.
------------------------------------------------------------------------
## 2. Objectives
- Deploy a complete web application using Docker containers
- Use multiple services (frontend, backend, database)
- Enable communication between services
- Implement persistent storage using Docker volumes
- Provide scripts for managing the application lifecycle
------------------------------------------------------------------------
## 3. System Architecture
The application consists of the following services:
### 3.1 Frontend (Nginx)
- Serves static files (HTML, CSS, JavaScript)
- Provides user interface for interacting with the system
### 3.2 Backend (Node.js + Express)
- Handles API requests
- Implements business logic
- Manages notes and file uploads
### 3.3 MongoDB
- NoSQL database for storing notes
- Uses persistent storage
### 3.4 Mongo Express
- Web interface to view and manage database data
------------------------------------------------------------------------
## 4. Features
- Create notes - Create notes
- Delete notes - Delete notes
- Upload files - Upload files
- List uploaded files
- Download files - Download files
- Persistent data storage
------------------------------------------------------------------------ It follows a 3-tier architecture:
## 5. Technologies Used - Frontend (Nginx)
- Backend (Node.js)
- Database (MongoDB)
- Docker ## Architecture
- Docker Compose
- Node.js (Express)
- MongoDB
- Nginx
- HTML, CSS, JavaScript
------------------------------------------------------------------------ ```
User -> Frontend (Nginx) -> Backend (Node.js) -> MongoDB
```
## 6. Ports and Services ## Containers
| Service | Port | Description | ### Frontend
|----------------|------|-----------------|
| Frontend | 8080 | Web interface |
| Backend | 3000 | API server |
| Mongo Express | 8081 | Database UI |
------------------------------------------------------------------------ - Image: `nginx:alpine`
## 7. Database Credentials - Role: Serves static UI
- Port: `80`
The MongoDB database is configured with the following credentials: ### Backend
- **Username:** admin - Image: `node:18`
- **Password:** pass - Role: API server (handles notes & files)
- Port: `3000`
These credentials are used by Mongo Express to connect to the MongoDB service. ### Database
------------------------------------------------------------------------ - Image: `mongo:6.0`
- Role: Stores notes and file data
- Port: `27017`
## 8. Persistent Storage ## Kubernetes Resources
The application uses Docker volumes: - Namespace: `z2`
- Deployments:
- `frontend`
- `backend`
- StatefulSet:
- `mongo`
- Services:
- `frontend` (NodePort -> 30007)
- `backend` (ClusterIP)
- `mongo` (Headless Service)
- mongo-data → stores database data ## Storage
- uploads → stores uploaded files
These ensure that data is not lost when containers restart. - Persistent Volume Claim: `mongo-storage`
- Size: `1Gi`
- Mount path: `/data/db`
- Purpose: Store MongoDB data persistently
------------------------------------------------------------------------ ## Setup Instructions
## 9. Network Requirement (IMPORTANT) ### 1. Prepare Application
⚠️ This application is hosted on a university virtual machine. ```bash
./prepare-app.sh
To access the application, you must: ```
- Be connected to the **Tuke university network**, OR
- Use a **Tuke VPN connection**
Without VPN/network access, the application URLs may not be reachable.
------------------------------------------------------------------------
## 10. Application Workflow
1. User accesses frontend via browser
2. Frontend sends requests to backend API
3. Backend processes requests
4. Backend interacts with MongoDB
5. MongoDB stores/retrieves data
6. Mongo Express allows database visualization
------------------------------------------------------------------------
## 11. Scripts
### 11.1 Prepare Application
./prepare-app.sh
- Builds Docker images - Builds Docker images
- Creates volumes and network - Loads them into MicroK8s
### 11.2 Start Application ### 2. Start Application
./start-app.sh ```bash
./start-app.sh
```
- Starts all containers - Deploys Kubernetes resources
- Application available at: - Starts all services
- http://147.232.204.210:8080
- http://147.232.204.210:8081
- http://147.232.204.210:3000
- http://147.232.204.210:3000/notes
### 3. Stop Application
### 11.3 Stop Application ```bash
./stop-app.sh
```
./stop-app.sh - Stops running pods
- Keeps configuration
- Stops all containers ### 4. Delete Application
- Data remains intact
### 11.4 Remove Application ```bash
microk8s kubectl delete all --all -n z2
microk8s kubectl delete pvc --all -n z2
```
./remove-app.sh - Removes everything including database
- Removes containers, volumes, and images ## Access Application
------------------------------------------------------------------------ Open in browser:
## 12. Docker Configuration ```
http://<server-ip>:30007
```
The application is configured using docker-compose.yml, where: Example:
- Each service runs in its own container ```
- Services communicate using Docker networking http://147.232.204.210:30007
- Volumes are used for persistent storage ```
------------------------------------------------------------------------ ## Useful Commands
## 13. Key Concepts Demonstrated Check pods:
- Multi-container Docker architecture ```bash
- Service isolation and communication microk8s kubectl get pods -n z2
- Persistent storage using volumes ```
- RESTful API design
- Static file serving
------------------------------------------------------------------------ Check services:
## 14. Conclusion ```bash
microk8s kubectl get svc -n z2
```
This project demonstrates how to deploy a scalable web application using View logs:
Docker containers. It highlights the importance of modular architecture,
persistent storage, and service communication.
------------------------------------------------------------------------ ```bash
microk8s kubectl logs <pod-name> -n z2
```
## Common Issues
### Mongo Crash (version error)
Fix:
```bash
microk8s kubectl delete pvc --all -n z2
```
### Frontend shows "Welcome to nginx"
Fix:
- Ensure `index.html` is copied in Dockerfile
- Rebuild using:
```bash
./prepare-app.sh
```
## Honesty Statement
This project was developed with the assistance of AI tools (such as ChatGPT) for:
- Debugging errors
- Understanding Kubernetes concepts
- Identifying fixes for deployment issues
All configurations, testing, and final implementation were completed independently, and the AI was used strictly as a learning aid.