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.
More on Kubernetes admission control and Pod Security
`Error from server: admission webhook "validate.kyverno.svc-fail" denied the request: policy Deployment/prod/api for resource violation: require-run-as-nonroot`BeginnerPods do not appear, but `kubectl apply` of the Deployment succeededBeginner`pods "api-7d9" is forbidden: violates PodSecurity "restricted:latest": allowPrivilegeEscalation != false, unrestricted capabilities, seccompProfile`BeginnerEnabling `enforce=restricted` on a namespace did not evict the existing non-compliant podsBeginner`Error from server (InternalError): Internal error occurred: failed calling webhook "validation.gatekeeper.sh": ... context deadline exceeded` blocks every deployIntermediateKyverno is down and now the whole cluster, including Kyverno's own namespace, cannot be fixed because writes are rejectedAdvanced