OpsCanary
Back to daily brief
kubernetesPractitioner

Kubernetes v1.36: Unlocking Rootless Security with User Namespaces

5 min read Kubernetes BlogApr 23, 2026
Share
PractitionerHands-on experience recommended

User Namespaces in Kubernetes are a game changer for security. They provide a way to run containers with root privileges while maintaining isolation from the host system. This means you can run workloads without granting them full root access on the host, significantly reducing the risk of security breaches. With User Namespaces, you can achieve a more secure environment by leveraging the kernel's capabilities to remap user IDs and group IDs transparently.

When you enable User Namespaces, the kernel handles UID and GID remapping seamlessly. For instance, when a volume is mounted into a Pod, the kernel translates the UIDs and GIDs so that files appear owned by UID 0 within the container, while the actual ownership on disk remains unchanged. This operation is efficient, operating in O(1) time, which means it’s both instant and resource-friendly. To configure this, you simply set the hostUsers parameter to false in your Pod spec, opting out of the host user namespace.

In production, the introduction of User Namespaces means you can run applications with a higher level of security without the complexity of managing file permissions on disk. However, remember that this feature is Linux-only, so it won't work in non-Linux environments. As you adopt this feature, keep an eye on the specific configurations and test thoroughly to ensure compatibility with your existing workloads.

Key takeaways

  • Leverage User Namespaces for enhanced security isolation in Kubernetes.
  • Set `hostUsers: false` to opt-out of the host user namespace.
  • Understand that UID and GID remapping is efficient and transparent during volume mounts.
  • Remember that this feature is Linux-only and may not be suitable for all environments.

Why it matters

Implementing User Namespaces can significantly reduce security risks by allowing workloads to run with root privileges in an isolated manner, protecting the host system from potential vulnerabilities.

Code examples

YAML
1apiVersion: v1
2kind: Pod
3metadata:
4  name: isolated-workload
5spec:
6  hostUsers: false
7  containers:
8  - name: app
9    image: fedora:42
10    securityContext:
11      runAsUser: 0

When NOT to use this

The official docs don't call out specific anti-patterns here. Use your judgment based on your scale and requirements.

Want the complete reference?

Read official docs

Test what you just learned

Quiz questions written from this article

Take the quiz →

Get the daily digest

One email. 5 articles. Every morning.

No spam. Unsubscribe anytime.