How to automatically delete persistent disks after deleting a Kubernetes cluster?

Mary-Kate Olsen
Release: 2024-10-23 18:52:30
Original
144 people have browsed it

How to automatically delete persistent disks after deleting a Kubernetes cluster?

How to Delete All Persistent Disks Associated with a Deleted Cluster

When a Kubernetes cluster is deleted, persistent disks (PDs) associated with it may persist. To automatically delete these PDs, identify their names or IDs.

Solution:

The Cloud SDK can be utilized with specific filters and formatting to list the disks associated with a GKE cluster.

Command to List All Disks Used by a GKE Cluster:

gcloud compute disks list --format="table(name,users)" --filter="name~^gke-"
Copy after login

Command to List Only Disks Used as PVC:

gcloud compute disks list --format="table(name,users)" --filter="name~^gke-.*-pvc-.*"
Copy after login

Command to List Detached PVC Disks:

gcloud compute disks list --format="table(name,users)" --filter="name~^gke-.*-pvc-.* AND -users:*"
Copy after login

Kubernetes Command to List Cluster's PVs and PD Names:

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

API Method for Listing Disks:

disks.list

The above is the detailed content of How to automatically delete persistent disks after deleting a Kubernetes cluster?. 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!