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
For Pods that want to opt-out from relabeling using mount options, they can set
714
+
`spec.securityContext.seLinuxChangePolicy`to `Recursive`. This is required
715
+
when multiple pods share a single volume on the same node, but they run with
716
+
different SELinux labels that allows simultaneous access to the volume. For example, a privileged pod
717
+
running with label `spc_t` and an unprivileged pod running with the default label `container_file_t`.
718
+
With unset `spec.securityContext.seLinuxChangePolicy` (or with the default value `MountOption`),
719
+
only one of such pods is able to run on a node, the other one gets ContainerCreating with error
720
+
`conflicting SELinux labels of volume <name of the volume>: <label of the running pod> and <label of the pod that can't start>`.
721
+
722
+
#### SELinuxWarningController
723
+
To make it easier to identify Pods that are affected by the change in SELinux volume relabeling,
724
+
a new controller called `SELinuxWarningController` has been introduced in kube-controller-manager.
725
+
It is disabled by default and can be enabled by either setting the `--controllers=*,selinux-warning-controller`
726
+
[command line flag](/docs/reference/command-line-tools-reference/kube-controller-manager/),
727
+
or by setting `genericControllerManagerConfiguration.controllers`
728
+
[field in KubeControllerManagerConfiguration](/docs/reference/config-api/kube-controller-manager-config.v1alpha1/#controllermanager-config-k8s-io-v1alpha1-GenericControllerManagerConfiguration).
729
+
This controller requires `SELinuxChangePolicy` feature gate to be enabled.
730
+
731
+
When enabled, the controller observes running Pods and when it detects that two Pods use the same volume
732
+
with different SELinux labels:
733
+
1. It emits an event to both of the Pods. `kubectl describe pod <pod-name>` the shows
734
+
`SELinuxLabel "<label on the pod>" conflicts with pod <the other pod name> that uses the same volume as this pod
735
+
with SELinuxLabel "<the other pod label>". If both pods land on the same node, only one of them may access the volume`.
736
+
2. Raise `selinux_warning_controller_selinux_volume_conflict` metric. The metric has both pod
737
+
names + namespaces as labels to identify the affected pods easily.
738
+
739
+
A cluster admin can use this information to identify pods affected by the planning change and
740
+
proactively opt-out Pods from the optimization (i.e. set `spec.securityContext.seLinuxChangePolicy: Recursive`).
741
+
742
+
#### Feature gates
743
+
744
+
The following feature gates control the behavior of SELinux volume relabeling:
745
+
746
+
* `SELinuxMountReadWriteOncePod`: enables the optimization for volumes with `accessModes: ["ReadWriteOncePod"]`.
747
+
This is a very safe feature gate to enable, as it cannot happen that two pods can share one single volume with
748
+
this access mode. This feature gate is enabled by default sine v1.28.
749
+
* `SELinuxChangePolicy`: enables `spec.securityContext.seLinuxChangePolicy` field in Pod and related SELinuxWarningController
750
+
in kube-controller-manager. This feature can be used before enabling `SELinuxMount` to check Pods running on a cluster,
751
+
and to pro-actively opt-out Pods from the optimization.
752
+
This feature gate requires `SELinuxMountReadWriteOncePod` enabled. It is alpha and disabled by default in 1.32.
753
+
* `SELinuxMount` enables the optimization for all eligible volumes. Since it can break existing workloads, we recommend
754
+
enabling `SELinuxChangePolicy` feature gate + SELinuxWarningController first to check the impact of the change.
755
+
This feature gate requires `SELinuxMountReadWriteOncePod` and `SELinuxChangePolicy` enabled. It is alpha and disabled
756
+
by default in 1.32.
710
757
711
758
## Managing access to the `/proc` filesystem {#proc-access}
0 commit comments