Skip to content

feat(gateway): Use Gateway API v1 for TCPRoute and UDPRoute - #4829

Merged
zac-nixon merged 14 commits into
kubernetes-sigs:mainfrom
nicomazzarello:feat/tcproute-udproute-v1
Jul 16, 2026
Merged

zac-nixon merged 14 commits into
kubernetes-sigs:mainfrom
nicomazzarello:feat/tcproute-udproute-v1

Conversation

@nicomazzarello

@nicomazzarello nicomazzarello commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Issue

Fixes #4816

Description

TCPRoute and UDPRoute graduated to GA (gateway.networking.k8s.io/v1) in Gateway API 1.6. The controller previously handled these routes only under v1alpha2, which on Gateway API 1.6 standard-channel clusters (that serve v1 only) causes the route watches to fail with no matches for kind "TCPRoute" in version "gateway.networking.k8s.io/v1alpha2" and, when the gateway feature flags are defaulted, silently disables NLBGatewayAPI because CRD detection only looks for the v1alpha2 kinds.

Per review feedback, this PR migrates TCPRoute/UDPRoute handling to the v1 API — one controller release supports one Gateway API release (same approach as the TLSRoute migration in the Gateway API 1.5 upgrade). There is no version fallback: clusters must install Gateway API >= 1.6 CRDs to use TCP/UDP routes.

How it works

  • Bumps sigs.k8s.io/gateway-api (and /conformance) to v1.6.0.
  • Migrates all TCPRoute/UDPRoute handling (watches, lists, status updates, event handlers) from the v1alpha2 types to the v1 types.
  • CRD detection now requires the v1 versions of TCPRoute/UDPRoute and disables NLBGatewayAPI (when the feature flags are defaulted) if they are not served.
  • Updates e2e resources and docs examples to v1; the L4 gateway docs note the Gateway API >= 1.6 requirement.

Note on the store changes: client-go v0.36 (pulled in by the gateway-api v1.6.0 bump) added LastStoreSyncResourceVersion() and Bookmark() to the cache.Store interface, so the two custom store wrappers (pkg/aga/resource_store.go, pkg/k8s/secrets_store.go) gain matching delegation methods.

Note on e2e: the TCP/UDP e2e tests require Gateway API >= 1.6 CRDs installed on the test cluster.

Checklist

  • Added tests that cover your change (if possible)
  • Added/modified documentation as required (such as the README.md, or the docs directory)
  • Manually tested
  • Made sure the title of the PR is a good description that can go into the release notes

BONUS POINTS checklist: complete for good vibes and maybe prizes?! 🤯

  • Backfilled missing tests for code in same general area 🎉
  • Refactored something and made the world a better place 🌟

@kubernetes-prow kubernetes-prow Bot added the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Jul 10, 2026
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jul 10, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

@kubernetes-prow kubernetes-prow Bot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Jul 10, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

Welcome @nicomazzarello!

It looks like this is your first PR to kubernetes-sigs/aws-load-balancer-controller 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/aws-load-balancer-controller has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@kubernetes-prow kubernetes-prow Bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 10, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

Hi @nicomazzarello. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@kubernetes-prow kubernetes-prow Bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jul 10, 2026
@kubernetes-prow kubernetes-prow Bot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jul 10, 2026
TCPRoute and UDPRoute graduated to GA (v1) in Gateway API 1.6.
This makes the v1 types available for the migration in follow-up commits.

