Reputation: 43
For example
- host: "domain.com"
http:
paths:
- path: /?(.*) # want to rewrite this with /$1
backend:
serviceName: RELEASE-NAME-svcname1
servicePort: 80
- path: /test/?(.*) # want to skip rewrite
backend:
serviceName: RELEASE-NAME-svcname2
servicePort: 80
Any way to handle this in a single ingress ?
Upvotes: 0
Views: 40
Reputation: 33231
Any way to handle this in a single ingress?
Not in a single Ingress resource, no, but it will work fine with a single ingress controller.
The reason you need to create two separate Ingress resources is so that you can apply the annotation to one but not the other; all Ingress resources across the whole cluster are unioned together, then grouped by virtual host, in the ultimate emitted nginx.conf
...
metadata:
name: ingress-svc-1
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
...
- host: "domain.com"
http:
paths:
- path: /?(.*) # want to rewrite this with /$1
backend:
serviceName: RELEASE-NAME-svcname1
servicePort: 80
---
...
metadata:
name: ingress-svc-2
spec:
...
- host: "domain.com"
http:
paths:
- path: /test/?(.*)
backend:
serviceName: RELEASE-NAME-svcname2
servicePort: 80
Upvotes: 1