/tmp.
Table of Contents
- Problem Overview
- Initial Deployment Configuration
- Why
readOnlyRootFilesystemIsn’t Applied - Original Deployment Script Analysis
- Quick Workaround: Always Apply Manifest
- Solution: Mounting an
emptyDirVolume - Applying the Updated Manifest
- Verification Steps
- Best Practices
- References
Problem Overview
You’ve addedreadOnlyRootFilesystem: true to your container’s securityContext, but after deployment, the pod spec doesn’t reflect this change. The Deployment script only updates the image, never reapplies the full YAML, so new securityContext settings are ignored.
Initial Deployment Configuration
Why readOnlyRootFilesystem Isn’t Applied
Because the deployment script checks for an existing Deployment and only runs kubectl set image…, it never reapplies the manifest changes (securityContext, volumes, etc.).
Original Deployment Script Analysis
Quick Workaround: Always Apply Manifest
Always applying the full manifest will restart pods and may cause brief downtime. Plan for rolling updates.
/tmp is on a read-only root, the Spring Boot app can’t create its temp directory.
Solution: Mounting an emptyDir Volume
To provide a writable /tmp while keeping the rest of the filesystem read-only, add an emptyDir volume and mount it at /tmp.
The
emptyDir volume is ephemeral and only persists for the pod’s lifetime. Use a PersistentVolume if you need data durability.