SaveMyCert
Log in
5 of 5 free questions left today·for 10 a day
Kubernetes Security Fundamentals

KCSA Pod Security Standards and Pod Security Admission

17 min readKCSA · Kubernetes Security FundamentalsUpdated

The Pod Security Standards are three Kubernetes security profiles, Privileged, Baseline and Restricted, that define which Pod settings are acceptable, and Pod Security Admission is the built-in admission controller that enforces them per namespace through labels. This lesson covers what each profile allows and forbids, how the enforce, audit and warn modes behave, how namespace labels, version pins, cluster defaults and exemptions work, how to roll out a stricter level without breaking workloads, and how to migrate from the removed PodSecurityPolicy.

What you’ll learn
  • Match the Privileged, Baseline and Restricted profiles to their intended audiences and tell a profile apart from a Pod's securityContext
  • Identify which Pod settings Baseline forbids and which additional controls Restricted requires, including Pod-level inheritance and allowed volume types
  • Predict the outcome of a Pod or workload request under any combination of enforce, audit and warn labels
  • Configure namespace labels, version pins and AdmissionConfiguration defaults, and explain why Namespace update rights control the level
  • Choose the right exemption (username, RuntimeClass or namespace) and avoid exempting controller service accounts
  • Plan a safe rollout with a server-side dry run, an audit soak and version pinning across upgrades
  • Explain how Pod Security Admission differs from PodSecurityPolicy and what breaks when migrating

What Pod Security Standards and Pod Security Admission are

The Pod Security Standards are three named security profiles (Privileged, Baseline and Restricted) that define which Pod settings are acceptable, and Pod Security Admission is the built-in Kubernetes admission controller that checks Pods against those profiles, namespace by namespace. The standards are the rulebook; Pod Security Admission is the referee in the API server that applies it.

Pod Security Admission is implemented by the PodSecurity admission plugin. It became stable in Kubernetes v1.25, the same release that removed PodSecurityPolicy, and it is enabled by default. It runs in the kube-apiserver during validating admission, after authentication and authorization, so a Pod it rejects is never stored, scheduled or started on a node.

Two things are easy to confuse here: the profiles and the Pod's own securityContext.

securityContextPod Security Standards profile
What it isFields in the Pod spec (Pod level and container level)A named policy level: privileged, baseline or restricted
Who acts on itThe kubelet and container runtime, which turn the fields into runtime parametersThe control plane (Pod Security Admission in the API server), which accepts or rejects the Pod
What it doesConfigures how the containers actually run (user, capabilities, seccomp and so on)Requires or forbids particular securityContext values and other Pod fields

The profiles never set or change anything. They are not defaults, the kubelet does not apply them, and setting a field explicitly does not escape them: the explicit value is exactly what admission evaluates. (How each securityContext field behaves at runtime belongs to the Pod security topic in the Cluster Component Security domain; this lesson covers which values the profiles allow.)

The Privileged, Baseline and Restricted profiles

The three profiles run from fully open to heavily hardened, and each is aimed at a different audience. They are cumulative: Restricted contains every Baseline control plus more, and Privileged contains none.

ProfileWhat it allowsIntended for
PrivilegedEverything. It is defined by the absence of restrictions and permits known privilege escalationsSystem and infrastructure workloads managed by privileged, trusted users, such as node agents, CNI plugins and storage drivers
BaselineA minimally restrictive policy: it blocks known privilege escalations but admits the default, minimally specified PodEase of adoption for common containerized workloads; developers and operators of non-critical applications
RestrictedHeavily restricted: it applies current Pod hardening best practice, at the cost of some compatibilitySecurity-critical applications and lower-trust users

Choosing a profile is choosing by audience and need. A workload that genuinely needs host networking or privileged containers can only run under Privileged, so it should live in a namespace of its own that only trusted administrators can deploy to. Baseline is the sensible floor for ordinary application namespaces, and Restricted is the target for anything security-critical. A namespace that is not labelled and has no cluster default is effectively Privileged (see the section on labels and defaults).

