Update z2/README.md

This commit is contained in:
Somangsu Mukherjee 2026-04-20 21:33:44 +00:00
parent 39530b2a80
commit 2d757a2bf1

View File

@ -1,236 +1,236 @@
1. Application Description *1. Application Description*
This project is a simple full-stack web application deployed on Kubernetes.
It allows users to submit names through a web interface and store them in a PostgreSQL database. This project is a simple full-stack web application deployed on Kubernetes.
The system consists of: It allows users to submit names through a web interface and store them in a PostgreSQL database.
The system consists of:
A frontend (static HTML interface)
A frontend (static HTML interface)
A backend API built with Node.js (Express) A backend API built with Node.js (Express)
A PostgreSQL database running as a StatefulSet with persistent storage A PostgreSQL database running as a StatefulSet with persistent storage
The backend provides REST endpoints: The backend provides REST endpoints:
POST /add → adds a name to the database POST /add → adds a name to the database
GET /names → retrieves all stored names GET /names → retrieves all stored names
2. Containers Used 2. Containers Used
Backend (Node.js) Backend (Node.js)
Image: docker-app-backend:latest Image: docker-app-backend:latest
Purpose: Handles API requests and communicates with the database Purpose: Handles API requests and communicates with the database
Database (PostgreSQL) Database (PostgreSQL)
Image: postgres:15 Image: postgres:15
Purpose: Stores application data persistently Purpose: Stores application data persistently
3. Kubernetes Objects 3. Kubernetes Objects
Namespace Namespace
Name: myapp Name: myapp
Used to isolate all application resources Used to isolate all application resources
Deployment Deployment
Name: backend Name: backend
Runs the Node.js backend Runs the Node.js backend
Ensures availability and automatic restart of the backend container Ensures availability and automatic restart of the backend container
StatefulSet StatefulSet
Name: db Name: db
Runs PostgreSQL Runs PostgreSQL
Provides stable identity and persistent storage Provides stable identity and persistent storage
PersistentVolume (PV) PersistentVolume (PV)
Stores PostgreSQL data on node storage Stores PostgreSQL data on node storage
PersistentVolumeClaim (PVC) PersistentVolumeClaim (PVC)
Automatically created via StatefulSet Automatically created via StatefulSet
Requests storage for database persistence Requests storage for database persistence
Services Services
backend-service (NodePort) backend-service (NodePort)
Exposes backend externally Exposes backend externally
Accessible at: Accessible at:
http://localhost:30007 http://localhost:30007
db service (ClusterIP) db service (ClusterIP)
Enables internal communication between backend and database Enables internal communication between backend and database
Backend connects using hostname: db Backend connects using hostname: db
4. Networking 4. Networking
Kubernetes DNS allows communication between differents components of the application using service names. Backend communicates with database using db and external users access backend via NodePort service Kubernetes DNS allows communication between differents components of the application using service names. Backend communicates with database using db and external users access backend via NodePort service
5. Persistent Storage 5. Persistent Storage
PostgreSQL uses: PostgreSQL uses:
PersistentVolume (PV) and PersistentVolumeClaim (PVC) PersistentVolume (PV) and PersistentVolumeClaim (PVC)
Using these ensures that data is not lost after pod restart and application state is preserved Using these ensures that data is not lost after pod restart and application state is preserved
6. Container Configuration 6. Container Configuration
Backend Backend
Port: 3000 Port: 3000
Database connection: Database connection:
Host: db Host: db
User: user User: user
Password: password Password: password
Database: mydb Database: mydb
Database Database
Port: 5432 Port: 5432
This uses persistent volume for data storage This uses persistent volume for data storage
7. Preparation 7. Preparation
Build backend image: Build backend image:
docker build -t docker-app-backend ./backend docker build -t docker-app-backend ./backend
8. Deployment 8. Deployment
Apply all Kubernetes resources: Apply all Kubernetes resources:
kubectl apply -f namespace.yamlkubectl apply -f deployment.yamlkubectl apply -f service.yamlkubectl apply -f statefulset.yamlkubectl apply -f db-service.yaml kubectl apply -f namespace.yamlkubectl apply -f deployment.yamlkubectl apply -f service.yamlkubectl apply -f statefulset.yamlkubectl apply -f db-service.yaml
9. Checking Application Status 9. Checking Application Status
kubectl get all -n myappkubectl get pods -n myappkubectl get svc -n myapp kubectl get all -n myappkubectl get pods -n myappkubectl get svc -n myapp
10. Accessing the Application 10. Accessing the Application
Backend API: Backend API:
http://localhost:30007 http://localhost:30007
Frontend: Frontend:
Open frontend/index.html in a browser Open frontend/index.html in a browser
11. Stopping the Application 11. Stopping the Application
kubectl delete -f deployment.yamlkubectl delete -f service.yamlkubectl delete -f statefulset.yamlkubectl delete -f db-service.yamlkubectl delete namespace myapp kubectl delete -f deployment.yamlkubectl delete -f service.yamlkubectl delete -f statefulset.yamlkubectl delete -f db-service.yamlkubectl delete namespace myapp
12. Removing All Resources 12. Removing All Resources
kubectl delete namespace myapp kubectl delete namespace myapp
13. Used Resources 13. Used Resources
Kubernetes Documentation: https://kubernetes.io/docs/ Kubernetes Documentation: https://kubernetes.io/docs/
Docker Documentation: https://docs.docker.com/ Docker Documentation: https://docs.docker.com/
PostgreSQL Docker Image PostgreSQL Docker Image
Node.js Express Framework Node.js Express Framework
14. Use of Artificial Intelligence 14. Use of Artificial Intelligence
Artificial intelligence tools were used to: Artificial intelligence tools were used to:
Assist with debugging deployment issues Assist with debugging deployment issues
Improve configuration of Kubernetes objects Improve configuration of Kubernetes objects
Help structure the project and documentation Help structure the project and documentation
All implementation, testing, and understanding were performed independently. All implementation, testing, and understanding were performed independently.
15. Summary 15. Summary
This project demonstrates: This project demonstrates:
Containerized web application architecture Containerized web application architecture
Kubernetes Deployment and StatefulSet usage Kubernetes Deployment and StatefulSet usage
Persistent storage with PVC Persistent storage with PVC
Internal service communication using DNS Internal service communication using DNS
External access using NodePort External access using NodePort
The application is fully functional and can store and retrieve data using a Kubernetes-based backend and database. AI was use strictly for learninf concepts and debugging, all coding and implementation was done independently. The application is fully functional and can store and retrieve data using a Kubernetes-based backend and database. AI was use strictly for learninf concepts and debugging, all coding and implementation was done independently.