Skip to content

Commit

Permalink
Implementing GEP 724: Refresh Route-Gateway Binding
Browse files Browse the repository at this point in the history
  • Loading branch information
robscott committed Aug 9, 2021
1 parent 5096d25 commit 052bf1f
Show file tree
Hide file tree
Showing 18 changed files with 1,105 additions and 664 deletions.
1 change: 1 addition & 0 deletions apis/v1alpha1/zz_generated.deepcopy.go

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

135 changes: 68 additions & 67 deletions apis/v1alpha2/gateway_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,17 @@ type GatewaySpec struct {
// combination of Hostname, Port, and Protocol. This will be enforced by a
// validating webhook.
type Listener struct {
// Name is the name of the Listener. If more than one Listener is present
// each Listener MUST specify a name. The names of Listeners MUST be unique
// within a Gateway.
//
// Support: Core
//
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=253
// +optional
Name *string `json:"name,omitempty"`

// Hostname specifies the virtual hostname to match for protocol types that
// define this concept. When unspecified, "", or `*`, all hostnames are
// matched. This field can be omitted for protocols that don't require
Expand Down Expand Up @@ -198,18 +209,7 @@ type Listener struct {
// +optional
TLS *GatewayTLSConfig `json:"tls,omitempty"`

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

// ProtocolType defines the application protocol accepted by a Listener.
Expand Down Expand Up @@ -383,59 +385,33 @@ const (
TLSModePassthrough TLSModeType = "Passthrough"
)

// RouteBindingSelector defines a schema for associating routes with the Gateway.
// If Namespaces and Selector are defined, only routes matching both selectors are
// associated with the Gateway.
type RouteBindingSelector struct {
// Namespaces indicates in which namespaces Routes should be selected
// for this Gateway. This is restricted to the namespace of this Gateway by
// ListenerRoutes defines which Routes may be attached to this Listener.
type ListenerRoutes struct {
// Namespaces indicates which namespaces Routes may be attached to this
// Listener from. This is restricted to the namespace of this Gateway by
// default.
//
// Support: Core
//
// +optional
// +kubebuilder:default={from: Same}
Namespaces *RouteNamespaces `json:"namespaces,omitempty"`
// Selector specifies a set of route labels used for selecting
// routes to associate with the Gateway. If this Selector is defined,
// only routes matching the Selector are associated with the Gateway.
// An empty Selector matches all routes.
//
// Support: Core
//
// +optional
Selector *metav1.LabelSelector `json:"selector,omitempty"`
// Group is the group of the route resource to select. Omitting the value
// indicates the gateway.networking.k8s.io API group.
// For example, use the following to select an HTTPRoute:
//
// routes:
// kind: HTTPRoute
//
// Otherwise, if an alternative API group is desired, specify the desired
// group:

// Kinds specifies the groups and kinds of Routes that are allowed to bind
// to this Gateway listener. When unspecified or empty, the kinds of Routes
// selected are determined using the Listener protocol.
//
// routes:
// group: acme.io
// kind: FooRoute
// Kind MUST correspond to kinds of Routes that are compatible with the
// application protocol specified in the Listener's Protocol field. If an
// implementation does not support or recognize this resource type, it
// SHOULD set the "ResolvedRefs" condition to false for this listener with
// the "InvalidRoutesRef" reason.
//
// Support: Core
//
// +optional
// +kubebuilder:default=gateway.networking.k8s.io
// +kubebuilder:validation:MaxLength=253
Group *string `json:"group,omitempty"`
// Kind is the kind of the route resource to select.
//
// Kind MUST correspond to kinds of routes that are compatible with the
// application protocol specified in the Listener's Protocol field.
//
// If an implementation does not support or recognize this
// resource type, it SHOULD set the "ResolvedRefs" condition to false for
// this listener with the "InvalidRoutesRef" reason.
//
// Support: Core
Kind string `json:"kind"`
// +kubebuilder:validation:MaxItems=8
Kinds []RouteGroupKind `json:"kinds,omitempty"`
}

// RouteSelectType specifies where Routes should be selected by a Gateway.
Expand Down Expand Up @@ -477,6 +453,26 @@ type RouteNamespaces struct {
Selector *metav1.LabelSelector `json:"selector,omitempty"`
}

// RouteGroupKind indicates the group and kind of a Route resource.
type RouteGroupKind struct {
// Group is the group of the Route.
//
// Support: Core
//
// +optional
// +kubebuilder:default=gateway.networking.k8s.io
// +kubebuilder:validation:MaxLength=253
Group *string `json:"group,omitempty"`

// Kind is the kind of the Route.
//
// Support: Core
//
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=253
Kind string `json:"kind"`
}

// GatewayAddress describes an address that can be bound to a Gateway.
type GatewayAddress struct {
// Type of the address.
Expand Down Expand Up @@ -566,8 +562,6 @@ type GatewayStatus struct {
// Listeners provide status for each unique listener port defined in the Spec.
//
// +optional
// +listType=map
// +listMapKey=port
// +kubebuilder:validation:MaxItems=64
Listeners []ListenerStatus `json:"listeners,omitempty"`
}
Expand Down Expand Up @@ -672,19 +666,26 @@ const (

// ListenerStatus is the status associated with a Listener.
type ListenerStatus struct {
// Port is the unique Listener port value for which this message is
// reporting the status.
Port PortNumber `json:"port"`

// Protocol is the Listener protocol value for which this message is
// reporting the status.
Protocol ProtocolType `json:"protocol"`

// Hostname is the Listener hostname value for which this message is
// reporting the status.
// Name is the name of the Listener.
//
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=253
// +optional
Hostname *Hostname `json:"hostname,omitempty"`
Name *string `json:"name,omitempty"`

// SupportedKinds is the list indicating the Kinds supported by this
// listener. When this is not specified on the Listener, this MUST represent
// the kinds an implementation supports for the specified protocol. When
// there are kinds specified on the Listener, this MUST represent the
// intersection of those kinds and the kinds supported by the implementation
// for the specified protocol.
//
// +kubebuilder:validation:MaxItems=8
SupportedKinds []RouteGroupKind `json:"supportedKinds,omitempty"`

// AttachedRoutes represents the total number of Routes that have been
// successfully attached to this Listener.
AttachedRoutes int32 `json:"attachedRoutes"`

// Conditions describe the current condition of this listener.
//
Expand Down
24 changes: 21 additions & 3 deletions apis/v1alpha2/httproute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,29 @@ type HTTPRouteList struct {

// HTTPRouteSpec defines the desired state of HTTPRoute
type HTTPRouteSpec struct {
// Gateways defines which Gateways can use this Route.
// ParentRefs references the resources (usually Gateways) that a Route wants
// to be attached to. Note that the referenced parent resource needs to
// allow this for the attachment to be complete. For Gateways, that means
// the Gateway needs to allow attachment from Routes of this kind and
// namespace.
//
// The only kind of parent resource with "Core" support is Gateway. This API
// may be extended in the future to support additional kinds of parent
// resources such as one of the route kinds.
//
// It is invalid to reference an identical parent more than once. It is
// valid to reference multiple distinct sections within the same parent
// resource, such as 2 Listeners within a Gateway.
//
// It is possible to separately reference multiple distinct objects that may
// be collapsed by an implementation. For example, some implementations may
// choose to merge compatible Gateway Listeners together. If that is the
// case, the list of routes attached to those resources should also be
// merged.
//
// +optional
// +kubebuilder:default={allow: "SameNamespace"}
Gateways *RouteGateways `json:"gateways,omitempty"`
// +kubebuilder:validation:MaxItems=16
ParentRefs []ParentRef `json:"parentRefs,omitempty"`

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

0 comments on commit 052bf1f

Please sign in to comment.