What the Baseline profile forbids

Baseline forbids the Pod settings that give a container a known path to the node: host namespaces, privileged mode, extra capabilities, hostPath volumes and a few related escape hatches. A Pod that sets none of these fields passes, which is why Baseline is easy to adopt.

Baseline controlWhat is allowed
Host namespacesspec.hostNetwork, hostPID and hostIPC must be unset or false
Privileged containerssecurityContext.privileged must be unset or false (Windows HostProcess containers are also disallowed)
CapabilitiesContainers may only add capabilities from the default set: AUDIT_WRITE, CHOWN, DAC_OVERRIDE, FOWNER, FSETID, KILL, MKNOD, NET_BIND_SERVICE, SETFCAP, SETGID, SETPCAP, SETUID and SYS_CHROOT. Adding anything else, such as NET_ADMIN or SYS_ADMIN, is a violation
hostPath volumesForbidden, because they expose the node's filesystem to the container
Host portshostPort must be unset or 0. The standard also permits a known list of ports, but the built-in Pod Security Admission controller does not support one
Host probes and lifecycle hooksFrom v1.34, the host field of httpGet and tcpSocket probes and lifecycle hooks must be unset or empty, so a probe cannot be pointed at another host
SeccompThe profile may not be explicitly set to Unconfined (leaving it unset is fine under Baseline)
AppArmor, SELinux, /proc mount, sysctlsAppArmor may not be overridden to unconfined; SELinux may only use a short list of container types (such as container_t) and may not set a custom user or role; procMount must stay Default; only a safe subset of sysctls is allowed

Just as important is what Baseline does not check: it lets a container run as root (user ID 0), leaves allowPrivilegeEscalation alone, does not require a seccomp profile, and does not restrict ordinary volume types. Those are Restricted controls. NET_ADMIN is the classic trap: it sounds like a networking convenience, but it lets a container change interfaces, routes and firewall rules, so it is outside Baseline's allowed set, while capabilities that sound powerful, such as KILL or CHOWN, are in it.

What the Restricted profile adds

Restricted keeps every Baseline control and adds hardening that a Pod must usually declare explicitly: a non-root user, no privilege escalation, an explicit seccomp profile, dropping all capabilities and a short list of volume types. Because several of these require a field to be present, a default Pod fails Restricted.

Restricted controlRequirementUnset passes?
Privilege escalationallowPrivilegeEscalation must be false on every containerNo: it must be set
Running as non-rootrunAsNonRoot: true, set at Pod level or on every containerNo: it must be set at one of the two levels
Non-root user IDrunAsUser must not be 0Yes: it may be left unset
SeccompThe profile must be explicitly RuntimeDefault or Localhost, at Pod level or on every containerNo: it must be set
CapabilitiesEvery container must drop ALL, and may add back only NET_BIND_SERVICENo: the drop must be present
Volume typesOnly configMap, csi, downwardAPI, emptyDir, ephemeral, persistentVolumeClaim, projected and secretNot applicable

Pod level covers the containers. A runAsNonRoot: true or seccompProfile set in the Pod's securityContext applies to every container that does not override it, so the containers do not need to repeat it. allowPrivilegeEscalation and capabilities exist only at container level, so each container must set them.

The volume check reads the Pod's own volume types. An in-tree volume declared inline in the Pod spec, such as iscsi or hostPath, fails Restricted because its type is not on the list. A persistentVolumeClaim is on the list, and admission evaluates only the claim, not the PersistentVolume or storage that is bound to it.

Good hardening is not always a profile control. A setting that no profile checks can make a container safer without changing the admission result: a Pod is admitted or rejected only on the controls listed in these tables, so fixing a rejection means supplying the specific control that failed. Three Restricted controls (privilege escalation, seccomp and capabilities) are Linux-specific and are not required for Pods that declare spec.os.name: windows.

