Skip to content

Latest commit

 

History

History
113 lines (81 loc) · 4.12 KB

README.md

File metadata and controls

113 lines (81 loc) · 4.12 KB

MongoDB Kubernetes Deployment

This project deploys MongoDB on a Kubernetes cluster. The goal is to set up a MongoDB instance that runs within a Kubernetes environment, leveraging Kubernetes' container orchestration capabilities to manage scaling, availability, and reliability.

Purpose

The purpose of this project is to simplify the deployment of a MongoDB database using Kubernetes, automating the management of database instances within a containerized infrastructure. This setup is ideal for applications that require a NoSQL database solution and benefit from the scalability and reliability provided by Kubernetes.

How to Run the Code

Prerequisites

  • Ensure that your Kubernetes cluster is up and running.
  • Install kubectl to manage your Kubernetes cluster.
  • Install helm if using Helm charts for MongoDB deployment.

Steps to Deploy MongoDB on Kubernetes

  1. Clone the Repository:

    git clone /~https://github.com/hasannader2040/mongodb_kubernetes.git
    cd mongodb_kubernetes
2. Navigate to the project directory:
   ```bash
cd <project-directory>
  1. Apply Kubernetes configurations: Apply the MongoDB deployment and service configurations using kubectl:
kubectl apply -f mongodb-deployment.yaml
kubectl apply -f mongodb-service.yaml
  1. Verify the deployment:

Check the status of the pods to ensure MongoDB is running:

kubectl get pods

Verify the service is created and accessible:

kubectl get svc
  1. Access MongoDB:

You can access the MongoDB shell within the running pod:

kubectl exec -it <mongo-pod-name> -- mongo
  1. Check MongoDB Logs:

To check MongoDB logs, use the following command:

kubectl logs <mongo-pod-name>

Tools Used

Kubernetes: For container orchestration and managing the MongoDB deployment. MongoDB : A NoSQL database deployed in the Kubernetes cluster. YAML: For Kubernetes resource configuration files. Helm: (Optional) If you're using Helm charts for MongoDB deployment. Usage Examples Checking MongoDB Logs To monitor the MongoDB logs, use:

kubectl logs <mongo-pod-name>

Accessing MongoDB Shell To access the MongoDB shell from within the pod, use:

kubectl exec -it <mongo-pod-name> -- mongo

Additional Information Ensure your Kubernetes cluster is up and running before deploying MongoDB. Modify the YAML files (mongodb-deployment .yaml, mongodb-service.yaml) as needed to customize the deployment (e.g., changing replica counts, resource requests/limits). If using Helm, customize the values.yaml file accordingly.

Kubeadm Cluster Setup Scripts

Here is the supporting documentation and video demo.

  1. Documentation - Kubeadm Cluster Setup Guide
  2. Kubeadm workflow explanation and demo video

🚀 For Kubernetes Certification Aspirants

As part of our commitment to helping the DevOps community save money on Kubernetes Certifications, we continuously update the latest voucher codes from the Linux Foundation

🚀 CKA, CKAD, CKS, or KCNA exam aspirants can save 30% today using code 30COMTECHIES at https://kube.promo/devops. It is a limited-time offer from the Linux Foundation.

The following are the best bundles to save 40% (up to $788) with code FOURTH24CT

Note: You have one year of validity to appear for the certification exam after registration

Kubernetes Learning Roadmap

If you are learning Kubernetes, check out the kubernetes Learning Roadmap