Hammed
Hammed

Reputation: 1557

Multiple ingress objects one service

Is it possible to create multiple ingress objects with similar rules referencing the same backend service on the same port?

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress1
spec:
  rules:
  - host: green.com
    http:
      paths:
      - path: /
        backend:
          serviceName: red-svc
          servicePort: 80

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress2
spec:
  rules:
  - host: pink.com
    http:
      paths:
      - path: /
        backend:
          serviceName: red-svc
          servicePort: 80

Upvotes: 4

Views: 5937

Answers (1)

Arghya Sadhu
Arghya Sadhu

Reputation: 44549

It depends on the implementation of the ingress controller you are using. For nginx below rules apply while building the nginx model

  1. If the same path for the same host is defined in more than one Ingress, the oldest rule wins.
  2. f multiple Ingresses define different paths for the same host, the ingress controller will merge the definitions

Since you have different host none of the above apply and it should fine i.e both green.com and pink.com should route traffic to the same backend red-svc on port 80

Upvotes: 3

Related Questions