nginx-gateway-fabric icon indicating copy to clipboard operation
nginx-gateway-fabric copied to clipboard

Add TCPRoute and UDPRoute Support for L4 Load Balancing

Open Skcey opened this issue 3 months ago • 14 comments
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:

  1. Added controllers to watch and process TCPRoute/UDPRoute resources, following the pattern used for HTTPRoute/TLSRoute.
  2. Implemented route construction logic in the state graph to resolve listeners, backend services, and reference grants for L4 routes.
  3. Extended the NGINX stream configuration generator to create upstream groups and server blocks for TCP/UDP traffic, mapping routes to their backend services.
  4. 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.


Skcey avatar Aug 05 '25 09:08 Skcey