This repository contains YAML files to deploy MongoDB on a Kubernetes cluster with a Deployment, Secrets, and Service.
- Deployment: Single MongoDB pod exposing port
27017
with credentials from a Secret. - Headless Service: Enables pod-to-pod communication using
clusterIP: None
. - Secrets: Stores base64-encoded MongoDB credentials securely.
mongodb-deployment.yaml
: Defines the Deployment and Service.mongodb-secret.yaml
: Contains Secrets with credentials.mongodb-service.yaml
: Defines the Service for MongoDB.
- Kubernetes cluster (e.g., Minikube, GKE, EKS).
kubectl
CLI configured.
- Apply Secrets:
kubectl apply -f mongodb-secret.yaml
- Deploy MongoDB:
kubectl apply -f mongodb-deployment.yaml
- Apply Service:
kubectl apply -f mongodb-service.yaml
- Verify:
kubectl get pods
Delete resources:
kubectl delete -f mongodb-deployment.yaml
kubectl delete -f mongodb-secret.yaml
kubectl delete -f mongodb-service.yaml