Sub topic 2
Privileged, Baseline, and Restricted: the three profiles
This chapter assumes you can read Pod manifests, know what a namespace is, and have a general idea of Linux users and capabilities. Later chapters cover the exact controls and the admission controller. Here you learn what the three profiles are and how to choose between them.
What the Pod Security Standards are
The Pod Security Standards (PSS) are a fixed set of three security profiles defined by Kubernetes. Each profile is a list of Pod spec fields and the values it allows. The profiles are cumulative. Each one is stricter than the one before it.
The standards only describe policy. A separate component, Pod Security Admission, enforces it. You will meet that component in a later chapter.
The three profiles
| Profile | Intent | Typical use |
|---|---|---|
| Privileged | No restrictions at all | System and infrastructure workloads, such as CNI plugins and storage drivers |
| Baseline | Blocks known privilege escalations, keeps most Pods working unchanged | Most ordinary applications |
| Restricted | Follows current hardening best practice, at some cost in compatibility | Security-sensitive workloads and new applications |
Privileged
Privileged is deliberately open. It allows host namespaces, privileged containers, and any capability. Use it only for trusted components that need deep access to the node. A namespace with this level gives Pods the same power as a process running as root on the node.
Baseline
Baseline aims to stop the most well-known paths from a container to the node while staying easy to adopt. A Pod that does not set any special security fields usually passes. Baseline blocks things such as hostNetwork, hostPID, privileged containers, and hostPath volumes. It also restricts the capabilities a container may add.
Restricted
Restricted adds hardening that Baseline leaves out. Containers must run as a non-root user, use a seccomp profile, forbid privilege escalation, and drop all capabilities. Many existing images fail this profile until you change them, for example an image that runs as root by default.
How the profiles build on each other
Think of the profiles as nested sets. Every Pod that passes Restricted also passes Baseline, and every Pod passes Privileged.
Seeing the difference with two Pods
The next Pod sets only a few fields. It passes Baseline, because nothing in it is on the Baseline block list. It fails Restricted, because it does not set the fields that profile requires.
apiVersion: v1
kind: Pod
metadata:
name: plain-demo
spec:
containers:
- name: app
image: busybox:1.36
command: ["sleep", "3600"]This second Pod uses hostNetwork and a privileged container. Baseline rejects it, and so does Restricted.
apiVersion: v1
kind: Pod
metadata:
name: privileged-demo
spec:
hostNetwork: true
containers:
- name: app
image: busybox:1.36
command: ["sleep", "3600"]
securityContext:
privileged: trueOnly a namespace set to Privileged accepts privileged-demo.
Choosing a profile
Use these questions in order:
- Does the workload need access to the node itself, such as host networking or device access? If yes, it needs Privileged. Put it in its own namespace so that other workloads do not inherit that level.
- Can the workload run as non-root and drop all capabilities? If yes, aim for Restricted.
- Otherwise, use Baseline as a floor and plan to move to Restricted later.
A common pattern is Baseline for the default application namespaces, Restricted for sensitive ones, and Privileged only for system namespaces.
Common mistakes
- Assuming Baseline requires a non-root user. It does not. Only Restricted does.
- Putting a single privileged workload in a shared namespace and setting the whole namespace to Privileged.
- Treating the profiles as customizable. They are fixed. If you need a rule that is not in a profile, you need another policy tool, covered in the last chapter.
Exercise
A Pod runs a stock image as root, sets no securityContext, and uses no host namespaces or hostPath volumes. Which of the three profiles accept it, and why?
Show answer
Privileged and Baseline accept it. Baseline only blocks known escalation paths such as host namespaces, privileged containers, and hostPath volumes, and this Pod uses none of them. Restricted rejects it because it requires a non-root user, a seccomp profile, no privilege escalation, and all capabilities dropped, and the Pod sets none of these.
Exercise
You run a node-level log collector that needs hostPath volumes and hostNetwork. How should you place it so the rest of your workloads stay protected?
Show answer
Put the collector in its own namespace that uses the Privileged profile, and keep application workloads in separate namespaces at Baseline or Restricted. The profile applies to the whole namespace, so sharing one would lower the protection for every Pod in it.