<p>I have 2 API backends Microservices in which each Microservice has MongoDB database. I want to deploy 2 or more instances of each of these in Kubernetes cluster on Cloud provider such as AWS.</p>
<p>Each instance of Microservice runs as a container in a Pod. Is it possible to deploy MongoDB as another container in the same Pod? Or what is the best practice for this use case?</p>
<p>If two or more instances of the same Microservice are running in different Pods, do I need to deploy 2 or more instances of MongoDB or single MongoDb is referenced by the multiple instances of the same Microservice? What is the best practice for this use case?</p>
<p>Each Microservice is Spring Boot application. Do I need to do anything special in the Spring Boot application source code just because it will be run as Microservice as opposed to traditional Spring Boot application?</p>

ace
<blockquote>
<p>Each instance of Microservice runs as a container in a Pod. Is it possible to deploy MongoDB as another container in the same Pod?</p>
</blockquote>
<p>Nope, then your data would be gone when you upgrade your application.</p>
<blockquote>
<p>Or what is the best practice for this use case?</p>
</blockquote>
<p>Databases in a modern production environment are run as <strong>clusters</strong> - for availability reasons. It is best practice to either use a managed service for the database or run it as a cluster with e.g. 3 instances on different nodes.</p>
<blockquote>
<p>If two or more instances of the same Microservice are running in different Pods, do I need to deploy 2 or more instances of MongoDB or single MongoDb is referenced by the multiple instances of the same Microservice?</p>
</blockquote>
<p>All your instances of the microservice should access the same database cluster, otherwise they would see different data.</p>
<blockquote>
<p>Each Microservice is Spring Boot application. Do I need to do anything special in the Spring Boot application source code just because it will be run as Microservice as opposed to traditional Spring Boot application?</p>
</blockquote>
<p>Spring Boot is designed according to <a href="https://12factor.net/" rel="nofollow noreferrer">The Twelve Factor App</a> and hence is designed to be run in a cloud environment like e.g. Kubernetes.</p>
