This blog post will show you how to delete a storage volume in a Kuberntes cluster runing on Azure AKS.
There are two components that we need to understand when it comes to deleting storage volumes in Kubernetes. Storage Volumes and Storage Claims. To create a storage volume in AKS, we need to create a storage claim that defines the storage type and volume size the claim will provide pods. The second is the storage volume which creates for the Pod to access. This post describes the process.
Delete a Volume
To delete a volume, let’s check which volumes are available on our cluster using the following command.
kubectl get persistentvolume
From the output, volume name and run the following command to delete the volume. Make sure you delete any pods that are attached to the volume before deleting it.
kubectl delete persistentvolume pvc-922e0472-846a-48c3-f4545gdrg
Delete a Storage Claim
To delete a volume claim, you can follow the above process but use the following commands.
kubectl get persistentvolumeclaims
And to delete a storage claim use the following command.
kubectl delete persistentvolumeclaims azure-premium-disk