Skip to main content
Gatekeeper and Kyverno are powerful admission controllers, but both require installing extra tooling. Pod Security Standards (PSS) are built into Kubernetes and let cluster administrators enforce security baselines at the namespace level without deploying operators or CRDs. PSS provides three predefined profiles and three enforcement modes. Use PSS when you want a simple, auditable, label-driven way to validate or block Pod specs at admission time.

Pod Security profiles and modes

The image shows a webpage from the Kubernetes documentation discussing Pod Security Standards. It outlines different policy levels: Privileged, Baseline, and Restricted, with a navigation sidebar on the left.
You can review the exact checks and rationale for each profile in the Kubernetes Pod Security Standards documentation.
The image shows a webpage from the Kubernetes documentation discussing baseline security policies for containerized workloads, with a focus on managing Windows Pods and HostProcess configurations.
Pod Security Standards are label-driven: a namespace’s enforcement behavior is determined solely by labels on that namespace (for example pod-security.kubernetes.io/enforce=baseline). Labels make policy auditable and easily reversible.
Applying or changing PSS labels requires permission to modify namespaces (typically cluster-admin). Test changes in a non-production cluster or dedicated namespaces before rolling higher-level enforcement.

Typical workflow

The common progression is:
  • Inspect namespaces and labels.
  • Label a namespace with PSS modes (warn/audit first to surface issues).
  • Attempt non-compliant workloads to capture warnings/audit entries.
  • Fix workloads to meet the profile.
  • Switch to enforce when ready to block non-compliant Pods.
Follow the steps below.
  1. Check current namespaces and labels
Example output (trimmed):
  1. Label a namespace to enforce the baseline profile but also audit/warn the restricted profile so you can see what would fail under stricter rules:
  1. Create a Pod that violates baseline to see the enforcement behavior
Save this as privileged-pod.yaml:
Apply it into pss-baseline:
You will see an error because baseline forbids host namespaces and privileged containers:
  1. Try a standard nginx Pod that baseline will admit but restricted will warn on
Use kubectl run for a quick test:
Admission will allow the Pod but print warnings (because pss-baseline has warn/audit for restricted):
These warnings let you discover which fields to add to meet the stricter profile without blocking workloads.
  1. Enforce the restricted profile on another namespace and observe rejections
Label pss-restricted to enforce:
Try to run the same nginx image there:
Since restricted is in enforce mode, creation is blocked and the required corrections are listed:
  1. Example Pod that complies with restricted
Save this as restricted-pod.yaml:
Apply it into the restricted namespace:
The image nginx/nginx-unprivileged:alpine runs as a non-root user and the securityContext fields satisfy the restricted checks.
  1. Use warn mode to discover non-compliant workloads (audit flow)
Create an audit namespace and start in warn mode:
Run a test Pod (baseline is permissive):
If you then change the warn label to restricted and create another Pod, admission prints warnings for restricted violations:
Admission-time output:
You can inspect events to correlate lifecycle events with admission-time messages:
Putting these into pod/container specs is the most common way to resolve restricted violations.

Summary

  • Start with warn and audit modes to safely discover issues.
  • Fix Pod specs (set runAsNonRoot, allowPrivilegeEscalation=false, drop capabilities, set seccompProfile, avoid host namespaces, etc.) until warnings disappear.
  • Switch to enforce for the target profile to block non-compliant workloads.
  • PSS offers a simple, label-driven approach that is easy to audit and reverse without extra operators.
Further reading:

Watch Video

Practice Lab