Skip to content

Commit b8ec2eb

Browse files
authored
Merge pull request #45280 from jsafrane/selinux-rwx-alpha
Document SELinuxMount feature gate
2 parents 7e1ed16 + 6a1761c commit b8ec2eb

File tree

2 files changed

+34
-11
lines changed

2 files changed

+34
-11
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
title: SELinuxMount
3+
content_type: feature_gate
4+
_build:
5+
list: never
6+
render: false
7+
8+
stages:
9+
- stage: alpha
10+
defaultValue: false
11+
fromVersion: "1.30"
12+
---
13+
Speeds up container startup by allowing kubelet to mount volumes
14+
for a Pod directly with the correct SELinux label instead of changing each file on the volumes
15+
recursively.
16+
It widens the performance improvements behind the `SELinuxMountReadWriteOncePod`
17+
feature gate by extending the implementation to all volumes.
18+
19+
Enabling the `SELinuxMount` feature gate requires the feature gate `SELinuxMountReadWriteOncePod` to
20+
be enabled.

content/en/docs/tasks/configure-pod-container/security-context.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,17 @@ To assign SELinux labels, the SELinux security module must be loaded on the host
440440

441441
### Efficient SELinux volume relabeling
442442

443-
{{< feature-state for_k8s_version="v1.27" state="beta" >}}
443+
{{< feature-state feature_gate_name="SELinuxMountReadWriteOncePod" >}}
444+
445+
{{< note >}}
446+
Kubernetes v1.27 introduced an early limited form of this behavior that was only applicable
447+
to volumes (and PersistentVolumeClaims) using the `ReadWriteOncePod` access mode.
448+
449+
As an alpha feature, you can enable the `SELinuxMount`
450+
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/) to widen that
451+
performance improvement to other kinds of PersistentVolumeClaims, as explained in detail
452+
below.
453+
{{< /note >}}
444454

445455
By default, the container runtime recursively assigns SELinux label to all
446456
files on all Pod volumes. To speed up this process, Kubernetes can change the
@@ -451,7 +461,9 @@ To benefit from this speedup, all these conditions must be met:
451461

452462
* The [feature gates](/docs/reference/command-line-tools-reference/feature-gates/) `ReadWriteOncePod`
453463
and `SELinuxMountReadWriteOncePod` must be enabled.
454-
* Pod must use PersistentVolumeClaim with `accessModes: ["ReadWriteOncePod"]`.
464+
* Pod must use PersistentVolumeClaim with applicable `accessModes` and [feature gates](/docs/reference/command-line-tools-reference/feature-gates/):
465+
* Either the volume has `accessModes: ["ReadWriteOncePod"]`, and feature gate `SELinuxMountReadWriteOncePod` is enabled.
466+
* Or the volume can use any other access modes and both feature gates `SELinuxMountReadWriteOncePod` and `SELinuxMount` must be enabled.
455467
* Pod (or all its Containers that use the PersistentVolumeClaim) must
456468
have `seLinuxOptions` set.
457469
* The corresponding PersistentVolume must be either:
@@ -465,15 +477,6 @@ runtime recursively changes the SELinux label for all inodes (files and directo
465477
in the volume.
466478
The more files and directories in the volume, the longer that relabelling takes.
467479

468-
{{< note >}}
469-
<!-- remove after Kubernetes v1.30 is released -->
470-
If you are running Kubernetes v1.25, refer to the v1.25 version of this task page:
471-
[Configure a Security Context for a Pod or Container](https://v1-25.docs.kubernetes.io/docs/tasks/configure-pod-container/security-context/) (v1.25).
472-
There is an important note in that documentation about a situation where the kubelet
473-
can lose track of volume labels after restart. This deficiency has been fixed
474-
in Kubernetes 1.26.
475-
{{< /note >}}
476-
477480
## Discussion
478481

479482
The security context for a Pod applies to the Pod's Containers and also to

0 commit comments

Comments
 (0)