Course contentsShow
← Security
Lesson 1970 of 3,05239. Cloud Security - Compute and ServerlessFree lesson

Pod Security Standards and Policies

Understand Pod Security Standards (privileged, baseline, restricted) and how to enforce security contexts and capabilities.

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 as
  • allowPrivilegeEscalation: Whether processes can gain more privileges
  • readOnlyRootFilesystem: Force read-only filesystem
  • capabilities: Add or drop Linux capabilities (like NET_ADMIN, SYS_TIME)
securityContext:
  runAsNonRoot: true
  runAsUser: 1000
  allowPrivilegeEscalation: false
  capabilities:
    drop: ["ALL"]

Enforcement Methods

You enforce these standards using:

  1. Pod Security Admission (built-in): Enforces PSS levels per namespace
  2. Security Context constraints: Define what pods can request
  3. 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.