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.
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.
- 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.
-
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>
- Apply Kubernetes configurations: Apply the MongoDB deployment and service configurations using kubectl:
kubectl apply -f mongodb-deployment.yaml
kubectl apply -f mongodb-service.yaml
- 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
- Access MongoDB:
You can access the MongoDB shell within the running pod:
kubectl exec -it <mongo-pod-name> -- mongo
- Check MongoDB Logs:
To check MongoDB logs, use the following command:
kubectl logs <mongo-pod-name>
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.
Here is the supporting documentation and video demo.
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
- KCNA + KCSA + CKA + CKAD + CKS ($788 Savings): kube.promo/kubestronaut
- CKA + CKAD + CKS Exam bundle ($528 Savings): kube.promo/k8s-bundle
- CKA + CKS Bundle ($355 Savings) kube.promo/bundle
- KCNA + CKA ( $288 Savings) kube.promo/kcka-bundle
- KCSA + CKS Exam Bundle ($229 Savings) kube.promo/kcsa-cks
- KCNA + KCSA Exam Bundle ($203 Savings) kube.promo/kcna-kcsa
Note: You have one year of validity to appear for the certification exam after registration
If you are learning Kubernetes, check out the kubernetes Learning Roadmap