What are Pod Security Standards and Pod Security Admission?

Pod Security Standards are three policy levels that Kubernetes defines for a Pod’s security settings: Privileged, which restricts nothing, Baseline, which blocks known privilege escalations such as privileged containers, host namespaces and hostPath volumes, and Restricted, which also requires non-root users, dropped capabilities and a seccomp profile. Pod Security Admission is the built-in admission controller that enforces these levels per namespace, configured with namespace labels. It has been stable since Kubernetes 1.25, the release that removed its predecessor, PodSecurityPolicy.

From PodSecurityPolicy to Pod Security Admission

PodSecurityPolicy was deprecated in Kubernetes 1.21 and removed in 1.25. It let administrators write custom policies, bind them to users through RBAC and change Pods to fit the policy, a combination that made it hard to tell which policy applied to a given Pod.

Pod Security Admission is deliberately simpler. It was alpha in 1.22, enabled by default as beta in 1.23 and generally available in 1.25. It offers only the three fixed levels, applies them per namespace, and only validates: it rejects or warns, but never changes a Pod. Anything beyond that belongs to a policy engine, covered at the end of this article.

The three levels

The Pod Security Standards are cumulative, so Restricted includes everything in Baseline.

LevelIntended forWhat it requires
PrivilegedSystem and infrastructure workloads run by trusted administrators, such as CNI and storage agentsNothing. Pods may use the host network, host paths and privileged mode
BaselineCommon application workloadsNo privileged: true, no host network, PID or IPC namespaces, no hostPath volumes, no host ports, no capabilities beyond a default list, no Unconfined seccomp or AppArmor, no custom SELinux users or roles, only a safe set of sysctls
RestrictedSecurity-critical applications and lower-trust workloadsBaseline, plus runAsNonRoot: true, no runAsUser: 0, allowPrivilegeEscalation: false, seccomp set to RuntimeDefault or Localhost, all capabilities dropped with only NET_BIND_SERVICE allowed back, and only these volume types: ConfigMap, CSI, downward API, emptyDir, ephemeral, PersistentVolumeClaim, projected and Secret

A Pod with no security settings at all passes Baseline, which the standard describes as allowing “the default (minimally specified) Pod configuration”. The same Pod fails Restricted, because Restricted requires settings to be explicit. A container that passes Restricted looks like this:

yaml
spec:
  securityContext:
    runAsNonRoot: true
    seccompProfile:
      type: RuntimeDefault
  containers:
  - name: api
    image: registry.example.com/api@sha256:...
    securityContext:
      allowPrivilegeEscalation: false
      capabilities:
        drop: ["ALL"]

The image must also run as a non-root user, either through a numeric USER in the Dockerfile or runAsUser in the Pod. If the image only names a user, such as USER app, the kubelet cannot verify that it is non-root and refuses to start the container.

Modes and namespace labels

Each namespace can set a level for three modes, independently:

ModeEffect of a violation
enforceThe Pod is rejected
auditThe Pod is allowed and an annotation is added to the audit log event
warnThe Pod is allowed and the client, such as kubectl, shows a warning

The labels are pod-security.kubernetes.io/<mode>: <level>, with an optional pod-security.kubernetes.io/<mode>-version that pins the rules to a Kubernetes minor version, so an upgrade does not tighten them unexpectedly:

yaml
apiVersion: v1
kind: Namespace
metadata:
  name: shop
  labels:
    pod-security.kubernetes.io/enforce: baseline
    pod-security.kubernetes.io/enforce-version: v1.34
    pod-security.kubernetes.io/warn: restricted
    pod-security.kubernetes.io/audit: restricted

One behavior surprises most teams. warn and audit check Deployments, Jobs and other workload resources, but enforce checks only the Pods they create. A Deployment that violates the enforced level is accepted, and its ReplicaSet then fails to create Pods. The error appears as a FailedCreate event on the ReplicaSet, not on the kubectl apply. Setting warn to the same level as enforce surfaces the problem at apply time.

How to roll it out

  1. Preview the impact. A server-side dry run reports which existing Pods would violate a level, without changing anything: kubectl label --dry-run=server --overwrite ns --all pod-security.kubernetes.io/enforce=baseline.
  2. Label every namespace with warn and audit at the level you are aiming for, then fix the workloads that show up.
  3. Turn on enforce namespace by namespace, starting with Baseline for application namespaces and Restricted where workloads already comply.
  4. Leave infrastructure namespaces, such as kube-system, at Privileged, and limit who can deploy there with RBAC.

Namespaces without labels fall back to the cluster default, which is Privileged unless an administrator sets other defaults in the API server’s admission configuration. The same file defines exemptions by user name, RuntimeClass or namespace. Managed services do not always expose that file, in which case namespace labels are the only lever, and a policy engine can require them on every new namespace.

When you need a policy engine

Pod Security Admission covers the Pod spec fields in the table above and nothing else. It cannot:

  • Allow an exception for one workload; exemptions apply to whole namespaces, users or runtime classes.
  • Enforce rules outside those fields, such as allowed registries, required labels or resource limits.
  • Set safe defaults on a Pod instead of rejecting it.
  • Check that an image is signed by your build pipeline.

Kubernetes has two built-in options for custom rules, both written in CEL: ValidatingAdmissionPolicy, stable since 1.30, and MutatingAdmissionPolicy, stable since 1.36. The Kubernetes documentation also lists Kyverno, OPA Gatekeeper and Kubewarden as policy engines that can enforce the standards and much more. A common setup keeps Pod Security Admission as the floor on every namespace and uses a policy engine for everything else, including verifying image signatures at admission.

Pod Security is one layer of isolation. For tenants that share a cluster, combine it with the controls in Kubernetes multi-tenancy. For untrusted code, the standards say there is no agreed definition of a sandboxed Pod, so add a sandboxed runtime as described in how to isolate untrusted workloads.

Pod security on Cloudfleet

The Kata Containers guide for Cloudfleet Kubernetes Engine (CFKE) shows a Deployment that combines a hardened security context, running as non-root with all capabilities dropped and the RuntimeDefault seccomp profile, with a micro VM runtime for untrusted code.

On this page