Skip to content

Add Hostname concept and explanation document#4516

Merged
k8s-ci-robot merged 1 commit intokubernetes-sigs:mainfrom
youngnick:add-hostnames-doc
Mar 4, 2026
Merged

Add Hostname concept and explanation document#4516
k8s-ci-robot merged 1 commit intokubernetes-sigs:mainfrom
youngnick:add-hostnames-doc

Conversation

@youngnick
Copy link
Contributor

This adds a document that further explains how the various hostname fields in Gateway API work together, and how integrations should consume them.

/kind documentation

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/documentation Categorizes issue or PR as related to documentation. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 9, 2026
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 9, 2026
Copy link
Contributor

@kflynn kflynn left a comment

Choose a reason for hiding this comment

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

@youngnick This is great, thanks! I made some suggestions, but with one exception (my question about "suffix match" at one point), these are minor. (The biggest diff is mostly reordering what you wrote. 🙂)


The main rule in this case is straightforward:

**All _intersected hostnames_ represented in all Listeners on the Gateway MUST resolve to all addresses in that Gateway's `status.addresses`**.

Choose a reason for hiding this comment

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

Is there a description of the algorithm used for intersecting hostnames? A pointer to actual code would be helpful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This the closest thing we have today. There is no supplied-by-the-project implementation of hostname intersection, it's just implied by how the spec and the conformance tests work.

I acknowledge this is not ideal, I've started roughing out what some library functions to handle this would look like.


There are a number of places you can configure a hostname in Gateway API, each of which with a different purpose. They are used for a number of purposes, including both **hostname intersection** between Routes and Gateways, which is used to determine if the Routes can attach, and also as a **routing discriminator**, to choose which Listener and Route should accept a particular request (more on both of these later in this document).

Each `hostname` field can accept either _precise_ hostnames (that is, a hostname like `www.example.com`), or _wildcard_ hostnames (that is, a hostname like `*.example.com`). The level of precision in a hostname also affects its effective order in the process of choosing which Listener will match particular traffic, with more precise beating less precise hostnames.

Choose a reason for hiding this comment

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

This line is maybe a little confusing because "precise" hostnames were just defined as e.g. "www.example.com", but there's no more precise version of that hostname, and any less precise would make it a wildcard hostname, right? It feels like the precision of any wildcard hostnames can be ordered, with the most-precise exact match (true "precise" hostname) being a winner over any wildcard.

Copy link
Contributor Author

@youngnick youngnick Feb 20, 2026

Choose a reason for hiding this comment

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

I added a little more explanation - this is intended to guide folks a little bit in implementation.

When sorting a list of hostnames:

  • hostnames with no wildcards sort before hostnames with wildcards
  • Precise Hostnames with more labels sort before precise hostnames with less labels (that is sub.domain.example.com is before www.example.com).
  • The special hostname * is always last.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Still aiming to add some helpers to the types to handle this, but this should help in the meantime.

Copy link
Member

@rostislavbobo rostislavbobo left a comment

Choose a reason for hiding this comment

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

Thanks @youngnick for clarifying this long-standing ambiguity! My main concern is introducing a breaking change if we force *.com TLS listeners to reject www.example.com SNI hostnames (whether for passthrough or termination using certificates with, for instance, both *.example.com, *.com SANs listed).


### Expected match examples

| Listener Hostname | TLS Mode| Route Type | Route hostname | Attached? | Intersected Hostname | SNI | SNI Match? | Host header | Host header match? | Notes |
Copy link
Member

Choose a reason for hiding this comment

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

A heads up this table is not rendered fine on the page (you need to scroll left/right), not sure how to improve it tho

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I didn't like that either, but I couldn't think of a better way to represent all this information at once.

Copy link

@krishicks krishicks left a comment

Choose a reason for hiding this comment

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

Some additional feedback after viewing the netlify preview, but otherwise it looks good to me!

* Find all ListenerSets that point those Gateways that have `Accepted` Conditions with `status: true`.
(Remember also that `hostname` fields must be unique across all Listeners attached to a Gateway,
whether those are in the Gateway or in attached ListnerSets.
The implementation should handle this by setting ListenerSets to `Accepted` `status: false` for duplicates.)
Copy link
Member

Choose a reason for hiding this comment

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

nit (do as a followup): it is slightly confusing if implementation here is the Gateway API implementation (which I know it is) or the controller integrating with Gateway API

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've tried to be consistent in using "implementation" for the actual Gateway API reconciler, and "integration" for things that consume Gateway API - that's what we call it on the implementations page as well.

Maybe I should explain that at the top of the page as well?

@rikatz
Copy link
Member

rikatz commented Mar 3, 2026

/hold
/lgtm
feel free to wait for @robscott or unhold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 3, 2026
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 3, 2026
Copy link
Member

@robscott robscott left a comment

Choose a reason for hiding this comment

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

Thanks @youngnick!

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: robscott, youngnick

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

@youngnick youngnick force-pushed the add-hostnames-doc branch from b742386 to 70e8428 Compare March 4, 2026 03:17
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 4, 2026
Signed-off-by: Nick Young <nick@isovalent.com>
@youngnick youngnick force-pushed the add-hostnames-doc branch from 70e8428 to 327d360 Compare March 4, 2026 03:18
@youngnick
Copy link
Contributor Author

/unhold

Next LGTM should merge this one, we can iterate from here.

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 4, 2026
@rikatz
Copy link
Member

rikatz commented Mar 4, 2026

/lgtm

Thanks Nick!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 4, 2026
@k8s-ci-robot k8s-ci-robot merged commit 50ab51a into kubernetes-sigs:main Mar 4, 2026
20 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. kind/documentation Categorizes issue or PR as related to documentation. 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.

8 participants