Kubernetes ingress-nginx call service from non-default namespace


#1

Hello everyone,

I have 3 services in my ingress, the first 2 use default namespace. The third service is prometheus-server service which has namespace ingress-nginx . Now, I want to map my prometheus DNS to the service, but getting error because ingress can’t find the prometheus service in default namespace.

How to deal with non-default namespace in ingress definition? TiA.


#2

Your nginx controller can serve any ns, you are probably setting up the ing wrong, there is no way to tell for sure until you provide more context on the issue and setup and errors


#3

Ingress objects don’t have to exist in the same namespace as the ingress controller itself. In this case you would create the prometheus ingress object in the prometheus namespace and assuming there aren’t any network policies that might interfere, it should be direct traffic to it.


#4

Yes, it works now. I created a new ingress object for the monitoring services (grafana and prometheus) with single ingress controller.