Update z1/README.md
This commit is contained in:
parent
2d757a2bf1
commit
e1990c8674
163
z1/README.md
163
z1/README.md
@ -1,114 +1,135 @@
|
|||||||
# DOCKER APP DOCUMENTATION
|
# KUBERNETES APP DOCUMENTATION
|
||||||
## AUTHOR : Somangsu Mukherjee
|
## AUTHOR : Somangsu Mukherjee
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
**1. Conditions for Deployment**
|
**1. Conditions for Deployment**
|
||||||
|
|
||||||
The application requires the following software:
|
The application requires the following software:
|
||||||
|
|
||||||
- Docker (version 20 or newer)
|
- Docker (version 20 or newer)
|
||||||
- Docker Compose (v2 or integrated with Docker)
|
- Kubernetes (Docker Desktop Kubernetes or Minikube)
|
||||||
- Bash shell (for .sh scripts) or PowerShell/CMD (Windows)
|
- kubectl (configured and working)
|
||||||
- Internet connection (to download Docker images)
|
- Bash shell (WSL recommended on Windows)
|
||||||
|
- Internet connection (to download container images)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
**2. Application Description**
|
**2. Application Description**
|
||||||
|
|
||||||
This is a simple multi-container web application.
|
This is a Kubernetes-based multi-container web application.
|
||||||
|
|
||||||
The application allows users to:
|
The application allows users to:
|
||||||
|
|
||||||
Enter their name in a web interface
|
- Enter their name in a web interface
|
||||||
Submit the name to a backend server
|
- Submit the name to a backend server
|
||||||
Store the name in a PostgreSQL database
|
- Store the name in a PostgreSQL database
|
||||||
Retrieve and display all stored names
|
- Retrieve and display all stored names
|
||||||
|
|
||||||
The application demonstrates communication between multiple services using Docker.
|
The application demonstrates communication and orchestration of multiple services using Kubernetes.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
**3. Virtual Networks and Volumes**
|
**3. Virtual Networks and Volumes**
|
||||||
Virtual Network
|
|
||||||
|
|
||||||
Docker Compose automatically creates a virtual network for communication between services.
|
**Virtual Network**
|
||||||
|
|
||||||
|
Kubernetes automatically manages networking between services and pods using internal DNS.
|
||||||
|
|
||||||
Services communicate using service names:
|
Services communicate using service names:
|
||||||
|
|
||||||
Frontend communicates with backend (backend)
|
- Backend communicates with database (`db`)
|
||||||
Backend communicates with database (db)
|
- External users access backend through NodePort service
|
||||||
Named Volume
|
|
||||||
pgdata is used for persistent database storage
|
**Named Volume**
|
||||||
It is mounted to /var/lib/postgresql/data inside the PostgreSQL container
|
|
||||||
This ensures that data is preserved even if containers are stopped or restarted
|
Persistent storage is implemented using:
|
||||||
|
|
||||||
|
- PersistentVolume (PV)
|
||||||
|
- PersistentVolumeClaim (PVC)
|
||||||
|
|
||||||
|
These are mounted to `/var/lib/postgresql/data` inside the PostgreSQL container
|
||||||
|
|
||||||
|
This ensures that data is preserved even if pods are restarted or recreated
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
**4. Container Configuration**
|
**4. Container Configuration**
|
||||||
Frontend
|
|
||||||
Image: nginx:latest
|
|
||||||
Port: 8080 (mapped to container port 80)
|
|
||||||
Volume: ./frontend mounted to /usr/share/nginx/html
|
|
||||||
Purpose: the frontend serves static HTML and JavaScript
|
|
||||||
|
|
||||||
Backend
|
**Backend**
|
||||||
Built from a custom Dockerfile (Node.js)
|
|
||||||
Port: 3000
|
|
||||||
Uses Express framework and also communicates with PostgreSQL database to send entered names to be stored
|
|
||||||
|
|
||||||
Database (PostgreSQL)
|
- Image: `docker-app-backend:latest`
|
||||||
Image: postgres:15
|
- Port: `3000`
|
||||||
Internal port: 5432
|
- Built using Node.js and Express framework
|
||||||
Environment variables:
|
- Communicates with PostgreSQL database to store and retrieve names
|
||||||
POSTGRES_USER=user
|
- Deployed using Kubernetes Deployment
|
||||||
POSTGRES_PASSWORD=password
|
|
||||||
POSTGRES_DB=mydb
|
|
||||||
the database uses named volume pgdata for persistence which makes sure that data is not lost even after stopping or removing the container.
|
|
||||||
Uses init.sql for initial database setup
|
|
||||||
|
|
||||||
Adminer
|
**Database (PostgreSQL)**
|
||||||
Image: adminer
|
|
||||||
Port: 8081
|
|
||||||
Purpose: Web interface for managing the PostgreSQL database which stores all the data that is entered
|
|
||||||
|
|
||||||
5. The table below describes all the containers utilised in this assignment
|
- Image: `postgres:15`
|
||||||
| Container | Description |
|
- Port: `5432`
|
||||||
| --------- | -------------------------------------------- |
|
- Environment variables:
|
||||||
| frontend | Nginx web server serving the frontend |
|
- `POSTGRES_USER=user`
|
||||||
| backend | Node.js server handling API requests |
|
- `POSTGRES_PASSWORD=password`
|
||||||
| db | PostgreSQL database storing application data |
|
- `POSTGRES_DB=mydb`
|
||||||
| adminer | Web interface for managing the database |
|
|
||||||
|
|
||||||
|
The database uses PersistentVolume and PersistentVolumeClaim for persistence which ensures that data is not lost even after pod restarts
|
||||||
|
|
||||||
|
Uses StatefulSet for stable identity and storage
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**5. The table below describes all the components utilised in this assignment**
|
||||||
|
|
||||||
|
| Component | Description |
|
||||||
|
|--------------|--------------------------------------------------|
|
||||||
|
| Namespace | Isolates all application resources |
|
||||||
|
| Deployment | Runs Node.js backend application |
|
||||||
|
| StatefulSet | Runs PostgreSQL database with persistent storage |
|
||||||
|
| Service | Exposes backend externally using NodePort |
|
||||||
|
| DB Service | Enables internal communication with database |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
**6. Application Control**
|
**6. Application Control**
|
||||||
|
|
||||||
Prepare Application:
|
**Prepare Application:**
|
||||||
To prepare the application, the command ./prepare-app.sh is run in wsl which builds images and prepares the environment for execution.
|
To prepare the application, the backend image must be built using:
|
||||||
|
|
||||||
Start Application:
|
```bash
|
||||||
./start-app.sh is run in the wsl command line to start all the 4 cointainers in detached mode.
|
docker build -t docker-app-backend ./backend
|
||||||
|
|
||||||
|
**Start Application:**
|
||||||
|
Run the following command in WSL:
|
||||||
|
|
||||||
|
./start-app.sh
|
||||||
|
|
||||||
|
This creates all Kubernetes resources and starts the application
|
||||||
|
|
||||||
Stop Application
|
Stop Application
|
||||||
to stop all the currently running containers without deleting data, ./stop-app.sh is run on wsl
|
To stop the application:
|
||||||
|
|
||||||
Remove Application
|
./stop-app.sh
|
||||||
./remove-app.sh stops all containers and removes volumes, networks, and all resources.
|
|
||||||
|
**Remove Application**
|
||||||
|
Deleting the namespace removes all resources completely:
|
||||||
|
|
||||||
|
kubectl delete namespace myapp
|
||||||
|
|
||||||
**7. Accessing the Application**
|
**7. Accessing the Application**
|
||||||
Main Web Application can be accessed on any browser locally running on http://localhost:8080
|
|
||||||
|
|
||||||
The database Interface (Adminer) can be accessed similarly at http://localhost:8081
|
Backend API can be accessed at:
|
||||||
|
http://localhost:30007
|
||||||
Login credentials for Adminer are:
|
Frontend can be accessed by opening:
|
||||||
|
frontend/index.html
|
||||||
System: PostgreSQL
|
|
||||||
Server: db
|
|
||||||
Username: user
|
|
||||||
Password: password
|
|
||||||
Database: mydb
|
|
||||||
|
|
||||||
**8. Used Resources**
|
**8. Used Resources**
|
||||||
Docker official documentation
|
|
||||||
Docker Compose documentation
|
Kubernetes official documentation
|
||||||
|
Docker documentation
|
||||||
Node.js documentation
|
Node.js documentation
|
||||||
PostgreSQL documentation
|
PostgreSQL documentation
|
||||||
Nginx documentation
|
|
||||||
|
|
||||||
**9. Use of Artificial Intelligence**
|
|
||||||
|
|
||||||
Artificial intelligence tools such as chatGPT and Claude were used as a support tool during development for understanding docker concepts and debugging scripts. Some configuration issues were also fixed by referring to AI. All implementation, testing, and integration were performed independently.
|
|
||||||
|
|
||||||
|
9. Use of Artificial Intelligence
|
||||||
|
|
||||||
|
Artificial intelligence tools were used as a support tool during development for understanding Kubernetes concepts and debugging deployment issues. Some configuration problems were resolved with AI assistance. All implementation, testing, and integration were performed independently.
|
||||||
Loading…
Reference in New Issue
Block a user