zkt25/z2
2025-04-15 15:49:52 +02:00
..
src Second assignment 2025-04-15 15:49:52 +02:00
deployment.yaml Second assignment 2025-04-15 15:49:52 +02:00
deployment.yaml:Zone.Identifier Second assignment 2025-04-15 15:49:52 +02:00
Dockerfile Second assignment 2025-04-15 15:49:52 +02:00
Dockerfile:Zone.Identifier Second assignment 2025-04-15 15:49:52 +02:00
namespace.yaml Second assignment 2025-04-15 15:49:52 +02:00
namespace.yaml:Zone.Identifier Second assignment 2025-04-15 15:49:52 +02:00
package.json Second assignment 2025-04-15 15:49:52 +02:00
package.json:Zone.Identifier Second assignment 2025-04-15 15:49:52 +02:00
prepare-app.sh Second assignment 2025-04-15 15:49:52 +02:00
prepare-app.sh:Zone.Identifier Second assignment 2025-04-15 15:49:52 +02:00
README.md Second assignment 2025-04-15 15:49:52 +02:00
README.md:Zone.Identifier Second assignment 2025-04-15 15:49:52 +02:00
service.yaml Second assignment 2025-04-15 15:49:52 +02:00
service.yaml:Zone.Identifier Second assignment 2025-04-15 15:49:52 +02:00
start-app.sh Second assignment 2025-04-15 15:49:52 +02:00
start-app.sh:Zone.Identifier Second assignment 2025-04-15 15:49:52 +02:00
statefulset.yaml Second assignment 2025-04-15 15:49:52 +02:00
statefulset.yaml:Zone.Identifier Second assignment 2025-04-15 15:49:52 +02:00
stop-app.sh Second assignment 2025-04-15 15:49:52 +02:00
stop-app.sh:Zone.Identifier Second assignment 2025-04-15 15:49:52 +02:00

Contact List Web Application on Kubernetes

Description

A simple web-based contact list app with name and number fields, using Node.js/Express and MongoDB. Data is persisted in MongoDB.

Containers

  • contact-app: Node.js/Express web server serving the frontend and API.
  • mongo: Official MongoDB container for data storage.

Kubernetes Objects

  • Namespace: contact-app — all resources are grouped here.
  • Deployment: Runs the Node.js web app.
  • StatefulSet: Runs MongoDB with persistent storage.
  • PersistentVolume/PersistentVolumeClaim: Stores MongoDB data.
  • Service:
    • contact-app: Exposes the web app on a NodePort.
    • mongo: Headless service for MongoDB.

Virtual Networks and Volumes

  • Headless Service: For MongoDB pod DNS discovery.
  • Named Volume: /data/mongo on the host, mounted to MongoDB for persistence.

Container Configuration

  • The Node.js app uses the MONGODB_URI environment variable to connect to MongoDB.
  • MongoDB uses a persistent volume for /data/db.

Instructions

Prepare

chmod +x prepare-app.sh start-app.sh stop-app.sh
./prepare-app.sh

Run

./start-app.sh

Access the App

  1. Get the NodePort:
    kubectl -n contact-app get service contact-app
    
  2. Open in browser:
    http://<minikube_ip>:<node_port>
    • Get Minikube IP: minikube ip

Pause/Stop

./stop-app.sh

Delete Volumes (optional)

rm -rf /data/mongo

View the Application

  • Open the NodePort URL in your browser.
  • Add and view contacts via the web UI.

Notes

  • Make sure Docker is running and Minikube is started.
  • All kubectl commands assume your context is set to Minikube.