-
Notifications
You must be signed in to change notification settings - Fork 365
feat: support port-based routing for Gateway API routes #2703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This change implements support for port-based routing in HTTPRoute and GRPCRoute by leveraging the 'server_port' variable in APISIX. When a route targets a specific Gateway listener (via 'sectionName' or matching), the translator now adds a condition to ensure the route only matches traffic on that specific port. Key changes: - Update translator to add 'server_port' matching variables to routes. - Enhance controller to track all matching listeners for a route. - Update E2E test framework to support multi-port APISIX and in-cluster testing. - Add comprehensive E2E tests for port-based routing scenarios.
Reflect the new port-based routing capability in Gateway API documentation. - Updated concepts/gateway-api.md to mark listener port as partially supported. - Updated reference/example.md to explain that port is used for matching.
This fixes a linting error flagged by errcheck where the return value of fmt.Sscanf was being ignored.
This ensures the alpine/curl image is present locally before attempting to load it into the Kind cluster, preventing build failures in CI.
- Add comprehensive unit tests for addServerPortVars function - Fix two-port test to use expectedPortList + ElementsMatch for non-deterministic map ordering - Consolidate redundant single-port tests (removed HTTP/HTTPS duplicates) - Fix image tag mismatch: alpine/curl:flattened -> alpine/curl:latest - Fix comment typo: port 9100 -> port 9081 Co-Authored-By: Claude <noreply@anthropic.com>
|
Hi there, While reviewing the IssueThe Example from acceptStatus := ResourceStatus{
status: true,
msg: "Route is accepted",
}
// ...
for _, gateway := range gateways {
if err := ProcessGatewayProxy(...); err != nil {
acceptStatus.status = false // Overwrites status for ALL parents
acceptStatus.msg = err.Error()
}
}Affected ControllersThis pattern exists in all 5 route controllers:
Impact
Proposed FixTrack status per-gateway using a map: gatewayStatuses := make(map[string]ResourceStatus)
for _, gateway := range gateways {
if err := ProcessGatewayProxy(...); err != nil {
gatewayStatuses[gateway.Gateway.Name] = ResourceStatus{status: false, msg: err.Error()}
} else {
gatewayStatuses[gateway.Gateway.Name] = ResourceStatus{status: true, msg: "Route is accepted"}
}
}
// Use per-gateway status when setting parent status conditionsQuestionHow would you like to proceed?
Happy to submit a fix either way. |
|
Hi again, I just realized this PR probably adds a breaking change: The Change My implementation now does exactly this: The Risk This is technically "correct" per the spec, but for users relying on the old "first match only" behavior, this could inadvertently expose internal services to public ports upon upgrade. Proposal
I'm leaning towards option 1 for safety, or at least a very prominent warning. Let me know your preference and I can update the PR accordingly. |
|
Anyone got time to review my PR and answer my questions? |
Type of change:
What this PR does / why we need it:
This change implements support for port-based routing in HTTPRoute and GRPCRoute by leveraging the 'server_port' variable in APISIX. When a route targets a specific Gateway listener (via 'sectionName' or matching), the translator now adds a condition to ensure the route only matches traffic on that specific port.
Key changes:
It fixes #2639.
Pre-submission checklist: