My issue: Traffic meant for a RegularExpression match is being incorrectly routed to a backend associated with a PathPrefix match. Despite the regex being more “complex,” the gateway prioritizes the simple prefix rule.
How I encountered the problem: I created an HTTPRoute with two rules. The first rule uses a RegularExpression to capture specific user profile patterns (e.g., /user/[0-9]+). The second rule is a “catch-all” using PathPrefix: /. When testing the regex path, the traffic is sent to the catch-all backend instead of the user-profile-service
Solutions I’ve tried:
* Moving the RegularExpression rule to the top of the rules list in the YAML file.
* Without PathPrefix rule, RegularExpression is working
NGF Version: 2.4.0
Deployment environment: Kubernetes
Example route:
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: demo-precedence-conflict
namespace: demo-ns
spec:
parentRefs:
- name: my-gateway
hostnames:
- example.com
rules:
- matches:
- path:
type: RegularExpression
value: /user/[0-9]+
backendRefs:
- name: user-profile-service
port: 8080
- matches:
- path:
type: PathPrefix
value: /
backendRefs:
- name: static-assets-service
port: 80