@notsureifkevin as far as I can see nginx ingress controller does not have this issue, it looks like it's traefik specific. The thread you linked that is linked from the traefik thread @jaycci linked discusses exactly that: that someone wants cross-namespace access but kubernetes people argue that it is not reasonable request, because it may be insecure. Let me know if you have read that differently.
On the other hand Traefik does allow that.
because this behavior historically was blocked by the Kubernetes API. It's possible there was a change to the Gateway API which allows this behavior, so it may be worth raising an issue on their repository.
Sorry, can you please expand on that? What is "Gateway API"? As far as I understand traefik is given certain RBAC permissions that allow it to access services in all configured namespaces, and thus, traefik ingress controller will happily do cross-namespace for you if configured so, there is no kubernetes machinery in-between that would prevent such access. What specifically in your view should prevent it?
that's typically relegated to a network policy provider.
This is something that occurred to me too, but I do not feel that this is necessarily the right answer. Network policy provider works at a lower level than either ingresses or services, it works at a pod level. Traefik Labs does not publish what kind of minimal network policies should be in place for your typical default-deny cluster. Setting those up from scratch is an interesting exercise. When you go through it you will realise, that since you do not know what applications and pods will be there in the future (and traefik will need access to them to do its job) you either have to create a specific allow rules for traefik for each future application, when you first deploy it or to have a blanket rule to whitelist traefik globally. In both cases the cross-namespace problem is sidestepped, that is if you give traefik enough permissions to do it's job it will also be able to do that cross-namespace.
Let me give you a more concrete example of the above.
Let's assume you have traefik ingress controller and two applications A and B. Both applications are exposed via a traefik ingress / ingress route. Both app live in their own specific namespace. In order for traefik to do it's work Network Policies has to be in place to access both A and B pods.
Now let's assume that a malicious person with access to namespace A but not B creates another ingress in namespace A that points to a service and then pod in namespace B.
Can you give an example of Network Policy/Policies that will allow traefik to continue exposing App B via its own ingress but prohibit ingress from namespace A from exposing that same App B?
For what I can see this configuration is impossible, and thus network policy provider
won't help here. It only can allow or disallow access between traefik itself and the target pod, and that has to be allowed for traefik to function. This means that traefik itself has to have some security controls for preventing this scenario, if it is undesirable.
I will be glad to be wrong here, could you please let me know what you think.