Skip to content

conformance: add TLSRoute hostname intersection conformance tests#4437

Merged
k8s-ci-robot merged 6 commits intokubernetes-sigs:mainfrom
rostislavbobo:tlsroute-conformance-hostname-intersection
Jan 29, 2026
Merged

conformance: add TLSRoute hostname intersection conformance tests#4437
k8s-ci-robot merged 6 commits intokubernetes-sigs:mainfrom
rostislavbobo:tlsroute-conformance-hostname-intersection

Conversation

@rostislavbobo
Copy link
Copy Markdown
Member

@rostislavbobo rostislavbobo commented Jan 19, 2026

What type of PR is this?

/kind test
/area conformance-test

What this PR does / why we need it:

This PR adds a conformance test for Gateway and TLSRoute hostnames intersection using wildcards (GEP-2643).

Gateway # Listener Hostname Attached TLSRoute Hostname
1 abc.example.com *.example.com
2 *.example.com abc.example.com
    *.com
3 *.com abc.example.com
    *.example.com
4 (Enpty) abc.example.com
    *.com

Note: TLSRoute rejection based on hostname mismatch is covered by #4433

Which issue(s) this PR fixes:

Fixes #

Part of #1579

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/test area/conformance-test Issues or PRs related to Conformance tests. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jan 19, 2026
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 19, 2026
@rostislavbobo rostislavbobo force-pushed the tlsroute-conformance-hostname-intersection branch from 98f0b01 to 430dfa9 Compare January 19, 2026 14:34
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 19, 2026
@rostislavbobo rostislavbobo force-pushed the tlsroute-conformance-hostname-intersection branch from 430dfa9 to 5410755 Compare January 19, 2026 14:35
@rostislavbobo rostislavbobo marked this pull request as ready for review January 19, 2026 14:39
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 19, 2026
@rostislavbobo
Copy link
Copy Markdown
Member Author

/cc @rikatz @Thealisyed

@k8s-ci-robot k8s-ci-robot requested a review from rikatz January 19, 2026 14:40
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@rostislavbobo: GitHub didn't allow me to request PR reviews from the following users: Thealisyed.

Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs.

Details

In response to this:

/cc @rikatz @Thealisyed

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.

@rikatz
Copy link
Copy Markdown
Member

rikatz commented Jan 20, 2026

/assign

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: gateway-exact-hostname
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

given this is a tlsroute test, can we have the name of the gateway containing it to differentiate from other tests?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

also question: what would be the impact of having all listeners on the same gateway, and attaching to the listener using sectionName?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

given this is a tlsroute test, can we have the name of the gateway containing it to differentiate from other tests?

Added "-tlsroute and "-intersection" to the Gateway names.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

what would be the impact of having all listeners on the same gateway, and attaching to the listener using sectionName?

This is possible, but it requires adding more TLS-terminating backends to be able to trace the request till it hits a distinct backend. Currently, the "gateway-conformance-infra" namespace has only one "tls_backend" Service and Deployment (see source).

