<p>I  made a persistent volume claim on kubernetes to save mongodb data after restarting the deployment I found that data is not existed also my PVC is in bound state.</p>
<p><strong>here is my yaml file</strong></p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: auth-mongo-depl
spec:
  replicas: 1
  selector:
    matchLabels:
      app: auth-mongo
  template:
    metadata:
      labels:
        app: auth-mongo
    spec:
      volumes:
        - name: auth-mongo-data
          persistentVolumeClaim:
            claimName: auth-mongo-pvc
      containers:
        - name: auth-mongo
          image: mongo
          ports:
            - containerPort: 27017
              name: 'auth-mongo-port'
          volumeMounts:
            - name: auth-mongo-data
              mountPath: '/data/db'
---
# Persistent Volume Claim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: auth-mongo-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 500Mi
</code></pre>
<p>and I made clusterIP service for the deployment</p>

MohamedSalah97
<p>First off, if the PVC status is still <code>Bound</code> and the desired pod happens to start on another node, it will fail as the PV can't be mounted into the pod. This happens because the <code>reclaimPolicy: Retain</code> of the StorageClass (can also be set on the PV directly <code>persistentVolumeReclaimPolicy: Retain</code>). In order to fix this, you have to manually overrite/delete the <code>claimRef</code> of the PV. Use <code>kubectl patch pv PV_NAME -p '{&quot;spec&quot;:{&quot;claimRef&quot;: null}}'</code> to do this, after doing so the PV's status should be <code>Available</code>.</p>
<p>In order to see if the your application writes any data to the desired path, run your application and exec into it (<code>kubectl -n NAMESPACE POD_NAME -it -- /bin/sh</code>) and check your <code>/data/db</code>. You could also create an file with some random text, restart your application and check again.</p>
<p>I'm fairly certain that if your PV isn't being recreated every time your application starts (which shouldn't be the case, because of <code>Retain</code>), then it's highly that your Application isn't writing to the path specified. But you could also share your <code>PersistentVolume</code> config with us, as there might be some misconfiguration there as well.</p>
