Update README.md

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

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