Same-host routes with common base using kong ingress controller

Hello,

Is it possible to handle ingress routes with the same host that share a base path? In the example below the common base-path is “/”

For example, I have a web app on the root ingress like:

    apiVersion: extensions/v1beta1
    kind: Ingress
    metadata:
      name: kong-ingress-web-app
      annotations:
        kubernetes.io/ingress.class: "kong"
    spec:
      rules:
      - http:
        host: example.com
          paths:
          - path: "/"
            backend:
              serviceName: {{ .Release.Name }}-app
              servicePort: 80

And then I want to host the api at /api like this:

    apiVersion: extensions/v1beta1
    kind: Ingress
    metadata:
      name: kong-ingress-web-api
      annotations:
        kubernetes.io/ingress.class: "kong"
    spec:
      rules:
      - http:
        host: example.com
          paths:
          - path: "/api"
            backend:
              serviceName: {{ .Release.Name }}-api
              servicePort: 80

Both endpoints have plugins tied to them so they need to be separete ingress’, and they will be public with TLS (which is one reason why the hosts need to be the same).

All my “/api” routes work as expected until i add the “/” route ingress and then they stop working. Any way to force literal path checking? Or is there a better way to design this?

If i set the app as the fallback service, everything works as expected… Hmm, perhaps that is ok

Thanks,
Ben

This is the right way to design it and should work out of the box.

Could you elaborate on what problem do you see when you add the / route?
Can you check if Kong has the two required routes present (exec into Kong’s container and get the routes from the Admin API (port 8444))?

looks like i was actually victim to this bug here: https://github.com/Kong/kubernetes-ingress-controller/issues/84

In my example i listed hosts in both ingress, but in practice I had actually removed a host on the “/api” route whilst debugging. Without that host it was causing things to behave they way they were.

So i no longer require the app to be set as a fallback service. Cool!

Thanks for the response @hbagdi

1 Like

© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