zkt26/z2
2026-04-20 21:33:44 +00:00
..
db-service.yaml Upload files to "z2" 2026-04-20 21:31:47 +00:00
deployment.yaml Upload files to "z2" 2026-04-20 21:31:47 +00:00
Dockerfile Upload files to "z2" 2026-04-20 21:31:47 +00:00
init.sql Upload files to "z2" 2026-04-20 21:31:47 +00:00
namespace.yaml Upload files to "z2" 2026-04-20 21:31:47 +00:00
package.json Upload files to "z2" 2026-04-20 21:31:47 +00:00
prepare-app.sh Upload files to "z2" 2026-04-20 21:31:47 +00:00
README.md Update z2/README.md 2026-04-20 21:33:44 +00:00
server.js Upload files to "z2" 2026-04-20 21:31:47 +00:00
service.yaml Upload files to "z2" 2026-04-20 21:31:47 +00:00
start-app.sh Upload files to "z2" 2026-04-20 21:31:47 +00:00
statefulset.yaml Upload files to "z2" 2026-04-20 21:31:47 +00:00
stop-app.sh Upload files to "z2" 2026-04-20 21:31:47 +00:00

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. The system consists of:

A frontend (static HTML interface)

A backend API built with Node.js (Express)

A PostgreSQL database running as a StatefulSet with persistent storage

The backend provides REST endpoints:

POST /add → adds a name to the database

GET /names → retrieves all stored names

  1. Containers Used Backend (Node.js)

Image: docker-app-backend:latest

Purpose: Handles API requests and communicates with the database

Database (PostgreSQL)

Image: postgres:15

Purpose: Stores application data persistently

  1. Kubernetes Objects Namespace

Name: myapp

Used to isolate all application resources

Deployment

Name: backend

Runs the Node.js backend

Ensures availability and automatic restart of the backend container

StatefulSet

Name: db

Runs PostgreSQL

Provides stable identity and persistent storage

PersistentVolume (PV)

Stores PostgreSQL data on node storage

PersistentVolumeClaim (PVC)

Automatically created via StatefulSet

Requests storage for database persistence

Services backend-service (NodePort)

Exposes backend externally

Accessible at: http://localhost:30007

db service (ClusterIP)

Enables internal communication between backend and database

Backend connects using hostname: db

  1. 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

  1. Persistent Storage PostgreSQL uses: PersistentVolume (PV) and PersistentVolumeClaim (PVC)

Using these ensures that data is not lost after pod restart and application state is preserved

  1. Container Configuration Backend

Port: 3000

Database connection:

Host: db

User: user

Password: password

Database: mydb

Database

Port: 5432

This uses persistent volume for data storage

  1. Preparation Build backend image: docker build -t docker-app-backend ./backend

  2. Deployment 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

  3. Checking Application Status kubectl get all -n myappkubectl get pods -n myappkubectl get svc -n myapp

  4. Accessing the Application Backend API: http://localhost:30007 Frontend: Open frontend/index.html in a browser

  5. Stopping the Application kubectl delete -f deployment.yamlkubectl delete -f service.yamlkubectl delete -f statefulset.yamlkubectl delete -f db-service.yamlkubectl delete namespace myapp

  6. Removing All Resources kubectl delete namespace myapp

  7. Used Resources

Kubernetes Documentation: https://kubernetes.io/docs/

Docker Documentation: https://docs.docker.com/

PostgreSQL Docker Image

Node.js Express Framework

  1. Use of Artificial Intelligence Artificial intelligence tools were used to:

Assist with debugging deployment issues

Improve configuration of Kubernetes objects

Help structure the project and documentation

All implementation, testing, and understanding were performed independently.

  1. Summary This project demonstrates:

Containerized web application architecture

Kubernetes Deployment and StatefulSet usage

Persistent storage with PVC

Internal service communication using DNS

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.