Skip to content

Lesson 4 of 13 · 11m

Pod Security Standards Are the Admission Floor

PSA's privileged, baseline, and restricted levels, the enforce-audit-warn modes on namespace labels, and why existing pods keep their violations.

The guardrail is a namespace label

Pod Security Admission is a built-in admission plugin — beta in 1.23, GA in 1.25, the same release that removed PodSecurityPolicy entirely after four years of deprecation pain. It applies one of three Pod Security Standards to every pod create/update in a namespace:

  • privileged: nothing blocked. For kube-system, CNI agents, kube-proxy — the parts that must be root-adjacent.
  • baseline: the "don't be obviously hostile" floor. Blocks hostNetwork/hostPID/hostIPC, hostPath volumes, privileged: true, hostPort, adding capabilities beyond the baseline set (NET_BIND_SERVICE survives), unsafe sysctls, unmasked /proc, non-default seccomp/AppArmor/SELinux settings.
  • restricted: baseline plus the hardened profile — runAsNonRoot, capabilities drop: ["ALL"] with at most NET_BIND_SERVICE re-added, seccomp required (RuntimeDefault or Localhost), no privilege escalation, and volumes limited to configMap, downwardAPI, emptyDir, ephemeral, persistentVolumeClaim, projected, secret.

You attach levels to namespaces, not clusters:

metadata:
  labels:
    pod-security.kubernetes.io/enforce: restricted
    pod-security.kubernetes.io/audit: restricted
    pod-security.kubernetes.io/warn: restricted

enforce rejects violators at admission. audit logs violations as pod-security.kubernetes.io/audit-violations annotations on the request's audit.k8s.io Event in the API server audit log — not on the pod object. warn returns a client-visible warning (kubectl prints it). enforce-version: v1.32 pins the standard to a Kubernetes minor version instead of latest, so the rules don't shift under you on an API server upgrade.

Violations surface as admission errors naming the exact rules broken:

Error from server (Forbidden): pods "web" is forbidden: violates PodSecurity
"restricted:v1.32": runAsNonRoot != true, allowPrivilegeEscalation != false,
unrestricted capabilities, seccompProfile

That message is the policy's diff — it tells you which fields to add, not just that it failed. enforce-version deserves attention here: restricted:latest tracks the API server's minor version, so pinning pod-security.kubernetes.io/enforce-version: v1.32 keeps the rule set stable while the cluster upgrades under you.

The wrong model: retroactive protection

The failure pattern: someone labels a running namespace enforce: restricted, sees existing pods still running, and declares the cluster hardened. Wrong. PSA is admission control — it fires on pod create and update. Pods that already exist keep running their violations until they are recreated, restarted, or rescheduled. A Deployment's pods only change when something touches the pod spec.

That is exactly why the audit mode exists. The correct rollout order:

  1. audit + warn at your target level on the namespace.
  2. Read the violations out of the API server audit log — the annotation lands on the audit.k8s.io Event there, so kubectl get pods will never show them — and fix the workloads.
  3. Flip enforce on.

Skipping step 2 gives you a deploy outage instead of a migration.

Exemptions and the honest edge cases

Cluster-level exemptions live in the admission-control config file (--admission-control-config-file on the API server) under PodSecurity — you can exempt specific namespaces, usernames, or runtimeClasses. kube-system is the canonical exemption case: kube-proxy needs host networking and elevated caps to program iptables. Don't force kube-system into restricted; label it privileged and treat it as infrastructure.

There's a subtler exemption too: pods exempted by runtimeClasses in the config. And one scope point people miss — PSA evaluates the pod spec being submitted, not the pod's runtime behavior. A pod can pass restricted cleanly and still run hostile code; the standard bounds what the spec may grant, not what the container may attempt. That gap is the dataplane's problem — seccomp, network policy, runtime detection.

What PSA does not cover, because it was never meant to: the node's own filesystem outside the pod spec, service-account token mounting, network reachability, or the content of container images. It bounds the pod spec's privileges. The rest is the next lessons' job.

What to actually do

Label every namespace. enforce: baseline is the floor for anything that isn't infrastructure — hostPath and privileged have no business in an application namespace. restricted for workloads you control the images of. Then add the audit-mode labels one level up (audit: restricted while you enforce: baseline) so the path to hardening is always measured, never guessed.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.