<p>I want to deploy a traditional monolithic application in Kubernetes.<br />
Thousands of customers use this application and each customer has its own instance of application. if we have 5 customers we should run 5 separate instances of this application.<br />
The application also calls Kubernetes API for running some jobs.</p>
<p>I want to make sure that everything is isolated, Is it a good idea to create a separate namespace for each customer? Does it cause some performance issues? Is there any better solution for it?</p>

<p>I think you should create <strong>multi-tenant</strong> cluster.</p>
<p>Such clusters  shared by multiple users and/or workloads which are referred to as &quot;tenants&quot;. The operators of multi-tenant clusters must isolate tenants from each other to avoid the damage that a compromised.  You should know that cluster resources must be fairly allocated among tenants.</p>
<p>When you plan a multi-tenant architecture you should consider the layers of resource isolation in Kubernetes: cluster, namespace, node, pod, and container. You should also consider the security aspects of sharing different types of resources among specific tenants.</p>
<p>Although Kubernetes cannot guarantee perfectly secure isolation between tenants, it does offer features that may be sufficient for specific solutions. For example you can separate each tenant and their Kubernetes resources into their own separate  <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/" rel="nofollow noreferrer">namespaces</a>. Then use  <a href="https://kubernetes.io/docs/concepts/policy/" rel="nofollow noreferrer">policies</a>  to enforce tenant isolation. Policies are usually scoped by namespace and can be used to restrict API access, to constrain resource usage, and to restrict what containers are allowed to do.</p>
<p>Read more: <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/multitenancy-overview#what_is_multi-tenancy" rel="nofollow noreferrer">multi-tenant-cluster</a>.</p>
<p>However while implementing multi-tenancy with Kubernetes, you need to decide if you need  soft multi-tenancy (is focused on minimising accidents and managing the fallout) or hard multi-tenancy(assumes tenants to be malicious and therefore advocates zero trust between them). In any case, you have to answer questions: how to limit their resource usage, how to manage the users/tenants  and how to isolate them from each other. There are many tools, for example:  <a href="https://loft.sh/" rel="nofollow noreferrer">loft</a> which can help you to get multi-tenancy with Kubernetes.</p>
<p>See: <a href="https://loft.sh/blog/kubernetes-multi-tenancy-best-practices-guide/" rel="nofollow noreferrer">multi-tenant-loft</a>.</p>
<p>Take a look: <a href="https://www.replex.io/blog/kubernetes-in-production-best-practices-and-checklist-for-multi-tenancy" rel="nofollow noreferrer">best-practices-multitenant</a>.</p>
