ExamPilot Global home

CKS lab · Enforce Restricted Pod Security

A new lab namespace needs Pod Security admission enforcement.

ExamPilot graduation owl

Initial conditions

Use a disposable cluster with the built-in PodSecurity admission controller. Create a new namespace ep-sec.

Objective

Apply Restricted enforcement and use a server-side dry run to check that a default test Pod is rejected.

Hint

The namespace label mode must be enforce.

Solution commands

kubectl create namespace ep-sec
kubectl label namespace ep-sec pod-security.kubernetes.io/enforce=restricted
kubectl -n ep-sec run insecure-test --image=busybox:1.36 --dry-run=server -- sleep 10

Validate the result

kubectl get namespace ep-sec --show-labels
kubectl -n ep-sec get pods

The default generated Pod lacks Restricted security settings. The dry run should return an admission error and leave no workload behind.

Common mistakes

Warn reports an issue without blocking it. Existing Pods are not automatically evicted when labels change.

Free official documentation · Verified 26 November 2026

Use your own disposable Kubernetes environment.