Skip to content

Commit f573729

Browse files
authored
Merge pull request #754 from robscott/gep-724-implementation
Implementing GEP 724: Refresh Route-Gateway Binding
2 parents a209add + 67902eb commit f573729

17 files changed

+1087
-724
lines changed

apis/v1alpha2/gateway_types.go

+65-66
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ type GatewaySpec struct {
112112
//
113113
// Support: Core
114114
//
115+
// +listType=map
116+
// +listMapKey=name
115117
// +kubebuilder:validation:MinItems=1
116118
// +kubebuilder:validation:MaxItems=64
117119
Listeners []Listener `json:"listeners"`
@@ -141,6 +143,15 @@ type GatewaySpec struct {
141143
// combination of Hostname, Port, and Protocol. This will be enforced by a
142144
// validating webhook.
143145
type Listener struct {
146+
// Name is the name of the Listener. If more than one Listener is present
147+
// each Listener MUST specify a name. The names of Listeners MUST be unique
148+
// within a Gateway.
149+
//
150+
// Support: Core
151+
//
152+
// +kubebuilder:validation:MaxLength=253
153+
Name string `json:"name"`
154+
144155
// Hostname specifies the virtual hostname to match for protocol types that
145156
// define this concept. When unspecified, "", or `*`, all hostnames are
146157
// matched. This field can be omitted for protocols that don't require
@@ -198,18 +209,7 @@ type Listener struct {
198209
// +optional
199210
TLS *GatewayTLSConfig `json:"tls,omitempty"`
200211

201-
// Routes specifies a schema for associating routes with the
202-
// Listener using selectors. A Route is a resource capable of
203-
// servicing a request and allows a cluster operator to expose
204-
// a cluster resource (i.e. Service) by externally-reachable
205-
// URL, load-balance traffic and terminate SSL/TLS. Typically,
206-
// a route is a "HTTPRoute" or "TCPRoute" in group
207-
// "gateway.networking.k8s.io", however, an implementation may support
208-
// other types of resources.
209-
//
210-
// The Routes selector MUST select a set of objects that
211-
// are compatible with the application protocol specified in
212-
// the Protocol field.
212+
// Routes specifies which Routes may be attached to this Listener.
213213
//
214214
// Although a client request may technically match multiple route rules,
215215
// only one rule may ultimately receive the request. Matching precedence
@@ -232,7 +232,9 @@ type Listener struct {
232232
// invalid, the rest of the Route should still be supported.
233233
//
234234
// Support: Core
235-
Routes RouteBindingSelector `json:"routes"`
235+
// +kubebuilder:default={namespaces:{from: Same}}
236+
// +optional
237+
Routes *ListenerRoutes `json:"routes,omitempty"`
236238
}
237239

238240
// ProtocolType defines the application protocol accepted by a Listener.
@@ -374,59 +376,33 @@ const (
374376
TLSModePassthrough TLSModeType = "Passthrough"
375377
)
376378

377-
// RouteBindingSelector defines a schema for associating routes with the Gateway.
378-
// If Namespaces and Selector are defined, only routes matching both selectors are
379-
// associated with the Gateway.
380-
type RouteBindingSelector struct {
381-
// Namespaces indicates in which namespaces Routes should be selected
382-
// for this Gateway. This is restricted to the namespace of this Gateway by
379+
// ListenerRoutes defines which Routes may be attached to this Listener.
380+
type ListenerRoutes struct {
381+
// Namespaces indicates which namespaces Routes may be attached to this
382+
// Listener from. This is restricted to the namespace of this Gateway by
383383
// default.
384384
//
385385
// Support: Core
386386
//
387387
// +optional
388388
// +kubebuilder:default={from: Same}
389389
Namespaces *RouteNamespaces `json:"namespaces,omitempty"`
390-
// Selector specifies a set of route labels used for selecting
391-
// routes to associate with the Gateway. If this Selector is defined,
392-
// only routes matching the Selector are associated with the Gateway.
393-
// An empty Selector matches all routes.
394-
//
395-
// Support: Core
396-
//
397-
// +optional
398-
Selector *metav1.LabelSelector `json:"selector,omitempty"`
399-
// Group is the group of the route resource to select. Omitting the value
400-
// indicates the gateway.networking.k8s.io API group.
401-
// For example, use the following to select an HTTPRoute:
402-
//
403-
// routes:
404-
// kind: HTTPRoute
405-
//
406-
// Otherwise, if an alternative API group is desired, specify the desired
407-
// group:
390+
391+
// Kinds specifies the groups and kinds of Routes that are allowed to bind
392+
// to this Gateway Listener. When unspecified or empty, the kinds of Routes
393+
// selected are determined using the Listener protocol.
408394
//
409-
// routes:
410-
// group: acme.io
411-
// kind: FooRoute
395+
// A RouteGroupKind MUST correspond to kinds of Routes that are compatible
396+
// with the application protocol specified in the Listener's Protocol field.
397+
// If an implementation does not support or recognize this resource type, it
398+
// MUST set the "ResolvedRefs" condition to false for this Listener with the
399+
// "InvalidRoutesRef" reason.
412400
//
413401
// Support: Core
414402
//
415403
// +optional
416-
// +kubebuilder:default=gateway.networking.k8s.io
417-
// +kubebuilder:validation:MaxLength=253
418-
Group *string `json:"group,omitempty"`
419-
// Kind is the kind of the route resource to select.
420-
//
421-
// Kind MUST correspond to kinds of routes that are compatible with the
422-
// application protocol specified in the Listener's Protocol field.
423-
//
424-
// If an implementation does not support or recognize this
425-
// resource type, it SHOULD set the "ResolvedRefs" condition to false for
426-
// this listener with the "InvalidRoutesRef" reason.
427-
//
428-
// Support: Core
429-
Kind string `json:"kind"`
404+
// +kubebuilder:validation:MaxItems=8
405+
Kinds []RouteGroupKind `json:"kinds,omitempty"`
430406
}
431407

432408
// RouteSelectType specifies where Routes should be selected by a Gateway.
@@ -468,6 +444,22 @@ type RouteNamespaces struct {
468444
Selector *metav1.LabelSelector `json:"selector,omitempty"`
469445
}
470446

447+
// RouteGroupKind indicates the group and kind of a Route resource.
448+
type RouteGroupKind struct {
449+
// Group is the group of the Route.
450+
//
451+
// +optional
452+
// +kubebuilder:default=gateway.networking.k8s.io
453+
// +kubebuilder:validation:MaxLength=253
454+
Group *string `json:"group,omitempty"`
455+
456+
// Kind is the kind of the Route.
457+
//
458+
// +kubebuilder:validation:MinLength=1
459+
// +kubebuilder:validation:MaxLength=253
460+
Kind string `json:"kind"`
461+
}
462+
471463
// GatewayAddress describes an address that can be bound to a Gateway.
472464
type GatewayAddress struct {
473465
// Type of the address.
@@ -558,7 +550,7 @@ type GatewayStatus struct {
558550
//
559551
// +optional
560552
// +listType=map
561-
// +listMapKey=port
553+
// +listMapKey=name
562554
// +kubebuilder:validation:MaxItems=64
563555
Listeners []ListenerStatus `json:"listeners,omitempty"`
564556
}
@@ -663,19 +655,26 @@ const (
663655

664656
// ListenerStatus is the status associated with a Listener.
665657
type ListenerStatus struct {
666-
// Port is the unique Listener port value for which this message is
667-
// reporting the status.
668-
Port PortNumber `json:"port"`
669-
670-
// Protocol is the Listener protocol value for which this message is
671-
// reporting the status.
672-
Protocol ProtocolType `json:"protocol"`
658+
// Name is the name of the Listener. If the Gateway has more than one
659+
// Listener present, each ListenerStatus MUST specify a name. The names of
660+
// ListenerStatus objects MUST be unique within a Gateway.
661+
//
662+
// +kubebuilder:validation:MaxLength=253
663+
Name string `json:"name"`
673664

674-
// Hostname is the Listener hostname value for which this message is
675-
// reporting the status.
665+
// SupportedKinds is the list indicating the Kinds supported by this
666+
// listener. When this is not specified on the Listener, this MUST represent
667+
// the kinds an implementation supports for the specified protocol. When
668+
// there are kinds specified on the Listener, this MUST represent the
669+
// intersection of those kinds and the kinds supported by the implementation
670+
// for the specified protocol.
676671
//
677-
// +optional
678-
Hostname *Hostname `json:"hostname,omitempty"`
672+
// +kubebuilder:validation:MaxItems=8
673+
SupportedKinds []RouteGroupKind `json:"supportedKinds"`
674+
675+
// AttachedRoutes represents the total number of Routes that have been
676+
// successfully attached to this Listener.
677+
AttachedRoutes int32 `json:"attachedRoutes"`
679678

680679
// Conditions describe the current condition of this listener.
681680
//

apis/v1alpha2/httproute_types.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,7 @@ type HTTPRouteList struct {
5151

5252
// HTTPRouteSpec defines the desired state of HTTPRoute
5353
type HTTPRouteSpec struct {
54-
// Gateways defines which Gateways can use this Route.
55-
//
56-
// +optional
57-
// +kubebuilder:default={allow: "SameNamespace"}
58-
Gateways *RouteGateways `json:"gateways,omitempty"`
54+
CommonRouteSpec `json:",inline"`
5955

6056
// Hostnames defines a set of hostname that should match against
6157
// the HTTP Host header to select a HTTPRoute to process the request.

0 commit comments

Comments
 (0)