The enforce, audit and warn modes

Pod Security Admission has three modes, and each one decides what happens when a Pod violates the level set for that mode: enforce rejects it, audit records it, and warn tells the user. A namespace can set any combination of them, each at its own level.

ModePod that violates the levelWho sees it
enforceRejected; the create request failsThe requesting client gets an error
auditAllowed; an annotation is added to the request's event in the API server audit logWhoever reviews the audit log; the developer sees nothing
warnAllowed; a warning is returned to the client (kubectl prints it)The requesting client; nothing is stored

The modes are evaluated independently. Each mode compares the Pod only with its own level. Take a namespace with enforce: privileged, warn: baseline and audit: restricted, and a Pod that meets Baseline but leaves out allowPrivilegeEscalation: enforce admits it (nothing violates Privileged), warn is silent (Baseline does not check that field) and audit annotates the event (Restricted requires it). Enforcing one level while warning and auditing a stricter one is the documented way to prepare a namespace for tightening.

Two practical limits: audit annotations exist only if the cluster has API server audit logging enabled (configuring audit policy is covered in the authentication, Secrets and audit logging lesson), and a label at the Privileged level never fires in any mode, because nothing violates Privileged. Pod Security Admission never mutates a Pod: it can allow, reject, warn or annotate, but it never changes a field such as hostPID to make a Pod pass.

Namespace labels, versions and cluster-wide defaults

Each namespace chooses its levels with labels on the Namespace object of the form pod-security.kubernetes.io/<MODE>: <LEVEL>, where the key names the mode (enforce, audit or warn) and the value names the level (privileged, baseline or restricted). For example, pod-security.kubernetes.io/enforce: baseline rejects Pods that fail Baseline.

apiVersion: v1
kind: Namespace
metadata:
  name: payments
  labels:
    pod-security.kubernetes.io/enforce: restricted
    pod-security.kubernetes.io/enforce-version: v1.36
    pod-security.kubernetes.io/warn: restricted
    pod-security.kubernetes.io/warn-version: latest

Only Namespace labels count. The same label on a Deployment, Pod or any other object is accepted (any object can carry labels) but has no effect on admission. Namespaces do not inherit levels from each other either: every namespace is labelled on its own or falls back to the cluster default.

Version labels pin the rules. The optional pod-security.kubernetes.io/<MODE>-version label takes a Kubernetes minor version such as v1.36, or latest (the default). A pinned version evaluates Pods against the level as it was defined in that release, which matters because profiles can gain checks in new releases. It has nothing to do with the client's version, and enforcement does not stop after an upgrade; the label only chooses which definition of the level applies. The value is a version, never a level.

Cluster defaults cover unlabelled namespaces. The PodSecurity plugin's configuration in the API server's AdmissionConfiguration file (passed with --admission-control-config-file) has a defaults block setting enforce, audit and warn and their versions. Those defaults apply to every namespace that has no label for that mode; they cannot target chosen namespaces. A namespace label for a mode replaces the default for that mode, even if the label is less strict: with a default of enforce: baseline, a namespace labelled enforce: privileged enforces Privileged. If nobody sets defaults, upstream Kubernetes uses privileged at latest for all three modes, so a new unlabelled namespace has no Pod restrictions at all. That is why namespace creation processes or cluster defaults must apply a real level.

Whoever can edit the Namespace controls its level. Because the level is just a label, any subject with update or patch on a Namespace (or create on namespaces, for new ones) can change it, including to privileged. Labels are part of the Namespace object, so RBAC cannot grant edit rights on the object while withholding its labels. Reviewing those permissions, and guarding the pod-security labels with an admission webhook where tenants must edit their namespaces, is part of using Pod Security Admission safely. RoleBindings and Pod create rights do not touch the level.

Workload resources and controller-created Pods

