A container works locally but fails in Kubernetes with "permission denied" writing to /app/data.

IntermediateHands-onLive debugging tasks
Answer
kubectl exec -it api-xyz -- id                       # uid=10001 (non-root, set by securityContext)
kubectl exec -it api-xyz -- ls -ld /app/data         # owned by root:root
kubectl get pod api-xyz -o jsonpath='{.spec.securityContext}'

Fix: set securityContext.fsGroup: 10001 so mounted volumes are group-owned by the pod, or chown the directory in the Dockerfile. With readOnlyRootFilesystem: true, mount an emptyDir at that path.

Key trick → Locally you ran as root, but the cluster enforces non-root and possibly a read-only root filesystem. Compare id with the directory's owner.

All Real-World Interview questions Roadmap: Interview readiness

More on Live debugging tasks