Skip to main content
In this tutorial, you’ll learn how to troubleshoot a Deployment script that skips full manifest updates and how to enable a read-only root filesystem in your container without breaking writable paths like /tmp.

Table of Contents


Problem Overview

You’ve added readOnlyRootFilesystem: 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

After applying:

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

This script never picks up any YAML changes besides the image tag.

Quick Workaround: Always Apply Manifest

Always applying the full manifest will restart pods and may cause brief downtime. Plan for rolling updates.
After pushing this change, pods now crash with:
Since /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.

Applying the Updated Manifest

Verification Steps

Best Practices

References

Watch Video