Example Pod with Unsafe Configuration
Below is a Pod manifest that uses an Ubuntu image but grants dangerous privileges:Risky Settings Explained
privileged: true
Grants the container root privileges on the host.runAsUser: 0
Forces the container process to run as the host’s root.CAP_SYS_BOOT
Adds a capability that allows rebooting the host.hostPathvolume
Exposes the host file system, increasing your cluster’s attack surface.
Allowing
privileged containers or hostPath volumes can compromise the security and stability of your entire cluster.Evolution of Pod Security in Kubernetes
Kubernetes originally enforced Pod restrictions through Pod Security Policies (PSP). As of v1.25, PSP was removed in favor of the simpler, namespace-scoped Pod Security Admission (PSA) and Pod Security Standards (PSS), which are now stable.
Pod Security Policies (PSP)
PSP was a cluster-level admission controller that validated each Pod creation request against defined policy objects. If a request violated any rule, it was rejected.Enabling the PSP Admission Controller
On your API server, includePodSecurityPolicy in the admission plugins:
Defining a Basic PSP
A minimal PSP that disallows privileged containers:Creating a More Restrictive PSP
Tighten policies to enforce non-root users, drop capabilities, and restrict volumes:requiredDropCapabilitiesremoves dangerous capabilities by default.defaultAddCapabilitieslets you explicitly add safe capabilities.- Volume types are limited to
persistentVolumeClaim—no host-mounted paths.
Granting PSP Access via RBAC
Even with PSP enabled, you must grant subjects permission to use a specific PSP object.Role for PSP Usage
RoleBinding to a ServiceAccount
Without these RBAC bindings, all Pod creation requests will be denied once the PSP admission plugin is enabled.
Common Challenges with PSP
- Not enabled by default—manual API server configuration is required.
- Complex policy rollout—existing clusters must define PSPs for every use case.
- RBAC overhead—each user or service account needs separate Role and RoleBinding.
- Controller workloads (Deployments, DaemonSets) also require PSP access.
- PSP could mutate Pod specs (e.g., add default capabilities), a feature not carried over to PSA.
Transition to Pod Security Admission (PSA)
Pod Security Admission and Pod Security Standards simplify namespace-level enforcement without PSP’s RBAC complexity or mutating behavior.| Aspect | Pod Security Policy (PSP) | Pod Security Admission (PSA) |
|---|---|---|
| Scope | Cluster-wide | Namespace |
| Lifecycle | Deprecated/Removed (v1.25) | Stable since v1.25 |
| RBAC Complexity | High (Roles & Bindings per PSP) | Lower (Namespace annotations) |
| Mutating Capability | Yes | No |
| Configuration | Custom CRDs | Built-in enforce, audit, warn modes |
Links and References
- Kubernetes Pod Security Admission
- Pod Security Standards
- Kubernetes API Server Admission Controllers
Next Steps
- Migrate legacy PSPs to PSA by annotating namespaces.
- Choose a Pod Security Standard (
restricted,baseline,privileged) per namespace. - Monitor audit events before enforcing stricter policies.