<p>Here is my persistent volume definition</p>
<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: task-pv-volume
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: &quot;/mnt/data&quot;
</code></pre>
<p>Here is my persistent volume claim</p>
<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: task-pv-claim
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 3Gi
</code></pre>
<p>Here is the pod I'm trying to deploy</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: task-pv-pod
spec:
  volumes:
    - name: task-pv-storage
      persistentVolumeClaim:
        claimName: task-pv-claim
  containers:
    - name: task-pv-container
      image: nginx
      ports:
        - containerPort: 80
          name: &quot;http-server&quot;
      volumeMounts:
        - mountPath: &quot;/usr/share/nginx/html&quot;
          name: task-pv-storage
</code></pre>
<p>When I try to deploy the pod using <code>kubectl create -f task-pv-pod.yaml</code>, I get this error</p>
<blockquote>
<p>failed to start container &quot;52c5f707bb90d87b4178e8508d710ae0912d8ee7bdd7c4b9b802bd6b35f266de&quot;: Error response from daemon: error while creating mount source path '/mnt/data': mkdir /mnt/data: read-only file system: RunContainerError</p>
</blockquote>
<p>I am following this guide <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/</a>, I have another pod running with a different application, and wanted to apply persistent storage to that pod once I had this one up and running.</p>

Rahul Chonkria
<p>While defining  <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/" rel="nofollow noreferrer">Persistent Volume</a>  you are using  <code>type: local</code> . This means that you want to create directory in  <code>/mnt</code>. Local  do not support  <a href="https://kubernetes.io/docs/concepts/storage/dynamic-provisioning/" rel="nofollow noreferrer">dynamic volume provisioning</a>. For example when you will SSH to any of your nodes you will find that this folder is  <code>ReadOnly</code> file system.</p>
<pre><code>/mnt $ mkdir something mkdir: cannot create directory ‘something’: Read-only file system
</code></pre>
<p>You just could change in your PV YAML</p>
<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: task-pv-volume
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteMany
  hostPath:
    path: &quot;/var/lib/data&quot;
</code></pre>
<p>Notice changes in accessMode and path.
Also in your PVC definition change:</p>
<pre><code>  accessModes:
    - ReadWriteMany
</code></pre>
<p>Remember that  must delete old PV and PVC (if they wont vanish you will probably need redeploy nginx pod also) as in some resources you cannot change values after creation.</p>
<p>Take a look: <a href="https://stackoverflow.com/questions/62577494/mkdir-mnt-data-read-only-file-system-back-off-restarting-failed-postgres-conta">read-only-fs</a>.</p>
<p>Read: <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/persistent-volumes" rel="nofollow noreferrer">gke-dynamics-provisioning</a>.</p>
