Skip to content

Commit

Permalink
Clarifying that wildcard hostname matching is suffix matching
Browse files Browse the repository at this point in the history
  • Loading branch information
robscott committed May 26, 2022
1 parent 50e6186 commit 6d506d0
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 28 deletions.
4 changes: 4 additions & 0 deletions apis/v1alpha2/gateway_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ type Listener struct {
// accepted. For more information, refer to the Route specific Hostnames
// documentation.
//
// Hostnames that are prefixed with a wildcard label (`*.`) are interpreted
// as a suffix match. That means that a match for `*.example.com` would match
// both `test.example.com`, and `foo.test.example.com`, but not `example.com`.
//
// Support: Core
//
// +optional
Expand Down
9 changes: 7 additions & 2 deletions apis/v1alpha2/httproute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,13 @@ type HTTPRouteSpec struct {
// * A Listener with `*.example.com` as the hostname matches HTTPRoutes
// that have either not specified any hostnames or have specified at least
// one hostname that matches the Listener hostname. For example,
// `test.example.com` and `*.example.com` would both match. On the other
// hand, `example.com` and `test.example.net` would not match.
// `*.example.com`, `test.example.com`, and `foo.test.example.com` would
// all match. On the other hand, `example.com` and `test.example.net` would
// not match.
//
// Hostnames that are prefixed with a wildcard label (`*.`) are interpreted
// as a suffix match. That means that a match for `*.example.com` would match
// both `test.example.com`, and `foo.test.example.com`, but not `example.com`.
//
// If both the Listener and HTTPRoute have specified hostnames, any
// HTTPRoute hostnames that do not match the Listener hostname MUST be
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 15 additions & 11 deletions config/crd/experimental/gateway.networking.k8s.io_httproutes.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion config/crd/stable/gateway.networking.k8s.io_gateways.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 15 additions & 11 deletions config/crd/stable/gateway.networking.k8s.io_httproutes.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions conformance/tests/httproute-listener-hostname-matching.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ var HTTPRouteListenerHostnameMatching = suite.ConformanceTest{
Backend: "infra-backend-v3",
Namespace: ns,
}, {
Request: http.ExpectedRequest{Host: "too.many.prefixes.bar.com", Path: "/"},
StatusCode: 404,
Request: http.ExpectedRequest{Host: "multiple.prefixes.bar.com", Path: "/"},
Backend: "infra-backend-v3",
Namespace: ns,
}, {
Request: http.ExpectedRequest{Host: "no.matching.host", Path: "/"},
StatusCode: 404,
Expand Down

0 comments on commit 6d506d0

Please sign in to comment.