@@ -96,6 +96,7 @@ tags, and then generate with `hack/update-toc.sh`.
96
96
- [ kubelet] ( #kubelet )
97
97
- [ CRI] ( #cri )
98
98
- [ Container Runtimes] ( #container-runtimes )
99
+ - [ SELinux] ( #selinux )
99
100
- [ Test Plan] ( #test-plan )
100
101
- [ Prerequisite testing updates] ( #prerequisite-testing-updates )
101
102
- [ Unit tests] ( #unit-tests )
@@ -360,13 +361,19 @@ message ImageSpec {
360
361
361
362
// Absolute local path where the image/artifacts should be mounted to.
362
363
string mountpoint = 20;
364
+
365
+ // List of additional mount options (` mount -o`).
366
+ repeated string mount_options = 21;
363
367
}
364
368
```
365
369
366
370
This allows to re-use the existing kubelet logic for managing the OCI objects,
367
371
with the caveat that the new ` VolumeSource ` won't be isolated in a dedicated
368
372
plugin as part of the existing [ volume manager] ( https://github.com/kubernetes/kubernetes/tree/6d0aab2/pkg/kubelet/volumemanager ) .
369
373
374
+ The added ` mount_options ` allow the kubelet to handle features like SELinux
375
+ relabelling by passing additional mount arguments.
376
+
370
377
#### Container Runtimes
371
378
372
379
Container runtimes need to support the new ` mountpoint ` field, otherwise the
@@ -379,6 +386,23 @@ to run on the node.
379
386
For security reasons, volume mounts should set the [ ` noexec ` ] and ` ro `
380
387
(read-only) options by default.
381
388
389
+ ##### SELinux
390
+
391
+ Traditionally, the container runtime is responsible of applying SELinux labels
392
+ to volume mounts, which are inherited from the ` securityContext ` of the pod or
393
+ container. Relabeling volume mounts can be time-consuming, especially when there
394
+ are many files on the volume.
395
+
396
+ If the following criteria are met, then the kubelet will use the ` mount_options `
397
+ field in the CRI to pass ` context=<SELinux label> ` (` mount -o ` ) to the container
398
+ runtime.
399
+
400
+ - The operating system must support SELinux
401
+ - The Pod must have at least ` seLinuxOptions.level ` assigned in the
402
+ ` PodSecurityContext ` or all volume using containers must have it set in their
403
+ ` SecurityContexts ` . Kubernetes will read the default user, role and type from
404
+ the operating system defaults (typically ` system_u ` , ` system_r ` and ` container_t ` ).
405
+
382
406
### Test Plan
383
407
384
408
<!--
0 commit comments