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
@@ -105,67 +43,102 @@ Items marked with (R) are required *prior to targeting to a milestone / release*
105
43
106
44
## Summary
107
45
108
-
The ability to target namespaces using names, when building NetworkPolicy objects, has been a request from the broader k8s community for quite some time. In the sig-network-networkpolicy API group, it was one of the most popular policies which was voted on.
46
+
The ability to target namespaces using names, when building NetworkPolicy
47
+
objects, has been a request from the broader k8s community for quite some
48
+
time. In the sig-network networkpolicy API sub project, it was one of the
49
+
most popular policies which was voted on.
109
50
110
51
## Motivation
111
52
112
-
NetworkPolicies are under utilized by developers when defining applications, and the most obvious tenancy boundary for a developer is that of **the Namespace**. We thus aim to make this boundary **extremely** obvious and easy for users to target in a maximally secure manner.
53
+
NetworkPolicies are under utilized by developers when defining applications,
54
+
and the most obvious tenancy boundary for a developer is that of **the Namespace**.
55
+
We thus aim to make this boundary **extremely** obvious and easy for users
56
+
to target in a maximally secure manner.
113
57
114
-
NetworkPolicies are also used by administrators to make specific default policies (for example, the common `kube-system` namespaces might be one which an administrator wants to protect from unwanted traffic).
58
+
NetworkPolicies are also used by administrators to make specific default
59
+
policies (for example, the common `kube-system` namespaces might be one which
60
+
an administrator wants to protect from unwanted traffic).
115
61
116
-
Although service-mesh and other technologies have been slated to obviate the need for developer driven security boundaries, these technologies aren't available in most clusters, and aren't supported by the Kubernetes API.
62
+
Although service-mesh and other technologies have been slated to obviate the
63
+
need for developer driven security boundaries, these technologies aren't
64
+
available in most clusters, and aren't supported by the Kubernetes API.
117
65
118
-
The ability to provide granular and intuitive network boundaries between apps is part of the braoder vision to make the NetworkPolicy API a universal security construct implemented in all production applications. Many conversations have come up around this topic, with https://github.com/kubernetes/kubernetes/issues/88253 being one of the most recent ones.
66
+
The ability to provide granular and intuitive network boundaries between apps
67
+
is part of the braoder vision to make the NetworkPolicy API a universal
68
+
security construct implemented in all production applications. Many
69
+
conversations have come up around this topic, with [kubernetes #88253](https://github.com/kubernetes/kubernetes/issues/88253)
70
+
being one of the most recent ones.
119
71
120
72
### Generic motivation
121
73
122
-
- Embrace the immutable nature of a namespace name as a fundamental security construct in the Kubernetes ecosystem.
123
-
- Making network policies more secure by making it impossible to "impersonate" a bespoke namespace.
124
-
- Making network policy tenancy boundaries more declarative to use by *not* requiring developers to copy/duplicate namespace labels
74
+
- Embrace the immutable nature of a namespace name as a fundamental security
75
+
construct in the Kubernetes ecosystem.
76
+
- Making network policies more secure by making it impossible to "impersonate"
77
+
a bespoke namespace.
78
+
- Making network policy tenancy boundaries more declarative to use by *not*
79
+
requiring developers to copy/duplicate namespace labels
125
80
126
-
These two motivating factors are mostly self explanatory, but in the next section we outline concrete feedback in these areas.
81
+
These three motivating factors are mostly self explanatory, but in the next
82
+
section we outline concrete feedback in these areas.
127
83
128
84
### Community feedback on the namespace.Name selector
129
85
130
-
- In 2016, the argument for namespace as name selectors was first made... https://groups.google.com/g/kubernetes-sig-network/c/GzSGt-pxBYQ/m/Rbrxve-gGgAJ, based on the fact that labels can be retroactively added to namespaces pretty easily, even if your namespace isn't intended to be able to send traffic somewhere:
86
+
- In 2016, the argument for namespace as name selectors was first made in
87
+
the [mailing list](https://groups.google.com/g/kubernetes-sig-network/c/GzSGt-pxBYQ/m/Rbrxve-gGgAJ), based on the fact that labels can be
88
+
retroactively added to namespaces pretty easily, even if your namespace isn't
89
+
intended to be able to send traffic somewhere:
131
90
132
91
```
133
-
we need to clarify how namespaces are matched. I'm pretty
92
+
we need to clarify how namespaces are matched. I'm pretty
134
93
uncomfortable with using labels here, since anyone can add labels at
135
94
any time to any namespace and thus send traffic to your pod if they
136
95
know the label you're using. If it were simply a namespace name, it's
137
96
much easier to specifically allow only namespaces you control since you
138
97
know your own namespace names.
139
98
```
140
99
141
-
- Another recent argument was made on the basis of targetting namespaces using names, rather then labels, on the basis of **sheer convenience**.
100
+
- Another recent argument was made on the basis of targetting namespaces
101
+
using names, rather then labels, on the basis of **sheer convenience**.
142
102
143
103
```
144
-
While matching things like pods etc by label is certainly worthwhile, when matching a namespace I suspect the majority of the time you only want to match a single namespace. It been great match against the name rather than just a label. I suspect most people don't think to add labels to the namespaces.
104
+
While matching things like pods etc by label is certainly worthwhile, when
105
+
matching a namespace I suspect the majority of the time you only want to match
106
+
a single namespace. It been great match against the name rather than just a
107
+
label. I suspect most people don't think to add labels to the namespaces.
145
108
```
146
109
147
-
The latter comment received 9 likes as a github issue - indiciating the general popularity of this as a request, and that correlates well to feedback we've seen in the broader community as well.
110
+
The latter comment received 9 likes as a github issue - indiciating the
111
+
general popularity of this as a request, and that correlates well to feedback
112
+
we've seen in the broader community as well.
148
113
149
-
We thus conclude that, even though targetting an object using its name is not normal in K8s, in the case of NetworkPolicies, the overwhelming need for universal, easy to define security boundaries, makes a strong case for amending the API to support a "special" selector for namespace names that is **independent** of labels.
114
+
We thus conclude that, even though targetting an object using its name is not
115
+
normal in K8s, in the case of NetworkPolicies, the overwhelming need for
116
+
universal, easy to define security boundaries, makes a strong case for
117
+
amending the API to support a "special" selector for namespace names that is
118
+
**independent** of labels.
150
119
151
120
### Goals
152
121
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
122
+
- Add a `namespaceNames` option (which is additive to the current `matchLabels` selector).
123
+
- Allow multiple `namespaceNames` values, so that many namespaces can be
124
+
allowed using the same field
155
125
156
126
### Non-Goals
157
127
158
128
- Support matching of wildcard namespaces
159
129
- 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)
130
+
- Depending on more sophisticated features (like virtual labels) to accomplish
131
+
this feature without changing the API (note that, if someone were
132
+
to write a virtualLabels KEP, however, it might change the trajectory of this
133
+
KEP, which is worth discussing)
162
134
163
135
## Proposal
164
136
165
137
In NetworkPolicy specification, inside `NetworkPolicyPeer` specify a new `namespaceNames` field.
166
138
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
139
+
1) One simple way to implement this feature is to modify the NetworkPolicyPeer
140
+
object, like so. Since this doesn't involve modifying a go type (i.e. were
141
+
not replacing a labelSelector with a different type, we expect it
169
142
to be a cleaner implementation:
170
143
171
144
```
@@ -182,36 +155,40 @@ type NetworkPolicyPeer struct {
182
155
183
156
### User Stories (Optional)
184
157
185
-
<!--
186
-
Detail the things that people will be able to do if this KEP is implemented.
187
-
Include as much detail as possible so that people can understand the "how" of
188
-
the system. The goal here is to make this feel real for users without getting
189
-
bogged down.
190
-
-->
191
-
192
158
#### Story 1
193
159
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.
160
+
As an administrator i want to allow access from monitoring pods in kube-system
161
+
namespace, into any pod in my cluster, as a fundamental policy.
195
162
196
163
#### Story 2
197
164
198
-
As an user I want to "just add" a namespace to my allow list without having to manage the labels which might get added/removed over time from said namespace.
165
+
As an user I want to "just add" a namespace to my allow list without having to
166
+
manage the labels which might get added/removed over time from said namespace.
199
167
200
168
### Notes/Constraints/Caveats (Optional)
201
169
202
170
### Risks and Mitigations
203
171
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.
205
-
- We need to make sure that hidden defaults don't break the meaning of existing policys, for example:
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).
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.
172
+
- CNIs may **NOT** choose, initially to support this construct, and dilligent
173
+
communication with CNI providers will be needed to make sure its widely
174
+
adopted.
175
+
- We need to make sure that hidden defaults don't break the meaning of
176
+
existing policys, for example:
177
+
- if a namespaece name is retrieved by an api client which doesn't yet
178
+
support it, the client doesnt crash (and the plugin doesnt crash, either).
179
+
- if a namespace name policy doesn't exist (is null), then the policy should
180
+
behave identically to any policy made before this field was added, that is,
181
+
- Both "allow all" and "allow none" could be incorrectly interpreted
182
+
incorrectly, so we need to make sure that plugins not implementing the feature
183
+
don't get misled by the new data structure.
184
+
185
+
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.
211
186
212
187
## Design Details
213
188
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:
189
+
- Add a new selector to the network policy peer data structure which can
190
+
switch between allowing a "namespaceNames" or "matchLabels" implementation,
191
+
supporting a policy that is expressed like this:
215
192
216
193
- A list of conventional namespaces
217
194
The "conventional namespaces" will look like so:
@@ -226,42 +203,53 @@ spec:
226
203
app: mysql
227
204
ingress:
228
205
- from:
229
-
matchName:
206
+
namespaceNames:
230
207
- my-frontend
231
208
```
232
209
233
210
### Test Plan
234
211
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.
212
+
We will add tests for this new api semantic into the exting test/e2e/ network
213
+
policy test suites in upstream which cover both of these scenarios, using the
214
+
validation framework outlined in https://github.com/kubernetes/enhancements/blob/master/keps/sig-network/20200204-NetworkPolicy-verification-rearchitecture.md#motivation.
236
215
237
216
### Graduation Criteria
238
217
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.
218
+
All new field introductions need gates for at least one release, thus, we
219
+
would add this feature gate in alpha, so we must use feature gates
220
+
idiomatically to implement this change.
241
221
242
222
Gone are the days of changing the API with reckless abandon.
243
223
244
224
#### Alpha
245
225
- Communicate CNI providers about the new field.
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.
226
+
- Add validation tests in API which confirm several positive / negative
227
+
scenarios in the test matrix for when this field is present/absent
228
+
- All new field introductions need gates for at least one release, thus, we
229
+
would add this feature gate in alpha.
248
230
249
231
250
232
#### Beta
251
233
- 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.
234
+
- Four commonly used NetworkPolicy (or CNI providers) implement the new field,
235
+
with generally positive feedback on its usage.
253
236
- Feature Gate is enabled by Default.
254
237
255
238
#### GA Graduation
256
239
257
-
- At least **four** NetworkPolicy providers (or CNI providers) support the The name selector field.
240
+
- At least **four** NetworkPolicy providers (or CNI providers) support the The
241
+
name selector field.
258
242
- The name selector has been enabled by default for at least 1 minor release.
259
243
260
244
### Upgrade / Downgrade Strategy
261
245
262
-
If upgraded no impact should happen as this is a new matching option and not colliding with old ones. There will potentially be some golang magic required to convert objects at the type level to be flexible enough to support different inputs, but this will use the K8s API Translation layer.
246
+
If upgraded no impact should happen as this is a new matching option and not
247
+
colliding with old ones. There will potentially be some golang magic required
248
+
to convert objects at the type level to be flexible enough to support
249
+
different inputs, but this will use the K8s API Translation layer.
263
250
264
-
If downgraded the CNI wont be able to look into the new field, as this does not exists and network policies using this field will stop working.
251
+
If downgraded the CNI wont be able to look into the new field, as this does
252
+
not exists and network policies using this field will stop working.
265
253
266
254
### Version Skew Strategy
267
255
@@ -285,7 +273,8 @@ _This section must be completed when targeting alpha to a release._
285
273
Yes, but CNIs relying on the new field wont recognize it anymore
286
274
287
275
***What happens if we reenable the feature if it was previously rolled back?**
288
-
Nothing. Just need to check if the data is persisted in ``etcd`` after the feature is disabled and reenabled or if the data is missed
276
+
Nothing. Just need to check if the data is persisted in ``etcd`` after the
277
+
feature is disabled and reenabled or if the data is missed
289
278
290
279
***Are there any tests for feature enablement/disablement?**
291
280
@@ -311,18 +300,7 @@ the health of the service?**
311
300
_This section must be completed when targeting beta graduation to a release._
312
301
313
302
***Does this feature depend on any specific services running in the cluster?**
314
-
Think about both cluster-level services (e.g. metrics-server) as well
315
-
as node-level agents (e.g. specific version of CRI). Focus on external or
316
-
optional services that are needed. For example, if this feature depends on
317
-
a cloud provider API, or upon an external software-defined storage or network
318
-
control plane.
319
-
320
-
For each of these, fill in the following—thinking about running existing user workloads
321
-
and creating new ones, as well as about cluster-level services (e.g. DNS):
322
-
-[Dependency name]
323
-
- Usage description:
324
-
- Impact of its outage on the feature:
325
-
- Impact of its degraded performance or high-error rates on the feature:
0 commit comments