How to Identify and Delete Persistent Disks Associated with Deleted Kubernetes Engine Clusters?

Mary-Kate Olsen
Release: 2024-10-23 22:19:30
Original
483 people have browsed it

How to Identify and Delete Persistent Disks Associated with Deleted Kubernetes Engine Clusters?

Cleaning Up Persistent Disks Associated with Deleted Clusters

When deleting a Kubernetes Engine cluster, the persistent disks associated with the cluster by default remain intact. To address this, you can leverage the Cloud SDK to identify and delete these disks.

Identifying Persistent Disks

Cloud SDK provides a versatile command-line interface to interact with Google Cloud resources. Using the gcloud compute disks list command with appropriate filters and formatting options, you can retrieve a list of disks based on their names or associated users.

Recommended Filters

  • To list all disks used by a GKE cluster:
gcloud compute disks list --format="table(name,users)" --filter="name~^gke-"
Copy after login
  • To list only disks used as Persistent Volume Claims (PVCs):
gcloud compute disks list --format="table(name,users)" --filter="name~^gke-.*-pvc-.*"
Copy after login
  • To list detached PVC disks:
gcloud compute disks list --format="table(name,users)" --filter="name~^gke-.*-pvc-.* AND -users:*"
Copy after login

Verifying Disk Status with Kubernetes

To ensure that a detached disk is not in use by a cluster, you can use the kubectl command:

kubectl get pv -o custom-columns=K8sPV:.metadata.name,GCEDisk:spec.gcePersistentDisk.pdName
Copy after login

This command will list Persistent Volumes (PVs) and their corresponding Google Compute Engine Persistent Disk (PD) names.

Cleaning Up Disks

Once you have identified the disks you want to delete, you can use the gcloud compute disks delete command to remove them.

API Reference

The corresponding API method for listing disks is disks.list.

The above is the detailed content of How to Identify and Delete Persistent Disks Associated with Deleted Kubernetes Engine Clusters?. For more information, please follow other related articles on the PHP Chinese website!

source:php
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!