Enforce mode checks only Pod objects, while audit and warn also check workload resources such as Deployments, ReplicaSets, StatefulSets, Jobs and CronJobs by evaluating their Pod templates. This split explains most surprising results.

  • A violating Deployment is still created. Under enforce alone, kubectl apply of a Deployment whose template breaks the level succeeds silently. The rejection happens later, when the ReplicaSet controller asks the API server to create each Pod. Those requests are denied, no Pods appear, and the controller records FailedCreate events on the ReplicaSet (or on the Job, for Job-managed Pods). The Pods never exist, so there are no Pod events and nothing reaches a node or the kubelet.
  • Warn on a template gives early feedback. With a warn label, kubectl prints a warning when the Deployment is applied, because warn evaluates the template. When warn and enforce share a level, the same violation shows up twice: with both at baseline, a StatefulSet whose template sets hostNetwork: true prints a warning at apply time, the StatefulSet is still created, and then each Pod its controller requests is rejected.
  • Warnings go to whoever made the request. For Pods created by a controller, the requester is the controller, so a warning about those Pods is returned to the controller and nobody reads it. Warnings are not stored as events. Audit annotations, by contrast, are kept in the audit log no matter who made the request.

Exemptions: usernames, RuntimeClasses and namespaces

Pod Security Admission exemptions are configured statically in the exemptions block of the PodSecurity plugin's configuration in the API server's AdmissionConfiguration, and a request that matches one skips enforce, audit and warn entirely. They are not set with RoleBindings, kubelet configuration or a ValidatingAdmissionPolicyBinding, and changing the file means restarting the API server to load it.

Exemption listMatchesScope and risk
usernamesRequests made by the listed authenticated usersMatches the requester, not the Pod. Most Pods are requested by controllers, so exempting a person or CI account does not exempt the Pods their Deployments create
runtimeClassesPods and workload resources that set a listed runtimeClassNamePrecise: exempts Pods by how they run (for example a sandboxed runtime such as gVisor) while their neighbours in the same namespace stay checked
namespacesEverything in the listed namespacesBroad: every Pod in the namespace skips the checks

Never exempt a controller's service account. Controllers such as the ReplicaSet, Job and DaemonSet controllers create Pods on behalf of everyone who can create the matching workload, so exempting their service accounts would in effect exempt all of those users. Kubernetes advises against it. For workloads that genuinely need privileged settings, isolating them is usually better than exempting them: a namespace labelled at the Privileged level, where only trusted administrators can deploy, keeps the exception visible in the namespace's labels and leaves every other namespace enforced.

Rolling out a stricter level safely

The safe way to tighten a namespace is to find violations first (with a server-side dry run, then an audit or warn soak) and enforce only once they are fixed. Enforcing first turns discovery into an outage.

  1. Check running Pods with a server-side dry run. When an enforce label or enforce version is added or changed, the API server evaluates the namespace's existing Pods against the new level and returns warnings for violators. It does not evict them. Because the check runs inside the API server, a server-side dry run triggers it while discarding the change, for example kubectl label --dry-run=server --overwrite ns reporting pod-security.kubernetes.io/enforce=restricted. The warnings list each existing Pod that would fail, and the namespace keeps its current labels.
  2. Soak with audit (and warn). A dry run checks only the Pods that exist at that moment. CronJob Pods that run at night and Deployments scaled to zero are invisible to it. Setting audit (and usually warn) to the target level for a period evaluates every Pod and workload request created during the soak and records violations in the audit log without blocking anything. Audit is the reliable record, since warnings for controller-created Pods go only to the controller.
  3. Enforce. Once the dry run and the soak are clean, set enforce to the target level.

Upgrades without surprises. To keep enforcement at full strength across a Kubernetes upgrade while still learning about checks the new release adds, pin enforce-version to the current release and set warn (or audit) to the same level at latest. Admission decisions stay identical, the warnings reveal workloads that would fail the newer definition, and the enforce pin is moved forward once they are fixed.

Migrating from PodSecurityPolicy