Bumping gateway-api transitively requires k8s.io/* v0.36.1 and
controller-runtime v0.24.1 (per gateway-api and conformance go.mod).
client-go v0.36 added LastStoreSyncResourceVersion() and Bookmark() to
the cache.Store interface; the two custom Store wrappers (pkg/aga and
pkg/k8s) gain matching delegation methods.
Adds RouteVersions resolution: prefer gateway.networking.k8s.io/v1 when
served (Gateway API >= 1.6), fall back to v1alpha2. Also accept TCPRoute
and UDPRoute under either group version in the NLBGatewayAPI CRD
detection, fixing silent feature disablement on Gateway API 1.6
standard-channel clusters that only serve v1.
Adds struct conversion helpers and a generic event-handler adapter so the
controller can keep a single internal v1 representation while watching
either served API version. Consumed by the migration commit.
…alpha2

Migrates all internal TCPRoute/UDPRoute handling to the v1 types (same
shape as the TLSRoute migration in the gateway-api 1.5 upgrade). The
group version resolved at startup is threaded to the three
version-sensitive boundaries:

- watches: registered at v1 or v1alpha2, with a converting adapter on
  the fallback path
- lists: ListTCPRoutes/ListUDPRoutes query the resolved version and
  convert to v1 at the boundary
- status updates: the route reconciler gets/patches objects at the
  resolved version

Clusters on Gateway API < 1.6 behave exactly as before; clusters
serving v1 (>= 1.6) now use the GA API.
gofmt reformatted struct field alignment in version_adapter_test.go and
gateway_feature_flags.go (files added/changed by this feature). Also fixed
conformance_test.go to use ParseSupportedFeaturesSlice (returns
[]features.FeatureName) instead of ParseSupportedFeatures (returns a map),
required by the gateway-api v1.6 conformance API.
Adds symmetric status-boundary coverage for TCPRoute and UDPRoute in
both the v1 (gwv1.TCPRoute, gwv1.UDPRoute) and legacy alpha2
(gwalpha2.TCPRoute, gwalpha2.UDPRoute) variants to Test_updateRouteStatus,
confirming that each type-switch arm in updateRouteStatus correctly
populates Status.Parents on the route object.

Also corrects the GatewayV1Alpha2GroupVersion doc comment from
"experimental" to "legacy alpha" to accurately describe the constant.
@nicomazzarello
nicomazzarello force-pushed the feat/tcproute-udproute-v1 branch from 2847a1d to 3ededfa Compare July 10, 2026 19:35
@kubernetes-prow kubernetes-prow Bot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Jul 10, 2026
@nicomazzarello nicomazzarello changed the title Support Gateway API v1 for TCPRoute/UDPRoute with v1alpha2 fallback feat(gateway): Support Gateway API v1 for TCPRoute/UDPRoute with v1alpha2 fallback Jul 10, 2026
@zac-nixon

Copy link
Copy Markdown
Collaborator

Thanks for the PR. I'll let the tests run first, then give the code a look!

@codecov-commenter

codecov-commenter commented Jul 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 31.57895% with 39 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.50%. Comparing base (82c3870) to head (ca8ed33).
⚠️ Report is 50 commits behind head on main.

Files with missing lines Patch % Lines
...trollers/gateway/eventhandlers/tcp_route_events.go 0.00% 6 Missing ⚠️
...trollers/gateway/eventhandlers/udp_route_events.go 0.00% 6 Missing ⚠️
...rs/gateway/eventhandlers/reference_grant_events.go 0.00% 4 Missing ⚠️
...ontrollers/gateway/eventhandlers/service_events.go 0.00% 4 Missing ⚠️
controllers/gateway/gateway_controller.go 0.00% 4 Missing ⚠️
controllers/gateway/route_reconciler.go 50.00% 4 Missing ⚠️
pkg/aga/resource_store.go 0.00% 4 Missing ⚠️
pkg/k8s/secrets_store.go 0.00% 4 Missing ⚠️
...eventhandlers/target_group_configuration_events.go 50.00% 2 Missing ⚠️
pkg/gateway/crddetect/gateway_feature_flags.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4829      +/-   ##
==========================================
+ Coverage   57.08%   57.50%   +0.42%     
==========================================
  Files         396      396              
  Lines       31572    31621      +49     
==========================================
+ Hits        18022    18184     +162     
+ Misses      12492    12380     -112     
+ Partials     1058     1057       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zac-nixon

Copy link
Copy Markdown
Collaborator

Most looks good, thanks! I see other Gateway API implementations just going ahead and bumping to the v1 version of TCP / UDP routes without a fallback. I think that this is the correct way to handle it, and it avoids a messy conversion adapter. What do you think about removing the adapter?

@nicomazzarello

Copy link
Copy Markdown
Contributor Author

Thanks for the review, @zac-nixon! A hard cut to v1 was actually my first instinct too.

The reason I went with the fallback is that TCPRoute/UDPRoute existed in v1alpha2 for some time, so there are still plenty of clusters running Gateway API ≤ 1.5 CRDs where only v1alpha2 is served. With a hard cut, upgrading the controller on those clusters either auto-disables NLBGatewayAPI (when the flags are defaulted, via the CRD detection) or fails the TCP/UDP watches (when the flags are set explicitly) until the CRDs are upgraded to 1.6.

That said, the migration path is easy (the v1alpha2 and v1 schemas are identical), and Gateway API CRDs 1.6 experimental channel still serves v1alpha2. If you're comfortable with that requirement (CRD detection disabling the feature when v1 isn't served), I'm happy to remove the adapter and the rest of the fallback code. It would be a big clean-up and shrink the PR considerably.

@zac-nixon

Copy link
Copy Markdown
Collaborator

I think the hard-cut is the clean approach, as it's too burdensome to make the controller work with every version of the Gateway API, we are trying to make one controller release == one gateway api release.

I tried with the Github UI to make the merge clean for you from our recent package upgrade from non-versioned => versioned but it seems I missed a spot. I apologize about that.

@nicomazzarello

Copy link
Copy Markdown
Contributor Author

No worries, I'll go ahead with the hard-cut and fix the branch. I'll mention you when it's done

The merge of the /v3 module rename left a few files still importing the
old sigs.k8s.io/aws-load-balancer-controller/... paths, which broke the
build. Point them at the /v3 module path so the branch compiles again.
Per maintainer feedback, require the Gateway API v1 versions of
TCPRoute and UDPRoute instead of auto-detecting the served version:
one controller release supports one Gateway API release. This removes
the version-resolution plumbing, the converting event adapter, and the
v1alpha2 conversion helpers. The NLB gateway CRD detection now
requires the v1 kinds and disables the feature when they are not
served, so clusters must install Gateway API >= 1.6 CRDs to use
TCP/UDP routes.
@nicomazzarello nicomazzarello changed the title feat(gateway): Support Gateway API v1 for TCPRoute/UDPRoute with v1alpha2 fallback feat(gateway): Use Gateway API v1 for TCPRoute and UDPRoute Jul 15, 2026
NLBRouteResourceGroupVersion documents the group version used by
TCPRoute and UDPRoute, which is now v1. Also restore the original
wording of the GatewayV1Alpha2GroupVersion doc comment.
With TCPRoute and UDPRoute detected under v1, nothing reads the
v1alpha2 discovery results anymore. Drop the group version from the
DetectCRDs query and remove the now-unreferenced constant.
Detection no longer queries the v1alpha2 group version, so fixtures
containing v1alpha2 kinds are inputs production can never produce. A
Gateway API < 1.6 cluster presents as v1 without TCPRoute/UDPRoute;
rewrite that case accordingly and drop the redundant alpha2-only case.
The multi-group-version test queried gateway.networking.k8s.io/v1alpha2,
which no caller queries anymore. Use the group versions the controller
actually asks for (gateway v1 and gateway.k8s.aws/v1beta1). The
ignore-not-in-interest-set test keeps serving v1alpha2 as the ignored
group version, since ignoring it is the behavior the controller now
relies on.
@nicomazzarello

Copy link
Copy Markdown
Contributor Author

Done @zac-nixon. The fallback and the adapter are removed — both route types are now handled through the v1 API only, and CRD detection requires the v1 kinds (disabling NLBGatewayAPI when they're not served).

I'd like your opinion on what I did with the tests — let me know if you'd have gone differently:

  • crddetect: detection only queries v1 now, so fixtures with kinds under v1alpha2 are inputs production can never produce. I rewrote the pre-1.6 case as what such a cluster actually looks like to the detector (v1 served without TCPRoute/UDPRoute → NLB disabled), and dropped the alpha2-only case (equivalent to "nothing present").
  • pkg/k8s DetectCRDs: the multi-group-version test now queries what production actually queries (gateway.networking.k8s.io/v1 + gateway.k8s.aws/v1beta1). I deliberately kept v1alpha2 in TestDetectCRDs_v1_ignoreNotInInterestSet as the ignored group version — ignoring it is exactly what the controller relies on when a pre-1.6 or experimental-channel cluster serves it.

Tested with the unit suite plus a live EKS cluster on Gateway API 1.6 CRDs: v1 watches clean, feature detection correct, and route status written at v1 end to end.

@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nicomazzarello, zac-nixon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow kubernetes-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 15, 2026
@zac-nixon

Copy link
Copy Markdown
Collaborator

Looks perfect! Thanks for making sure to update the documentation too.

Appreciate the hardwork here.

/lgtm /approved

@zac-nixon
zac-nixon merged commit e8b3496 into kubernetes-sigs:main Jul 16, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Gateway API] Upgrade TCPRoute and UDPRoute from v1alpha2 to v1 (Gateway API 1.6 GA graduation)

3 participants