Skip to content

Commit 47516aa

Browse files
committed
Variety of fixes in response to feedback on kubernetes-sigs#780
1 parent 09526c9 commit 47516aa

16 files changed

+440
-396
lines changed

apis/v1alpha2/gateway_types.go

Lines changed: 42 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,8 @@ import (
3030
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`
3131
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
3232

33-
// Gateway represents an instantiation of a service-traffic handling
34-
// infrastructure by binding Listeners to a set of IP addresses.
35-
//
36-
// Implementations should add the `gateway-exists-finalizer.gateway.networking.k8s.io`
37-
// finalizer on the associated GatewayClass whenever Gateway(s) is running.
38-
// This ensures that a GatewayClass associated with a Gateway(s) is not
39-
// deleted while in use.
33+
// Gateway represents an instance of a service-traffic handling infrastructure
34+
// by binding Listeners to a set of IP addresses.
4035
type Gateway struct {
4136
metav1.TypeMeta `json:",inline"`
4237
metav1.ObjectMeta `json:"metadata,omitempty"`
@@ -52,7 +47,7 @@ type Gateway struct {
5247

5348
// +kubebuilder:object:root=true
5449

55-
// GatewayList contains a list of Gateway.
50+
// GatewayList contains a list of Gateways.
5651
type GatewayList struct {
5752
metav1.TypeMeta `json:",inline"`
5853
metav1.ListMeta `json:"metadata,omitempty"`
@@ -118,18 +113,17 @@ type GatewaySpec struct {
118113
// +kubebuilder:validation:MaxItems=64
119114
Listeners []Listener `json:"listeners"`
120115

121-
// Addresses requested for this gateway. This is optional and
122-
// behavior can depend on the GatewayClass. If a value is set
123-
// in the spec and the requested address is invalid, the
124-
// GatewayClass MUST indicate this in the associated entry in
125-
// GatewayStatus.Addresses.
116+
// Addresses requested for this Gateway. This is optional and behavior can
117+
// depend on the implementation. If a value is set in the spec and the
118+
// requested address is invalid or unavailable, the implementation MUST
119+
// indicate this in the associated entry in GatewayStatus.Addresses.
126120
//
127-
// If no Addresses are specified, the GatewayClass may
128-
// schedule the Gateway in an implementation-defined manner,
129-
// assigning an appropriate set of Addresses.
121+
// If no Addresses are specified, the implementation MAY schedule the
122+
// Gateway in an implementation-specific manner, assigning an appropriate
123+
// set of Addresses.
130124
//
131-
// The GatewayClass MUST bind all Listeners to every
132-
// GatewayAddress that it assigns to the Gateway.
125+
// The implementation MUST bind all Listeners to every GatewayAddress that
126+
// it assigns to the Gateway.
133127
//
134128
// Support: Core
135129
//
@@ -151,18 +145,18 @@ type Listener struct {
151145
Name SectionName `json:"name"`
152146

153147
// Hostname specifies the virtual hostname to match for protocol types that
154-
// define this concept. When unspecified, "", or `*`, all hostnames are
155-
// matched. This field can be omitted for protocols that don't require
156-
// hostname based matching.
157-
//
158-
// For HTTPRoute objects, there is an interaction with the
159-
// `spec.hostnames` array. When both listener and route specify hostnames,
160-
// there must be an intersection between the values for a Route to be admitted.
161-
// For example, a Gateway with `*.example.com` would admit a Route that included
148+
// define this concept. When unspecified or `*`, all hostnames are matched.
149+
// This field can be omitted for protocols that don't require hostname based
150+
// matching.
151+
//
152+
// For HTTPRoute objects, there is an interaction with the `spec.hostnames`
153+
// array. When both listener and route specify hostnames, there must be an
154+
// intersection between the values for a Route to be admitted. For example,
155+
// a Gateway with `*.example.com` would admit a Route that included
162156
// `foo.example.com` as a hostname, but not a Route that *only* included
163-
// `foo.acme.io` as a hostname. A Route that included both `foo.example.com`
164-
// and `foo.acme.io` would be admitted, but the `foo.acme.io` hostname would
165-
// be silently ignored.
157+
// `foo.example.net` as a hostname. A Route that included both
158+
// `foo.example.com` and `foo.example.net` would be admitted, but the
159+
// `foo.example.net` hostname would be silently ignored.
166160
//
167161
// Support: Core
168162
//
@@ -207,7 +201,7 @@ type Listener struct {
207201
// +optional
208202
TLS *GatewayTLSConfig `json:"tls,omitempty"`
209203

210-
// Routes specifies which Routes may be attached to this Listener.
204+
// AllowedRoutes specifies which Routes may be attached to this Listener.
211205
//
212206
// Although a client request may technically match multiple route rules,
213207
// only one rule may ultimately receive the request. Matching precedence
@@ -232,7 +226,7 @@ type Listener struct {
232226
// Support: Core
233227
// +kubebuilder:default={namespaces:{from: Same}}
234228
// +optional
235-
Routes *ListenerRoutes `json:"routes,omitempty"`
229+
AllowedRoutes *AllowedRoutes `json:"allowedRoutes,omitempty"`
236230
}
237231

238232
// ProtocolType defines the application protocol accepted by a Listener.
@@ -293,7 +287,7 @@ type GatewayTLSConfig struct {
293287
// References to a resource in different namespace are invalid UNLESS there
294288
// is a ReferencePolicy in the target namespace that allows the certificate
295289
// to be attached. If a ReferencePolicy does not allow this reference, the
296-
// "ResolvedRefs" condition MUST be set to false for this listener with the
290+
// "ResolvedRefs" condition MUST be set to False for this listener with the
297291
// "InvalidCertificateRef" reason.
298292
//
299293
// This field is required when mode is set to "Terminate" (default) and
@@ -339,8 +333,8 @@ const (
339333
TLSModePassthrough TLSModeType = "Passthrough"
340334
)
341335

342-
// ListenerRoutes defines which Routes may be attached to this Listener.
343-
type ListenerRoutes struct {
336+
// AllowedRoutes defines which Routes may be attached to this Listener.
337+
type AllowedRoutes struct {
344338
// Namespaces indicates which namespaces Routes may be attached to this
345339
// Listener from. This is restricted to the namespace of this Gateway by
346340
// default.
@@ -358,7 +352,7 @@ type ListenerRoutes struct {
358352
// A RouteGroupKind MUST correspond to kinds of Routes that are compatible
359353
// with the application protocol specified in the Listener's Protocol field.
360354
// If an implementation does not support or recognize this resource type, it
361-
// MUST set the "ResolvedRefs" condition to false for this Listener with the
355+
// MUST set the "ResolvedRefs" condition to False for this Listener with the
362356
// "InvalidRoutesRef" reason.
363357
//
364358
// Support: Core
@@ -532,10 +526,9 @@ const (
532526
//
533527
// * "Scheduled"
534528
//
535-
// Possible reasons for this condition to be false are:
529+
// Possible reasons for this condition to be False are:
536530
//
537531
// * "NotReconciled"
538-
// * "NoSuchGatewayClass"
539532
// * "NoResources"
540533
//
541534
// Controllers may raise this condition with other reasons,
@@ -551,13 +544,6 @@ const (
551544
// been recently created and no controller has reconciled it yet.
552545
GatewayReasonNotReconciled GatewayConditionReason = "NotReconciled"
553546

554-
// This reason is used with the "Scheduled" condition when the Gateway is
555-
// not scheduled because there is no controller that recognizes the
556-
// GatewayClassName. This reason has been deprecated and will be removed in
557-
// a future release.
558-
// +deprecated
559-
GatewayReasonNoSuchGatewayClass GatewayConditionReason = "NoSuchGatewayClass"
560-
561547
// This reason is used with the "Scheduled" condition when the
562548
// Gateway is not scheduled because insufficient infrastructure
563549
// resources are available.
@@ -579,7 +565,7 @@ const (
579565
//
580566
// * "Ready"
581567
//
582-
// Possible reasons for this condition to be false are:
568+
// Possible reasons for this condition to be False are:
583569
//
584570
// * "ListenersNotValid"
585571
// * "ListenersNotReady"
@@ -614,9 +600,7 @@ const (
614600

615601
// ListenerStatus is the status associated with a Listener.
616602
type ListenerStatus struct {
617-
// Name is the name of the Listener. If the Gateway has more than one
618-
// Listener present, each ListenerStatus MUST specify a name. The names of
619-
// ListenerStatus objects MUST be unique within a Gateway.
603+
// Name is the name of the Listener that this status corresponds to.
620604
Name SectionName `json:"name"`
621605

622606
// SupportedKinds is the list indicating the Kinds supported by this
@@ -662,7 +646,7 @@ const (
662646
// * "ProtocolConflict"
663647
// * "RouteConflict"
664648
//
665-
// Possible reasons for this condition to be false are:
649+
// Possible reasons for this condition to be False are:
666650
//
667651
// * "NoConflicts"
668652
//
@@ -690,7 +674,7 @@ const (
690674
ListenerReasonRouteConflict ListenerConditionReason = "RouteConflict"
691675

692676
// This reason is used with the "Conflicted" condition when the condition
693-
// is false.
677+
// is False.
694678
ListenerReasonNoConflicts ListenerConditionReason = "NoConflicts"
695679
)
696680

@@ -712,7 +696,7 @@ const (
712696
// * "UnsupportedProtocol"
713697
// * "UnsupportedAddress"
714698
//
715-
// Possible reasons for this condition to be false are:
699+
// Possible reasons for this condition to be False are:
716700
//
717701
// * "Attached"
718702
//
@@ -742,7 +726,7 @@ const (
742726
ListenerReasonUnsupportedAddress ListenerConditionReason = "UnsupportedAddress"
743727

744728
// This reason is used with the "Detached" condition when the condition is
745-
// false.
729+
// False.
746730
ListenerReasonAttached ListenerConditionReason = "Attached"
747731
)
748732

@@ -754,7 +738,7 @@ const (
754738
//
755739
// * "ResolvedRefs"
756740
//
757-
// Possible reasons for this condition to be false are:
741+
// Possible reasons for this condition to be False are:
758742
//
759743
// * "DegradedRoutes"
760744
// * "InvalidCertificateRef"
@@ -770,10 +754,10 @@ const (
770754
// is true.
771755
ListenerReasonResolvedRefs ListenerConditionReason = "ResolvedRefs"
772756

773-
// This reason is used with the "ResolvedRefs" condition
774-
// when not all of the routes selected by this Listener could be
775-
// configured. The specific reason for the degraded route should
776-
// be indicated in the route's .Status.Conditions field.
757+
// This reason is used with the "ResolvedRefs" condition when not all of the
758+
// routes selected by this Listener could be configured. The specific reason
759+
// for the degraded route should be indicated in the Conditions field of the
760+
// appropriate entry of the route's .Status.Parents.
777761
ListenerReasonDegradedRoutes ListenerConditionReason = "DegradedRoutes"
778762

779763
// This reason is used with the "ResolvedRefs" condition when the
@@ -803,7 +787,7 @@ const (
803787
//
804788
// * "Ready"
805789
//
806-
// Possible reasons for this condition to be false are:
790+
// Possible reasons for this condition to be False are:
807791
//
808792
// * "Invalid"
809793
// * "Pending"

apis/v1alpha2/gatewayclass_types.go

Lines changed: 27 additions & 11 deletions
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.

0 commit comments

Comments
 (0)