K8s pod with a writable /tmp volume

on 2025-03-05 |  1 minute read

Table of Contents

Setup

Basically you need

Example YAML Here’s an example of a pod with a writable /tmp volume using emptyDir:


apiVersion: v1
kind: Pod
metadata:
  name: writable-tmp-pod
spec:
  containers:
  - name: my-container
    image: busybox
    command: ["sleep", "3600"]
    volumeMounts:
    - name: temp-volume
      mountPath: /tmp
      readOnly: false  # Ensure this is false or omitted
  volumes:
  - name: temp-volume
    emptyDir: {}

Debugging Steps

Describe the Pod: Use kubectl describe pod to check for errors or warnings related to volume mounting.

Check Logs: Look at the container logs for any errors related to filesystem access.

Exec into the Pod: Use kubectl exec -it <pod-name> -- /bin/sh to inspect the /tmp directory and its permissions.

References