With multiple ingress controllers - Is it possible to have a "default" one?

4/2/2019

On my cluster I use traefik as an ingress-controller, but now also want to provide an nginx controller.

I don't want my developers to think about how exactly their application is exposed. Therefore I would like to make traefik the "default" controller and only use nginx if the developer explicitly requests that controller by setting the proper ingress.class.

Unfortunately it looks like setting no class will result in both controllers fighting about that ingress. :( Is there a way to tell a controller to only handle a ingress object if has the correct ingress.class?

If that is not possible, I was thinking about writing a MutatingAdmissionWebhook which will insert the traefik class in case no class is set. - Does this make sense, or is there a better way?

-- michas
kubernetes
kubernetes-ingress
nginx-ingress
traefik
traefik-ingress

1 Answer

4/2/2019

Handling no class is an arbitrary ingress implementation decision. You typically pass the desired class into a binary and it then filters all the config map events with a corresponding class: https://github.com/helm/charts/blob/master/stable/nginx-ingress/templates/controller-deployment.yaml#L60

As far as I know, no one does no class, nor do I recommend as it would be error-prone. Someone will forget to add class and will implicitly get exposed where they did not want.

Mutating hook is a way to go, as it will add an explicit note of what ingress this belongs to. Try https://github.com/HotelsDotCom/kube-graffiti

The simplest way will be just to register traefik to listen on ingress.class: default or dev and ask developers to put this in all their templates. In this way, you will abstract them from a particular ingress choice underneath.

-- Max Lobur
Source: StackOverflow