Skip to content

Commit c5bca72

Browse files
authored
Merge pull request #1173 from robscott/wildcard-hostname-spec
Clarifying that wildcard hostname matching is suffix matching
2 parents d1b8664 + 2672b1a commit c5bca72

8 files changed

+70
-27
lines changed

apis/v1alpha2/gateway_types.go

+4
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ type Listener struct {
172172
// accepted. For more information, refer to the Route specific Hostnames
173173
// documentation.
174174
//
175+
// Hostnames that are prefixed with a wildcard label (`*.`) are interpreted
176+
// as a suffix match. That means that a match for `*.example.com` would match
177+
// both `test.example.com`, and `foo.test.example.com`, but not `example.com`.
178+
//
175179
// Support: Core
176180
//
177181
// +optional

apis/v1alpha2/httproute_types.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,13 @@ type HTTPRouteSpec struct {
7474
// * A Listener with `*.example.com` as the hostname matches HTTPRoutes
7575
// that have either not specified any hostnames or have specified at least
7676
// one hostname that matches the Listener hostname. For example,
77-
// `test.example.com` and `*.example.com` would both match. On the other
78-
// hand, `example.com` and `test.example.net` would not match.
77+
// `*.example.com`, `test.example.com`, and `foo.test.example.com` would
78+
// all match. On the other hand, `example.com` and `test.example.net` would
79+
// not match.
80+
//
81+
// Hostnames that are prefixed with a wildcard label (`*.`) are interpreted
82+
// as a suffix match. That means that a match for `*.example.com` would match
83+
// both `test.example.com`, and `foo.test.example.com`, but not `example.com`.
7984
//
8085
// If both the Listener and HTTPRoute have specified hostnames, any
8186
// HTTPRoute hostnames that do not match the Listener hostname MUST be

config/crd/experimental/gateway.networking.k8s.io_gateways.yaml

+5-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/experimental/gateway.networking.k8s.io_httproutes.yaml

+15-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/stable/gateway.networking.k8s.io_gateways.yaml

+5-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/stable/gateway.networking.k8s.io_httproutes.yaml

+15-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

conformance/tests/httproute-listener-hostname-matching.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,15 @@ var HTTPRouteListenerHostnameMatching = suite.ConformanceTest{
6666
Backend: "infra-backend-v3",
6767
Namespace: ns,
6868
}, {
69-
Request: http.ExpectedRequest{Host: "too.many.prefixes.bar.com", Path: "/"},
69+
Request: http.ExpectedRequest{Host: "multiple.prefixes.bar.com", Path: "/"},
70+
Backend: "infra-backend-v3",
71+
Namespace: ns,
72+
}, {
73+
Request: http.ExpectedRequest{Host: "multiple.prefixes.foo.com", Path: "/"},
74+
Backend: "infra-backend-v3",
75+
Namespace: ns,
76+
}, {
77+
Request: http.ExpectedRequest{Host: "foo.com", Path: "/"},
7078
StatusCode: 404,
7179
}, {
7280
Request: http.ExpectedRequest{Host: "no.matching.host", Path: "/"},

conformance/tests/httproute-listener-hostname-matching.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ spec:
2727
namespaces:
2828
from: Same
2929
hostname: "*.bar.com"
30+
- name: listener-4
31+
port: 80
32+
protocol: HTTP
33+
allowedRoutes:
34+
namespaces:
35+
from: Same
36+
hostname: "*.foo.com"
3037
---
3138
apiVersion: gateway.networking.k8s.io/v1alpha2
3239
kind: HTTPRoute
@@ -68,6 +75,9 @@ spec:
6875
- name: httproute-listener-hostname-matching
6976
namespace: gateway-conformance-infra
7077
sectionName: listener-3
78+
- name: httproute-listener-hostname-matching
79+
namespace: gateway-conformance-infra
80+
sectionName: listener-4
7181
rules:
7282
- backendRefs:
7383
- name: infra-backend-v3

0 commit comments

Comments
 (0)