Kong Ingress controller and path base routing?

Hi
I have succcessfully tried kongs ingress controller , but, I wasn’t able to find any documentation nor examples of how to use path based routing with the ingress controller? Does this mean it is not supported and that you must use Host header?

In my case, we (the company I work for) have a hosting solution where we don’t wan to expose any information about our internal hosts to our customers. Therefore we have used path based routing so far, but, this door seems closed with the ingress controller?

Can anyone confirm if this is the case?

BR

krister

Hello @krimal,

Does this mean it is not supported and that you must use Host header?

Kong Ingress Controller follows the Ingress Spec of Kubernetes, which allows you to route your traffic based on HTTP Host header and HTTP path. So, it will be possible for Kong Ingress Controller to route your traffic based on path.

Having said that, there is current one limitation in Kong Ingress Controller that you might be running into.
You can use path based routing but you’ll need to specify the Host header in addtion to your path.
Please checkout an example in our getting started guide.

In my case, we (the company I work for) have a hosting solution where we don’t wan to expose any information about our internal hosts to our customers. Therefore we have used path based routing so far, but, this door seems closed with the ingress controller?

I recommend you to create Ingress rules with Host that is public and then use path based routing to break traffic up and send it to different services upstream.

Let me know if you have further questions.

Thanks for fast reply. I will look into your suggestion and I think it can work for us.

Hello @krimal,
If my answer above is acceptable, please mark it as “Solved”, to help future users who will navigate to this question. Thanks!

Can you clarify how one would go about adding the host header for a given path?

I have created an ingress for a service (service.foo.bar) and I want it to be accessible through api.foo.bar/service so my understanding is that I should then create an ingress for api.foo.bar and add the path /service, but I’m unsure how I can set the host header service.foo.bar for the path /service

Also the link to the example is broken

1 Like

Do you specifically need that host header?
Creating the following ingress will actually configure Kong to route the requests to your upstream. It is currently not possible to alert the host header that Kong Ingress uses for upstream calls.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: foo-bar
spec:
  rules:
  - host: api.foo.bar
    http:
      paths:
      - path: /service
        backend:
          serviceName: service.foo.bar
          servicePort: 80

From what I had gathered from the documentation was that I was supposed to create ingress for each service (host:service1.foo.bar, host:service2.foo.bar etc) and didn’t know how to front those services with api.foo.bar and have the service accessible through api.foo.bar/service1 using the ingresses.

Then I figured out that I could use the same host for multiple ingresses which solved my case

apiVersion: extensions/v1beta1 
  kind: Ingress 
  metadata: 
    name: service1
  spec: 
    rules: 
     - host: api.foo.bar 
       http: 
         paths: 
         - path: /service1 
           backend: 
             serviceName: service1 
              servicePort: 80

apiVersion: extensions/v1beta1 
  kind: Ingress 
  metadata: 
    name: service2
  spec: 
    rules: 
     - host: api.foo.bar 
       http: 
         paths: 
         - path: /service2 
           backend: 
             serviceName: service2 
              servicePort: 80

I have 2 different domains for 2 different namespaces
host 1 : dev.example.com mapped to dev namespace
host 2: qa.example.com mapped to qa namespace
and there is service1 in both of them
When I am accessing dev.example.com/service1 it is rendering correctly
But when I am acessing qa.example.com/service1 it is rendering dev service1 pages and not qa ones .
Could you please help
@hbagdi

@ssaila Please open a new issue instead of resurrecting this old one.