Skip to content

Commit a639f55

Browse files
authored
Merge pull request #362 from robscott/route-namespaces
Updating RouteNamespaces to use RouteGateways pattern
2 parents 79b5ac6 + cf17434 commit a639f55

16 files changed

+108
-102
lines changed

apis/v1alpha1/gateway_types.go

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,7 @@ type RouteBindingSelector struct {
430430
// default.
431431
//
432432
// Support: Core
433-
//
434-
// +kubebuilder:default={onlySameNamespace:true}
435-
RouteNamespaces RouteNamespaces `json:"routeNamespaces,omitempty"`
433+
RouteNamespaces RouteNamespaces `json:"routeNamespaces"`
436434
// RouteSelector specifies a set of route labels used for selecting
437435
// routes to associate with the Gateway. If RouteSelector is defined,
438436
// only routes matching the RouteSelector are associated with the Gateway.
@@ -475,36 +473,43 @@ type RouteBindingSelector struct {
475473
Kind string `json:"kind"`
476474
}
477475

476+
// RouteSelectType specifies where Routes should be selected by a Gateway.
477+
// +kubebuilder:validation:Enum=All;Selector;Same
478+
// +kubebuilder:default=Same
479+
type RouteSelectType string
480+
481+
const (
482+
// RouteSelectAll indicates that Routes in all namespaces may be used by
483+
// this Gateway.
484+
RouteSelectAll RouteSelectType = "All"
485+
// RouteSelectSelector indicates that only Routes in namespaces selected by
486+
// the selector may be used by this Gateway.
487+
RouteSelectSelector RouteSelectType = "Selector"
488+
// RouteSelectSame indicates that Only Routes in the same namespace may be
489+
// used by this Gateway.
490+
RouteSelectSame RouteSelectType = "Same"
491+
)
492+
478493
// RouteNamespaces indicate which namespaces Routes should be selected from.
479494
type RouteNamespaces struct {
480-
// NamespaceSelector is a selector of namespaces that Routes should be
481-
// selected from. This is a standard Kubernetes LabelSelector, a label query
482-
// over a set of resources. The result of matchLabels and matchExpressions
483-
// are ANDed. Controllers must not support Routes in namespaces outside this
484-
// selector.
485-
//
486-
// An empty selector (default) indicates that Routes in any namespace can be
487-
// selected.
488-
//
489-
// The OnlySameNamespace field takes precedence over this field. This
490-
// selector will only take effect when OnlySameNamespace is false.
495+
// From indicates where Routes will be selected for this Gateway. Possible
496+
// values are:
497+
// * All: Routes in all namespaces may be used by this Gateway.
498+
// * Selector: Routes in namespaces selected by the selector may be used by
499+
// this Gateway.
500+
// * Same: Only Routes in the same namespace may be used by this Gateway.
491501
//
492502
// Support: Core
493-
//
494-
// +optional
495-
NamespaceSelector metav1.LabelSelector `json:"namespaceSelector,omitempty"`
503+
From RouteSelectType `json:"from,omitempty"`
496504

497-
// OnlySameNamespace is a boolean used to indicate if Route references are
498-
// limited to the same Namespace as the Gateway. When true, only Routes
499-
// within the same Namespace as the Gateway should be selected.
500-
//
501-
// This field takes precedence over the NamespaceSelector field. That
502-
// selector should only take effect when this field is set to false.
505+
// Selector must be specified when From is set to "Selector". In that case,
506+
// only Routes in Namespaces matching this Selector will be selected by this
507+
// Gateway. This field is ignored for other values of "From".
503508
//
504509
// Support: Core
505510
//
506-
// +kubebuilder:default=true
507-
OnlySameNamespace bool `json:"onlySameNamespace,omitempty"`
511+
// +optional
512+
Selector metav1.LabelSelector `json:"selector,omitempty"`
508513
}
509514

510515
// GatewayAddress describes an address that can be bound to a Gateway.

apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/networking.x-k8s.io_gateways.yaml

Lines changed: 10 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs-src/spec.md

Lines changed: 26 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/spec/index.html

Lines changed: 26 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/basic-http.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ spec:
2222
routes:
2323
kind: HTTPRoute
2424
routeNamespaces:
25-
namespaceSelector: {}
26-
onlySameNamespace: false
25+
from: "All"
2726
routeSelector:
2827
matchLabels:
2928
app: foo

examples/basic-tcp.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ spec:
2222
routes:
2323
kind: TCPRoute
2424
routeNamespaces:
25-
namespaceSelector: {}
26-
onlySameNamespace: false
25+
from: "All"
2726
routeSelector:
2827
matchLabels:
2928
"app": "foo"

examples/basic-udp.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ spec:
2222
routes:
2323
kind: UDPRoute
2424
routeNamespaces:
25-
namespaceSelector: {}
26-
onlySameNamespace: false
25+
from: "All"
2726
routeSelector:
2827
matchLabels:
2928
"app": "foo"

examples/default-match-http.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ spec:
2020
routes:
2121
kind: HTTPRoute
2222
routeNamespaces:
23-
namespaceSelector: {}
24-
onlySameNamespace: false
23+
from: "All"
2524
routeSelector:
2625
matchLabels:
2726
app: default-match

examples/http-trafficsplit.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ spec:
2121
routes:
2222
kind: HTTPRoute
2323
routeNamespaces:
24-
namespaceSelector: {}
25-
onlySameNamespace: false
24+
from: "Selector"
25+
selector: {}
2626
routeSelector:
2727
matchLabels:
2828
app: split

0 commit comments

Comments
 (0)