You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: keps/sig-network/20201014-NamespaceAsName.md
+61-46
Original file line number
Diff line number
Diff line change
@@ -150,29 +150,34 @@ We thus conclude that, even though targetting an object using its name is not no
150
150
151
151
### Goals
152
152
153
-
- Add a `matchName` option (which is additive to the current `matchLabels` selector).
154
-
-Add an additional semantic mechanism to "allow all" namespaces while excluding a finite, specific, list of namespaces (concretely, this might involve blocking the `kube-system` namespace, as this is an obvious security boundary which most clusters would prefer).
153
+
- Add a `namespace` option (which is additive to the current `matchLabels` selector).
154
+
-Allow multiple `matchName` values, so that many namespaces can be allowed using the same field
155
155
156
156
### Non-Goals
157
157
158
158
- Support matching of wildcard namespaces
159
+
- Changing the internal details of how namespaceSelector works with arbitrary syntax
160
+
- Depending on more sophisticated features (like virtual labels) to accomplish this feature without changing the API (note that, if someone were
161
+
to write a virtualLabels KEP, however, it might change the trajectory of this KEP, which is worth discussing)
159
162
160
163
## Proposal
161
164
162
-
In NetworkPolicy specification, inside `namespaceSelector` specify a new `Name` field. One possible implementation of this would be:
165
+
In NetworkPolicy specification, inside `NetworkPolicyPeer` specify a new `namespaceNames` field.
163
166
164
-
```
165
-
type NamespaceSelector struct {
166
-
names []string
167
-
labels *metav1.LabelSelector
168
-
}
169
-
```
170
-
171
-
which is referenced from the namespaceSelector:
167
+
1) One simple way to implement this feature is to modify the NetworkPolicyPeer object, like so. Since this
168
+
doesn't involve modifying a go type (i.e. were not replacing a labelSelector with a different type, we expect it
As an administrator I want to block all users from accessing the kube-system namespace as a fundamental default policy, and I want to do this regardless of labels that might be added or removed from it over time.
194
+
As an administrator i want to allow access from monitoring pods in kube-system namespace, into any pod in my cluster, as a fundamental policy.
190
195
191
196
#### Story 2
192
197
@@ -196,21 +201,19 @@ As an user I want to "just add" a namespace to my allow list without having to m
196
201
197
202
### Risks and Mitigations
198
203
199
-
- CNIs may not choose, initially, to support this construct, and diligent communication with CNI providers will be needed to make sure it's widely adopted.
200
-
- CNIs may not choose, initially to support this construct, and dilligent communication with CNI providers will be needed to make sure its widely adopted.
204
+
- CNIs may **NOT** choose, initially to support this construct, and dilligent communication with CNI providers will be needed to make sure its widely adopted.
201
205
- We need to make sure that hidden defaults don't break the meaning of existing policys, for example:
202
206
- if a namespcee name is retrieved by an api client which doesn't yet support it, the client doesnt crash (and the plugin doesnt crash, either).
203
-
- if a namespace name policy doesn't exist (is null), then the policy should behave identically to any policy made before this field was added, that is, the `NetworkPolicyPeer` should be as obvious as possible to interpret in a way that is compatible with the semantics of the v1 policy API **before** this feature was added to it.
207
+
- if a namespace name policy doesn't exist (is null), then the policy should behave identically to any policy made before this field was added, that is,
208
+
- Both "allow all" and "allow none" could be incorrectly interpretted incorrectly, so we need to make sure that plugins not implementing the feature don't get misled by the new data structure.
209
+
210
+
the `NetworkPolicyPeer` should be as obvious as possible to interpret in a way that is compatible with the semantics of the v1 policy API **before** this feature was added to it.
204
211
205
212
## Design Details
206
213
207
214
- Add a new selector to the network policy peer data structure which can switch between allowing a "matchName" or "matchLabels" implementation, supporting a policy that is expressed like this:
208
215
209
-
This selector has two, EXCLUSIVE, possible input types:
210
-
211
-
- A list of conventional namespaces OR
212
-
- A `*` with an `exclude` rule as in input to this selector
213
-
216
+
- A list of conventional namespaces
214
217
The "conventional namespaces" will look like so:
215
218
```
216
219
kind: NetworkPolicy
@@ -223,45 +226,36 @@ spec:
223
226
app: mysql
224
227
ingress:
225
228
- from:
226
-
- namespaceSelector:
227
-
matchName:
228
-
- my-frontend
229
-
```
230
-
231
-
Meanwhile, the "exclude" implementation, will look like this:
232
-
233
-
```
234
-
ingress:
235
-
- from:
236
-
- namespaceSelector:
237
-
matchName:
238
-
- *
239
-
exclude:
240
-
- kube-system
229
+
matchName:
230
+
- my-frontend
241
231
```
242
232
243
-
244
233
### Test Plan
245
234
246
-
We will add tests for this new api semantic into the exting test/e2e/ network policy test suites in upstream which cover both of these scenarios, using the validation framework outlined in https://github.com/kubernetes/enhancements/blob/master/keps/sig-network/20200204-NetworkPolicy-verification-rearchitecture.md#motivation
235
+
We will add tests for this new api semantic into the exting test/e2e/ network policy test suites in upstream which cover both of these scenarios, using the validation framework outlined in https://github.com/kubernetes/enhancements/blob/master/keps/sig-network/20200204-NetworkPolicy-verification-rearchitecture.md#motivation.
247
236
248
237
### Graduation Criteria
249
238
250
-
Note that we may not have explicity feature gates for this KEP, because NetworkPolicies typically haven't been implemented with gates. We keep this section for the time being in any case as it organizes our thinking around the general progression of the feature over time.
239
+
All new field introductions need gates for at least one release, thus, we would add this feature gate in alpha, so we must use
240
+
feature gates idiomatically to implement this change.
241
+
242
+
Gone are the days of changing the API with reckless abandon.
251
243
252
244
#### Alpha
253
-
- Communicate CNI providers about the new field
245
+
- Communicate CNI providers about the new field.
254
246
- Add validation tests in API which confirm several positive / negative scenarios in the test matrix for when this field is present/absent
247
+
- All new field introductions need gates for at least one release, thus, we would add this feature gate in alpha.
248
+
255
249
256
250
#### Beta
257
-
- The name selector has been supported for at least 1 minor release
258
-
- Four commonly used CNI providers implement the new field, with generally positive feedback on its usage.
259
-
- Feature Gate is enabled by Default
251
+
- The name selector has been supported for at least 1 minor release.
252
+
- Four commonly used NetworkPolicy (or CNI providers) implement the new field, with generally positive feedback on its usage.
253
+
- Feature Gate is enabled by Default.
260
254
261
255
#### GA Graduation
262
256
263
-
- At least two CNIs support the The name selector field
264
-
- The name selector has been enabled by default for at least 1 minor release
257
+
- At least **four** NetworkPolicy providers (or CNI providers) support the The name selector field.
258
+
- The name selector has been enabled by default for at least 1 minor release.
265
259
266
260
### Upgrade / Downgrade Strategy
267
261
@@ -342,6 +336,27 @@ We dont want to have > 1 way to select namespaces.
342
336
343
337
A network policy operator could be created which translated a CRD into many networkpolicys on the fly, by watching namespaces and updating labels dynamically. This would be a privileged container in a cluster and likely would not gain much adoption.
344
338
339
+
### Alternative API implementation change
340
+
341
+
Another (possibly more disruptive ) possible implementation of this would be. We include this for completeness, but
342
+
are proposing the 1st, simpler option for this KEP. This is interesting because it "folds" into the existing API, thus
343
+
paving the way for symmetrical implementation for podSelectors, and so on. However, its increased complexity due to the
344
+
fact that it breaks the existing type system by changing the `labels` implementation, makes it less attractive.
0 commit comments