Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kubernetes MongoDB Web App

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.

🔧 Tech Stack

  • 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

📁 Project Structure

kubernetes-mongodb-webapp/ ├── mongo-config.yaml ├── mongo-secret.yaml ├── mongo.yaml └── webapp.yaml

📦 Kubernetes Components

mongo-secret.yaml

Stores MongoDB credentials (username and password) as base64-encoded Kubernetes Secrets, keeping sensitive data out of application code.

mongo-config.yaml

A ConfigMap that stores the MongoDB service URL, decoupling configuration from the application.

mongo.yaml

  • 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

webapp.yaml

  • 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

🏗️ Architecture

            ┌─────────────────────────────────────┐
            │         Minikube Cluster             │
            │                                      │

Browser │ ┌──────────┐ ┌─────────────┐ │ │ │ │ webapp │ │ mongodb │ │ │ NodePort │ │ pod │─────▶│ pod │ │ └─────────────▶│ │ :3000 │ │ :27017 │ │ :30100 │ └──────────┘ └─────────────┘ │ │ │ │ │ │ ┌────┴────┐ ┌──────┴──────┐ │ │ │ webapp │ │ mongo │ │ │ │ service │ │ service │ │ │ └─────────┘ └─────────────┘ │ │ │ │ ┌─────────────┐ ┌──────────────┐ │ │ │ ConfigMap │ │ Secret │ │ │ │ mongo-url │ │ user + pass │ │ │ └─────────────┘ └──────────────┘ │ └─────────────────────────────────────┘

🚀 How to Run

Prerequisites: Minikube and kubectl installed.

1. Start Minikube:

minikube start

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

3. Verify pods are running:

kubectl get pods
kubectl get services

4. Get Minikube IP and open in browser:

minikube ip

Then visit: http://<minikube-ip>:30100

🔐 Secrets & Config

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

📝 Notes

This project was built to learn core Kubernetes concepts including Deployments, Services, ConfigMaps, and Secrets on a local Minikube cluster.

👤 Author

Umar Jalal

About

A Kubernetes demo project deploying a MongoDB database and Node.js web app on Minikube using Deployments, Services, ConfigMaps and Secrets.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors