Introduction
The KCNA curriculum weights Container Orchestration at 28% and Kubernetes Fundamentals at 44%, and the current curriculum outline lists Containerization as a named topic. Yet most study material explains containers with a metaphor (“a lightweight VM”, “a shipping box”) and moves on. The exam does not reward metaphors. It asks what actually isolates a container from the host, why a Pod’s containers share an IP address, what happens when a container exceeds its memory limit, and what the letters OCI, CRI and runc refer to.
This guide answers those questions at the level of the kernel features and specifications that make containers real. A container is an ordinary Linux process that the kernel has fenced off using namespaces (what the process can see), cgroups (how much it can consume), and a privilege envelope of capabilities, seccomp and no_new_privs (what it may do), running on a filesystem assembled from image layers. Everything else — Docker, containerd, CRI-O, runc, crun, Kubernetes — is machinery that writes those kernel settings for you, following the OCI runtime and image specifications.
We will walk from the kernel upward: namespaces, cgroups v1 vs v2, the OCI bundle and config.json, the runc lifecycle, image layers and OverlayFS, the Pod sandbox and the pause process, and finally how a Pod’s resources block becomes cpu.max and memory.max on the node. A kind-based lab lets you see every piece, and a cue table collapses it into exam-ready recall.
This article is a companion to our container runtimes guide (which explains the CRI/OCI layer cake and the Dockershim story) and the Container Orchestration domain overview. Those posts tell you who does the work; this one shows you what the work is.
A Container Is a Process: The Mental Model
Start with the single sentence the exam is testing: containers share the host kernel; virtual machines do not. A VM boots its own kernel on virtualised hardware. A container never boots anything. The runtime calls clone() or unshare() with a handful of flags, moves the new process into a cgroup, drops privileges, pivots into a new root filesystem, and execs the program you asked for. The result is a process with a restricted view of the system, a budget for resources, and a reduced set of permissions. Three mechanisms, one process.
| Question the kernel answers | Mechanism | Examples |
|---|---|---|
| What can the process see? | Namespaces | Its own PID 1, its own network interfaces, its own hostname, its own mount table |
| How much can the process use? | Control groups (cgroups) | CPU weight and ceiling, memory ceiling, number of PIDs, I/O bandwidth |
| What may the process do? | Capabilities, seccomp, LSMs, no_new_privs | No CAP_SYS_ADMIN, no mount(2) syscall, AppArmor or SELinux confinement |
| What files does it run on? | Image layers + union filesystem | Read-only image layers stacked by OverlayFS plus a thin writable layer |
Because the kernel is shared, a kernel vulnerability affects every container on the node. That is why sandboxed runtimes such as gVisor and Kata Containers exist (via RuntimeClass), and why the KCSA and CKS exams spend so much time on the “Container” layer of the 4Cs. For KCNA you need the principle, not the hardening detail.
Linux Namespaces: What the Container Can See
A namespace wraps a global system resource so that processes inside it see their own isolated instance of that resource. The namespaces(7) man page lists eight types. The exam will not ask for CLONE_ flags, but knowing them makes the unshare lab below readable, and the “what it isolates” column is directly testable.
| Namespace | clone(2) flag | What it isolates | /proc/PID/ns/ entry since |
|---|---|---|---|
| Mount | CLONE_NEWNS | Mount points (the mount table) | Linux 3.8 |
| PID | CLONE_NEWPID | Process IDs; the first process is PID 1 | Linux 3.8 |
| Network | CLONE_NEWNET | Network devices, IP stacks, ports, routing tables, firewall rules | Linux 3.0 |
| IPC | CLONE_NEWIPC | System V IPC objects and POSIX message queues | Linux 3.0 |
| UTS | CLONE_NEWUTS | Hostname and NIS domain name | Linux 3.0 |
| User | CLONE_NEWUSER | User and group IDs, and therefore capabilities | Linux 3.8 |
| Cgroup | CLONE_NEWCGROUP | The visible cgroup root directory | Linux 4.6 |
| Time | CLONE_NEWTIME | Boot-time and monotonic clocks | Linux 5.6 |
Three facts about namespaces matter beyond the table:
- Membership is per-type. A process can be in a new network namespace but still share the host’s PID namespace. Kubernetes exploits this constantly: Pod containers share a network namespace but, by default, each has its own PID namespace.
- A namespace lives as long as something references it — a member process, an open file descriptor or bind mount of its
/proc/PID/ns/*file, or a child namespace. Kubernetes keeps a Pod’s network namespace alive with a process that does nothing but sleep: thepausecontainer (covered below). - Since Linux 3.8, no privilege is required to create a user namespace, which is the foundation of rootless containers and of Kubernetes’
hostUsers: false.
The PID namespace and the meaning of PID 1
The PID namespace carries the semantics the exam most often probes. The first process created in a new PID namespace gets PID 1 and becomes the “init” of that namespace:
- Orphaned processes in the namespace are re-parented to it, so it must reap zombies or they accumulate.
- If PID 1 terminates, the kernel sends
SIGKILLto every other process in the namespace. This is why a container “dies” when its main process exits, and why Kubernetes’restartPolicyoperates at the container level. - From inside the namespace, PID 1 can only receive signals for which it has installed a handler. From an ancestor namespace,
SIGKILLandSIGSTOPare always delivered. That is how the kubelet’s termination sequence (SIGTERM, waitterminationGracePeriodSeconds, thenSIGKILL) can always finish the job, as described in our Pod status guide. - A process’s PID namespace is fixed at creation and cannot be changed afterwards;
setns(2)into a PID namespace only affects children the caller creates next. Nesting is capped at 32 levels.
The user namespace: root inside, nobody outside
A user namespace maps a range of UIDs/GIDs inside the namespace to a different range outside, through /proc/PID/uid_map and gid_map (each line: inside-start outside-start length). A process can therefore be UID 0 with a full capability set inside while being an unprivileged UID with no capabilities in the parent namespace. Kubernetes exposes this as pod.spec.hostUsers: false, generally available and locked on since Kubernetes 1.36, which maps the container’s 0–65535 range onto a disjoint host range chosen per Pod by the kubelet; see our user namespaces guide for the kernel 6.3, idmap-mount and runtime prerequisites. For KCNA, the takeaway is the principle: a process that is root in the container is not necessarily root on the node.
Control Groups: How Much the Container Can Use
Namespaces limit visibility; cgroups limit consumption. A cgroup is a node in a hierarchy; each node has interface files written by the kernel’s resource controllers (cpu, memory, pids, io, …). A process belongs to exactly one cgroup per hierarchy, and the kernel accounts and limits its resources at that node.
cgroups v1 vs v2
| cgroups v1 | cgroups v2 | |
|---|---|---|
| Hierarchies | One per controller (/sys/fs/cgroup/cpu, /sys/fs/cgroup/memory, …), mountable separately | One unified hierarchy (cgroup2 filesystem) that every controller attaches to |
| Official since | Linux 2.6.24 (2008) | Linux 4.5 (2016); controllers arrived progressively (io, memory, pids 4.5; cpu 4.15; cpuset 5.0; freezer 5.2; hugetlb 5.6) |
| Where processes may live | Anywhere, including interior nodes | No internal processes: a non-root cgroup cannot both contain processes and delegate controllers to children |
| Enabling a controller for children | Implicit by mounting the hierarchy | Explicit: write +memory +pids into cgroup.subtree_control |
| Emptiness notification | release_agent / notify_on_release | populated key in cgroup.events |
| Delegation to unprivileged managers | Ad hoc | Designed in: nsdelegate mount option treats cgroup namespaces as delegation boundaries |
| Kubernetes status | Deprecated since Kubernetes 1.35; the kubelet refuses to start on a v1 node unless failCgroupV1: false is set in KubeletConfiguration | Stable since Kubernetes 1.25; required for Memory QoS and Pressure Stall Information |
Kubernetes’ documented requirements for cgroup v2 are a distribution that enables it, Linux kernel 5.8 or later, containerd v1.4+ or CRI-O v1.20+, and the systemd cgroup driver on both the kubelet and the runtime (the driver choice is explained in our kubelet configuration guide). Distributions that default to v2 include Container-Optimized OS (M97+), Ubuntu 21.10+ (22.04+ recommended), Debian 11+, Fedora 31+, Arch Linux (April 2021+), and RHEL 9 and derivatives. The one-liner to check a node is:
stat -fc %T /sys/fs/cgroup/
# cgroup2fs -> cgroup v2
# tmpfs -> cgroup v1
The exam-relevant reasons v2 won: a single hierarchy means consistent accounting (including page-cache write-back) across memory types, safe delegation of a subtree to a non-root manager, and the memory.min/memory.low/memory.high controls that Kubernetes’ Memory QoS depends on.
The cgroup v2 files that Kubernetes writes
You do not need to memorise the full interface, but you should be able to recognise the files a Pod’s resources block ends up in. All weights in cgroup v2 share one range, and the token max means “no limit”.
| File | Controller | Format / range | What Kubernetes puts there |
|---|---|---|---|
cpu.weight | cpu | 1–10000, default 100 | Derived from the container’s CPU request (relative share under contention) |
cpu.max | cpu | $MAX $PERIOD in µs, default max 100000 | CPU limit as a CFS quota per 100 ms period; max when there is no limit |
cpu.max.burst | cpu | 0 to $MAX | Not set by default |
cpu.stat | cpu | nr_periods, nr_throttled, throttled_usec, … | Read by cAdvisor; non-zero nr_throttled means the limit is biting |
memory.max | memory | bytes or max | Memory limit; exceeding it invokes the OOM killer |
memory.high | memory | bytes or max | Memory QoS throttling threshold for Burstable/BestEffort (beta-on in 1.37) |
memory.min / memory.low | memory | bytes, default 0 | Memory QoS protection from the request under memoryReservationPolicy: TieredReservation |
memory.current | memory | bytes | Current charged usage (what kubectl top ultimately reflects) |
memory.events | memory | low high max oom oom_kill counters | oom_kill increments when the kernel kills a process in the cgroup |
memory.swap.max | memory | bytes or max | Swap allowance when the kubelet’s swap support is enabled |
pids.max / pids.current | pids | integer or max | The kubelet’s podPidsLimit; fork() fails with EAGAIN beyond it |
io.max / io.weight | io | per-device limits; weight 1–10000 | Not set by Kubernetes core (used by some runtimes and local storage add-ons) |
cgroup.procs | core | PIDs | The container’s process IDs; writing a PID moves the whole process |
cgroup.events | core | populated 0/1, frozen 0/1 | Lets the runtime learn that a container’s last process exited |
On a systemd-driver node the hierarchy looks like /sys/fs/cgroup/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod<uid>.slice/cri-containerd-<container-id>.scope/. The top-level kubepods.slice is the Node Allocatable budget described in our node allocatable guide; the QoS-class slices come next; then one slice per Pod; then one scope per container. Memory ownership is charged to the cgroup that instantiated the page, which is why a Pod that writes to a memory-backed emptyDir sees that usage counted against its own limit.
The Privilege Envelope: Capabilities, seccomp and no_new_privs
A container’s process usually runs with a reduced bounding set of Linux capabilities (no CAP_SYS_ADMIN, no CAP_NET_ADMIN by default), a seccomp filter that denies dangerous syscalls (mount, reboot, kexec_load, …), optionally an AppArmor or SELinux profile, and the no_new_privs bit that prevents setuid binaries from escalating. Kubernetes exposes these through securityContext (capabilities, seccompProfile, allowPrivilegeEscalation, appArmorProfile, seLinuxOptions), and the OCI runtime spec carries them into the kernel. The deep dives live in our Pod securityContext guide and seccomp and AppArmor guide. For KCNA, know that privileged: true switches all of this off: full capabilities, no seccomp, all host devices — effectively a root process on the node with a different view of the filesystem.
The OCI Runtime Specification: config.json and the Bundle
Everything above is Linux. The Open Container Initiative (OCI) standardises how a runtime is told to build it. The OCI runtime spec defines a filesystem bundle: a directory containing exactly two things, a config.json file and a root filesystem directory (conventionally rootfs/) referenced by root.path. Any compliant runtime — runc (Go), crun (C), youki (Rust), or sandboxed runtimes like gVisor’s runsc and Kata — consumes the same bundle.
What config.json contains
| Section | Key fields | Kernel feature it drives |
|---|---|---|
ociVersion | SemVer of the spec the bundle complies with | — |
root | path, readonly | The container’s root filesystem (pivot_root), readOnlyRootFilesystem |
mounts | destination, source, type, options (incl. bind/rbind, idmap) | Mount namespace contents: volumes, /proc, /sys, /dev/shm, Secrets and ConfigMaps |
process | args, env, cwd, user.uid/gid/additionalGids, terminal, rlimits, capabilities (five sets: bounding, effective, inheritable, permitted, ambient), noNewPrivileges, apparmorProfile, selinuxLabel, oomScoreAdj | The user process and its privilege envelope |
hostname, domainname | strings | UTS namespace |
linux.namespaces | array of type (pid, network, mount, ipc, uts, user, cgroup, time) with optional path | New namespace if path is omitted; join an existing one if path points at /proc/PID/ns/...; inherit the runtime’s if the type is absent |
linux.uidMappings / gidMappings | containerID, hostID, size | User namespace ID maps |
linux.cgroupsPath | path | Which cgroup to create and move the process into |
linux.resources | memory.limit/reservation/swap, cpu.shares/quota/period/cpus/mems, pids.limit, blockIO, hugepageLimits, unified (raw cgroup v2 key/values such as memory.max), devices allowlist | The cgroup files in the previous section |
linux.seccomp | defaultAction, architectures, syscalls[] with actions (SCMP_ACT_ALLOW, ERRNO, KILL_PROCESS, LOG, …) | seccomp-bpf filter |
linux.maskedPaths, linux.readonlyPaths | e.g. /proc/kcore; /proc/sys | Hide or freeze sensitive procfs/sysfs paths (Kubernetes’ procMount: Default) |
linux.sysctl | key/value | Namespaced kernel parameters (securityContext.sysctls) |
linux.rootfsPropagation | shared, slave, private, unbindable | Mount propagation for the root |
hooks | createRuntime, createContainer, startContainer, poststart, poststop (prestart deprecated) | Where CNI plugins, GPU drivers and device injection hook in |
annotations | key/value | Opaque metadata (Kubernetes stores Pod name/namespace here) |
Two rules from the namespaces section are exam-grade: an omitted namespace type means “inherit the runtime’s namespace”, and a path means “join that existing namespace”. Kubernetes uses the second rule to make a Pod: every container’s config.json has network, ipc and uts entries whose path points at the sandbox’s namespaces.
The runtime lifecycle and the five operations
The spec defines a state object (ociVersion, id, status, pid, bundle, annotations) whose status is one of creating, created, running, stopped, and five operations:
| Operation | Rule |
|---|---|
state <id> | Returns the state object |
create <id> <bundle> | Applies everything in config.json except process: namespaces, cgroups, mounts, rootfs. The user program must not run yet. Fails without side effects if the ID is taken or a property cannot be applied |
start <id> | Runs the process program. Only valid from created |
kill <id> <signal> | Sends the signal to the container process. Only valid in created or running |
delete <id> | Tears down what create built. Only valid in created or stopped |
The lifecycle in order: create is invoked → the runtime builds the environment (later edits to config.json have no effect) → createRuntime hooks (runtime namespace; this is where CNI typically runs) → createContainer hooks (container namespaces) → start is invoked → startContainer hooks → the user process runs → poststart hooks → the process exits or is killed → delete → environment destroyed → poststop hooks. The create/start split is deliberate: it gives the higher-level runtime a window to wire networking and attach streams before the application’s first instruction executes. It is also why crictl shows a container in CONTAINER_CREATED before CONTAINER_RUNNING.
Images: Layers, Whiteouts and OverlayFS
The OCI image spec governs the rootfs/ half of the bundle. An image is a manifest (list of layer descriptors plus a config descriptor), an optional image index (per-platform manifests), an image configuration JSON, and a set of layers.
- A layer is a tar archive of a filesystem changeset relative to its parent. Additions and modifications appear as full entries. Deletions are whiteouts: an empty file whose basename is prefixed
.wh.(deleting/etc/app.confproduces/etc/.wh.app.conf); the special.wh..wh..opqfile in a directory hides everything below it in lower layers. Whiteouts apply only to lower layers. - Layer media types are
application/vnd.oci.image.layer.v1.tar,+gzipand+zstd. - The image configuration lists
rootfs.diff_ids— digests of the uncompressed layer tars, in order — plusarchitecture,os, and theconfigblock Kubernetes cares about:Entrypoint,Cmd,Env,User,WorkingDir,ExposedPorts,Volumes,StopSignal,Labels. The manifest instead references layers by the digest of the distributed (usually compressed) blob. A DiffID is not a layer digest; registries and runtimes keep both. The historical “image ID = sha256 of the config JSON” definition is no longer normative, though most tools still display it. - At run time, containerd’s default snapshotter unpacks each layer once and composes the root filesystem with OverlayFS: the image layers become read-only
lowerdirs, a fresh empty directory becomes the container’s writableupperdir, and the merged view is whatroot.pathpoints to. Writes go toupperdir; deletes become whiteouts there; the writable layer is discarded when the container is deleted and counts toward the Pod’s ephemeral storage (which is whyreadOnlyRootFilesystem: trueplus anemptyDirfor scratch is the recommended pattern).
How the kubelet decides whether to pull those layers at all (imagePullPolicy, tags vs digests, imagePullSecrets) is covered in our image pull internals guide.
The Pod Sandbox and the pause Process
A Pod is “one or more containers that share storage and network”. Now you can state how: the CRI’s RunPodSandbox call asks the runtime to create a sandbox — on Linux, a set of namespaces held open by a tiny process — and every container in the Pod is created with config.json namespace entries that join the sandbox’s network, IPC and UTS namespaces. That is why containers in a Pod share one IP, one localhost, one hostname and one System V IPC space, while each keeps its own mount namespace (its own image rootfs) and, by default, its own PID namespace.
The process that holds the sandbox namespaces is the pause container (registry.k8s.io/pause). Its entire source fits on a screen: it installs handlers for SIGINT and SIGTERM (exit 0), installs a SIGCHLD handler that loops waitpid(-1, NULL, WNOHANG) to reap zombies, warns Warning: pause should be the first process if it is not PID 1, and then loops on pause() forever. The zombie reaping matters only when the Pod shares a PID namespace.
The CRI NamespaceOption for a sandbox or container uses a NamespaceMode enum you should recognise:
| Mode | Meaning | Pod spec field that selects it |
|---|---|---|
POD | Namespace shared by every container in the Pod (the sandbox’s) | Default for network and ipc; pid when shareProcessNamespace: true |
CONTAINER | A private namespace per container | Default for pid (the CRI’s own default is POD, but the PodSpec default is CONTAINER) |
NODE | The node’s namespace | hostNetwork: true, hostPID: true, hostIPC: true |
TARGET | Join the namespace of another named container | Ephemeral debug containers with targetContainerName |
With shareProcessNamespace: true, the Pod’s PID 1 becomes /pause, every container’s processes are visible to every other container (including /proc/<pid>/environ and /proc/<pid>/root, so secrets in environment variables become readable across containers), and a container can signal another container’s process — the documented example is kill -HUP to an nginx master from a sidecar, which needs SYS_PTRACE. Containers that expect to be PID 1 (systemd-based images) may refuse to start. The kubelet also uses the sandbox as the unit for network setup: the CNI plugin is invoked once per Pod against the sandbox’s network namespace, not once per container.
From resources: to Kernel Settings
Here is the chain the exam is really asking about when it says “what does a CPU limit do?”:
resources:
requests:
cpu: "250m"
memory: "256Mi"
limits:
cpu: "500m"
memory: "512Mi"
- Scheduling. kube-scheduler sums the requests of Pods already placed on a node and admits this Pod only if each resource total stays within the node’s allocatable capacity. Actual usage is irrelevant to that check. (Unit rules:
0.1CPU equals100m, precision is1m, and400mmemory means 0.4 bytes — the classic typo for400Mi.) - QoS class. Requests equal limits for every container and every resource → Guaranteed. Any request or limit set but not that → Burstable. Nothing set → BestEffort. The class is fixed at creation, decides which slice the Pod’s cgroup lives in, and sets eviction order under node pressure: BestEffort first, then Burstable, then Guaranteed (and only Pods exceeding their requests are candidates). Resizing a Pod in place so that its class would change is rejected, as our in-place resize guide explains.
- CRI translation. The kubelet converts the block to
LinuxContainerResources:cpu_sharesfrom the request (1024 per core),cpu_quotaandcpu_periodfrom the limit (50,000 µs per 100,000 µs here),memory_limit_in_bytesfrom the limit,oom_score_adjfrom the QoS class, plus optionalcpuset_cpus/cpuset_mems,hugepage_limitsand aunifiedmap of raw cgroup v2 keys. - Runtime writes cgroup files. On cgroup v2 the runtime converts
cpu_sharestocpu.weight(the v2 scale is 1–10000) and writescpu.max = 50000 100000andmemory.max = 536870912. - Kernel enforces. CPU is a hard ceiling with throttling: once the cgroup burns its quota in a period, it waits for the next period; the process is never killed for CPU, but
cpu.stat’snr_throttledclimbs and latency rises. Memory is enforced reactively: when usage reachesmemory.max, the OOM killer terminates a process in the cgroup; if that process is the container’s PID 1 and the restart policy allows, the kubelet restarts the container and recordsOOMKilledwith exit code 137. If Memory QoS is active (feature gateMemoryQoS, beta and on by default in Kubernetes 1.37, cgroup v2 only, kernel 5.9+ recommended), the kubelet additionally writesmemory.high = request + memoryThrottlingFactor × (limit − request)for Burstable containers so the kernel throttles and reclaims before the OOM cliff, and withmemoryReservationPolicy: TieredReservationit protects the request viamemory.min(Guaranteed) ormemory.low(Burstable).
Two subtleties close the loop. A memory request is primarily a scheduling input; by itself it writes nothing enforceable unless Memory QoS reservation is on. And the sum of limits may exceed node capacity (overcommit); only requests are guaranteed, which is why “Pods evicted even though they were under their limits” is a sign of node memory pressure, not a bug. The scheduling side of this story is in our scheduling and resource management guide; the denial-of-service angle (LimitRange, ResourceQuota, pids.max) is in the KCSA resource exhaustion guide.
Hands-On Lab: See Every Layer With a kind Cluster
You need Docker (or Podman), kind, kubectl, and about 15 minutes. Every step is read-only against the kernel; nothing here needs a cloud account.
Step 1 — Build a “container” by hand with unshare. Inside any Linux shell (or docker run --rm -it --privileged ubuntu), create new user, PID, mount and UTS namespaces and watch PID 1 appear:
unshare --user --map-root-user --pid --fork --mount-proc --uts bash
hostname sandbox-demo && hostname
echo $$ # 1 — this bash is PID 1 of a new PID namespace
ps -ef # only bash and ps are visible
cat /proc/self/uid_map # 0 1000 1 — root inside maps to your UID outside
exit
Step 2 — Create a cluster and a Pod with requests and limits.
kind create cluster --name internals
kubectl run demo --image=nginx:1.27 --restart=Never \
--overrides='{"spec":{"containers":[{"name":"demo","image":"nginx:1.27",
"resources":{"requests":{"cpu":"250m","memory":"256Mi"},
"limits":{"cpu":"500m","memory":"512Mi"}}}]}}'
kubectl wait --for=condition=Ready pod/demo --timeout=60s
kubectl get pod demo -o jsonpath='{.status.qosClass}{"\n"}' # Burstable
Step 3 — Confirm cgroup v2 and find the Pod’s cgroup on the node.
docker exec internals-control-plane stat -fc %T /sys/fs/cgroup/ # cgroup2fs
CID=$(kubectl get pod demo -o jsonpath='{.status.containerStatuses[0].containerID}' | sed 's|containerd://||')
docker exec internals-control-plane sh -c "
CG=\$(find /sys/fs/cgroup/kubepods.slice -type d -name '*${CID:0:12}*' | head -1)
echo \$CG
cat \$CG/cpu.weight \$CG/cpu.max \$CG/memory.max \$CG/pids.max"
Expect a path under kubepods-burstable.slice, cpu.max reading 50000 100000, and memory.max reading 536870912. Change the limits in Step 2 to equal the requests and the Pod moves to the Guaranteed slice.
Step 4 — Inspect the sandbox and the namespaces with crictl.
docker exec internals-control-plane sh -c '
POD=$(crictl pods --name demo -q)
crictl inspectp $POD | grep -A4 "\"namespaces\""
CTR=$(crictl ps --pod $POD -q)
crictl inspect $CTR | grep -B1 -A3 "\"type\": \"network\""
ps -o pid,comm -C pause | head -3'
The container’s network, ipc and uts entries carry a path into the sandbox’s /proc/<pause-pid>/ns/; pid has no path, so it is private.
Step 5 — Share the PID namespace and meet PID 1.
kubectl apply -f - <<'EOF'
apiVersion: v1
kind: Pod
metadata: { name: shared }
spec:
shareProcessNamespace: true
containers:
- name: web
image: nginx:1.27
- name: shell
image: busybox:1.36
command: ["sleep", "infinity"]
EOF
kubectl wait --for=condition=Ready pod/shared --timeout=60s
kubectl exec shared -c shell -- ps # PID 1 is /pause; nginx processes are visible
kubectl exec shared -c shell -- head -3 /proc/1/cmdline
Step 6 — Trigger the OOM killer and read the evidence.
kubectl run oom --image=polinux/stress --restart=Never \
--limits=memory=64Mi --requests=memory=32Mi -- \
stress --vm 1 --vm-bytes 128M --vm-hang 0
sleep 10
kubectl get pod oom -o jsonpath='{.status.containerStatuses[0].lastState.terminated.reason}{" "}{.status.containerStatuses[0].lastState.terminated.exitCode}{"\n"}'
# OOMKilled 137
Compare with a CPU limit: run the same image with --limits=cpu=100m and stress --cpu 2; the Pod is never killed, but the container’s cpu.stat shows nr_throttled climbing.
Step 7 — Look at a real OCI bundle. On the node, containerd keeps each running container’s config.json:
docker exec internals-control-plane sh -c '
CTR=$(crictl ps --name demo -q)
cat /run/containerd/io.containerd.runtime.v2.task/k8s.io/$CTR/config.json' | python3 -m json.tool | less
Find linux.namespaces, linux.resources.unified (or memory.limit and cpu.quota), maskedPaths with /proc/kcore, and process.capabilities.bounding.
Step 8 — Clean up.
kind delete cluster --name internals
Exam Cue Table: 36 Rows to Memorise
| Cue in the question | Answer |
|---|---|
| ”Containers are lightweight because…” | They share the host kernel; no guest OS boots |
| ”The feature that limits what a process can see” | Linux namespaces |
| ”The feature that limits how much a process can use” | cgroups (control groups) |
| “Which namespace gives a container its own PID 1?” | PID namespace |
| ”Which namespace gives a container its own IP and ports?” | Network namespace |
| ”Which namespace gives a container its own hostname?” | UTS namespace |
| ”Which namespace lets root in the container be unprivileged on the host?” | User namespace (hostUsers: false, GA 1.36) |
| “Which namespace isolates the mount table?” | Mount namespace |
| ”Containers in a Pod share…” | Network, IPC and UTS namespaces (one IP, localhost, hostname); storage via volumes |
| ”Containers in a Pod do NOT share by default…” | Mount namespace (own rootfs) and PID namespace |
| ”Make processes visible across containers in a Pod” | shareProcessNamespace: true |
| ”Who is PID 1 when the PID namespace is shared?” | The pause sandbox process |
| ”What does the pause container do?” | Holds the Pod’s namespaces open and reaps zombies |
| ”Give a Pod the node’s network stack” | hostNetwork: true (CRI NamespaceMode: NODE) |
| “PID 1 exits in a container” | Kernel SIGKILLs every other process in that PID namespace; the container stops |
| ”cgroups v2 differs from v1 because…” | Single unified hierarchy; no internal processes; explicit subtree_control; designed delegation |
| ”Kubernetes cgroup v2 requirements” | Kernel 5.8+, containerd 1.4+ or CRI-O 1.20+, systemd cgroup driver |
| ”Check cgroup version on a node” | stat -fc %T /sys/fs/cgroup/ → cgroup2fs |
| ”cgroup v1 in Kubernetes today” | Deprecated since 1.35; kubelet fails to start unless failCgroupV1: false |
| ”CPU request becomes…” | A scheduling reservation and cpu.weight (relative share) |
| “CPU limit becomes…” | cpu.max quota per 100 ms period → throttling, never a kill |
| ”Memory limit becomes…” | memory.max → OOM kill, OOMKilled, exit code 137 |
| ”Memory request becomes…” | Scheduling input only (plus memory.min/memory.low under Memory QoS reservation) |
“cpu: 0.1 equals” | 100m; precision is 1m |
”memory: 400m means” | 0.4 bytes — a typo for 400Mi |
| ”Requests = limits for all containers” | Guaranteed QoS |
| ”Eviction order under node pressure” | BestEffort → Burstable → Guaranteed |
| ”OCI runtime spec bundle contains” | config.json + root filesystem directory |
| ”OCI runtime operations” | state, create, start, kill, delete |
| ”Which operation runs the user process?” | start (never create) |
| “Container states in the OCI spec” | creating, created, running, stopped |
| ”Low-level runtimes” | runc, crun, youki; sandboxed: gVisor runsc, Kata |
| ”What is an image layer?” | A tar changeset; deletions are .wh. whiteout files |
| ”How are layers combined at run time?” | A union filesystem (OverlayFS): read-only lowerdirs + one writable upperdir |
| ”Where do a container’s writes go?” | The writable layer; lost on container deletion; counts as ephemeral storage |
| ”DiffID vs layer digest” | DiffID = uncompressed tar digest in the image config; layer digest = distributed blob digest in the manifest |
Common Mistakes
Calling a container a lightweight VM. The exam will offer this as a distractor. A VM virtualises hardware and boots a kernel; a container is a process. If you remember one sentence, remember “shared kernel”.
Thinking a CPU limit kills a container. CPU limits throttle; only memory limits kill. “Container restarted with exit code 137” points at memory, not CPU.
Thinking a memory request is enforced. By default it only affects scheduling (and QoS class). Enforcement comes from the limit, or from Memory QoS protection when memoryReservationPolicy is set.
Assuming containers in a Pod share a PID namespace. They share network, IPC and UTS. PID sharing is opt-in (shareProcessNamespace) or node-wide (hostPID).
Confusing the pause container with an init container. Init containers are yours and run to completion before app containers. The pause container is infrastructure that the runtime creates for every Pod and that lives as long as the Pod does.
Believing root in a container is harmless. Without a user namespace, UID 0 in the container is UID 0 on the node, constrained only by capabilities, seccomp and the mount namespace. That is why runAsNonRoot and hostUsers: false exist.
Mixing up cgroup drivers with cgroup versions. cgroupfs vs systemd is who writes the files; v1 vs v2 is which filesystem layout they write to. Kubernetes wants systemd on v2.
Thinking create starts the process. In the OCI lifecycle create builds namespaces, cgroups and mounts; start executes process.args. The gap is where CNI and hooks run.
Conclusion
Strip away the tooling and a container is simple: one Linux process, eight possible namespaces to narrow its view, a cgroup node to meter it, a capability/seccomp envelope to defang it, and a union-mounted stack of tar changesets to run on. The OCI runtime spec writes that recipe down as config.json, runc or crun cooks it through create → start → kill → delete, containerd or CRI-O manages the images and sandboxes, and the kubelet orders everything through the CRI. A Pod is just several of those processes told to join one sandbox’s network, IPC and UTS namespaces — held open by pause — and a resources block is just a few numbers destined for cpu.weight, cpu.max and memory.max.
Once that picture is in your head, whole families of KCNA questions become obvious: why containers in a Pod talk over localhost, why a memory limit produces OOMKilled but a CPU limit only slows things down, why cgroup v2 and the systemd driver are required together, why root inside a container matters, and what each acronym in the runtime stack actually does.
The KCNA tests this material as multiple choice under a 90-minute clock, often by pairing one correct mechanism with three plausible-sounding ones. Reading about cpu.max once is not the same as recognising it in a question stem. If you want to pressure-test your recall across the Container Orchestration and Kubernetes Fundamentals domains — isolation, runtimes, scheduling, resource management, Pod lifecycle — the KCNA mock exam bundle presents exactly these mechanisms as timed, exam-style scenarios with explanations that point back to the kernel behaviour, so the gaps show up before the real exam does. Pair it with our KCNA study guide and practice questions for a complete loop.
Frequently Asked Questions
Does the KCNA exam ask about Linux namespaces and cgroups directly?
Yes, at a conceptual level. The curriculum lists Containerization under the Container Orchestration domain, and typical questions ask which kernel feature provides isolation versus resource limits, why containers are lighter than VMs, and what containers in a Pod share. You will not be asked for clone(2) flags or cgroup file formats, but knowing them makes the concepts stick.
What is the difference between a namespace and a cgroup in one sentence?
A namespace controls what a process can see (its own PIDs, network, hostname, mounts, users); a cgroup controls how much it can use (CPU, memory, PIDs, I/O). Containers need both.
Why do containers in the same Pod share an IP address?
Because the runtime creates one network namespace for the Pod sandbox, held open by the pause process, and every container’s OCI config.json points its network namespace entry at that sandbox namespace. One namespace, one IP, one set of ports — which is also why two containers in a Pod cannot both listen on port 80.
What happens when a container exceeds its memory limit versus its CPU limit?
A memory limit is written to memory.max; exceeding it triggers the kernel OOM killer, the container is restarted according to restartPolicy, and its status shows OOMKilled with exit code 137. A CPU limit is written to cpu.max as a CFS quota; exceeding it causes throttling until the next 100 ms period, never a kill.
Is cgroups v1 still supported by Kubernetes?
It is deprecated as of Kubernetes 1.35. By default the kubelet refuses to start on a cgroup v1 node; you can temporarily override that with failCgroupV1: false in the kubelet configuration, but migration to a cgroup v2 distribution with the systemd cgroup driver is the supported path. cgroup v2 support has been stable since Kubernetes 1.25.
What does the pause container do, and can I remove it?
It holds the Pod’s shared namespaces open so they survive application container restarts, and when the PID namespace is shared it acts as PID 1 and reaps zombie processes. It is created by the container runtime for every Pod and is not something you declare or remove; sandboxed runtimes such as Kata replace it with their own sandbox implementation.
What is the OCI runtime spec, and how is it different from the OCI image spec?
The runtime spec defines how to run a container: a bundle of config.json plus a root filesystem, and the create/start/kill/delete/state operations a runtime like runc implements. The image spec defines how to package and distribute a container’s filesystem and configuration: manifests, indexes, layers as tar changesets with whiteouts, and the image configuration JSON. containerd and CRI-O bridge the two by unpacking image layers into a bundle rootfs and generating config.json from the Pod spec.
Does running as root inside a container mean root on the node?
Without a user namespace, yes in terms of UID: UID 0 inside is UID 0 outside, limited only by capabilities, seccomp, LSM profiles and the mount namespace. With hostUsers: false (user namespaces, GA and locked on since Kubernetes 1.36), the container’s UID 0 maps to an unprivileged host UID and the process has no capabilities in the host’s user namespace.