A robust, production-ready Kubernetes deployment for MongoDB and its web-based management tool, Mongo Express, on AWS EKS.
The deployment consists of a multi-tier architecture where MongoDB acts as the backend database and Mongo Express provides a user-friendly frontend interface.
Complete system architecture showing all K8s resources and integrations.
Visual representation of the K8s deployed resources and their traffic flow.
- 💾 Stateful Data Persistence: Data survives pod restarts using AWS Elastic Block Store (EBS) via
StorageClassandPVC. - ⚖️ High Availability: Mongo Express is horizontally scaled and load-balanced natively on AWS using Application Load Balancers (ALB).
- 🔐 Robust Security: Passwords and sensitive data are safely stored in Kubernetes Secrets and ConfigMaps.
- ☁️ AWS Native: Seamless integration with AWS EKS, EBS, and IAM Roles.
📁 K8S-Deploy MongoDB Database and Mongo Express
├── 📜 mongodb-Namspaces.yaml # Defines the isolated environment
├── 📜 momgoDB-secret.yaml # Encrypted root credentials
├── 📜 mongoExpress-Configmap.yaml # Database connection URLs
├── 📜 mongoDB-SC.yaml # AWS EBS StorageClass
├── 📜 mongoDB-PVC.YAML # Persistent Volume Claim for Mongo
├── 📜 mongoDB-deployment.yaml # MongoDB Pods definitions
├── 📜 mongoDB-Service.yaml # Internal ClusterIP for routing
├── 📜 mongo-Express-deployment.yaml # Frontend Web UI Pods
├── 📜 mongo-Express-Service.yaml # AWS LoadBalancer for external access
└── 📁 screenshot # Architecture & Execution snaps
Dynamically provisions AWS EBS volumes for MongoDB to ensure no data loss ever occurs.
AWS EBS volume dynamically provisioned to our cluster.
Appropriate IAM roles assigned to the cluster to allow interaction with EBS arrays and AWS load balancers securely.
AWS EC2 IAM Roles for worker nodes.
Deployed with high availability, traffic is routed smoothly into the specific Pods using AWS Native Target Groups.
AWS Target Groups routing traffic to our Mongo Express nodes.
The sleek Mongo Express inner dashboard for database management.
- Active AWS EKS Cluster.
kubectlconfigured to communicate with your cluster.- AWS EBS CSI Driver installed in the cluster.
-
Create the Namespace:
kubectl apply -f mongodb-Namspaces.yaml
-
Setup Storage (SC & PVC):
kubectl apply -f mongoDB-SC.yaml kubectl apply -f mongoDB-PVC.YAML
-
Configure Secrets & ConfigMaps:
kubectl apply -f momgoDB-secret.yaml kubectl apply -f mongoExpress-Configmap.yaml
-
Deploy MongoDB Backend:
kubectl apply -f mongoDB-deployment.yaml kubectl apply -f mongoDB-Service.yaml
-
Deploy Mongo Express Frontend:
kubectl apply -f mongo-Express-deployment.yaml kubectl apply -f mongo-Express-Service.yaml
Check if your resources are spinning up correctly:
kubectl get all -n mongodb-namespace
Verifying running pods, deployments, and services in our namespace.
- Extract the LoadBalancer external IP/DNS:
kubectl get svc -n mongodb-namespace
- Navigate to the extracted URL in your browser on port
8081. - Login using the Basic Auth credentials provided in your Secrets.
Secure login interface for Mongo Express.
GitHub Profile