<p>We are trying to choose schema for allocation microservices in multi tenant application. We want to use kubernates and see two cases:</p>

<p>First case: </p>

<p>+ Looks like a more productive scheme <br>
+ Easy to administer <br>
- Difficult to implement<br></p>

<p><a href="https://i.stack.imgur.com/hiYCQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hiYCQ.png" alt="enter image description here"></a></p>

<p>Second case:</p>

<p>+ More incapsulated <br>
- Looks like a less productive scheme<br></p>

<p><a href="https://i.stack.imgur.com/F2dqR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F2dqR.png" alt="enter image description here"></a></p>

Vladimir
<p>Use the <em>second case</em> with a separate namespace per tenant.</p>

<p><strong>Different configurations</strong></p>

<p>You have designed a solution with a separate database for each tenant. You can run the same <em>container image</em> for the tenants but the should use <strong>different configurations</strong> e.g. they have different address to the database. See <a href="https://12factor.net/config" rel="nofollow noreferrer">Twelve factor - externalize configuration</a>.</p>

<blockquote>
  <p>We must always create a new service's container for each tenant. Although if load is low we could use one general container for all tenants</p>
</blockquote>

<p>You can easily create the same service for each tenant using Kubernetes <strong>declarative</strong> Deployment manifests. You can also assign only the resources that is needed for each tenant, e.g. variations in number of replicas or different CPU or Memory resources.</p>

<p><strong>Route error information to a central service</strong></p>

<blockquote>
  <p>We have single entry point for detect errors</p>
</blockquote>

<p>You should always route observability information, e.g. logs, metrics and events to a central service for your cluster.</p>

<p><strong>Isolate tenants</strong></p>

<p>In addition, if you have separate namespaces for tenants, you can isolate them more using <a href="https://kubernetes.io/docs/concepts/services-networking/network-policies/" rel="nofollow noreferrer">Network Policies</a></p>
