Nginx Ingress Looking for Service in all Custom Namespaces

3/27/2018

I have three namespaces dev, test and staging. test and staging have no pods in them. In dev I have nginx, ingress and a frontend service. For all requests to the nginx it's forwarded to the frontend service.

But the issue is nginx in dev trying to find frontend service in test and staging namespaces also. It's doing round robin between the 3 namespaces. So sometimes the page is loading and sometimes it's 503 error.

Here is the ingress:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: frontend-ingress
  namespace: dev
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
    ingress.kubernetes.io/ssl-redirect: "false"
spec:
  rules:
  - http:
      paths:
      - path: /
        backend:
          serviceName: frontend
          servicePort: 80

And here is the log of nginx:

I0327 07:54:50.867120       1 command.go:76] change in configuration detected. Reloading...
W0327 07:54:50.867339       1 controller.go:841] service test/frontend does not have any active endpoints
W0327 07:54:50.867370       1 controller.go:841] service staging/frontend does not have any active endpoints
W0327 07:54:50.868198       1 controller.go:777] upstream test-frontend-80 does not have any active endpoints. Using default backend
W0327 07:54:50.868219       1 controller.go:777] upstream staging-frontend-80 does not have any active endpoints. Using default backend
-- Narayan Prusty
docker
kubernetes
kubernetes-ingress
nginx
openshift

2 Answers

8/14/2018

I'd like to elaborate on @Narayan-Prusty's answer.

I had to add --force-namespace-isolation=true and set image to quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.12.0 but also had to add --watch-namespace=$(POD_NAMESPACE).

-- PeterH
Source: StackOverflow

3/27/2018

Specify --force-namespace-isolation=true argument when deploying nginx pod. And update image to quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.12.0

-- Narayan Prusty
Source: StackOverflow