We need to decide between
a) Multiple Gateways – create more Gateways in conformance/tests/*.yaml that use the single "tls_backend", or
b) Multiple Backends – add more "tls_backend_{N}" Services and Deployments to conformance/base/manifests.yaml and use a single Gateway with multiple listeners in conformance/tests/*.yaml

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ok I see your point, yes. We won't be able to assert which listener was used.

I think we can consider multiple backends as some part of the evolution, but looks good to me for now. I will approve and let the lgtm for someone else

@rikatz
Copy link
Copy Markdown
Member

rikatz commented Jan 20, 2026

@rostislavbobo two asks/questions, otherwise lgtm!

Copy link
Copy Markdown
Contributor

@Thealisyed Thealisyed left a comment

Choose a reason for hiding this comment

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

lgtm :)

@rikatz
Copy link
Copy Markdown
Member

rikatz commented Jan 21, 2026

/approve
/retest
thanks @rostislavbobo

I will check with someone else for a 2nd pass

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rikatz, rostislavbobo

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 21, 2026
@rikatz
Copy link
Copy Markdown
Member

rikatz commented Jan 21, 2026

/cc @snorwin @kl52752 @kflynn

@rikatz
Copy link
Copy Markdown
Member

rikatz commented Jan 28, 2026

I have tested with envoy gateway and cilium and it works fine.
Istio and kgateway are broken because of the size of the gateway name, but IMO this should be fixed on the implementation and not on the test.

/lgtm
/hold
@kl52752 I think we can fix any of these t.Runs on a followup, but will leave it for you to decide

Thanks!

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Jan 28, 2026
@howardjohn
Copy link
Copy Markdown
Contributor

Istio and kgateway are broken because of the size of the gateway name, but IMO this should be fixed on the implementation and not on the test.

IMO if we have a test for TLS it should not be testing "too long hostname".

The spec even says to copy the name: https://gateway-api.sigs.k8s.io/geps/gep-1762/?h=cl#automated-deployments

@rikatz
Copy link
Copy Markdown
Member

rikatz commented Jan 28, 2026

IMO if we have a test for TLS it should not be testing "too long hostname".

It is not, it is testing within the boundaries of 62 characters for the Gateway name (not about hostname). But once Istio copies the labels to the deployment spec, it adds an "istio" suffix and this violates the size.

@howardjohn
Copy link
Copy Markdown
Contributor

IMO if we have a test for TLS it should not be testing "too long hostname".

It is not, it is testing within the boundaries of 62 characters for the Gateway name (not about hostname). But once Istio copies the labels to the deployment spec, it adds an "istio" suffix and this violates the size.

The spec says an implementation should do this. A TLS test does not require 62 character Gateway name. If we want to enforce this for conformance, we should change the spec. We cannot have a conformance test that requires you to violate the spec...

@rikatz
Copy link
Copy Markdown
Member

rikatz commented Jan 28, 2026

The spec says an implementation should do this. A TLS test does not require 62 character Gateway name. If we want to enforce this for conformance, we should change the spec. We cannot have a conformance test that requires you to violate the spec...

OK, I see your point, the issue here is that we enforce that the generated label is - and this test "enforces" the worst case.

I have missed that.

@rostislavbobo can you reduce the size name for now?

@howardjohn while we do not explicitly define a limit for a Gateway name, I think we may need to make it clear that a user creating a gateway with a big name will cause problems once those names are concatenated. We should probably enforce that in this case a better condition is exposed on Gateway status to let users now that the name is too big (a new conformance, a new specification, etc).

@howardjohn
Copy link
Copy Markdown
Contributor

Yeah I definitely agree some tweaks are needed around how to handle large names - just that we should do that in a dedicated manner instead of tying it to TLSRoute 🙂 . Thanks!

@rostislavbobo
Copy link
Copy Markdown
Member Author

makes sense @howardjohn , will reduce the name sizes, we can address it separately, no need to be part of TLSRoutes

@rikatz
Copy link
Copy Markdown
Member

rikatz commented Jan 28, 2026

Created the issue #4464 for a followup on gateway name size.

Thanks folks

@kl52752
Copy link
Copy Markdown
Contributor

kl52752 commented Jan 29, 2026

/lgtm

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 29, 2026
@rostislavbobo
Copy link
Copy Markdown
Member Author

rostislavbobo commented Jan 29, 2026

  • non-matching specific hostnames do not intersect
  • non-matching wildcard hostnames do not intersect (so, *.example.com and *.com, for example).
  • what happens when both are wildcard hostnames? I don't know if we've specified this.

@youngnick , I've added more test cases to cover, here's a quick summary:

Gateway # Listener Hostname Attached TLSRoute Hostname
1 abc.example.com *.example.com
2 *.example.com abc.example.com
    *.com
3 *.com abc.example.com
    *.example.com
4 (Enpty) abc.example.com
    *.com

Here you can see we do support when both are wildcard hostnames (even for *.example.com and *.com).

No matching hostnames are covered by #4433

@rikatz
Copy link
Copy Markdown
Member

rikatz commented Jan 29, 2026

/retest
This error on ci wasn't happening yesterday, and in theory we do not run retroactive linters...

- name: gw-tlsroute-more-specific-wc-hostname-x-2
namespace: gateway-conformance-infra
hostnames:
- "*.com"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@rostislavbobo I think this should not pass? the spec of gw-tlsroute-more-specific-wc-hostname-x-2 says: hostname: "*.example.com" so should trying to attach a *.com work?

Copy link
Copy Markdown
Member Author

@rostislavbobo rostislavbobo Jan 29, 2026

Choose a reason for hiding this comment

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

it passes for istio, fails for eg

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have some split feelings. Let me think loud here

  • the hostname on listener is used for infrastructure configuration and routing. It means "what listener hostname can attach here"
  • the hostname on route is used for proper routing, like "anything that is *.com should route here" and it may rely on the parentRef for the right routing

I think the test makes sense given the parentRef case, let's see how this goes during implementations running their conformance

Copy link
Copy Markdown
Member Author

@rostislavbobo rostislavbobo Jan 29, 2026

Choose a reason for hiding this comment

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

Same with HTTPRoutes: A Gateway { hostname: "*.example.com" } <-- HTTPRoute { hostnames: ["*.com"] } is supported by istio and gke-l7-*, but is not supported by eg.

@robscott , @youngnick , the GW spec doesn't clearly state how to handle wildcard-to-wildcard attachments. I can
a) add this test for HTTPRoute, or
b) remove this test from TLSRoute
so that it's consistent across both.

WDYT?

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.

The thing you're missing here @rikatz is that * only means a single label. So *.com will only match example.com, not www.example.com.

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.

I do not recall when we added the stuff about the suffix match, but I do recall us agreeing that * only matched a single label. Let me look at the blame for those files and see if I can find some context, as that's not how I remember things working.

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.

Okay, turns out I am wrong, I guess, sigh, as of #1173, years ago. So yes, @rostislavbobo, you're right here. That is how the wildcard matching works, so it makes sense to test it.

I suspect I've written Cilium's implementation incorrectly and I'll fail this test, but that's on me.

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.

Oh, one thing that is not the same as RFC-2818 is that * only matches on a full label (or multiple full labels). No partial matches, so f*.example.com is not valid and does not match anything. This is recorded on the Hostname type:

// Hostname is the fully qualified domain name of a network host. This matches
// the RFC 1123 definition of a hostname with 2 notable exceptions:
//
// 1. IPs are not allowed.
// 2. A hostname may be prefixed with a wildcard label (`*.`). The wildcard
// label must appear by itself as the first label.
//
// Hostname can be "precise" which is a domain name without the terminating
// dot of a network host (e.g. "foo.example.com") or "wildcard", which is a
// domain name prefixed with a single wildcard label (e.g. `*.example.com`).

But the "must match a full label or multiple labels" is implied rather than fully specified. I'll make a note to fix this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes, * matches full label(s) only. I don't recall any implementation supporting partial domain matches with * (e.g. f*.example.com) for SNI hostname or L7 Host.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I’ll also create a similar test for HTTPRoute (*.example.com and *.com intersection) since we keep that test for TLSRoute, and invite you all to the review.

@rikatz
Copy link
Copy Markdown
Member

rikatz commented Jan 29, 2026

/lgtm
/hold cancel

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Jan 29, 2026
@k8s-ci-robot k8s-ci-robot merged commit a4bd92b into kubernetes-sigs:main Jan 29, 2026
20 checks passed
danehans pushed a commit to danehans/gateway-api that referenced this pull request Mar 10, 2026
…bernetes-sigs#4437)

* conformance: add TLSRoute hostname intersection conformance tests

* TLSRoute: Indicate tlsroute in Gateway names

* TLSRoute: Add test for wildcard hostname intersects with wildcard listener hostname

* TLSRoute: Fetch the Secret once and reuse it

* TLSRoute: Add more conformance tests to cover more intersection cases

* TLSRoute: Make TLS request tests run in parallel
jcmoraisjr added a commit to jcmoraisjr/haproxy-ingress that referenced this pull request Mar 22, 2026
Gateway API uses distinct wildcard hostname match on HTTP and TLS:

* Host header and HTTPRoute hostnames matching understand a wildcard as
  one or more DNS labels, so the wildcard hostname is used as a suffix;
* TLS SNI extension and TLSRoute hostnames matching understand a
  wildcard as a single DNS label, following RFC-2818.

Context:

https://github.com/kubernetes-sigs/gateway-api/blob/8f9b904306371cbfed9f9d542e9af667de804286/site-src/concepts/hostnames.md?plain=1#L142-L145

kubernetes-sigs/gateway-api#4437 (comment)

TLSRoute was not following this configuration, but instead the suffix
approach of the HTTPRoute, making one of the conformance tests to fail.
This update configures ExtendedWildcard to false, so HAProxy configures
the TLS/SNI match using single DNS label instead.
jcmoraisjr added a commit to jcmoraisjr/haproxy-ingress that referenced this pull request Mar 23, 2026
Gateway API uses distinct wildcard hostname match on HTTP and TLS:

* Host header and HTTPRoute hostnames matching understand a wildcard as
  one or more DNS labels, so the wildcard hostname is used as a suffix;
* TLS SNI extension and TLSRoute hostnames matching understand a
  wildcard as a single DNS label, following RFC-2818.

Context:

https://github.com/kubernetes-sigs/gateway-api/blob/8f9b904306371cbfed9f9d542e9af667de804286/site-src/concepts/hostnames.md?plain=1#L142-L145

kubernetes-sigs/gateway-api#4437 (comment)

TLSRoute was not following this configuration, but instead the suffix
approach of the HTTPRoute, making one of the conformance tests to fail.
This update configures ExtendedWildcard to false, so HAProxy configures
the TLS/SNI match using single DNS label instead.
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. area/conformance-test Issues or PRs related to Conformance tests. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/test lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants