A Kubernetes project that deploys a full-stack application on a local Minikube cluster, consisting of a Node.js web app connected to a MongoDB database — configured using Kubernetes-native ConfigMaps and Secrets.
- Kubernetes / Minikube — Local cluster orchestration
- MongoDB 5.0 — Database
- Node.js Web App — Frontend/backend application
- Docker — Container runtime
- ConfigMap — External configuration management
- Secrets — Secure credentials management
kubernetes-mongodb-webapp/ ├── mongo-config.yaml ├── mongo-secret.yaml ├── mongo.yaml └── webapp.yaml
Stores MongoDB credentials (username and password) as base64-encoded Kubernetes Secrets, keeping sensitive data out of application code.
A ConfigMap that stores the MongoDB service URL, decoupling configuration from the application.
- Deployment — Runs a single MongoDB 5.0 pod, injecting credentials from the Secret as environment variables
- Service — Internal ClusterIP service exposing MongoDB on port
27017
- Deployment — Runs the web app pod, pulling DB credentials from Secrets and the DB URL from the ConfigMap
- Service — NodePort service exposing the app externally on port
30100
┌─────────────────────────────────────┐
│ Minikube Cluster │
│ │
Browser │ ┌──────────┐ ┌─────────────┐ │ │ │ │ webapp │ │ mongodb │ │ │ NodePort │ │ pod │─────▶│ pod │ │ └─────────────▶│ │ :3000 │ │ :27017 │ │ :30100 │ └──────────┘ └─────────────┘ │ │ │ │ │ │ ┌────┴────┐ ┌──────┴──────┐ │ │ │ webapp │ │ mongo │ │ │ │ service │ │ service │ │ │ └─────────┘ └─────────────┘ │ │ │ │ ┌─────────────┐ ┌──────────────┐ │ │ │ ConfigMap │ │ Secret │ │ │ │ mongo-url │ │ user + pass │ │ │ └─────────────┘ └──────────────┘ │ └─────────────────────────────────────┘
Prerequisites: Minikube and kubectl installed.
1. Start Minikube:
minikube start2. Apply the configs in order:
kubectl apply -f mongo-secret.yaml
kubectl apply -f mongo-config.yaml
kubectl apply -f mongo.yaml
kubectl apply -f webapp.yaml3. Verify pods are running:
kubectl get pods
kubectl get services4. Get Minikube IP and open in browser:
minikube ipThen visit: http://<minikube-ip>:30100
Credentials in mongo-secret.yaml are base64 encoded. To generate your own:
echo -n 'your-username' | base64
echo -n 'your-password' | base64| Config | Source | Key |
|---|---|---|
| MongoDB Username | Secret | USER_NAME |
| MongoDB Password | Secret | PASSWORD |
| MongoDB URL | ConfigMap | mongo-url |
This project was built to learn core Kubernetes concepts including Deployments, Services, ConfigMaps, and Secrets on a local Minikube cluster.
Umar Jalal