Skip to content

Commit a009ed3

Browse files
authored
Merge pull request kubernetes#4728 from everpeace/kep-3619-SupplemnetalGroupsPolicy-runtimehandler-api-change
KEP-3619: Add `SupplementalGroupsPolicy` feature fields in Kubernetes API(`Node.Status`) and CRI(`RuntimeStatusResponse`)
2 parents 6f64800 + eb4932e commit a009ed3

File tree

1 file changed

+141
-0
lines changed
  • keps/sig-node/3619-supplemental-groups-policy

1 file changed

+141
-0
lines changed

keps/sig-node/3619-supplemental-groups-policy/README.md

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ tags, and then generate with `hack/update-toc.sh`.
1818
- [Kubernetes API](#kubernetes-api)
1919
- [SupplementalGroupsPolicy in PodSecurityContext](#supplementalgroupspolicy-in-podsecuritycontext)
2020
- [User in ContainerStatus](#user-in-containerstatus)
21+
- [NodeFeatures in NodeStatus which contains SupplementalGroupsPolicy field](#nodefeatures-in-nodestatus-which-contains-supplementalgroupspolicy-field)
2122
- [CRI](#cri)
2223
- [SupplementalGroupsPolicy in SecurityContext](#supplementalgroupspolicy-in-securitycontext)
2324
- [user in ContainerStatus](#user-in-containerstatus-1)
25+
- [features in StatusResponse which contains supplemental_groups_policy field](#features-in-statusresponse-which-contains-supplemental_groups_policy-field)
2426
- [User Stories (Optional)](#user-stories-optional)
2527
- [Story 1: Deploy a Security Policy to enforce <code>SupplementalGroupsPolicy</code> field](#story-1-deploy-a-security-policy-to-enforce-supplementalgroupspolicy-field)
2628
- [Notes/Constraints/Caveats (Optional)](#notesconstraintscaveats-optional)
@@ -29,9 +31,11 @@ tags, and then generate with `hack/update-toc.sh`.
2931
- [Kubernetes API](#kubernetes-api-1)
3032
- [SupplementalGroupsPolicy in PodSecurityContext](#supplementalgroupspolicy-in-podsecuritycontext-1)
3133
- [User in ContainerStatus](#user-in-containerstatus-2)
34+
- [NodeFeatures in NodeStatus which contains SupplementalGroupsPolicy field](#nodefeatures-in-nodestatus-which-contains-supplementalgroupspolicy-field-1)
3235
- [CRI](#cri-1)
3336
- [SupplementalGroupsPolicy in SecurityContext](#supplementalgroupspolicy-in-securitycontext-1)
3437
- [user in ContainerStatus](#user-in-containerstatus-3)
38+
- [features in StatusResponse which contains supplemental_groups_policy field](#features-in-statusresponse-which-contains-supplemental_groups_policy-field-1)
3539
- [Test Plan](#test-plan)
3640
- [Prerequisite testing updates](#prerequisite-testing-updates)
3741
- [Unit tests](#unit-tests)
@@ -201,6 +205,30 @@ Note that both policies diverge from the semantics of [`config.User` OCI image c
201205

202206
To provide users/administrators to know which identities are actually attached to the container process, it proposes to introduce new `User` field in `ContainerStatus`. `User` is an object which consists of `Uid`, `Gid`, `SupplementalGroups` fields for linux containers. This will help users to identify unexpected identities. This field is derived by CRI response (See [user in ContainerStatus](#user-in-containerstatus-1) section).
203207

208+
#### NodeFeatures in NodeStatus which contains SupplementalGroupsPolicy field
209+
210+
Because the actual control(calculation) of supplementary groups to be attached to the first container process will happen inside of CRI implementations (container runtimes), it proposes to add `NodeFeatures` field in `NodeStatus` which contains the `SupplementalGroupsPolicy` feature field inside of it like below so that kubernetes can correctly understand whether underlying CRI implementation implements the feature or not. The field is populated by CRI response.
211+
212+
```golang
213+
type NodeStatus struct {
214+
// Features describes the set of features implemented by the CRI implementation.
215+
Features *NodeFeatures
216+
}
217+
type NodeFeatures struct {
218+
// SupplementalGroupsPolicy is set to true if the runtime supports SupplementalGroupsPolicy and ContainerUser.
219+
SupplementalGroupsPolicy *bool
220+
}
221+
```
222+
223+
Recently [KEP-3857: Recursive Read-only (RRO) mounts](https://kep.k8s.io/3857) introduced `RuntimeHandlers[].Features`. But it is not fit to use for this KEP because RRO mounts requires inspecting [the OCI runtime spec's Feature](https://github.com/opencontainers/runtime-spec/blob/main/features.md) to understand whether the low-level OCI runtime supports RRO or not. However, for this KEP(SupplementalGroupsPolicy), it does not need to inspect [the OCI runtime spec's Feature](https://github.com/opencontainers/runtime-spec/blob/main/features.md) because this KEP only affects [`Process.User.additionalGid`](https://github.com/opencontainers/runtime-spec/blob/main/config.md#user) and does not depend on [the OCI runtime spec's Feature](https://github.com/opencontainers/runtime-spec/blob/main/features.md). So, introducing new `NodeFeatures` in `NodeStatus` does not conflict with `RuntimeHandlerFeatures` as we can clearly define how to use them as below:
224+
225+
- `NodeFeatures`(added in this KEP):
226+
- focusses on features that depend only on cri implementation, be independent of runtime handlers(low-level container runtimes), (i.e. it should not require to inspect to any information from oci runtime-spec's features).
227+
- `RuntimeHandlerFeature` (introduced in KEP-3857):
228+
- focuses features that depend on the runtime handlers, (i.e. dependent to the information exposed by oci runtime-spec's features).
229+
230+
See [this section](#runtimefeatures-in-nodestatus-which-contains-supplementalgroupspolicy-field-1) for details.
231+
204232
### CRI
205233

206234
#### SupplementalGroupsPolicy in SecurityContext
@@ -232,6 +260,30 @@ message ContainerUser {
232260
}
233261
```
234262

263+
#### features in StatusResponse which contains supplemental_groups_policy field
264+
265+
To propagate whether the runtime supports fine-grained supplemental group control to `NodeFeatures.SupplementalGroupsPolicy`, it proposes to add a corresponding field `features` in `StatusResponse`.
266+
267+
```proto
268+
// service RuntimeService {
269+
// ...
270+
// rpc Status(StatusRequest) returns (StatusResponse) {}
271+
// }
272+
message StatusResponse {
273+
...
274+
// features describes the set of features implemented by the CRI implementation.
275+
// This field is supposed to propagate to NodeFeatures in Kubernetes API.
276+
RuntimeFeatures features = ?;
277+
}
278+
message RuntimeFeatures {
279+
// supplemental_groups_policy is set to true if the runtime supports SupplementalGroupsPolicy and ContainerUser.
280+
bool supplemental_groups_policy = 1;
281+
}
282+
```
283+
284+
As discussed in [Kubernetes API section](#runtimefeatures-in-nodestatus-which-contains-supplementalgroupspolicy-field), `RuntimeHandlerFeature` introduced in [KEP-3857](https://kep.k8s.io/3857) should focus on features only for ones which requires to inspect [OCI runtime spec's Feature](https://github.com/opencontainers/runtime-spec/blob/main/features.md). But `RuntimeFeatuers` proposed in this KEP should focus on ones which does NOT require to inepect it.
285+
286+
235287
### User Stories (Optional)
236288

237289
#### Story 1: Deploy a Security Policy to enforce `SupplementalGroupsPolicy` field
@@ -356,6 +408,53 @@ type LinuxContainerUser struct {
356408
// }
357409
```
358410

411+
#### NodeFeatures in NodeStatus which contains SupplementalGroupsPolicy field
412+
413+
```golang
414+
type NodeStatus struct {
415+
// Features describes the set of implemented features implemented by the CRI implementation.
416+
// +featureGate=SupplementalGroupsPolicy
417+
// +optional
418+
Features *NodeFeatures
419+
420+
// The available runtime handlers.
421+
// +featureGate=RecursiveReadOnlyMounts
422+
// +optional
423+
RuntimeHandlers []RuntimeHandlers
424+
}
425+
426+
// NodeFeatures describes the set of implemented features implemented by the CRI implementation.
427+
// THE FEATURES CONTAINED IN THE NodeFeatures SHOULD DEPEND ON ONLY CRI IMPLEMENTATION, BE INDEPENDENT ON RUNTIME HANDLERS,
428+
// (I.E. IT SHOULD NOT REQUIRE TO INSPECT TO ANY INFORMATION FROM OCI RUNTIME-SPEC'S FEATURES).
429+
type NodeFeatures {
430+
// SupplementalGroupsPolicy is set to true if the runtime supports SupplementalGroupsPolicy and ContainerUser.
431+
// +optional
432+
SupplementalGroupsPolicy *bool
433+
}
434+
435+
// NodeRuntimeHandler is a set of runtime handler information.
436+
type NodeRuntimeHandler struct {
437+
// Runtime handler name.
438+
// Empty for the default runtime handler.
439+
// +optional
440+
Name string
441+
// Supported features in the runtime handlers.
442+
// +optional
443+
Features *NodeRuntimeHandlerFeatures
444+
}
445+
446+
// NodeRuntimeHandlerFeatures is a set of features implementedy by the runtime handler.
447+
// THE FEATURES CONTAINED IN THE NodeRuntimeHandlerFeatures SHOULD DEPEND ON THE RUNTIME HANDLERS,
448+
// (I.E. DEPENDENT TO THE INFORMATION EXPOSED BY OCI RUNTIME-SPEC'S FEATURES).
449+
type NodeRuntimeHandlerFeatures struct {
450+
// RecursiveReadOnlyMounts is set to true if the runtime handler supports RecursiveReadOnlyMounts.
451+
// +featureGate=RecursiveReadOnlyMounts
452+
// +optional
453+
RecursiveReadOnlyMounts *bool
454+
// Reserved: UserNamespaces *bool
455+
}
456+
```
457+
359458
### CRI
360459

361460
#### SupplementalGroupsPolicy in SecurityContext
@@ -414,6 +513,48 @@ message LinuxContainerUser {
414513
// }
415514
```
416515

516+
#### features in StatusResponse which contains supplemental_groups_policy field
517+
518+
```proto
519+
// service RuntimeService {
520+
// ...
521+
// rpc Status(StatusRequest) returns (StatusResponse) {}
522+
// }
523+
message StatusResponse {
524+
...
525+
// Runtime handlers.
526+
repeated RuntimeHandler runtime_handlers = 3;
527+
528+
// features describes the set of features implemented by the CRI implementation.
529+
// This field is supposed to propagate to NodeFeatures in Kubernetes API.
530+
RuntimeFeatures features = ?;
531+
}
532+
533+
// RuntimeFeatures describes the set of features implemented by the CRI implementation.
534+
// THE FEATURES CONTAINED IN THE RuntimeFeatures SHOULD DEPEND ON ONLY CRI IMPLEMENTATION, BE INDEPENDENT ON RUNTIME HANDLERS,
535+
// (I.E. IT SHOULD NOT REQUIRE TO INSPECT TO ANY INFORMATION FROM OCI RUNTIME-SPEC'S FEATURES).
536+
message RuntimeFeatures {
537+
// supplemental_groups_policy is set to true if the runtime supports SupplementalGroupsPolicy and ContainerUser.
538+
bool supplemental_groups_policy = 1;
539+
}
540+
541+
// message RuntimeHandler {
542+
// // Name must be unique in StatusResponse.
543+
// // An empty string denotes the default handler.
544+
// string name = 1;
545+
// // Supported features.
546+
// RuntimeHandlerFeatures features = 2;
547+
// }
548+
549+
// RuntimeHandlerFeatures is a set of features implementedy by the runtime handler.
550+
// THE FEATURES CONTAINED IN THE RuntimeHandlerFeatures SHOULD DEPEND ON THE RUNTIME HANDLERS,
551+
// (I.E. DEPENDENT TO THE INFORMATION EXPOSED BY OCI RUNTIME-SPEC'S FEATURES).
552+
message RuntimeHandlerFeatures {
553+
bool recursive_read_only_mounts = 1;
554+
bool user_namespaces = 2;
555+
}
556+
```
557+
417558
### Test Plan
418559

419560
<!--

0 commit comments

Comments
 (0)