Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactors gateway api type to use label selectors #12

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 38 additions & 10 deletions api/v1alpha1/gateway_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,16 @@ type GatewaySpec struct {
// Listeners associated with this Gateway. Listeners define what addresses,
// ports, protocols are bound on this Gateway.
Listeners []Listener `json:"listeners" protobuf:"bytes,2,rep,name=listeners"`
// Routes is a list of resources to associate with the Gateway. 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 "networking.x.k8s.io". However, an
// implementation may support other resources.
//
// If unspecified, no routes will be associated to the Gateway.
// Routes specifies a schema for associating routes with the Gateway 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
// "networking.x.k8s.io". However, an implementation may support other resources.
//
// Support: Core
//
// +optional
Routes []RouteObjectReference `json:"routes" protobuf:"bytes,3,rep,name=routes"`
Routes RouteBindingSelector `json:"routes" protobuf:"bytes,3,opt,name=routes"`
}

const (
Expand Down Expand Up @@ -238,6 +235,37 @@ type LocalObjectReference struct {
Name string `json:"name" protobuf:"bytes,3,opt,name=name"`
}

// RouteBindingSelector defines a schema for associating routes with the Gateway.
// If NamespaceSelector and RouteSelector are defined, only routes matching both
// selectors are associated with the Gateway.
type RouteBindingSelector struct {
// NamespaceSelector specifies a set of namespace labels used for selecting
// routes to associate with the Gateway. If NamespaceSelector is defined,
// all routes in namespaces matching the NamespaceSelector are associated
// to the Gateway.
//
// An empty NamespaceSelector (default) indicates that routes from any
// namespace will be associated to this Gateway. This field is intentionally
// not a pointer because the nil behavior (no namespaces) is undesirable here.
//
// Support: Core
//
NamespaceSelector metav1.LabelSelector `json:"namespaceSelector" protobuf:"bytes,1,opt,name=namespaceSelector"`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just specify the namespace itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We decided to follow the established k8s pattern of using selectors. We may add additional RouteBindingSelector properties in the future. Feel free to create an issue to capture your use case.

// RouteSelector specifies a set of route labels used for selecting
// routes to associate with the Gateway. If RouteSelector is defined,
// only routes matching the RouteSelector are associated with the Gateway.
// An empty RouteSelector matches all routes.
//
//
// If undefined, route labels are not used for associating routes to
// the gateway.
//
// Support: Core
//
// +optional
RouteSelector *metav1.LabelSelector `json:"routeSelector,omitempty" protobuf:"bytes,2,opt,name=routeSelector"`
}

// CertificateObjectReference identifies a certificate object within a known
// namespace.
//
Expand Down
Loading