Deleting Associated Persistent Disks When Deleting a Cluster
When deleting a Kubernetes Engine cluster, persistent disks may still remain even though the cluster has been removed. To address this, consider using the Cloud SDK to identify the associated disks and take appropriate action.
The gcloud compute disks list command can be employed with specific filters and formatting to identify disks used by a cluster. For instance:
To list all disks utilized by a cluster:
gcloud compute disks list --format="table(name,users)" --filter="name~^gke-"
To list only disks used as Persistent Volume Claims (PVCs):
gcloud compute disks list --format="table(name,users)" --filter="name~^gke-.*-pvc-.*"
To identify detached PVC disks:
gcloud compute disks list --format="table(name,users)" --filter="name~^gke-.*-pvc-.* AND -users:*"
To verify that a detached disk is not still in use by a cluster, employ the following kubectl command to list a cluster's PVs and their associated GCE PDs:
kubectl get pv -o custom-columns=K8sPV:.metadata.name,GCEDisk:spec.gcePersistentDisk.pdName
The API method disks.list can also be used for this purpose.
The above is the detailed content of How to Identify and Manage Persistent Disks After Deleting a Kubernetes Engine Cluster?. For more information, please follow other related articles on the PHP Chinese website!