I have a java application that writes data to MnogoDB database which so far I run it in a monolithic approach for Production.
We consider moving it to Kubernetes cluster:
the data should not be lost and should be persistent.
should we deploy the MongoDB inside the Kubernetes cluster as a pod with persistent volume pod? is it safe ? what happens if the cluster is crushed?
Or should I deploy only the Java application to the cluster and the database will be outside of the cluster?
2
Answers
I recommend you to use MongoDB Atlas for Database Deployments.
Kubernetes is a stateless container orchestrator by its nature ( meaning it is not designed for databases by intension ) , later it was extended and adapted for databases with the statefullset API and you can customize and adapt it for mongoDB , but the statefull deployments become alot complex and difficult to support and mantain so it become alot easier to use k8s operator for the task.
The choices are:
1) Keep your database outside k8s.
pros:
cons:
2) Go to ATLAS(mongoDB SaaS).
pros:
cons:
3) Use mongoDB k8s enterprise operator.
pros:
cons:
4) Use mongoDB k8s community operator.
pros:
cons:
5) Use 3th party community operator.
pros:
cons:
6) Deploy via custom statefulset helm chart.
pros:
cons:
I will not sound very modern if I say keep it outside k8s for reliability , but this is my choice , if you need to be modern it is best to use the SaaS provided by the vendor(mongoDB ATLAS) …