<p>i got a configuration of a postgres deployment, something like this..</p>
<p>on the volumeMounts level</p>
<pre><code>      volumeMounts:
        - mountPath: /var/lib/postgresql/data
          name: postgres-persistance-storage-new
</code></pre>
<p>on the volumes level</p>
<pre><code>  volumes:
    - name: postgres-persistance-storage-new
      persistentVolumeClaim:
        claimName: postgres-pv-claim-new
</code></pre>
<p>the PersistentVolumeClaim spec</p>
<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: postgres-pv-claim-new # name of PVC essential for identifying the storage data
  labels:
    app: postgres
    tier: database
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
</code></pre>
<p>My problem is the following : when i delete persistentVolumeClaim via a kubectl command, and then launch again my postgres deployment yaml spec,
the persistentVolume seems to be always here, as logs in postgres container say :</p>
<pre><code>PostgreSQL Database directory appears to contain a database; Skipping initialization
</code></pre>
<p>How is it possible ?</p>

<p>When you delete a PVC, if there is a resource that uses it (for example if the volume is attached to a Deployments with running Pods) this remains ACTIVE.</p>
<p>This is the reason:
<a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/#storage-object-in-use-protection" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/storage/persistent-volumes/#storage-object-in-use-protection</a></p>
<p>When you reapply the YAML describing the Deployment, Kubernetes will upgrade to rolling-update mode.</p>
<blockquote>
<p>Rolling updates allow Deployments' update to take place with zero downtime by incrementally updating Pods instances with new ones. The new Pods will be scheduled on Nodes with available resources.</p>
</blockquote>
<p><a href="https://kubernetes.io/docs/tutorials/kubernetes-basics/update/update-intro/" rel="nofollow noreferrer">https://kubernetes.io/docs/tutorials/kubernetes-basics/update/update-intro/</a></p>
<p>This means that your &quot;old&quot; Pod will remain active until the &quot;new&quot; becomes Up&amp;Running (but continuing to fail, the &quot;old&quot; will never be killed and consequently the PVC will never be destroyed, continuing to maintain the application configurations).</p>
<p>To conclude, I suggest you delete the resources (postgresql Deployment in this case) that use the deleted PVC before re-installing them.</p>
