A team asks to run a privileged pod with a hostPath mount in a shared cluster "just for debugging." How do you enforce policy and respond?
Short answer
Don't approve it in a shared namespace; make the cluster enforce it. Pod Security Admission labels each namespace with a mode (enforce, audit, warn) and a level (privileged, baseline, restricted). The baseline level forbids privileged containers, hostPath volumes, and host namespaces, and restricted adds non-root, allowPrivilegeEscalation=false, dropping ALL capabilities, and a seccomp profile. Roll out with warn and audit, then enforce; enforce is applied to Pods, not to Deployments. Any true exception belongs in a separate namespace at the privileged level.
This scenario tests whether you reach for a cluster-enforced guardrail instead of a one-off approval. A privileged pod with a hostPath mount is, in practice, a way onto the node.
Why the request is risky
The Kubernetes Pod Security Standards say "Privileged Pods disable most security mechanisms and must be disallowed" at the baseline level, and that "HostPath volumes must be forbidden." Sharing host namespaces (hostNetwork, hostPID, hostIPC) is also disallowed at baseline. Allowing all of these together in a shared cluster means one compromised or careless pod can affect the node and its neighbours.
The enforcement mechanism
Pod Security Admission is configured with namespace labels of the form pod-security.kubernetes.io/<MODE>: <LEVEL>. The modes are enforce (violating pods are rejected), audit (an audit annotation is recorded, but the pod is allowed) and warn (a user-facing warning, but allowed). The levels are privileged (unrestricted, "allows known privilege escalations"), baseline ("prevents known privilege escalations") and restricted (current hardening best practice: non-root, allowPrivilegeEscalation: false, drop ALL capabilities, and a RuntimeDefault or Localhost seccomp profile).
Rolling it out safely
Start with warn and audit to see what would break, fix workloads, then switch on enforce. Remember that audit and warn also apply to workload resources like Deployments, but enforce is applied only to the resulting pods, so a Deployment can exist while its pods are rejected.
Why the distractors fail
- Approve it: debugging intent is not a control.
- Privileged level cluster-wide: that level is the unrestricted one; "prevents known privilege escalations" describes baseline.
- Deployment-level check: enforce acts on pods, not on the Deployment.
What interviewers want
Policy as namespace labels, a staged warn → audit → enforce rollout, and any real exception isolated in its own namespace at the privileged level with tight control over who can create pods there.
Likely follow-ups
- What exactly do the baseline and restricted levels forbid, and which would you pick for a typical web workload?
- Why can a Deployment be created successfully even though its pods are then rejected under enforce mode?
- How would you handle a node-level monitoring agent that legitimately needs host access?