Kubernetes: Having same host name but different paths in ingresses in different namespaces in Kubernetes

1k views Asked by At

I want to use the same hostname e.g. example.com in two different namespaces with different paths. e.g. in namespace A I want example.com/clientA and in namespace B I want example.com/clientB. Any ideas on how to achieve this?

2

There are 2 answers

0
Vit On BEST ANSWER

nginxinc has Cross-Namespace Configuration feature that allows you do exactly what you described. You can also find there prepared examples with deployments, services, etc.

The only thing you most probably wont like..nginxinc is not free..

Also look here

Cross-namespace Configuration You can spread the Ingress configuration for a common host across multiple Ingress resources using Mergeable Ingress resources. Such resources can belong to the same or different namespaces. This enables easier management when using a large number of paths. See the Mergeable Ingress Resources example on our GitHub.

As an alternative to Mergeable Ingress resources, you can use VirtualServer and VirtualServerRoute resources for cross-namespace configuration. See the Cross-Namespace Configuration example on our GitHub.

0
Markus Dresch On

If you do not want to change your default ingress controller (nginx-ingress), another option is to define a service of type ExternalName in your default namespace that points to the full internal service name of the service in the other namespace.

Something like this:

apiVersion: v1
kind: Service
metadata:
  labels:
    app: my-svc
  name: webapp
  namespace: default
spec:
  externalName: my-svc.my-namespace.svc # <-- put your service name with namespace here
  type: ExternalName