diff --git a/apis/v1alpha1/httproute_types.go b/apis/v1alpha1/httproute_types.go index 7a95e4a8f5..c11e22f8ea 100644 --- a/apis/v1alpha1/httproute_types.go +++ b/apis/v1alpha1/httproute_types.go @@ -16,7 +16,6 @@ limitations under the License. package v1alpha1 import ( - core "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -453,66 +452,7 @@ type RouteHostExtensionObjectReference = ConfigMapsDefaultLocalObjectReference // HTTPRouteStatus defines the observed state of HTTPRoute. type HTTPRouteStatus struct { - // Gateways is a list of the Gateways that are associated with the - // HTTPRoute, and the status of the route with respect to each of these - // Gateways. When a Gateway selects this route, the controller that - // manages the Gateway should add an entry to this list when the - // controller first sees the route and should update the entry as - // appropriate when the route is modified. - Gateways []RouteGatewayStatus `json:"gateways"` -} - -// GatewayObjectReference identifies a Gateway object. -type GatewayObjectReference struct { - // Namespace is the namespace of the referent. - // +optional - Namespace string `json:"namespace,omitempty"` - // Name is the name of the referent. - // - // +kubebuilder:validation:Required - // +required - Name string `json:"name"` -} - -// RouteGatewayStatus describes the status of a route with respect to an -// associated Gateway. -type RouteGatewayStatus struct { - // GatewayRef is a reference to a Gateway object that is associated with - // the route. - GatewayRef GatewayObjectReference `json:"gatewayRef"` - // Conditions describes the status of the route with respect to the - // Gateway. For example, the "Admitted" condition indicates whether the - // route has been admitted or rejected by the Gateway, and why. Note - // that the route's availability is also subject to the Gateway's own - // status conditions and listener status. - Conditions []RouteCondition `json:"conditions,omitempty"` -} - -// RouteConditionType is a type of condition for a route. -type RouteConditionType string - -const ( - // ConditionRouteAdmitted indicates whether the route has been admitted - // or rejected by a Gateway, and why. - ConditionRouteAdmitted RouteConditionType = "Admitted" -) - -// RouteCondition is a status condition for a given route. -type RouteCondition struct { - // Type indicates the type of condition. - Type RouteConditionType `json:"type"` - // Status describes the current state of this condition. Can be "True", - // "False", or "Unknown". - Status core.ConditionStatus `json:"status"` - // Message is a human-understandable message describing the condition. - // +optional - Message string `json:"message,omitempty"` - // Reason indicates why the condition is in this state. - // +optional - Reason string `json:"reason,omitempty"` - // LastTransitionTime indicates the last time this condition changed. - // +optional - LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` + RouteStatus `json:",inline"` } // +genclient diff --git a/apis/v1alpha1/route_types.go b/apis/v1alpha1/route_types.go new file mode 100644 index 0000000000..20a508812e --- /dev/null +++ b/apis/v1alpha1/route_types.go @@ -0,0 +1,86 @@ +/* + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + core "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// GatewayObjectReference identifies a Gateway object. +type GatewayObjectReference struct { + // Namespace is the namespace of the referent. + // +optional + Namespace string `json:"namespace,omitempty"` + // Name is the name of the referent. + // + // +kubebuilder:validation:Required + // +required + Name string `json:"name"` +} + +// RouteConditionType is a type of condition for a route. +type RouteConditionType string + +const ( + // ConditionRouteAdmitted indicates whether the route has been admitted + // or rejected by a Gateway, and why. + ConditionRouteAdmitted RouteConditionType = "Admitted" +) + +// RouteCondition is a status condition for a given route. +type RouteCondition struct { + // Type indicates the type of condition. + Type RouteConditionType `json:"type"` + // Status describes the current state of this condition. Can be "True", + // "False", or "Unknown". + Status core.ConditionStatus `json:"status"` + // Message is a human-understandable message describing the condition. + // +optional + Message string `json:"message,omitempty"` + // Reason indicates why the condition is in this state. + // +optional + Reason string `json:"reason,omitempty"` + // LastTransitionTime indicates the last time this condition changed. + // +optional + LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` +} + +// RouteGatewayStatus describes the status of a route with respect to an +// associated Gateway. +type RouteGatewayStatus struct { + // GatewayRef is a reference to a Gateway object that is associated with + // the route. + GatewayRef GatewayObjectReference `json:"gatewayRef"` + // Conditions describes the status of the route with respect to the + // Gateway. For example, the "Admitted" condition indicates whether the + // route has been admitted or rejected by the Gateway, and why. Note + // that the route's availability is also subject to the Gateway's own + // status conditions and listener status. + Conditions []RouteCondition `json:"conditions,omitempty"` +} + +// RouteStatus defines the observed state that is required across +// all route types. +type RouteStatus struct { + // Gateways is a list of the Gateways that are associated with the + // route, and the status of the route with respect to each of these + // Gateways. When a Gateway selects this route, the controller that + // manages the Gateway should add an entry to this list when the + // controller first sees the route and should update the entry as + // appropriate when the route is modified. + Gateways []RouteGatewayStatus `json:"gateways"` +} diff --git a/apis/v1alpha1/tcproute_types.go b/apis/v1alpha1/tcproute_types.go index 1cb3549a83..25a98bd196 100644 --- a/apis/v1alpha1/tcproute_types.go +++ b/apis/v1alpha1/tcproute_types.go @@ -27,13 +27,7 @@ type TCPRouteSpec struct { // TCPRouteStatus defines the observed state of TCPRoute type TCPRouteStatus struct { - // Gateways is a list of the Gateways that are associated with the - // TCPRoute, and the status of the route with respect to each of these - // Gateways. When a Gateway selects this route, the controller that - // manages the Gateway should add an entry to this list when the - // controller first sees the route and should update the entry as - // appropriate when the route is modified. - Gateways []RouteGatewayStatus `json:"gateways"` + RouteStatus `json:",inline"` } // +genclient diff --git a/apis/v1alpha1/udproute_types.go b/apis/v1alpha1/udproute_types.go index 5364c0f47e..b8116efd2b 100644 --- a/apis/v1alpha1/udproute_types.go +++ b/apis/v1alpha1/udproute_types.go @@ -27,7 +27,7 @@ type UDPRouteSpec struct { // UDPRouteStatus defines the observed state of UDPRoute. type UDPRouteStatus struct { - GatewayRefs []GatewayObjectReference `json:"gatewayRefs" protobuf:"bytes,1,rep,name=gatewayRefs"` + RouteStatus `json:",inline"` } // +genclient diff --git a/apis/v1alpha1/zz_generated.deepcopy.go b/apis/v1alpha1/zz_generated.deepcopy.go index 54cad67581..e67e2cdd51 100644 --- a/apis/v1alpha1/zz_generated.deepcopy.go +++ b/apis/v1alpha1/zz_generated.deepcopy.go @@ -673,13 +673,7 @@ func (in *HTTPRouteSpec) DeepCopy() *HTTPRouteSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HTTPRouteStatus) DeepCopyInto(out *HTTPRouteStatus) { *out = *in - if in.Gateways != nil { - in, out := &in.Gateways, &out.Gateways - *out = make([]RouteGatewayStatus, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } + in.RouteStatus.DeepCopyInto(&out.RouteStatus) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPRouteStatus. @@ -839,6 +833,28 @@ func (in *RouteNamespaces) DeepCopy() *RouteNamespaces { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RouteStatus) DeepCopyInto(out *RouteStatus) { + *out = *in + if in.Gateways != nil { + in, out := &in.Gateways, &out.Gateways + *out = make([]RouteGatewayStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteStatus. +func (in *RouteStatus) DeepCopy() *RouteStatus { + if in == nil { + return nil + } + out := new(RouteStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SecretsDefaultLocalObjectReference) DeepCopyInto(out *SecretsDefaultLocalObjectReference) { *out = *in @@ -1023,13 +1039,7 @@ func (in *TCPRouteSpec) DeepCopy() *TCPRouteSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TCPRouteStatus) DeepCopyInto(out *TCPRouteStatus) { *out = *in - if in.Gateways != nil { - in, out := &in.Gateways, &out.Gateways - *out = make([]RouteGatewayStatus, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } + in.RouteStatus.DeepCopyInto(&out.RouteStatus) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TCPRouteStatus. @@ -1219,11 +1229,7 @@ func (in *UDPRouteSpec) DeepCopy() *UDPRouteSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *UDPRouteStatus) DeepCopyInto(out *UDPRouteStatus) { *out = *in - if in.GatewayRefs != nil { - in, out := &in.GatewayRefs, &out.GatewayRefs - *out = make([]GatewayObjectReference, len(*in)) - copy(*out, *in) - } + in.RouteStatus.DeepCopyInto(&out.RouteStatus) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UDPRouteStatus. diff --git a/config/crd/bases/networking.x-k8s.io_httproutes.yaml b/config/crd/bases/networking.x-k8s.io_httproutes.yaml index 4ed7aaca22..272193bcd2 100644 --- a/config/crd/bases/networking.x-k8s.io_httproutes.yaml +++ b/config/crd/bases/networking.x-k8s.io_httproutes.yaml @@ -353,7 +353,7 @@ spec: description: HTTPRouteStatus defines the observed state of HTTPRoute. properties: gateways: - description: Gateways is a list of the Gateways that are associated with the HTTPRoute, and the status of the route with respect to each of these Gateways. When a Gateway selects this route, the controller that manages the Gateway should add an entry to this list when the controller first sees the route and should update the entry as appropriate when the route is modified. + description: Gateways is a list of the Gateways that are associated with the route, and the status of the route with respect to each of these Gateways. When a Gateway selects this route, the controller that manages the Gateway should add an entry to this list when the controller first sees the route and should update the entry as appropriate when the route is modified. items: description: RouteGatewayStatus describes the status of a route with respect to an associated Gateway. properties: diff --git a/config/crd/bases/networking.x-k8s.io_tcproutes.yaml b/config/crd/bases/networking.x-k8s.io_tcproutes.yaml index 422712d38b..700f95808c 100644 --- a/config/crd/bases/networking.x-k8s.io_tcproutes.yaml +++ b/config/crd/bases/networking.x-k8s.io_tcproutes.yaml @@ -206,7 +206,7 @@ spec: description: TCPRouteStatus defines the observed state of TCPRoute properties: gateways: - description: Gateways is a list of the Gateways that are associated with the TCPRoute, and the status of the route with respect to each of these Gateways. When a Gateway selects this route, the controller that manages the Gateway should add an entry to this list when the controller first sees the route and should update the entry as appropriate when the route is modified. + description: Gateways is a list of the Gateways that are associated with the route, and the status of the route with respect to each of these Gateways. When a Gateway selects this route, the controller that manages the Gateway should add an entry to this list when the controller first sees the route and should update the entry as appropriate when the route is modified. items: description: RouteGatewayStatus describes the status of a route with respect to an associated Gateway. properties: diff --git a/config/crd/bases/networking.x-k8s.io_udproutes.yaml b/config/crd/bases/networking.x-k8s.io_udproutes.yaml index cbeced78d7..40fb1dc047 100644 --- a/config/crd/bases/networking.x-k8s.io_udproutes.yaml +++ b/config/crd/bases/networking.x-k8s.io_udproutes.yaml @@ -196,22 +196,55 @@ spec: status: description: UDPRouteStatus defines the observed state of UDPRoute. properties: - gatewayRefs: + gateways: + description: Gateways is a list of the Gateways that are associated with the route, and the status of the route with respect to each of these Gateways. When a Gateway selects this route, the controller that manages the Gateway should add an entry to this list when the controller first sees the route and should update the entry as appropriate when the route is modified. items: - description: GatewayObjectReference identifies a Gateway object. + description: RouteGatewayStatus describes the status of a route with respect to an associated Gateway. properties: - name: - description: Name is the name of the referent. - type: string - namespace: - description: Namespace is the namespace of the referent. - type: string + conditions: + description: Conditions describes the status of the route with respect to the Gateway. For example, the "Admitted" condition indicates whether the route has been admitted or rejected by the Gateway, and why. Note that the route's availability is also subject to the Gateway's own status conditions and listener status. + items: + description: RouteCondition is a status condition for a given route. + properties: + lastTransitionTime: + description: LastTransitionTime indicates the last time this condition changed. + format: date-time + type: string + message: + description: Message is a human-understandable message describing the condition. + type: string + reason: + description: Reason indicates why the condition is in this state. + type: string + status: + description: Status describes the current state of this condition. Can be "True", "False", or "Unknown". + type: string + type: + description: Type indicates the type of condition. + type: string + required: + - status + - type + type: object + type: array + gatewayRef: + description: GatewayRef is a reference to a Gateway object that is associated with the route. + properties: + name: + description: Name is the name of the referent. + type: string + namespace: + description: Namespace is the namespace of the referent. + type: string + required: + - name + type: object required: - - name + - gatewayRef type: object type: array required: - - gatewayRefs + - gateways type: object type: object served: true diff --git a/docs-src/spec.md b/docs-src/spec.md index 268e10bc80..5c5c3b9945 100644 --- a/docs-src/spec.md +++ b/docs-src/spec.md @@ -1222,8 +1222,7 @@ with respect to the current state of the instance.

(Appears on: -RouteGatewayStatus, -UDPRouteStatus) +RouteGatewayStatus)

