Kubernetes 1.36 SELinux Mount-Time Labeling
Configure SELinux mount-time volume labeling in Kubernetes 1.36 to eliminate slow recursive relabeling and speed up Pod startup times dramatically.
π‘ Quick Answer: Kubernetes 1.36 graduates SELinux mount-time labeling to Stable. Volume labels are now applied at mount time instead of recursively walking every file, dramatically reducing Pod startup times for secure environments.
The Problem
In SELinux-enforced environments, Kubernetes previously had to recursively relabel every file in a volume when a Pod started. For volumes with millions of files, this could take minutes or even hours, causing:
- Extremely slow Pod startup times
- Timeouts during deployments
- Rolling updates taking 10-100x longer than necessary
- Pressure to disable SELinux entirely (bad security practice)
The Solution
With Kubernetes 1.36, SELinux labels are applied at mount time using the kernelβs native mount option support. No more recursive file walks.
Enable SELinux Mount Labeling
This feature is now GA and enabled by default in 1.36. No feature gates needed.
apiVersion: v1
kind: Pod
metadata:
name: fast-selinux-pod
spec:
securityContext:
seLinuxOptions:
level: "s0:c123,c456"
seLinuxChangePolicy: MountOption
containers:
- name: app
image: registry.example.com/app:v2.1
volumeMounts:
- name: data
mountPath: /data
volumes:
- name: data
persistentVolumeClaim:
claimName: app-dataKey Field: seLinuxChangePolicy
securityContext:
seLinuxChangePolicy: MountOption # NEW: mount-time labeling (fast)
# seLinuxChangePolicy: Recursive # OLD: walk every file (slow)MountOptionβ Labels applied via mount options. Instant, regardless of file count.Recursiveβ Legacy behavior. Walks every file and relabels. Still available if needed.
Verify Mount-Time Labeling
# Check that the volume is mounted with SELinux context
kubectl exec fast-selinux-pod -- mount | grep /data
# Output should show: context="system_u:object_r:container_file_t:s0:c123,c456"
# Verify SELinux labels on files
kubectl exec fast-selinux-pod -- ls -Z /dataPerformance Comparison
# Before (Recursive) - 1 million files
# Pod startup: ~4 minutes
# After (MountOption) - 1 million files
# Pod startup: ~2 secondsCSI Driver Requirements
Your CSI driver must support SELinux mount options. Check compatibility:
# Verify CSI driver supports SELinux
kubectl get csidriver <driver-name> -o jsonpath='{.spec.seLinuxMount}'
# Should return: trueMost major CSI drivers (EBS, GCE PD, Azure Disk, Ceph, NFS) support this in their latest versions.
Common Issues
Mount option not applied
- Cause: CSI driver doesnβt support
seLinuxMount - Fix: Update your CSI driver or fall back to
Recursivepolicy
Permission denied after enabling MountOption
- Cause: Existing files have wrong labels from previous Recursive runs
- Fix: One-time relabel with
Recursive, then switch toMountOption
Pod stuck in ContainerCreating
- Cause: Incompatible SELinux level format
- Fix: Verify
levelfollowss0:cXXX,cYYYformat
Best Practices
- Use
MountOptionfor all new workloads β itβs the default in 1.36 - Update CSI drivers first before relying on mount-time labeling
- Test with existing volumes β one-time Recursive relabel may be needed
- Monitor Pod startup times β you should see immediate improvements
- Donβt disable SELinux β with mount-time labeling, thereβs no performance excuse
Key Takeaways
- SELinux mount-time labeling is GA in Kubernetes 1.36
- Pod startup goes from minutes to seconds for large volumes
- Set
seLinuxChangePolicy: MountOptionin your Pod security context - CSI drivers must support
seLinuxMountcapability - No more choosing between security and performance

Recommended
Kubernetes Recipes β The Complete Book100+ production-ready patterns with detailed explanations, best practices, and copy-paste YAML. Everything in one place.
Get the Book βLearn by Doing
CopyPasteLearn β Hands-on Cloud & DevOps CoursesMaster Kubernetes, Ansible, Terraform, and MLOps with interactive, copy-paste-run lessons. Start free.
Browse Courses βπ Deepen Your Skills β Hands-on Courses
Courses by CopyPasteLearn.com β Learn IT by Doing
