☸️Kubernetes Pod Security Context Labs
🎯 Objective
🧰 Prerequisites
🔹 Lab 1: Run a Pod as a Non-Root User
# non-root-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: non-root-pod
spec:
securityContext:
runAsUser: 1000
runAsGroup: 3000
fsGroup: 2000
containers:
- name: app
image: busybox
command: ["sh", "-c", "id && sleep 3600"]🔹 Lab 2: Set a Read-Only Root Filesystem
🔹 Lab 3: Drop Linux Capabilities
🔹 Lab 4: Disable Privilege Escalation
🔹 Lab 5: A really Pod Security Context
Key Security Fields
Field
Default
Recommended
Reason
Step 1: Define a really Secure Pod Specification
Step 2: Apply and Verify the Secure Pod
Step 3: Test File System Protection
✅ Summary
🔹 Lab 6: Clean Up
✅ Wrap-Up
Last updated