PodSecurityPolicy (PSP) was deprecated in Kubernetes v1.21 and removed in v1.25, and its built-in replacement is Pod Security Admission, implemented by the PodSecurity admission plugin. The two work very differently, which is where migrations break.

PodSecurityPolicy (removed)Pod Security Admission
Policy definitionCustom cluster-scoped PSP objects with many fieldsThree fixed profiles from the Pod Security Standards
Who a policy applies toUsers and service accounts authorized with the RBAC use verb on a policyEverything in a namespace, chosen by Namespace labels; no per-user or per-service-account targeting
MutationCould default fields (for example defaultAllowPrivilegeEscalation, default capabilities)Non-mutating: validates only
GranularityFine-grainedCoarser: a level per mode per namespace, plus static exemptions

Defaulting is the classic break. Workloads whose manifests never set a field because a PSP filled it in will be rejected once that PSP is gone. If a policy defaulted allowPrivilegeEscalation: false, Pods from the same manifests now arrive without it and fail Restricted. The migration guide's answer is to stop relying on purely mutating PSP fields: put the values in the manifests (or add a mutating webhook) before switching. There is no step that converts old policies into labels; the namespace labels alone decide the level.

A typical migration reviews who can create, update or patch namespaces (they can change the level), removes reliance on PSP mutation, picks a level per namespace and checks it with a server-side dry run and an audit/warn soak, then enforces. Requirements PSA cannot express, such as per-user rules or mutation, are handled by external policy engines or ValidatingAdmissionPolicy, which belong to the platform security domain.

Other admission plugins are not replacements. Pod Security Admission is the only built-in plugin that enforces the Pod Security Standards. The older SecurityContextDeny plugin was a limited stopgap rather than a replacement for PSP, and it was removed in v1.30.

Tip. KCSA questions on this topic are short definitions and scenarios. Expect to match profiles to audiences, decide whether a particular Pod setting violates Baseline or only Restricted, and spot the missing fields in a rejected manifest, including whether a Pod-level setting already covers the containers. Mode questions combine labels and ask what the developer sees, what is recorded and whether the Pod or workload is created. Others test label syntax and version pins, how cluster defaults and namespace labels interact, which exemption fits a requirement, how to check a level before enforcing it, and what changed when PodSecurityPolicy was removed. Distractors are usually real controls that belong to a different profile, mode or mechanism.

Key takeaways
  • Privileged has no restrictions (trusted infrastructure), Baseline blocks known privilege escalations but admits default Pods, and Restricted applies current hardening for security-critical workloads.
  • Baseline forbids host namespaces, privileged containers, adding capabilities outside the default set (such as NET_ADMIN), hostPath volumes and an Unconfined seccomp profile; it allows root.
  • Restricted adds allowPrivilegeEscalation: false, runAsNonRoot, runAsUser not 0, an explicit RuntimeDefault or Localhost seccomp profile, drop ALL (add back only NET_BIND_SERVICE) and a short list of volume types.
  • A securityContext configures the runtime; a profile is a control-plane rule about which values are accepted. Pod Security Admission never mutates a Pod.
  • enforce rejects, audit annotates the audit log, warn returns a client warning; each mode is evaluated independently at its own level.
  • Levels are pod-security.kubernetes.io/<MODE>: <LEVEL> labels on the Namespace only; -version labels pin a release's definition or track latest.
  • Unlabelled namespaces fall back to AdmissionConfiguration defaults, which are privileged unless set; a namespace label overrides the default for that mode.
  • enforce checks only Pods, so a violating Deployment is created and its ReplicaSet records FailedCreate events; audit and warn also check Pod templates.
  • Exemptions (usernames, runtimeClasses, namespaces) live in the API server's AdmissionConfiguration; never exempt controller service accounts.
  • Roll out with kubectl label --dry-run=server, then an audit soak (dry runs miss CronJobs and scaled-to-zero workloads), then enforce; PSP was removed in v1.25 and PSA is its non-mutating replacement.

