ExamPilot Global home

CKS lab · Validate a Restricted workload manifest

A team wants a lintable baseline before submitting a test Pod to a Restricted namespace.

ExamPilot graduation owl

Initial conditions

Use a disposable ep-sec namespace labeled for Restricted enforcement. Use an image that supports a non-root UID.

Objective

Specify non-root execution, seccomp, dropped capabilities and disabled privilege escalation.

Hint

Place the container-specific controls under the container securityContext.

Solution manifest

apiVersion: v1
kind: Pod
metadata:
  name: hardened-demo
spec:
  securityContext:
    runAsNonRoot: true
    runAsUser: 10001
    seccompProfile:
      type: RuntimeDefault
  containers:
  - name: task
    image: busybox:1.36
    command: ["sleep", "60"]
    securityContext:
      allowPrivilegeEscalation: false
      capabilities:
        drop: ["ALL"]

Solution commands

kubectl -n ep-sec apply --dry-run=server -f hardened-pod.yaml

Validate the result

kubectl -n ep-sec apply --dry-run=server -f hardened-pod.yaml -o jsonpath="{.spec.securityContext.runAsUser}"

The server should accept UID 10001 and the required controls. A successful admission check does not establish application compatibility.

Common mistakes

An image that writes to a root-owned directory may still fail at runtime. Validate the actual image separately.

Free official documentation · Verified 26 November 2026

Use your own disposable Kubernetes environment.