GatewayObjectReference identifies a Gateway object.

@@ -2132,20 +2131,17 @@ HTTPRouteAction -gateways
+RouteStatus
- -[]RouteGatewayStatus + +RouteStatus -

Gateways is a list of the Gateways that are associated with the -HTTPRoute, and the status of the route with respect to each of these -Gateways. When a Gateway selects this route, the controller that -manages the Gateway should add an entry to this list when the -controller first sees the route and should update the entry as -appropriate when the route is modified.

+

+(Members of RouteStatus are embedded into this type.) +

@@ -2754,8 +2750,7 @@ Kubernetes meta/v1.Time

(Appears on: -HTTPRouteStatus, -TCPRouteStatus) +RouteStatus)

RouteGatewayStatus describes the status of a route with respect to an @@ -2863,6 +2858,46 @@ selector should only take effect when this field is set to false.

+

RouteStatus +

+

+(Appears on: +HTTPRouteStatus, +TCPRouteStatus, +UDPRouteStatus) +

+

+

RouteStatus defines the observed state that is required across +all route types.

+

+ + + + + + + + + + + + + +
FieldDescription
+gateways
+ + +[]RouteGatewayStatus + + +
+

Gateways is a list of the Gateways that are associated with the +route, and the status of the route with respect to each of these +Gateways. When a Gateway selects this route, the controller that +manages the Gateway should add an entry to this list when the +controller first sees the route and should update the entry as +appropriate when the route is modified.

