Skip to content

gateway-api: fix allowedRoute namespace and kind restrictions on multi-listener - #45693

Merged
youngnick merged 2 commits into
cilium:mainfrom
eufriction:fix/allowed-routes-main
May 6, 2026
Merged

youngnick merged 2 commits into
cilium:mainfrom
eufriction:fix/allowed-routes-main

Conversation

@eufriction

Copy link
Copy Markdown
Contributor

Fix two related bugs in the Gateway API route allowedRoute logic where multi-listener Gateways produce incorrect Accepted conditions on routes. This is a follow up of #44889.

This PR was prepared with AIL:3. I personally reviewed each line of the submission as well as run regression tests from https://github.com/eufriction/k8s-cilium-gapi#test-results-by-version.

See each commit for description of the changes.

Fixes: #42159
Fixes: #45559

Fix allowedRoute namespace and kind restrictions on multi-listener Gateways.

@eufriction
eufriction requested a review from a team as a code owner April 29, 2026 20:07
@eufriction
eufriction requested a review from youngnick April 29, 2026 20:07
@maintainer-s-little-helper maintainer-s-little-helper Bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Apr 29, 2026
@github-actions github-actions Bot added feature/k8s-gateway-api kind/community-contribution This was a contribution made by a community member. labels Apr 29, 2026
@youngnick

Copy link
Copy Markdown
Contributor

The code changes look great, in the first commit, could you add an overall manifest test case for the allowedRoutes bug? tbh we probably should be testing that upstream, so having a manifest here will let us get ahead on adding that to upstream conformance.

@youngnick youngnick left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last small thing, and this one is ready to go.

eufriction added 2 commits May 1, 2026 12:51
Filter listener loop by parentRef.SectionName and parentRef.Port so
a non-targeted listener cannot overwrite the Accepted condition.

Fixes: cilium#45559

Signed-off-by: Martin Lindberg <[email protected]>
Continue to the next listener when a Selector doesn't match instead of
returning false immediately, so a permissive listener later in the
spec is still evaluated.

Fixes: cilium#42159

Signed-off-by: Martin Lindberg <[email protected]>
@eufriction
eufriction force-pushed the fix/allowed-routes-main branch from 88bc557 to 5083b33 Compare May 1, 2026 10:52
@eufriction

Copy link
Copy Markdown
Contributor Author

One last small thing, and this one is ready to go.

@youngnick Makes sense, added the requests paths and methods.

@youngnick

Copy link
Copy Markdown
Contributor

/test

@youngnick youngnick added release-note/minor This PR changes functionality that users may find relevant to operating Cilium. release-note/bug This PR fixes an issue in a previous release of Cilium. and removed dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. release-note/minor This PR changes functionality that users may find relevant to operating Cilium. labels May 5, 2026
@youngnick
youngnick enabled auto-merge May 6, 2026 07:49
@youngnick
youngnick added this pull request to the merge queue May 6, 2026
@maintainer-s-little-helper maintainer-s-little-helper Bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label May 6, 2026
Merged via the queue into cilium:main with commit f334eb4 May 6, 2026
77 of 81 checks passed
@0xch4z 0xch4z mentioned this pull request Jul 1, 2026
4 tasks
@github-actions github-actions Bot added the backport-done/1.19 The backport for Cilium 1.19.x for this PR is done. label Jul 15, 2026
julianmaze added a commit to julianmaze/homelab that referenced this pull request Jul 26, 2026
- Fix config drift: git had the unifi TLS passthrough listener commented
  out while the live Gateway still had it (with 0 attached routes) because
  the TLSRoute's parentRef had been repointed at the local-subdomain
  listener, which only allows HTTPRoute. This is why the gateway wasn't
  serving unifi at all.
- Attempted the intended end-state (HTTPRoute + Terminate TLS at the
  gateway + BackendTLSPolicy re-encrypting to the self-signed backend
  cert), but confirmed empirically that Cilium 1.19.4's operator does not
  implement BackendTLSPolicy at all (missing from its required/optional
  GatewayAPI GVK set; no TLS transport_socket ever added to the backend
  envoy cluster). That feature only ships starting in Cilium 1.20 (not yet
  GA). Reverted this part and restored/renamed unifi/app/http_route.yaml
  to tls_route.yaml (TLSRoute, matching the working passthrough model).
