Skip to content

This project demonstrates how to deploy MongoDB and Mongo-Express in a local Kubernetes cluster set up with Minikube. MongoDB is a popular, document-based NoSQL database, and Mongo-Express is a web-based MongoDB admin interface written with Node.js, Express.js. Both applications are containerised using Docker images and managed by Kubernetes.

Notifications You must be signed in to change notification settings

imsalmanmalik/MongoDB-Kubernetes-Deployment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

The deployment consists of two major components:

  • MongoDB Database
  • Mongo-Express (a web-based admin interface for MongoDB)

Each component is deployed using Kubernetes resources such as ConfigMaps, Secrets, Deployments and Services.

Prerequisites

  • Docker
  • Minikube
  • Kubectl or another Kubernetes management tool
  • Deployment Files

The repository contains the following Kubernetes configuration files to deploy a MongoDB database and its web-based admin interface, Mongo-Express.

mongo-configmap.yaml

This file holds the configuration map used in the MongoDB and Mongo-Express deployments. It contains the database URL which is utilized by Mongo-Express to connect to the MongoDB database.

mongo-express.yaml

This is a two-part YAML file which includes:

The Deployment configuration for Mongo-Express. It references the MongoDB connection information stored in the ConfigMap and Secret to access the MongoDB database. The image used is the official mongo-express Docker image.

The Service configuration to expose the Mongo-Express deployment to the network. It utilizes the LoadBalancer service type to make the service accessible outside of the Kubernetes cluster.

mongo-secret.yaml

This file holds the Secrets used for the MongoDB deployment. It contains the base64 encoded MongoDB admin username and password, which are used by both the MongoDB and Mongo-Express deployments.

mongodb.yaml

This is also a two-part YAML file which includes:

The Deployment configuration for MongoDB. It utilizes the official mongo Docker image, and references the admin username and password stored in the Secret.

The Service configuration which exposes the MongoDB deployment to the network, enabling Mongo-Express and potentially other applications to connect to the database.

Deployment Instructions

  1. Clone this repository.
  2. Start the Minikube cluster with the command:
minikube start
  1. The commands for deployment are as follows:
kubectl apply -f mongo-configmap.yaml
kubectl apply -f mongo-secret.yaml
kubectl apply -f mongodb.yaml
kubectl apply -f mongo-express.yaml

Accessing the Applications

MongoDB is running on port 27017 and Mongo-Express on port 8081. As the services are set up with type LoadBalancer and we are using Minikube, you can access the Mongo-Express web interface via a web browser by running the command:

minikube service mongo-express-service

This command will automatically open the service in your default web browser.

About

This project demonstrates how to deploy MongoDB and Mongo-Express in a local Kubernetes cluster set up with Minikube. MongoDB is a popular, document-based NoSQL database, and Mongo-Express is a web-based MongoDB admin interface written with Node.js, Express.js. Both applications are containerised using Docker images and managed by Kubernetes.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published