Repository navigation
feat(gateway): Use Gateway API v1 for TCPRoute and UDPRoute - #4829
Conversation
|
Welcome @nicomazzarello! |
|
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 Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
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.
2847a1d to
3ededfa
Compare
|
Thanks for the PR. I'll let the tests run first, then give the code a look! |
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
|
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? |
|
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. |
|
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. |
|
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.
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.
|
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:
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. |
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Looks perfect! Thanks for making sure to update the documentation too. Appreciate the hardwork here. /lgtm /approved |
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 underv1alpha2, which on Gateway API 1.6 standard-channel clusters (that servev1only) causes the route watches to fail withno matches for kind "TCPRoute" in version "gateway.networking.k8s.io/v1alpha2"and, when the gateway feature flags are defaulted, silently disablesNLBGatewayAPIbecause CRD detection only looks for thev1alpha2kinds.Per review feedback, this PR migrates TCPRoute/UDPRoute handling to the
v1API — 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
sigs.k8s.io/gateway-api(and/conformance) to v1.6.0.v1alpha2types to thev1types.v1versions of TCPRoute/UDPRoute and disablesNLBGatewayAPI(when the feature flags are defaulted) if they are not served.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()andBookmark()to thecache.Storeinterface, 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
README.md, or thedocsdirectory)BONUS POINTS checklist: complete for good vibes and maybe prizes?! 🤯