Justinus Hermawan
Justinus Hermawan

Reputation: 1214

Kubernetes ingress-nginx call service from non-default namespace

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?

Upvotes: 2

Views: 4229

Answers (2)

Paul Annetts
Paul Annetts

Reputation: 9604

You will need to refer to your service in the other namespace with its full path, that is prometheus-server.ingress-nginx.svc.cluster.local.

You shouldn’t need a second Ingress to do this.

Upvotes: 3

Fei
Fei

Reputation: 1996

You would want to create a new Ingress in namespace ingress-nginx that would route your DNS to that service. For example:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: example
  namespace: ingress-nginx
spec:
  rules:  
  - host: your.domain.com
    http:
      paths:
      - path: /
        backend:
          serviceName: prometheus-server
          servicePort: 80

Upvotes: 4

Related Questions