A security team is hardening a Kubernetes cluster. They need to ensure that all control plane components run with the least privilege. Which approach should they take?
Trap 1: Use seccomp profiles to block privilege escalation syscalls
A seccomp profile filters system calls at the kernel boundary, but it does not change the UID/GID that the container process runs with; a root user inside the container simply cannot invoke blacklisted syscalls, yet retains a broad set of permitted root-only operations. Blocking syscalls such as unshare or mount does not satisfy the requirement to run the control plane as a non-root user with a read-only filesystem.
Trap 2: Apply AppArmor profiles to all control plane pods
AppArmor confines a specific executable or daemon to an allowed set of files, capabilities, and network operations via an LSM profile, but it leaves the container's user context untouched. The profile is also tied to the host's loaded profiles and must be applied per pod via annotations; it cannot force the control plane process to run as non-root or make its root filesystem read-only.
Trap 3: Enable PodSecurityPolicy with 'MustRunAsNonRoot' for control plane…
PodSecurityPolicy is deprecated since Kubernetes 1.21 and removed in 1.25, so it cannot be reliably used on modern versions; the replacement Pod Security Admission does not define a must-run-as-non-root and read-only-filesystem pair. Even if MustRunAsNonRoot were valid, it only validates that the container runs with a non-zero UID, and it does nothing to prevent container processes from modifying the root filesystem.
- A
Use seccomp profiles to block privilege escalation syscalls
Why wrong: A seccomp profile filters system calls at the kernel boundary, but it does not change the UID/GID that the container process runs with; a root user inside the container simply cannot invoke blacklisted syscalls, yet retains a broad set of permitted root-only operations. Blocking syscalls such as unshare or mount does not satisfy the requirement to run the control plane as a non-root user with a read-only filesystem.
- B
Apply AppArmor profiles to all control plane pods
Why wrong: AppArmor confines a specific executable or daemon to an allowed set of files, capabilities, and network operations via an LSM profile, but it leaves the container's user context untouched. The profile is also tied to the host's loaded profiles and must be applied per pod via annotations; it cannot force the control plane process to run as non-root or make its root filesystem read-only.
- C
Configure control plane containers to run as non-root user and with read-only root filesystem
Setting runAsNonRoot: true and an explicit runAsUser (for example, 1000) in the pod security context, along with readOnlyRootFilesystem: true, directly removes root privileges and makes the container's immutable root filesystem fail-closed on any write attempt. This is the most effective hardening for control plane components because it attacks both privilege escalation and tampering of the container's filesystem at the source, rather than filtering specific kernel or program actions.
- D
Enable PodSecurityPolicy with 'MustRunAsNonRoot' for control plane namespaces
Why wrong: PodSecurityPolicy is deprecated since Kubernetes 1.21 and removed in 1.25, so it cannot be reliably used on modern versions; the replacement Pod Security Admission does not define a must-run-as-non-root and read-only-filesystem pair. Even if MustRunAsNonRoot were valid, it only validates that the container runs with a non-zero UID, and it does nothing to prevent container processes from modifying the root filesystem.