☸️Basic Kubernetes Security Labs
🎯 Objective
🧰 Prerequisites
🔹 Lab 1: Run Containers as Non-Root
Step 1: Create the pod spec
# non-root-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: non-root-demo
spec:
containers:
- name: app
image: busybox
command: ["sh", "-c", "id && sleep 3600"]
securityContext:
runAsUser: 1000
allowPrivilegeEscalation: falseStep 2: Apply and check logs
🔹 Lab 2: Drop Linux Capabilities
🔹 Lab 3: Use Read-Only Root Filesystem
🔹 Lab 4: Apply Seccomp and AppArmor (if supported)
🔹 Lab 5: Enforce Policies with Pod Security Admission (PSA)
Step 1: Create secure namespace
Step 2: Try applying an insecure pod
Step 3: Clean up and remove label again
✅ Wrap-Up
Last updated