0

I am testing out GKE with attaching existing disk using this GCP tutorial. I've created a Storage Class for my storage with the reclaimPolicy set to Delete

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: pd-ssd
provisioner: pd.csi.storage.gke.io
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
parameters:
  type: pd-ssd

However after attaching my GCP persistent disk using PV below, I found that my reclaimPolicy is set to retain again. Even after patching the PV back to Delete. The disk still fails to auto delete from my GCP Persistent Disk page (After using the disk with PVC and Pod and deleted). Am I doing anything wrong? or is this the mechanism for GCP that persistent disk can't be auto deleted when using PV static provisioning. Thank you very much for your response in advance.

apiVersion: v1
kind: PersistentVolume
metadata:
  name: test-pv
spec:
  storageClassName: "pd-ssd"
  capacity:
    storage: 50Gi
  accessModes:
    - ReadWriteOnce
  claimRef:
    namespace: default
    name: test-pvc
  csi:
    driver: pd.csi.storage.gke.io
    volumeHandle: projects/{project}/zones/{zone-of-my-disk}/disks/{my-disk-name}
    fsType: ext4
  • You can also refer to the SO [link1](https://stackoverflow.com/questions/73297596/how-to-delete-data-from-a-persistent-volume-in-gke), [link2](https://stackoverflow.com/questions/59655519) which discusses similar issues. – Fariya Rahmat May 25 '23 at 08:56

1 Answers1

1

As mentioned in the document:

GKE might not delete the following resources: 1. External load balancers created by the cluster. 2. Internal load balancers created by the cluster. 3. Persistent disk volumes
Persistent disks are located independently from your virtual machine (VM) instances, so you can detach or move persistent disks to keep your data even after you delete your instances.  If you want to delete the disk also permanently then this can be fixed by first deleting all the namespaces. When you delete a claim, the corresponding PersistentVolume object and the provisioned Compute Engine persistent disk are also deleted.
Fariya Rahmat
  • 2,123
  • 3
  • 11
  • Thanks for the documentation! However that's when the case we are deleting a cluster. In my case I was destroying my resource (Pod, PVC), GKE failed to delete my Persistent Disk from GKE even when I set the reclaimPolicy to Delete. But interestingly if I let GKE auto provision the disk (Only use PVC but not manually attaching my PV). It will automatically delete the disk when deleting PVC. – jasonmacintosh May 29 '23 at 07:14