Hi, I have an ingress with a single rule containing several paths using regex matching:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-ingress
annotations:
kubernetes.io/ingress.class: "kong"
[...]
konghq.com/strip-path: "true"
spec:
[...]
rules:
- http:
paths:
[...]
- path: /api/restrictions/(.*)
backend:
serviceName: restriction-api
servicePort: 80
[...]
- path: /api/(.*)
backend:
serviceName: api
servicePort: 80
What I want to achieve is that /api/whatever goes to a service and /api/restriction/whatever goes to another service. The example is simplified and may not make much sense. We can de-simplify it if any questions why I am attempting this.
The problem I have is that the last regex is evaluated first and shadows the one about “restrictions”. This is in a cluster running k8s 1.18. In another cluster running k8s 1.17 the order of the paths determines the evaluation order (restrictions getting higher priority if they are defined above in the yaml).
I couldn’t find in the documentation how this works. I’ve found the following:
-
Some doc writen in a Kong Nation entry:
A few words on regex URIs usage and common pitfalls. It mentions “URI regexes are evaluated in the order that they are defined too”. Would that ordering be the one of the Ingress paths? In that case this behavior would be a bug (and I would report it). -
It seems that we can use a regex-priority annotation at the Ingress level. If this is the only solution I’d need to split the Ingress in two, in order to set different regex-priority, is that right?
Any help is appreciated.