How to bind a pv retained from previous deployment to a newly creating pvc

Hi,
I deployed a wordpress with mysql as backend along with pvc. Corresponding pv has been created and retained it by changing the RECLAIM POLICY. After that, I deleted the deployment and added the below line in yaml of pvc to bind the pv to pvc.
volumeName: “pv name”
I deployed it again but the pvc isn’t bounding to the pv.
What could be the issue?

If you want the application to bind to the same PV when redeployed, then you should use StatefulSet instead of Deployment and put volumeClaimTemplates inside the statefulset, instead of declaring a separate PVC.

1 Like