CertGrid CertGrid
Hands-on Lab·Certified Kubernetes Application Developer

securityContext: runAsNonRoot and Capabilities

A securityContext decides who the process is and what it may do, and each setting has a characteristic failure. `runAsNonRoot` against a root image refuses to start at all; `readOnlyRootFilesystem` lets the container start and then breaks its first write; dropping capabilities produces `Operation not permitted` from a command that has always worked. All three are reproduced, with the exact wording.

Configuration and Security Guide 28 of 44 Intermediate

Written against the versions above. `securityContext` exists at two levels and they are not the same set of fields. Pod level takes `runAsUser`, `runAsGroup`, `fsGroup` and `runAsNonRoot`; container level takes those plus `capabilities`, `readOnlyRootFilesystem`, `allowPrivilegeEscalation` and `privileged`. `fsGroup` and `capabilities` are the two that are only available at one level each, and putting either in the wrong place is a silent no-op or a rejection.

Five short-lived Pods in one namespace. Everything here is enforced by the kubelet and the kernel on whichever worker they land on.
Server NameIP AddressOSRolesCPURAMHDD
CKA1001192.168.0.175Ubuntu 26.04 LTSControl Plane Node2 Core4 GB50 GB
CKA1001-NODE01192.168.0.176Ubuntu 26.04 LTSWorker Node2 Core4 GB50 GB
CKA1001-NODE02192.168.0.177Ubuntu 26.04 LTSWorker Node2 Core4 GB50 GB
CKA1001-NODE03192.168.0.178Ubuntu 26.04 LTSWorker Node2 Core4 GB50 GB

Before you start

  1. Who the process is by default

  2. Refusing to run as root

  3. Running as someone specific

  4. A read-only root filesystem

  5. Capabilities

Official sources