+

SecretsDefaultLocalObjectReference

@@ -3222,20 +3257,17 @@ TCPRouteAction -gateways
+RouteStatus
- -[]RouteGatewayStatus + +RouteStatus -

Gateways is a list of the Gateways that are associated with the -TCPRoute, and the status of the route with respect to each of these -Gateways. When a Gateway selects this route, the controller that -manages the Gateway should add an entry to this list when the -controller first sees the route and should update the entry as -appropriate when the route is modified.

+

+(Members of RouteStatus are embedded into this type.) +

@@ -3555,14 +3587,17 @@ UDPRouteAction -gatewayRefs
+RouteStatus
- -[]GatewayObjectReference + +RouteStatus +

+(Members of RouteStatus are embedded into this type.) +

diff --git a/docs/spec/index.html b/docs/spec/index.html index 0d5b86426e..979de43afb 100644 --- a/docs/spec/index.html +++ b/docs/spec/index.html @@ -1547,8 +1547,7 @@

GatewayObjectRefere

(Appears on: -RouteGatewayStatus, -UDPRouteStatus) +RouteGatewayStatus)

GatewayObjectReference identifies a Gateway object.

@@ -2457,20 +2456,17 @@

HTTPRouteStatus -gateways
+RouteStatus
- -[]RouteGatewayStatus + +RouteStatus -

