Pod Security Standards and Policies
What you'll learn: How Kubernetes enforces container security through Pod Security Standards and policies that control what privileges containers can request.
What Are Pod Security Standards?
In Kubernetes, pods are the smallest deployable units, and they can request various permissions and capabilities. Pod Security Standards (PSS) are three predefined security profiles that define what's allowed:
- Privileged: No restrictions (effectively "root on the host")
- Baseline: Minimal restrictions preventing known privilege escalations
- Restricted: Heavily restricted, follows hardening best practices
Think of these like security clearance levels: privileged is "full access," baseline is "reasonable limits," and restricted is "need-to-know only."
How Security Contexts Work
A security context defines privilege and access control settings for a pod or container. You can specify:
runAsUser/runAsGroup: Which user/group ID to run asallowPrivilegeEscalation: Whether processes can gain more privilegesreadOnlyRootFilesystem: Force read-only filesystemcapabilities: Add or drop Linux capabilities (likeNET_ADMIN,SYS_TIME)
securityContext:
runAsNonRoot: true
runAsUser: 1000
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
Enforcement Methods
You enforce these standards using:
- Pod Security Admission (built-in): Enforces PSS levels per namespace
- Security Context constraints: Define what pods can request
- Third-party tools (OPA, Kyverno): Custom policy enforcement
Key Takeaway: Pod Security Standards provide three levels of container restriction (privileged, baseline, restricted), enforced through security contexts that control user IDs, capabilities, and privilege escalation to prevent containers from compromising the host system.