How can i achieve multi Tenancy web application using namespace and ingress

There are multiple same pods running in one cluster but different namespaces. This is the web application running in Kubernetes. I have the URL <HOSTNAME>:<PORT>/context/abc/def/..... . I want to redirect to particular service based on the context. Is there a way i can achieve it using ingress controller ? Or Is there any way i can achieve it using different ports through ingress ?

My web application works fine if the URL is <HOSTNAME>:<PORT>/abc/def/..... . Since i have to access the different pods using the same URL, I am adding context to it. Do we have any other way to achieve this use case ? My Rest End point will change if i add context path for each tenancy.

Asking for help? Comment out what you need so we can get more information to help you!

Cluster information:

Kubernetes version:
Cloud being used: (put bare-metal if not on a public cloud)
Installation method:
Host OS:
CNI and version:
CRI and version:

You can format your yaml by highlighting it and pressing Ctrl-Shift-C, it will make your output easier to read.

You can consider two options:

  • use a subdomain as a context - http://context1.api.example.com/abc/def

  • use dedicated ingress controllers (nginx?) for each context - and these controllers will be exposed on different ports probably.

i am using nginx, can i expose multiple http ports. So that i can have one port for each context. Like 81 for host:81/abc, host:82/abc. If it is possible i can go for path based routing.