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
feat(shim): add per-pod user namespace injection via annotation
When the runtime opts in (`enable_user_namespace_annotation = true` in
`runsc.toml`) and a pod sets `dev.gvisor.spec.user-namespace = "true"` in
its `metadata.annotations`, the runsc containerd shim injects a Linux
user namespace and a contiguous, non-overlapping uid/gid block into the
sandbox container's OCI spec before invoking runsc. Application/exec
containers in the same pod inherit the sandbox's user namespace from
runsc; only the sandbox spec is modified. Caller-provided mappings (e.g.
from kubelet pod.spec.hostUsers: false plumbing) take precedence.
Two gates are required so a misconfigured pod cannot unilaterally enable
a userns on a runtime that is not provisioned for one:
1. operator opt-in: `enable_user_namespace_annotation = true`.
2. pod opt-in: `dev.gvisor.spec.user-namespace: "true"` annotation.
This exists to let runsc workloads run inside a user namespace on
Kubernetes nodes whose kubelet+containerd stack does not yet plumb
pod.spec.hostUsers (KEP-127) through to runsc. The shim never claims CRI
RuntimeFeatures.UserNamespaces, so kubelet's KEP-127 admission is
unaffected; this annotation is the per-pod opt-in until the upstream
path lands. When that happens, drop the annotation and use
`hostUsers: false` on the pod spec instead.
Per-sandbox uniqueness is provided by a directory-based allocator under
`user_namespace_state_dir` (default `/run/runsc/userns-pool`). os.Mkdir
is the synchronization primitive: the kernel guarantees mkdir(2) is
atomic, so two shim invocations racing on the same slot resolve
correctly. Allocations survive shim restarts and clear on reboot
(`/run` is tmpfs).
Defaults: range_size=65536 UIDs per sandbox, pool_size=1000 concurrent
sandboxes. host_uid_base / host_gid_base must be configured explicitly.
Refs: #13303
0 commit comments