@@ -50,7 +50,7 @@ Items marked with (R) are required *prior to targeting to a milestone / release*
50
50
51
51
## Summary
52
52
53
- Today the `` ports `` field in ingress and egress network policies is an array
53
+ Today the ` ports ` field in ingress and egress network policies is an array
54
54
that needs a declaration of each single port to be contemplated. This KEP
55
55
proposes to add a new field that allows a declaration of a port range,
56
56
simplifying the creation of rules with multiple ports.
@@ -87,25 +87,25 @@ spec:
87
87
88
88
So for the user:
89
89
* To allow a range of ports, each of them must be declared as an item from
90
- `` ports ` ` array
90
+ ` ports ` array
91
91
* To make an exception needs a declaration of all ports but the exception
92
92
93
- Adding a new `` endPort `` field inside the `` ports ` ` will allow a simpler
93
+ Adding a new ` endPort ` field inside the ` ports ` will allow a simpler
94
94
creation of NetworkPolicy to the user.
95
95
96
96
### Goals
97
97
98
- Add an endPort field in `` NetworkPolicyPort ` `
98
+ Add an endPort field in ` NetworkPolicyPort `
99
99
100
100
### Non-Goals
101
101
102
- * Support specific `` Exception ` ` field.
103
- * Support `` endPort `` when the starting `` port ` ` is a named port.
102
+ * Support specific ` Exception ` field.
103
+ * Support ` endPort ` when the starting ` port ` is a named port.
104
104
105
105
## Proposal
106
106
107
- In NetworkPolicy specification, inside `` NetworkPolicyPort ` ` specify a new
108
- `` endPort ` ` field composed of a numbered port that defines if this is a range
107
+ In NetworkPolicy specification, inside ` NetworkPolicyPort ` specify a new
108
+ ` endPort ` field composed of a numbered port that defines if this is a range
109
109
and when it ends.
110
110
111
111
### User Stories
@@ -150,7 +150,7 @@ of the new field.
150
150
## Design Details
151
151
152
152
API changes to NetworkPolicy:
153
- * Add a new field called `` EndPort `` inside `` NetworkPolicyPort ` ` as the following:
153
+ * Add a new field called ` EndPort ` inside ` NetworkPolicyPort ` as the following:
154
154
```
155
155
// NetworkPolicyPort describes a port to allow traffic on
156
156
type NetworkPolicyPort struct {
@@ -159,22 +159,25 @@ type NetworkPolicyPort struct {
159
159
// +optional
160
160
Protocol *v1.Protocol `json:"protocol,omitempty" protobuf:"bytes,1,opt,name=protocol,casttype=k8s.io/api/core/v1.Protocol"`
161
161
162
- // The port on the given protocol. This can either be a numerical or named port on
163
- // a pod. If this field is not provided, this matches all port names and numbers.
162
+ // The port on the given protocol. This can either be a numerical or named
163
+ // port on a pod. If this field is not provided, this matches all port names and
164
+ // numbers, whether an endPort is defined or not.
164
165
// +optional
165
166
Port *intstr.IntOrString `json:"port,omitempty" protobuf:"bytes,2,opt,name=port"`
166
167
167
- // EndPort defines the end of the port range, being the end included within the
168
- // range
168
+ // EndPort defines the last port included in the port range.
169
+ // Example:
170
+ // endPort: 12345
169
171
// +optional
170
172
EndPort int32 `json:"port,omitempty" protobuf:"bytes,2,opt,name=endPort"`
171
173
}
172
174
```
173
175
174
176
### Validations
175
- The `` NetworkPolicyPort `` will need to be validated, with the following scenarios:
176
- * If an `` EndPort `` is specified a `` Port `` must also be specified
177
- * If `` Port `` is a string `` EndPort `` cannot be specified
177
+ The ` NetworkPolicyPort ` will need to be validated, with the following scenarios:
178
+ * If an ` EndPort ` is specified a ` Port ` must also be specified
179
+ * If ` Port ` is a string (named port) ` EndPort ` cannot be specified
180
+ * ` EndPort ` must be equal or bigger than ` Port `
178
181
179
182
### Test Plan
180
183
@@ -195,23 +198,23 @@ validation should be done by CNIs.
195
198
- Add validation tests in API
196
199
197
200
#### Beta
198
- - `` EndPort ` ` has been supported for at least 1 minor release
201
+ - ` EndPort ` has been supported for at least 1 minor release
199
202
- Four commonly used NetworkPolicy (or CNI providers) implement the new field,
200
203
with generally positive feedback on its usage.
201
204
- Feature Gate is enabled by Default.
202
205
203
206
#### GA Graduation
204
207
205
- - At least ** four** NetworkPolicy providers (or CNI providers) support the `` EndPort ` ` field
206
- - `` EndPort ` ` has been enabled by default for at least 1 minor release
208
+ - At least ** four** NetworkPolicy providers (or CNI providers) support the ` EndPort ` field
209
+ - ` EndPort ` has been enabled by default for at least 1 minor release
207
210
208
211
### Upgrade / Downgrade Strategy
209
212
210
213
If upgraded no impact should happen as this is a new field.
211
214
212
215
If downgraded the CNI wont be able to look into the new field, as this does not
213
216
exists and network policies using this field will stop working correctly and
214
- start working incorrectly.
217
+ start working incorrectly. This is a fail-closed failure, so it is acceptable.
215
218
216
219
## Production Readiness Review Questionnaire
217
220
@@ -232,7 +235,7 @@ _This section must be completed when targeting alpha to a release._
232
235
Yes, but CNIs relying on the new field wont recognize it anymore
233
236
234
237
* ** What happens if we reenable the feature if it was previously rolled back?**
235
- Nothing. Just need to check if the data is persisted in `` etcd ` ` after the
238
+ Nothing. Just need to check if the data is persisted in ` etcd ` after the
236
239
feature is disabled and reenabled or if the data is missed
237
240
238
241
* ** Are there any tests for feature enablement/disablement?**
@@ -282,7 +285,7 @@ previous answers based on experience in the field._
282
285
TBD
283
286
284
287
* ** Will enabling / using this feature result in introducing new API types?**
285
- No, unless the new `` EndPort ` ` is considered a new API type
288
+ No, unless the new ` EndPort ` is considered a new API type
286
289
287
290
* ** Will enabling / using this feature result in any new calls to the cloud
288
291
provider?**
@@ -292,7 +295,7 @@ provider?**
292
295
the existing API objects?**
293
296
294
297
- API type(s): NetworkPolicyPorts
295
- - Estimated increase in size: 2 bytes for each new `` EndPort ` ` specified
298
+ - Estimated increase in size: 2 bytes for each new ` EndPort ` specified
296
299
- Estimated amount of new objects: N/A
297
300
298
301
* ** Will enabling / using this feature result in increasing time taken by any
@@ -336,7 +339,7 @@ populate their packet filtering tables with each port.
336
339
## Alternatives
337
340
338
341
During the development of this KEP there was an alternative implementation
339
- of the `` NetworkPolicyPortRange `` field inside the `` NetworkPolicyPort ` ` as the following:
342
+ of the ` NetworkPolicyPortRange ` field inside the ` NetworkPolicyPort ` as the following:
340
343
341
344
```
342
345
// NetworkPolicyPort describes a port or a range of ports to allow traffic on
@@ -363,7 +366,7 @@ type NetworkPolicyPort struct {
363
366
But the main design suggested in this Kep seems more clear, so this alternative
364
367
has been discarded.
365
368
366
- Also it has been proposed that the implementation contains an `` Except`` ` array and a new
369
+ Also it has been proposed that the implementation contains an ` Except ` array and a new
367
370
struct to be used in Ingress/Egress rules, but because it would bring much more complexity
368
371
than desired the proposal has been dropped right now:
369
372
0 commit comments