@@ -686,6 +686,8 @@ securityContext:
686
686
687
687
{{< note >}}
688
688
To assign SELinux labels, the SELinux security module must be loaded on the host operating system.
689
+ On Windows and Linux worker nodes without SELinux support, this field and any SELinux feature gates described
690
+ below have no effect.
689
691
{{< /note >}}
690
692
691
693
# ## Efficient SELinux volume relabeling
@@ -696,24 +698,25 @@ To assign SELinux labels, the SELinux security module must be loaded on the host
696
698
Kubernetes v1.27 introduced an early limited form of this behavior that was only applicable
697
699
to volumes (and PersistentVolumeClaims) using the `ReadWriteOncePod` access mode.
698
700
699
- As an alpha feature, you can enable the `SELinuxMount ` and `SELinuxChangePolicy `
700
- [feature gates](/docs/reference/command-line-tools-reference/feature-gates/) to widen that
701
- performance improvement to other kinds of PersistentVolumeClaims, as explained in detail
702
- below.
701
+ Kubernetes v1.33 promotes `SELinuxChangePolicy ` and `SELinuxMount `
702
+ [feature gates](/docs/reference/command-line-tools-reference/feature-gates/)
703
+ as beta to widen that performance improvement to other kinds of PersistentVolumeClaims,
704
+ as explained in detail below. While in beta, `SELinuxMount` is still disabled by default .
703
705
{{< /note >}}
704
706
705
- By default, the container runtime recursively assigns SELinux label to all
706
- files on all Pod volumes. To speed up this process, Kubernetes can change the
707
+ With `SELinuxMount` feature gate disabled (the default in Kubernetes 1.33 and any previous release),
708
+ the container runtime recursively assigns SELinux label to all
709
+ files on all Pod volumes by default. To speed up this process, Kubernetes can change the
707
710
SELinux label of a volume instantly by using a mount option
708
711
` -o context=<label>` .
709
712
710
713
To benefit from this speedup, all these conditions must be met :
711
714
712
- * The [feature gates ](/docs/reference/command-line-tools-reference/feature-gates/) `ReadWriteOncePod`
713
- and `SELinuxMountReadWriteOncePod` must be enabled.
715
+ * The [feature gate ](/docs/reference/command-line-tools-reference/feature-gates/)
716
+ ` SELinuxMountReadWriteOncePod` must be enabled.
714
717
* Pod must use PersistentVolumeClaim with applicable `accessModes` and [feature gates](/docs/reference/command-line-tools-reference/feature-gates/):
715
718
* Either the volume has `accessModes: ["ReadWriteOncePod"]`, and feature gate `SELinuxMountReadWriteOncePod` is enabled.
716
- * Or the volume can use any other access modes and both feature gates
719
+ * Or the volume can use any other access modes and all feature gates
717
720
` SELinuxMountReadWriteOncePod` , `SELinuxChangePolicy` and `SELinuxMount` must be enabled
718
721
and the Pod has `spec.securityContext.seLinuxChangePolicy` either nil (default) or `MountOption`.
719
722
* Pod (or all its Containers that use the PersistentVolumeClaim) must
@@ -724,9 +727,15 @@ To benefit from this speedup, all these conditions must be met:
724
727
The CSI driver must announce that it supports mounting with `-o context` by setting
725
728
`spec.seLinuxMount : true` in its CSIDriver instance.
726
729
727
- For any other volume types , SELinux relabelling happens another way : the container
730
+ When any of these conditions is not met , SELinux relabelling happens another way : the container
728
731
runtime recursively changes the SELinux label for all inodes (files and directories)
729
- in the volume.
732
+ in the volume. Calling out explicitly, this applies to Kubernetes ephemeral volumes like
733
+ ` secret` , `configMap` and `projected`, and all volumes whose CSIDriver instance does not
734
+ explicitly announce mounting with `-o context`.
735
+
736
+ When this speedup is used, all Pods that use the same applicable volume concurrently on the same node
737
+ **must have the same SELinux label**. A Pod with a different SELinux label will fail to start and will be
738
+ ` ContainerCreating` until all Pods with other SELinux labels that use the volume are deleted.
730
739
731
740
{{< feature-state feature_gate_name="SELinuxChangePolicy" >}}
732
741
For Pods that want to opt-out from relabeling using mount options, they can set
@@ -758,6 +767,12 @@ with different SELinux labels:
758
767
A cluster admin can use this information to identify pods affected by the planning change and
759
768
proactively opt-out Pods from the optimization (i.e. set `spec.securityContext.seLinuxChangePolicy : Recursive`).
760
769
770
+ {{< warning >}}
771
+ We strongly recommend clusters that use SELinux to enable this controller and make sure that
772
+ ` selinux_warning_controller_selinux_volume_conflict` metric does not report any conflicts before enabling `SELinuxMount`
773
+ feature gate or upgrading to a version where `SELinuxMount` is enabled by default.
774
+ {{< /warning >}}
775
+
761
776
# ### Feature gates
762
777
763
778
The following feature gates control the behavior of SELinux volume relabeling :
@@ -768,11 +783,11 @@ The following feature gates control the behavior of SELinux volume relabeling:
768
783
* `SELinuxChangePolicy`: enables `spec.securityContext.seLinuxChangePolicy` field in Pod and related SELinuxWarningController
769
784
in kube-controller-manager. This feature can be used before enabling `SELinuxMount` to check Pods running on a cluster,
770
785
and to pro-actively opt-out Pods from the optimization.
771
- This feature gate requires `SELinuxMountReadWriteOncePod` enabled. It is alpha and disabled by default in 1.32 .
786
+ This feature gate requires `SELinuxMountReadWriteOncePod` enabled. It is beta and enabled by default in 1.33 .
772
787
* `SELinuxMount` enables the optimization for all eligible volumes. Since it can break existing workloads, we recommend
773
788
enabling `SELinuxChangePolicy` feature gate + SELinuxWarningController first to check the impact of the change.
774
- This feature gate requires `SELinuxMountReadWriteOncePod` and `SELinuxChangePolicy` enabled. It is alpha and disabled
775
- by default in 1.32 .
789
+ This feature gate requires `SELinuxMountReadWriteOncePod` and `SELinuxChangePolicy` enabled. It is beta, but disabled
790
+ by default in 1.33 .
776
791
777
792
# # Managing access to the `/proc` filesystem {#proc-access}
778
793
0 commit comments