- While restoring TLS Passthrough, hit a second, pre-existing Cilium bug:
  allowedRoutes namespace/kind restrictions misbehave on multi-listener
  Gateways (cilium/cilium#45559, #42159), fixed by cilium/cilium#45693 and
  released in v1.19.6 (we're on 1.19.4). This is the real root cause of
  unifi being unreachable via the Gateway; it's independent of the
  BackendTLSPolicy work above.
- Documented both blockers in gateway/default.yaml and unifi/README.md.
  Holding off on the Cilium upgrade for now per discussion - 1.19.6 alone
  doesn't unlock gateway-terminated SSL (still needs 1.20 for
  BackendTLSPolicy), so there's no rush. unifi remains reachable directly
  via its LoadBalancer IP in the meantime.
lexfrei added a commit to cozystack/cozystack that referenced this pull request Aug 17, 2026
Some GatewayClasses have their provider terminate TLS in front of the
Gateway and reach it over plain HTTP. On such a class the platform
issued origin certificates nobody serves, and where ACME could not
complete, the Gateway's listeners never became ready.

Add certMode=edge to TenantGateway. The controller renders the apex,
its wildcard and every inheriting child apex as plain HTTP listeners
carrying the same label-based allowedRoutes as the HTTPS listeners of
the other modes, so application HTTPRoutes attach by hostname
unchanged. It mints no Issuer and no Certificate, and removes the
http-to-https redirect route, because the edge performs that redirect
itself. TLSPassthroughServices are not rendered: an HTTP-only edge
cannot carry a TLS listener, which leaves the endpoints relying on one
unpublished through such a Gateway.

The hostname-less port-80 listener is left out. It carries the ACME
challenge and the redirect in the other modes and has neither here, so
it would only be a catch-all admitting any hostname. Leaving it out
also keeps a hostname-pinned listener at index 0, which is what
Cilium's first-listener-wins namespace check reads before the fix in
cilium/cilium#45693.

Moving into the mode garbage-collects the Issuer and Certificate
objects the controller owned. The TLS Secrets they issued stay behind:
cert-manager runs with enableCertificateOwnerRef false, so a
Certificate does not own the Secret it issued into. Every mode
transition already behaves that way.

Assisted-By: Claude <[email protected]>
Signed-off-by: Aleksei Sviridkin <[email protected]>
lexfrei added a commit to cozystack/cozystack that referenced this pull request Aug 20, 2026
Some GatewayClasses have their provider terminate TLS in front of the
Gateway and reach it over plain HTTP. On such a class the platform
issued origin certificates nobody serves, and where ACME could not
complete, the Gateway's listeners never became ready.

Add certMode=edge to TenantGateway. The controller renders the apex,
its wildcard and every inheriting child apex as plain HTTP listeners
carrying the same label-based allowedRoutes as the HTTPS listeners of
the other modes, so application HTTPRoutes attach by hostname
unchanged. It mints no Issuer and no Certificate, and removes the
http-to-https redirect route, because the edge performs that redirect
itself. TLSPassthroughServices are not rendered: an HTTP-only edge
cannot carry a TLS listener, which leaves the endpoints relying on one
unpublished through such a Gateway.

The hostname-less port-80 listener is left out. It carries the ACME
challenge and the redirect in the other modes and has neither here, so
it would only be a catch-all admitting any hostname. Leaving it out
also keeps a hostname-pinned listener at index 0, which is what
Cilium's first-listener-wins namespace check reads before the fix in
cilium/cilium#45693.

Moving into the mode garbage-collects the Issuer and Certificate
objects the controller owned. The TLS Secrets they issued stay behind:
cert-manager runs with enableCertificateOwnerRef false, so a
Certificate does not own the Secret it issued into. Every mode
transition already behaves that way.

Assisted-By: Claude <[email protected]>
Signed-off-by: Aleksei Sviridkin <[email protected]>
lexfrei added a commit to cozystack/cozystack that referenced this pull request Sep 2, 2026
Some GatewayClasses have their provider terminate TLS in front of the
Gateway and reach it over plain HTTP. On such a class the platform
issued origin certificates nobody serves, and where ACME could not
complete, the Gateway's listeners never became ready.

Add certMode=edge to TenantGateway. The controller renders the apex,
its wildcard and every inheriting child apex as plain HTTP listeners
carrying the same label-based allowedRoutes as the HTTPS listeners of
the other modes, so application HTTPRoutes attach by hostname
unchanged. It mints no Issuer and no Certificate, and removes the
http-to-https redirect route, because the edge performs that redirect
itself. TLSPassthroughServices are not rendered: an HTTP-only edge
cannot carry a TLS listener, which leaves the endpoints relying on one
unpublished through such a Gateway.

The hostname-less port-80 listener is left out. It carries the ACME
challenge and the redirect in the other modes and has neither here, so
it would only be a catch-all admitting any hostname. Leaving it out
also keeps a hostname-pinned listener at index 0, which is what
Cilium's first-listener-wins namespace check reads before the fix in
cilium/cilium#45693.

Moving into the mode garbage-collects the Issuer and Certificate
objects the controller owned. The TLS Secrets they issued stay behind:
cert-manager runs with enableCertificateOwnerRef false, so a
Certificate does not own the Secret it issued into. Every mode
transition already behaves that way.

Assisted-By: Claude <[email protected]>
Signed-off-by: Aleksei Sviridkin <[email protected]>
lexfrei added a commit to cozystack/cozystack that referenced this pull request Sep 3, 2026
Some GatewayClasses have their provider terminate TLS in front of the
Gateway and reach it over plain HTTP. On such a class the platform
issued origin certificates nobody serves, and where ACME could not
complete, the Gateway's listeners never became ready.

Add certMode=edge to TenantGateway. The controller renders the apex,
its wildcard and every inheriting child apex as plain HTTP listeners
carrying the same label-based allowedRoutes as the HTTPS listeners of
the other modes, so application HTTPRoutes attach by hostname
unchanged. It mints no Issuer and no Certificate, and removes the
http-to-https redirect route, because the edge performs that redirect
itself. TLSPassthroughServices are not rendered: an HTTP-only edge
cannot carry a TLS listener, which leaves the endpoints relying on one
unpublished through such a Gateway.

The hostname-less port-80 listener is left out. It carries the ACME
challenge and the redirect in the other modes and has neither here, so
it would only be a catch-all admitting any hostname. Leaving it out
also keeps a hostname-pinned listener at index 0, which is what
Cilium's first-listener-wins namespace check reads before the fix in
cilium/cilium#45693.

Moving into the mode garbage-collects the Issuer and Certificate
objects the controller owned. The TLS Secrets they issued stay behind:
cert-manager runs with enableCertificateOwnerRef false, so a
Certificate does not own the Secret it issued into. Every mode
transition already behaves that way.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <[email protected]>
lexfrei added a commit to cozystack/cozystack that referenced this pull request Sep 4, 2026
Some GatewayClasses have their provider terminate TLS in front of the
Gateway and reach it over plain HTTP. On such a class the platform
issued origin certificates nobody serves, and where ACME could not
complete, the Gateway's listeners never became ready.

Add certMode=edge to TenantGateway. The controller renders the apex,
its wildcard and every inheriting child apex as plain HTTP listeners
carrying the same label-based allowedRoutes as the HTTPS listeners of
the other modes, so application HTTPRoutes attach by hostname
unchanged. It mints no Issuer and no Certificate, and removes the
http-to-https redirect route, because the edge performs that redirect
itself. TLSPassthroughServices are not rendered: an HTTP-only edge
cannot carry a TLS listener, which leaves the endpoints relying on one
unpublished through such a Gateway.

The hostname-less port-80 listener is left out. It carries the ACME
challenge and the redirect in the other modes and has neither here, so
it would only be a catch-all admitting any hostname. Leaving it out
also keeps a hostname-pinned listener at index 0, which is what
Cilium's first-listener-wins namespace check reads before the fix in
cilium/cilium#45693.

Moving into the mode garbage-collects the Issuer and Certificate
objects the controller owned. The TLS Secrets they issued stay behind:
cert-manager runs with enableCertificateOwnerRef false, so a
Certificate does not own the Secret it issued into. Every mode
transition already behaves that way.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <[email protected]>
@joestringer joestringer added the ail:3 AI Created, Human Full Structure. Generated content with editing done by a human. label Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ail:3 AI Created, Human Full Structure. Generated content with editing done by a human. backport-done/1.19 The backport for Cilium 1.19.x for this PR is done. feature/k8s-gateway-api kind/community-contribution This was a contribution made by a community member. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/bug This PR fixes an issue in a previous release of Cilium.

Projects

None yet

3 participants