Delete a PersistentVolumeClaim
Follow the instructions on this page to delete PersistentVolumeClaims (PVCs) managed by PX-CSI. These operations help clean up unused resources.
Run the following command to remove a PVC that is no longer needed:
kubectl delete pvc <pvc-name> -n <pvc-namespace>
persistentvolumeclaim "<pvc-name>" deleted
Known limitation: For FlashArray file services, deleting a PVC doesn't delete the persistent volume (PV) in the FlashArray if the volume contains data and remains in the Released
state. You must manually delete the PVs. For more information, see Delete persistent volumes in a released state in FA file services.
Delete persistent volumes in a released state in FA file services
To delete PVs in the Released
state, follow these steps:
-
List the PVs in the
Released
state:kubectl get pv | grep Released
pvc-xxxxxxxx-xxxx-xxxx-xxxx-105a73740493 50Gi RWO Delete Released fio/fio-log-fio-0 fa-file-sc-v4-authsys <unset> 41m
pvc-xxxxxxxx-xxxx-xxxx-xxxx-3aefabb5a065 200Gi RWO Delete Released fio/fio-data-fio-1 fa-file-sc-v4-authsys <unset> 40m
pvc-xxxxxxxx-xxxx-xxxx-xxxx-2b76f4288bdc 50Gi RWO Delete Released fio/fio-log-fio-1 fa-file-sc-v4-authsys <unset> 40m
pvc-xxxxxxxx-xxxx-xxxx-xxxx-ce081914311c 200Gi RWO Delete Released fio/fio-data-fio-0 fa-file-sc-v4-authsys <unset> 41m -
Describe the PV to verify whether the deletion failed due to the volume containing data:
kubectl describe pv <pvc-xxxxxxxx-xxxx-xxxx-xxxx-78be96424d27>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning VolumeFailedDelete 83s (x3 over 86s) pxd.portworx.com_px-pure-csi-controller-5d8d999569-h5trd_4e51323f-xxxx-xxxx-xxxx-964da5f4c298 persistentvolume pvc-xxxxxxxx-xxxx-xxxx-xxxx-78be96424d27 is still attached to node pwx-ocp-208-201-8rhmg-worker-0-dfh6t
Warning VolumeFailedDelete 23s (x4 over 79s) pxd.portworx.com_px-pure-csi-controller-5d8d999569-h5trd_4e51323f-xxxx-xxxx-xxxx-964da5f4c298 rpc error: code = Internal desc = failed to delete backend volume: rpc error: code = Internal desc = delete failed: deletion of non-empty Directory not allowed -
Log in to a worker node and inspect the PVC mount to retrieve the volume label and NFS endpoint:
mount |grep <pvc-xxxxxxxx-xxxx-xxxx-xxxx-78be96424d27>
-
Mount the file system to a new directory so you can remove its contents:
mkdir /var/lib/osd/mounts/pvc_xxxxxxxxxxx-clean-up
mount -t nfs xx.xx.xxx.95:/px_20e4c7e1-pvc-xxxxxxxx-xxxx-xxxx-xxxx-78be96424d27 /var/lib/osd/mounts/1004978454102986342-clean-upIn this example:
xx.xx.xxx.95
is the NFS endpoint.px_20e4c7e1
consists ofpx
and the prefix of the cluster UUID. For example, if the UUID is20e4c7e1-xxxx-xxxx-xxxx-c367b2933167
, use20e4c7e1
.
-
Delete the directory contents and unmount the volume:
rm -rf /var/lib/osd/mounts/1004978454102986342-clean-up/{..?*,.[!.]*,*}
umount /var/lib/osd/mounts/1004978454102986342-clean-up
rm -rf /var/lib/osd/mounts/1004978454102986342-clean-up
After completing these steps, the PV is automatically deleted.