This repository provides basic MongoDB Kubernetes settings with Persistance Storage for development purposes. I found it hard to find an easy Kubernetes specification to run and test MongoDB with persistant storage.
Easy to use commands to get your MongoDB running in Kubernetes with persistant storage in matter of seconds.
(Note for specifying your own data path clone the repo and specify your data path in the localstoragevolume.yml file. The current data path might not give you persistance)
Set the secrets for MongoDB: admin
, admin
(Note this is not Secure, and should not be used in production environments!!).
Do you want to change the credentials?
echo -n '<your password or username>' | base64
and paste this into the mongodb-secret.yml file (Requires you to clone this repo)
kubectl create -f https://raw.githubusercontent.com/thehoodbuddha/MongoDB-Kubernetes-Persistant-Storage/main/mongodb-secret.yml
kubectl apply -f https://raw.githubusercontent.com/thehoodbuddha/MongoDB-Kubernetes-Persistant-Storage/main/localstoragevolume.yml
kubectl apply -f https://raw.githubusercontent.com/thehoodbuddha/MongoDB-Kubernetes-Persistant-Storage/main/storageclaim.yml
kubectl apply -f https://raw.githubusercontent.com/thehoodbuddha/MongoDB-Kubernetes-Persistant-Storage/main/mongoDB.yml
Use the following commands to remove the volume. (Note data might be lost)
kubectl describe pvc example-claim | grep Finalizers
should give: Finalizers: [kubernetes.io/pvc-protection]
Fix
kubectl patch pvc example-claim -p '{"metadata":{"finalizers": []}}' --type=merge
(Link to StackOverflow)