<p>I have a project that uses the following resources to work:</p>

<ul>
<li><p>A jsf application running under JBoss and using a PostgreSQL</p></li>
<li><p>2 spring boot API using MongoDB. </p></li>
</ul>

<p>So, I have the following dockers:</p>

<ul>
<li><p>jsf+JBoss in same docker</p></li>
<li><p>PostgreSQL docker</p></li>
<li><p>mongo docker</p></li>
<li><p>one docker for each spring boot app.</p></li>
</ul>

<p>In kubernates I need organize this containers in PODs, so my ideia is create the following:</p>

<ul>
<li><p>A POD for jsf+JBoss docker</p></li>
<li><p>Another for PostgreSQL</p></li>
<li><p>Another POD for MongoDB</p></li>
<li><p>Only one POD for both spring boot app, because they need each other.</p></li>
</ul>

<p>So, I have 4 POD and 6 containers. Thinking about best practices to use ks8, this is a good way to organize my project?</p>

<p>tl;dr; This doesn't follow Kubernetes best practices. Each application should be a separate <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/" rel="nofollow noreferrer">deployment</a> or <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/" rel="nofollow noreferrer">StatefulSet</a>.</p>

<p>A better way to run this in Kubernetes would be using a <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/" rel="nofollow noreferrer">deployment</a> or <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/" rel="nofollow noreferrer">StatefulSet</a> for each individual application, so it would be:</p>

<p>One Deployment with a single container for jsf+JBoss</p>

<p>One StatefulSet for PostgreSQL (though I would suggest looking at an Operator to manage your PostgreSQL cluster, i.e. <a href="https://kubedb.com/" rel="nofollow noreferrer">kubedb</a></p>

<p>One StatefulSet for MongoDB (again, strongly suggest using an Operator to manage your MongoDB cluster, which <a href="https://kubedb.com/" rel="nofollow noreferrer">kubedb</a> can also handle)</p>

<p>One deployment <em>each</em> for your Spring Boot applications, assuming they communicate with each other via a network. You can then manage and scale each independently of each other, regardless of their dependency on each other.</p>