Check yourself: 3 questions on this topic

Exam-style KCSA questions on Pod Security Standards and Pod Security Admission, answered right here with an explanation after each. Want more? KCSA Kubernetes Security Fundamentals practice questions.

Frequently asked questions

What is the difference between the Baseline and Restricted Pod Security Standards?

Baseline is a minimally restrictive Kubernetes profile that blocks known privilege escalations, such as privileged containers, host namespaces, hostPath volumes and extra capabilities, while still admitting a default Pod. Restricted includes every Baseline control and adds hardening a Pod must declare: allowPrivilegeEscalation set to false, running as non-root, an explicit RuntimeDefault or Localhost seccomp profile, dropping ALL capabilities and using only allowed volume types. Baseline allows a container to run as root; Restricted does not.

What do the enforce, audit and warn modes of Pod Security Admission do?

In Kubernetes Pod Security Admission, enforce rejects a Pod that violates the namespace's enforce level, audit allows it but adds a violation annotation to the API server audit log event, and warn allows it but returns a warning to the client, which kubectl prints. Each mode has its own level and is evaluated independently, so a namespace can enforce Baseline while warning and auditing against Restricted.

Why is my Deployment created but no Pods appear under Pod Security Admission?

Pod Security Admission's enforce mode checks only Pod objects, not Deployments or other workload resources. The Deployment and its ReplicaSet are created normally, then the API server rejects each Pod the ReplicaSet controller tries to create, and the controller records FailedCreate events on the ReplicaSet. Adding a warn label at the same level makes kubectl warn about the Pod template at apply time.

What Pod Security level applies to a namespace with no pod-security labels?

A Kubernetes namespace without pod-security.kubernetes.io labels uses the defaults set for the PodSecurity plugin in the API server's AdmissionConfiguration. If no defaults are configured, upstream Kubernetes uses privileged at version latest for enforce, audit and warn, so the namespace places no restrictions on Pods. A label on the namespace overrides the default for that mode.

How do I exempt Pods from Pod Security Admission?

Pod Security Admission exemptions are configured statically in the exemptions block of the PodSecurity plugin configuration in the API server's AdmissionConfiguration file, with three lists: usernames, runtimeClasses and namespaces. A matching request skips enforce, audit and warn. Kubernetes advises against exempting controller service accounts, because that exempts anyone who can create the matching workload; a runtimeClasses exemption or a dedicated Privileged namespace is usually narrower.

How can I test a Pod Security level before enforcing it?

Run kubectl label with --dry-run=server and --overwrite to propose the pod-security.kubernetes.io/enforce label on the namespace: the API server evaluates the existing Pods and returns warnings without saving the label. Because a dry run sees only Pods that exist at that moment, also set audit (and warn) to the target level for a soak period to catch CronJob Pods and scaled-to-zero workloads, then enforce.

What replaced PodSecurityPolicy in Kubernetes?

PodSecurityPolicy was deprecated in Kubernetes v1.21 and removed in v1.25, and the built-in replacement is Pod Security Admission, implemented by the PodSecurity admission plugin, which enforces the Pod Security Standards from namespace labels. Unlike PSP it never mutates Pods and cannot target individual users or service accounts, so workloads that relied on PSP defaulting must set those fields themselves before migrating.

Who can change the Pod Security level of a namespace?

Any user or service account with update or patch permission on a Namespace object, or create permission on namespaces for new ones, can change its pod-security.kubernetes.io labels and therefore its Pod Security level, including setting it to privileged. Reviewing those RBAC permissions, or guarding the labels with an admission webhook, is a required step when relying on Pod Security Admission.

Source

This lesson covers the "Kubernetes Security Fundamentals" domain of the official KCSA exam guide. Vendors revise their guides — check the source for the current version.

Sign up free to mark lessons complete, bookmark topics and track your exam readiness.

Spotted a mistake in this lesson?