Gateways is a list of the Gateways that are associated with the -HTTPRoute, and the status of the route with respect to each of these -Gateways. When a Gateway selects this route, the controller that -manages the Gateway should add an entry to this list when the -controller first sees the route and should update the entry as -appropriate when the route is modified.

+

+(Members of RouteStatus are embedded into this type.) +

@@ -3079,8 +3075,7 @@

RouteGatewayStatus

(Appears on: -HTTPRouteStatus, -TCPRouteStatus) +RouteStatus)

RouteGatewayStatus describes the status of a route with respect to an @@ -3188,6 +3183,46 @@

RouteNamespaces +

RouteStatus +

+

+(Appears on: +HTTPRouteStatus, +TCPRouteStatus, +UDPRouteStatus) +

+

+

RouteStatus defines the observed state that is required across +all route types.

+

+ + + + + + + + + + + + + +
FieldDescription
+gateways
+ + +[]RouteGatewayStatus + + +
+

Gateways is a list of the Gateways that are associated with the +route, and the status of the route with respect to each of these +Gateways. When a Gateway selects this route, the controller that +manages the Gateway should add an entry to this list when the +controller first sees the route and should update the entry as +appropriate when the route is modified.

+

SecretsDefaultLocalObjectReference

@@ -3547,20 +3582,17 @@

TCPRouteStatus -gateways
+RouteStatus
- -[]RouteGatewayStatus + +RouteStatus -

Gateways is a list of the Gateways that are associated with the -TCPRoute, and the status of the route with respect to each of these -Gateways. When a Gateway selects this route, the controller that -manages the Gateway should add an entry to this list when the -controller first sees the route and should update the entry as -appropriate when the route is modified.

+

+(Members of RouteStatus are embedded into this type.) +

@@ -3880,14 +3912,17 @@

UDPRouteStatus -gatewayRefs
+RouteStatus
- -[]GatewayObjectReference + +RouteStatus +

+(Members of RouteStatus are embedded into this type.) +