Pod Security Admission Controller
What you'll learn: How to enforce Pod Security Standards automatically across namespaces using Kubernetes' built-in admission controller.
The Core Idea
You've learned about Pod Security Standards (Privileged, Baseline, Restricted) that define different security profiles. Now it's time to enforce them. The Pod Security Admission Controller is a built-in Kubernetes feature that automatically validates pods against these standards when they're created or updated. It works at the namespace level, letting you apply different security policies to different parts of your cluster.
Think of it like airport security checkpoints: each terminal (namespace) can have different screening levels—some allow everything through (Privileged), some block obvious threats (Baseline), and some apply maximum scrutiny (Restricted).
How It Works
You configure the admission controller by adding labels to your namespaces. These labels specify:
-
Mode: How to enforce the policy
enforce: Block non-compliant podsaudit: Allow but log violationswarn: Allow but show warnings to users
-
Level: Which Pod Security Standard to apply (
privileged,baseline, orrestricted) -
Version: Which Kubernetes version's standards to use (e.g.,
latestorv1.28)
Configuration Example
apiVersion: v1
kind: Namespace
metadata:
name: production
labels:
pod-security.kubernetes.io/enforce: restricted
pod-security.kubernetes.io/audit: restricted
pod-security.kubernetes.io/warn: restricted
This namespace will block any pod that doesn't meet the Restricted standard, while also auditing and warning about violations.
Mix and Match
You can combine modes—for example, enforce Baseline but audit against Restricted to see what would break if you tightened security later.
Key Takeaway: The Pod Security Admission Controller enforces Pod Security Standards at the namespace level using labels, giving you automated, declarative security policies without installing third-party tools.