nginx – Tenant specific URL in multi tenant SaaS using Kubernetes

Considering, there are more than 1 K8s cluster in one region, i am planning to generate tenant URLs like below.

Format:

<K8s-cluster-id>-<ingress-id>-<pool-id/dedicate-id/namespace-id>-<tenant-d>.<region>.mytest.com

tenant1, tenant2 deployed in cluster1 – pool1(id is 01)

01-1-01-tenant1.ca-west-1.mytest.com

01-1-01-tenant2.ca-west-1.mytest.com

tenant3, tenant4 deployed in cluster1 – pool2(id is 02)

01-1-02-tenant3.ca-west-1.mytest.com

01-1-02-tenant4.ca-west-1.mytest.com

tenant5 is dedicated, deployed in cluster1(id is ‘d’ i.e dedicated)

01-1-d-tenant5.ca-west-1.mytest.com

tenant6, tenant7 deployed in cluster2 – pool1(id is 01)

02-1-01-tenant6.ca-west-1.mytest.com

02-1-01-tenant7.ca-west-1.mytest.com

tenant8, tenant9 deployed in cluster2 – pool2(id is 02)

02-1-02-tenant8.ca-west-1.mytest.com

02-1-02-tenant9.ca-west-1.mytest.com

tenant10 is dedicated, deployed in cluster2(id is ‘d’ i.e dedicated)

02-1-d-tenant10.ca-west-1.mytest.com

Here, idea is the based on URL, redirect traffic to appropriate K8s cluster ingress controller.

For eg. If URL starts with 01-1, redirect it to cluster 01, ingress controller 1. Basically, like below:

Input traffic -> Nginx/other load balancer outside K8s cluster -> Target k8s cluster ingress controller.

Now, the target cluster ingress controller will redirect it to appropriate K8s service based on pool group/dedicated.

Approach is designed by considering below:

  1. Will need more than one K8s cluster in single region.
  2. Single K8s cluster could have more than one ingress controller.
  3. There could be batching of tenants in pool or dedicate env for tenant.

What all challenges with this approach? Or any better way to handle this?

Read more here: Source link