.. | ||
src | ||
deployment.yaml | ||
deployment.yaml:Zone.Identifier | ||
Dockerfile | ||
Dockerfile:Zone.Identifier | ||
namespace.yaml | ||
namespace.yaml:Zone.Identifier | ||
package.json | ||
package.json:Zone.Identifier | ||
prepare-app.sh | ||
prepare-app.sh:Zone.Identifier | ||
README.md | ||
README.md:Zone.Identifier | ||
service.yaml | ||
service.yaml:Zone.Identifier | ||
start-app.sh | ||
start-app.sh:Zone.Identifier | ||
statefulset.yaml | ||
statefulset.yaml:Zone.Identifier | ||
stop-app.sh | ||
stop-app.sh:Zone.Identifier |
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
- Get the NodePort:
kubectl -n contact-app get service contact-app
- Open in browser:
http://<minikube_ip>:<node_port>
- Get Minikube IP:
minikube ip
- Get 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.