Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 348
Hammed Avatar asked Sep 19 '25 22:09

Hammed


1 Answers

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

like image 193
Arghya Sadhu Avatar answered Sep 22 '25 21:09

Arghya Sadhu