Skip to content

Commit 5836f6f

Browse files
authored
ListenerSet adjust PortNumber kubebuilder validations (#3750)
* use a custom min/max marker controller-tools only allows this to work on object types and not ref types * update GEP with optional port * adjust markers * make generate
1 parent c011e67 commit 5836f6f

File tree

13 files changed

+121
-18
lines changed

13 files changed

+121
-18
lines changed

apis/v1/gateway_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,10 @@ type Listener struct {
396396
// same port, subject to the Listener compatibility rules.
397397
//
398398
// Support: Core
399+
//
400+
// +kubebuilder:validation:Minimum=1
401+
// +kubebuilder:validation:Maximum=65535
402+
//
399403
// +required
400404
Port PortNumber `json:"port"`
401405

apis/v1/httproute_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,9 @@ type HTTPRequestRedirectFilter struct {
12191219
// Support: Extended
12201220
//
12211221
// +optional
1222+
//
1223+
// +kubebuilder:validation:Minimum=1
1224+
// +kubebuilder:validation:Maximum=65535
12221225
Port *PortNumber `json:"port,omitempty"`
12231226

12241227
// StatusCode is the HTTP status code to be used in response.

apis/v1/object_reference_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ type BackendObjectReference struct {
148148
// resource or this field.
149149
//
150150
// +optional
151+
// +kubebuilder:validation:Minimum=1
152+
// +kubebuilder:validation:Maximum=65535
151153
Port *PortNumber `json:"port,omitempty"`
152154
}
153155

apis/v1/shared_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ type ParentReference struct {
149149
// Support: Extended
150150
//
151151
// +optional
152+
//
153+
// +kubebuilder:validation:Minimum=1
154+
// +kubebuilder:validation:Maximum=65535
152155
Port *PortNumber `json:"port,omitempty"`
153156
}
154157

@@ -228,9 +231,6 @@ type CommonRouteSpec struct {
228231
}
229232

230233
// PortNumber defines a network port.
231-
//
232-
// +kubebuilder:validation:Minimum=1
233-
// +kubebuilder:validation:Maximum=65535
234234
type PortNumber int32
235235

236236
// BackendRef defines how a Route should forward a request to a Kubernetes

apis/v1alpha2/shared_types.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ type ParentReference = v1.ParentReference
4040
type CommonRouteSpec = v1.CommonRouteSpec
4141

4242
// PortNumber defines a network port.
43-
//
44-
// +kubebuilder:validation:Minimum=1
45-
// +kubebuilder:validation:Maximum=65535
4643
type PortNumber = v1.PortNumber
4744

4845
// BackendRef defines how a Route should forward a request to a Kubernetes

apis/v1beta1/shared_types.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ type ParentReference = v1.ParentReference
4040
type CommonRouteSpec = v1.CommonRouteSpec
4141

4242
// PortNumber defines a network port.
43-
//
44-
// +kubebuilder:validation:Minimum=1
45-
// +kubebuilder:validation:Maximum=65535
4643
type PortNumber = v1.PortNumber
4744

4845
// BackendRef defines how a Route should forward a request to a Kubernetes

apisx/v1alpha1/xlistenerset_types.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,18 @@ type ListenerEntry struct {
158158

159159
// Port is the network port. Multiple listeners may use the
160160
// same port, subject to the Listener compatibility rules.
161-
// +required
162-
Port PortNumber `json:"port"`
161+
//
162+
// If the port is not set or specified as zero, the implementation will assign
163+
// a unique port. If the implementation does not support dynamic port
164+
// assignment, it MUST set `Accepted` condition to `False` with the
165+
// `UnsupportedPort` reason.
166+
//
167+
// +optional
168+
//
169+
// +kubebuilder:default=0
170+
// +kubebuilder:validation:Minimum=0
171+
// +kubebuilder:validation:Maximum=65535
172+
Port PortNumber `json:"port,omitempty"`
163173

164174
// Protocol specifies the network protocol this listener expects to receive.
165175
// +required
@@ -242,6 +252,10 @@ type ListenerEntryStatus struct {
242252
Name SectionName `json:"name"`
243253

244254
// Port is the network port the listener is configured to listen on.
255+
//
256+
// +kubebuilder:validation:Minimum=1
257+
// +kubebuilder:validation:Maximum=65535
258+
//
245259
// +required
246260
Port PortNumber `json:"port"`
247261

applyconfiguration/internal/internal.go

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

config/crd/experimental/gateway.networking.x-k8s.io_xlistenersets.yaml

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

geps/gep-1713/index.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,19 @@ type ListenerEntry struct {
163163

164164
// Port is the network port. Multiple listeners may use the
165165
// same port, subject to the Listener compatibility rules.
166-
//
166+
//
167+
// If the port is not set or specified as zero, the implementation will assign
168+
// a unique port. If the implementation does not support dynamic port
169+
// assignment, it MUST set `Accepted` condition to `False` with the
170+
// `UnsupportedPort` reason.
171+
//
167172
// Support: Core
173+
//
174+
// +optional
175+
//
176+
// +kubebuilder:default=0
177+
// +kubebuilder:validation:Minimum=0
178+
// +kubebuilder:validation:Maximum=65535
168179
Port PortNumber `json:"port,omitempty"`
169180

170181
// Protocol specifies the network protocol this listener expects to receive.
@@ -380,6 +391,10 @@ spec:
380391
381392
`ListenerEntry` is currently a copy of the `Listener` struct with some changes noted in the below sections
382393

394+
#### Port
395+
396+
`Port` is now optional to allow for dynamic port assignment. If the port is unspecified or set to zero, the implementation will assign a unique port. If the implementation does not support dynamic port assignment, it MUST set `Accepted` condition to `False` with the `UnsupportedPort` reason.
397+
383398
## Semantics
384399

385400
### Gateway Changes

0 commit comments

Comments
 (0)