Skip to content

Commit 8343da8

Browse files
authored
Merge pull request #796 from robscott/780-small-fixes
Variety of fixes in response to feedback on #780
2 parents 323694d + 0fbc16b commit 8343da8

19 files changed

+638
-616
lines changed

apis/v1alpha2/gateway_types.go

+87-101
Large diffs are not rendered by default.

apis/v1alpha2/gatewayclass_types.go

+27-11
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,21 @@ import (
3030
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
3131
// +kubebuilder:printcolumn:name="Description",type=string,JSONPath=`.spec.description`,priority=1
3232

33-
// GatewayClass describes a class of Gateways available to the user
34-
// for creating Gateway resources.
33+
// GatewayClass describes a class of Gateways available to the user for creating
34+
// Gateway resources.
35+
//
36+
// It is recommended that this resource be used as a template for Gateways. This
37+
// means that a Gateway is based on the state of the GatewayClass at the time it
38+
// was created and changes to the GatewayClass or associated parameters are not
39+
// propagated down to existing Gateways. This recommendation is intended to
40+
// limit the blast radius of changes to GatewayClass or associated parameters.
41+
// If implementations choose to propagate GatewayClass changes to existing
42+
// Gateways, that MUST be clearly documented by the implementation.
43+
//
44+
// Whenever one or more Gateways are using a GatewayClass, implementations MUST
45+
// add the `gateway-exists-finalizer.gateway.networking.k8s.io` finalizer on the
46+
// associated GatewayClass. This ensures that a GatewayClass associated with a
47+
// Gateway is not deleted while in use.
3548
//
3649
// GatewayClass is a Cluster level resource.
3750
type GatewayClass struct {
@@ -47,12 +60,19 @@ type GatewayClass struct {
4760
Status GatewayClassStatus `json:"status,omitempty"`
4861
}
4962

63+
const (
64+
// GatewayClassFinalizerGatewaysExist should be added as a finalizer to the
65+
// GatewayClass whenever there are provisioned Gateways using a
66+
// GatewayClass.
67+
GatewayClassFinalizerGatewaysExist = "gateway-exists-finalizer.gateway.networking.k8s.io"
68+
)
69+
5070
// GatewayClassSpec reflects the configuration of a class of Gateways.
5171
type GatewayClassSpec struct {
5272
// Controller is a domain/path string that indicates the
5373
// controller that is managing Gateways of this class.
5474
//
55-
// Example: "acme.io/gateway-controller".
75+
// Example: "example.net/gateway-controller".
5676
//
5777
// This field is not mutable and cannot be empty.
5878
//
@@ -133,15 +153,15 @@ const (
133153
// This condition defaults to False, and MUST be set by a controller when it
134154
// sees a GatewayClass using its controller string. The status of this
135155
// condition MUST be set to true if the controller will support provisioning
136-
// Gateways using this class. Otherwise, this status MUST be set to false.
137-
// If the status is set to false, the controller SHOULD set a Message and
156+
// Gateways using this class. Otherwise, this status MUST be set to False.
157+
// If the status is set to False, the controller SHOULD set a Message and
138158
// Reason as an explanation.
139159
//
140160
// Possible reasons for this condition to be true are:
141161
//
142162
// * "Admitted"
143163
//
144-
// Possible reasons for this condition to be false are:
164+
// Possible reasons for this condition to be False are:
145165
//
146166
// * "InvalidParameters"
147167
// * "Waiting"
@@ -162,12 +182,8 @@ const (
162182
// This reason is used with the "Admitted" condition when the
163183
// requested controller has not yet made a decision about whether
164184
// to admit the GatewayClass. It is the default Reason on a new
165-
// GatewayClass. It indicates
185+
// GatewayClass.
166186
GatewayClassReasonWaiting GatewayClassConditionReason = "Waiting"
167-
168-
// GatewayClassFinalizerGatewaysExist should be added as a finalizer to the
169-
// GatewayClass whenever there are provisioned Gateways using a GatewayClass.
170-
GatewayClassFinalizerGatewaysExist = "gateway-exists-finalizer.gateway.networking.k8s.io"
171187
)
172188

173189
// GatewayClassStatus is the current status for the GatewayClass.

apis/v1alpha2/httproute_types.go

+54-67
Original file line numberDiff line numberDiff line change
@@ -62,44 +62,29 @@ type HTTPRouteSpec struct {
6262
// 1. IPs are not allowed.
6363
// 2. The `:` delimiter is not respected because ports are not allowed.
6464
//
65-
// Incoming requests are matched against the hostnames before the
66-
// HTTPRoute rules. If no hostname is specified, traffic is routed
67-
// based on the HTTPRouteRules.
68-
//
69-
// Requests will be matched against the Host field in the following order:
70-
//
71-
// 1. If Hostname is precise, the request matches this rule if
72-
// the HTTP Host header is equal to the Hostname.
73-
// 2. If Hostname is a wildcard, then the request matches this rule if
74-
// the HTTP Host header is to equal to the suffix
75-
// (removing the first label) of the wildcard rule.
76-
// 3. If Hostname is unspecified, empty, or `*`, then any request will match
77-
// this route.
78-
//
79-
// If a hostname is specified by the Listener that the HTTPRoute is bound
80-
// to, at least one hostname specified here must match the Listener specified
81-
// hostname as per the rules above. Other hostnames will not affect processing
82-
// of the route in that case.
83-
//
84-
// If no hostname is specified by the Listener, then that value will be treated
85-
// as '*', match any hostname, and so any hostname on this Route will match.
86-
//
87-
// If all hostnames do not match, then the HTTPRoute is not admitted, and
88-
// the implementation must raise an 'Admitted' Condition with a status of
89-
// `false` for that Listener.
90-
//
91-
// Examples:
92-
// - A Listener with unspecified, empty, or `*` values for Hostname matches
93-
// any HTTPRoute hostname.
94-
// - A HTTPRoute with unspecified, empty, or `*` values for Hostname matches
95-
// any Listener hostname.
96-
// - A Listener with `test.foo.com` as the hostname matches *only*
97-
// `test.foo.com` or `*.foo.com`. Any other hostnames present must be ignored.
98-
// - A Listener with `*.foo.com` as hostname, all hostnames in the HTTPRoute
99-
// must have any single label where the star is, and the rest of the hostname
100-
// must match exactly. So, `test.foo.com`, `*.foo.com` or `blog.foo.com` match.
101-
// `test.blog.foo.com`, `test.bar.com`, or `bar.com` do not. Hostnames that do
102-
// not match will be ignored.
65+
// If a hostname is specified by both the Listener and HTTPRoute, there
66+
// must be at least one intersecting hostname for the HTTPRoute to be
67+
// attached to the Listener. For example:
68+
//
69+
// * A Listener with `test.example.com` as the hostname matches HTTPRoutes
70+
// that have either not specified any hostnames, or have specified at
71+
// least one of `test.example.com` or `*.example.com`.
72+
// * A Listener with `*.example.com` as as the hostname matches HTTPRoutes
73+
// that have either not specified any hostnames or have specified at least
74+
// one hostname that matches the Listener hostname. For example,
75+
// `test.example.com` and `*.example.com` would both match. On the other
76+
// hand, `a.b.example.com`, `example.com`, and `test.example.net` would
77+
// not match.
78+
//
79+
// If both the Listener and HTTPRoute have specified hostnames, any
80+
// HTTPRoute hostnames that do not match the Listener hostname MUST be
81+
// ignored. For example, if a Listener specified `*.example.com`, and the
82+
// HTTPRoute specified `test.example.com` and `test.example.net`,
83+
// `test.example.net` must not be considered for a match.
84+
//
85+
// If hostnames do not match with the criteria above, then the HTTPRoute is
86+
// not admitted, and the implementation must raise an 'Admitted' Condition
87+
// with a status of `False` for the target Listener(s).
10388
//
10489
// Support: Core
10590
//
@@ -155,8 +140,10 @@ type HTTPRouteRule struct {
155140
// of the following criteria, continuing on ties:
156141
//
157142
// * The longest matching hostname.
143+
// * The longest matching non-wildcard hostname.
158144
// * The longest matching path.
159145
// * The largest number of header matches.
146+
// * The largest number of query param matches.
160147
//
161148
// If ties still exist across multiple Routes, matching precedence MUST be
162149
// determined in order of the following criteria, continuing on ties:
@@ -199,11 +186,14 @@ type HTTPRouteRule struct {
199186
Filters []HTTPRouteFilter `json:"filters,omitempty"`
200187

201188
// BackendRefs defines the backend(s) where matching requests should be
202-
// sent. If unspecified or invalid (refers to a non-existent resource or a Service with no endpoints),
203-
// the rule performs no forwarding; if no filters are specified that would result in a
204-
// response being sent, a HTTP 503 status code is returned. 503 responses must be sent so that the overall
205-
// weight is respected; if an invalid backend is requested to have 80% of requests, then 80% of requests
206-
// must get a 503 instead.
189+
// sent.
190+
191+
// If unspecified or invalid (refers to a non-existent resource or a Service
192+
// with no endpoints), the rule performs no forwarding. If that are also no
193+
// filters specified that would result in a response being sent, a HTTP 503
194+
// status code is returned. 503 responses must be sent so that the overall
195+
// weight is respected; if an invalid backend is requested to have 80% of
196+
// requests, then 80% of requests must get a 503 instead.
207197
//
208198
// Support: Core for Kubernetes Service
209199
// Support: Custom for any other resource
@@ -466,11 +456,9 @@ type HTTPRouteMatch struct {
466456

467457
// ExtensionRef is an optional, implementation-specific extension to the
468458
// "match" behavior. For example, resource "myroutematcher" in group
469-
// "networking.acme.io". If the referent cannot be found, the rule is not
470-
// included in the route. The controller should raise the "ResolvedRefs"
471-
// condition on the Gateway with the "DegradedRoutes" reason. The gateway
472-
// status for this route should be updated with a condition that describes
473-
// the error more specifically.
459+
// "networking.example.net". If the referent cannot be found, the rule is
460+
// not included in the route. The controller must ensure the "ResolvedRefs"
461+
// condition on the Route status is set to `status: False`.
474462
//
475463
// Support: Custom
476464
//
@@ -528,7 +516,8 @@ type HTTPRouteFilter struct {
528516
// +optional
529517
RequestMirror *HTTPRequestMirrorFilter `json:"requestMirror,omitempty"`
530518

531-
// RequestRedirect defines a schema for a filter that redirects request.
519+
// RequestRedirect defines a schema for a filter that responds to the
520+
// request with an HTTP redirection.
532521
//
533522
// Support: Core
534523
//
@@ -537,7 +526,7 @@ type HTTPRouteFilter struct {
537526

538527
// ExtensionRef is an optional, implementation-specific extension to the
539528
// "filter" behavior. For example, resource "myroutefilter" in group
540-
// "networking.acme.io"). ExtensionRef MUST NOT be used for core and
529+
// "networking.example.net"). ExtensionRef MUST NOT be used for core and
541530
// extended filters.
542531
//
543532
// Support: Implementation-specific
@@ -650,10 +639,10 @@ type HTTPRequestHeaderFilter struct {
650639
// +kubebuilder:validation:MaxItems=16
651640
Add []HTTPHeader `json:"add,omitempty"`
652641

653-
// Remove the given header(s) from the HTTP request before the
654-
// action. The value of RemoveHeader is a list of HTTP header
655-
// names. Note that the header names are case-insensitive
656-
// (see https://datatracker.ietf.org/doc/html/rfc2616#section-4.2).
642+
// Remove the given header(s) from the HTTP request before the action. The
643+
// value of Remove is a list of HTTP header names. Note that the header
644+
// names are case-insensitive (see
645+
// https://datatracker.ietf.org/doc/html/rfc2616#section-4.2).
657646
//
658647
// Input:
659648
// GET /foo HTTP/1.1
@@ -717,15 +706,14 @@ type HTTPRequestRedirect struct {
717706
type HTTPRequestMirrorFilter struct {
718707
// BackendRef references a resource where mirrored requests are sent.
719708
//
720-
// If the referent cannot be found, this HTTPBackendRef is invalid
721-
// and must be dropped from the Gateway. The controller must ensure the
722-
// "ResolvedRefs" condition on the Gateway is set to `status: true`
723-
// with the "DegradedRoutes" reason, and not configure this backend in the
724-
// underlying implemenation.
709+
// If the referent cannot be found, this BackendRef is invalid and must be
710+
// dropped from the Gateway. The controller must ensure the "ResolvedRefs"
711+
// condition on the Route status is set to `status: False` and not configure
712+
// this backend in the underlying implementation.
725713
//
726714
// If there is a cross-namespace reference to an *existing* object
727715
// that is not allowed by a ReferencePolicy, the controller must ensure the
728-
// "ResolvedRefs" condition on the Gateway is set to `status: true`,
716+
// "ResolvedRefs" condition on the Route is set to `status: False`,
729717
// with the "RefNotPermitted" reason and not configure this backend in the
730718
// underlying implementation.
731719
//
@@ -743,15 +731,14 @@ type HTTPRequestMirrorFilter struct {
743731
type HTTPBackendRef struct {
744732
// BackendRef is a reference to a backend to forward matched requests to.
745733
//
746-
// If the referent cannot be found, this HTTPBackendRef is invalid
747-
// and must be dropped from the Gateway. The controller must ensure the
748-
// "ResolvedRefs" condition on the Gateway is set to `status: true`
749-
// with the "DegradedRoutes" reason, and not configure this backend in the
750-
// underlying implemenation.
734+
// If the referent cannot be found, this HTTPBackendRef is invalid and must
735+
// be dropped from the Gateway. The controller must ensure the
736+
// "ResolvedRefs" condition on the Route is set to `status: False` and not
737+
// configure this backend in the underlying implementation.
751738
//
752739
// If there is a cross-namespace reference to an *existing* object
753740
// that is not covered by a ReferencePolicy, the controller must ensure the
754-
// "ResolvedRefs" condition on the Gateway is set to `status: true`,
741+
// "ResolvedRefs" condition on the Route is set to `status: true`,
755742
// with the "RefNotPermitted" reason and not configure this backend in the
756743
// underlying implementation.
757744
//
@@ -763,7 +750,7 @@ type HTTPBackendRef struct {
763750
// +optional
764751
BackendRef `json:",inline"`
765752

766-
// Filters defined at this-level should be executed if and only if the
753+
// Filters defined at this level should be executed if and only if the
767754
// request is being forwarded to the backend defined here.
768755
//
769756
// Support: Custom (For broader support of filters, use the Filters field

apis/v1alpha2/shared_types.go

+32-16
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,12 @@ type BackendRef struct {
141141
// BackendObjectReference references a Kubernetes object.
142142
BackendObjectReference `json:",inline"`
143143

144-
// Weight specifies the proportion of HTTP requests forwarded to the
145-
// referenced backend. This is computed as
146-
// weight/(sum of all weights in this ForwardTo list). For non-zero values,
147-
// there may be some epsilon from the exact proportion defined here
148-
// depending on the precision an implementation supports. Weight is not a
149-
// percentage and the sum of weights does not need to equal 100.
144+
// Weight specifies the proportion of requests forwarded to the referenced
145+
// backend. This is computed as weight/(sum of all weights in this
146+
// BackendRefs list). For non-zero values, there may be some epsilon from
147+
// the exact proportion defined here depending on the precision an
148+
// implementation supports. Weight is not a percentage and the sum of
149+
// weights does not need to equal 100.
150150
//
151151
// If only one backend is specified and it has a weight greater than 0, 100%
152152
// of the traffic is forwarded to that backend. If weight is set to 0, no
@@ -166,9 +166,13 @@ type BackendRef struct {
166166
type RouteConditionType string
167167

168168
const (
169-
// This condition indicates whether the route has been admitted
170-
// or rejected by a Gateway, and why.
169+
// This condition indicates whether the route has been admitted or rejected
170+
// by a Gateway, and why.
171171
ConditionRouteAdmitted RouteConditionType = "Admitted"
172+
173+
// This condition indicates whether the controller was able to resolve all
174+
// the object references for the Route.
175+
ConditionRouteResolvedRefs RouteConditionType = "ResolvedRefs"
172176
)
173177

174178
// RouteParentStatus describes the status of a route with respect to an
@@ -182,18 +186,32 @@ type RouteParentStatus struct {
182186
// wrote this status. This corresponds with the controller field on
183187
// GatewayClass.
184188
//
185-
// Example: "acme.io/gateway-controller".
189+
// Example: "example.net/gateway-controller".
186190
//
187191
// The format of this field is DOMAIN "/" PATH, where DOMAIN and PATH are
188192
// valid Kubernetes names
189193
// (https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names).
190194
Controller GatewayController `json:"controller"`
191195

192-
// Conditions describes the status of the route with respect to the
193-
// Gateway. The "Admitted" condition must always be specified by controllers
194-
// to indicate whether the route has been admitted or rejected by the Gateway,
195-
// and why. Note that the route's availability is also subject to the Gateway's
196-
// own status conditions and listener status.
196+
// Conditions describes the status of the route with respect to the Gateway.
197+
// Note that the route's availability is also subject to the Gateway's own
198+
// status conditions and listener status.
199+
//
200+
// If the Route's ParentRef specifies an existing Gateway that supports
201+
// Routes of this kind AND that Gateway's controller has sufficient access,
202+
// then that Gateway's controller MUST set the "Admitted" condition on the
203+
// Route, to indicate whether the route has been admitted or rejected by the
204+
// Gateway, and why.
205+
//
206+
// A Route MUST be considered "Admitted" if at least one of the Route's
207+
// rules is implemented by the Gateway.
208+
//
209+
// There are a number of cases where the "Admitted" condition may not be set
210+
// due to lack of controller visibility, that includes when:
211+
//
212+
// * The Route refers to a non-existent parent.
213+
// * The Route is of a type that the controller does not support.
214+
// * The Route is in a namespace the the controller does not have access to.
197215
//
198216
// +listType=map
199217
// +listMapKey=type
@@ -229,8 +247,6 @@ type RouteStatus struct {
229247
// Hostname can be "precise" which is a domain name without the terminating
230248
// dot of a network host (e.g. "foo.example.com") or "wildcard", which is a
231249
// domain name prefixed with a single wildcard label (e.g. `*.example.com`).
232-
// The wildcard character `*` must appear by itself as the first DNS label
233-
// and matches only a single label.
234250
//
235251
// Note that as per RFC1035 and RFC1123, a *label* must consist of lower case
236252
// alphanumeric characters or '-', and must start and end with an alphanumeric

apis/v1alpha2/tcproute_types.go

+9-13
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,11 @@ type TCPRouteRule struct {
8989
Matches []TCPRouteMatch `json:"matches,omitempty"`
9090

9191
// BackendRefs defines the backend(s) where matching requests should be
92-
// sent. If unspecified or invalid (refers to a non-existent resource or
93-
// a Service with no endpoints), the rule performs no forwarding; if no
94-
// filters are specified that would result in a response being sent, the
95-
// underlying implementation must actively reject connection attempts to
96-
// this backend. Connection rejections must respect weight; if an invalid
97-
// backend is requested to have 80% of connections, then 80% of connections
98-
// must be rejected instead.
92+
// sent. If unspecified or invalid (refers to a non-existent resource or a
93+
// Service with no endpoints), the underlying implementation MUST actively
94+
// reject connection attempts to this backend. Connection rejections must
95+
// respect weight; if an invalid backend is requested to have 80% of
96+
// connections, then 80% of connections must be rejected instead.
9997
//
10098
// Support: Core for Kubernetes Service
10199
// Support: Custom for any other resource
@@ -111,12 +109,10 @@ type TCPRouteRule struct {
111109
// given action.
112110
type TCPRouteMatch struct {
113111
// ExtensionRef is an optional, implementation-specific extension to the
114-
// "match" behavior. For example, resource "mytcproutematcher" in group
115-
// "networking.acme.io". If the referent cannot be found, the rule is not
116-
// included in the route. The controller should raise the "ResolvedRefs"
117-
// condition on the Gateway with the "DegradedRoutes" reason. The gateway
118-
// status for this route should be updated with a condition that describes
119-
// the error more specifically.
112+
// "match" behavior. For example, resource "mytcproutematcher" in group
113+
// "networking.example.net". If the referent cannot be found, the rule MUST
114+
// not be included in the route. The controller must ensure the
115+
// "ResolvedRefs" condition on the Route status is set to `status: False`.
120116
//
121117
// Support: Custom
122118
//

0 commit comments

Comments
 (0)