A Pod user namespace maps container user IDs to different host IDs when hostUsers is false. This can reduce what a process that appears to be root inside the container can do on the node. It does not make a compromised application harmless. Node kernel, runtime, and filesystem support determine whether the Pod starts, and some volume or host-namespace combinations are incompatible with this mode.
Pod user namespaces: verify host mapping and volume compatibility
Operational decision
A media-conversion worker needs temporary files and a restricted input volume. In an isolated Linux node pool that supports user namespaces, launch a canary with hostUsers false and record the UID shown inside the container and the mapped host identity. Verify read and write permissions on every mounted volume and exercise the entire conversion path. The fragment is only the relevant Pod-spec portion; the production manifest must supply the approved image, resources, and placement. Confirm the storage driver's idmapped-mount support before migration. Raw block volumeDevices and NFS mounts are incompatible with user-namespace Pods in current Kubernetes behavior, and hostNetwork, hostPID, and hostIPC cannot be combined with hostUsers false. If the worker needs one of those facilities, do not force the flag into its manifest; isolate it through an alternative node and access design. Repeat after node upgrades because kernel and runtime changes can alter mount behavior.
spec:
hostUsers: false
securityContext:
runAsUser: 2047
runAsGroup: 2047
containers:
- name: media-converter
volumeMounts:
- name: conversion-scratch
mountPath: /var/tmp/conversion
volumes:
- name: conversion-scratch
emptyDir: {}Cost and verification
User namespaces reduce host-identity exposure but add node and storage compatibility constraints. A failed mount can leave capacity stranded if only some nodes support the workload. Measure start failures by node, permission errors, eligible-node headroom, and host-versus-container UID mapping. The example UID is an application choice, not a promise about its exact host mapping; inspect the real mapping on the target runtime.
Common Mistakes
- Do not equate container root with host root after a user namespace is enabled.
- Do not schedule a user-namespace Pod onto storage that lacks required idmapped mounts.
- Do not combine hostUsers false with raw block devices or prohibited host namespaces.
Connected lessons
- DevOps: delivery, infrastructure, and reliable operations
- Container runtime restrictions: remove privileges a service does not use
- Raw block PVCs: make the application's formatting responsibility explicit
- Node autoscaling: make pending Pods schedulable before traffic rises
- Read-only root filesystems: inventory every required write path
