Interview Prep/DevSecOps/Kubernetes admission control and Pod Security

App crashes with `EACCES: permission denied, open '/app/cache/x'` after `readOnlyRootFilesystem: true` and non-root were enforced

IntermediateTroubleshootingKubernetes admission control and Pod Security
Answer

Likely causes → The app writes to its image filesystem, which is now read-only, or the directory is owned by root.

Diagnose → kubectl logs, then find write paths: kubectl debug -it pod/api-7d9 --image=busybox --target=api -- ls -ld /app/cache.

Fix → Mount writable emptyDir volumes at the write paths, and set fsGroup if volume ownership matters:

volumeMounts: [{ name: cache, mountPath: /app/cache }]
volumes: [{ name: cache, emptyDir: {} }]

Prevent → Test images with docker run --read-only --user 10001 in CI.

All DevSecOps questions Roadmap: Policy as code

More on Kubernetes admission control and Pod Security