nginx-gateway-fabric
nginx-gateway-fabric copied to clipboard
Add TCPRoute and UDPRoute Support for L4 Load Balancing
trafficstars
Proposed changes
Problem: NGF currently lacks support for TCPRoute and UDPRoute resources, which are essential for managing Layer 4 (TCP/UDP) traffic via the Gateway API.
Solution: This PR adds basic support for TCPRoute and UDPRoute to NGF, enabling Layer 4 load balancing. Key implementations include:
- Added controllers to watch and process TCPRoute/UDPRoute resources, following the pattern used for HTTPRoute/TLSRoute.
- Implemented route construction logic in the state graph to resolve listeners, backend services, and reference grants for L4 routes.
- Extended the NGINX stream configuration generator to create upstream groups and server blocks for TCP/UDP traffic, mapping routes to their backend services.
- Implemented support for multiple backend services in TCPRoute and UDPRoute, enabling traffic distribution to different backend services based on configured weights.
Testing: Packaged into an image and tested in my environment.
Closes #3687
Checklist
Before creating a PR, run through this checklist and mark each as complete.
- [ ✔️] I have read the CONTRIBUTING doc
- [✔️ ] I have added tests that prove my fix is effective or that my feature works
- [ ✔️] I have checked that all unit tests pass after adding my changes
- [ ] I have updated necessary documentation
- [ ✔️] I have rebased my branch onto main
- [ ✔️] I will ensure my PR is targeting the main branch and pulling from my branch from my own fork
Release notes
If this PR introduces a change that affects users and needs to be mentioned in the release notes, please add a brief note that summarizes the change.