TKC PVC with Reclaim Policy set to "Retain" is not deleted from the Supervisor
search cancel

TKC PVC with Reclaim Policy set to "Retain" is not deleted from the Supervisor

book

Article ID: 391505

calendar_today

Updated On:

Products

Tanzu Kubernetes Runtime VMware vSphere ESXi

Issue/Introduction

After deleting a PVC (and PV) from a guest cluster that has a Reclaim Policy of "Retain", it is still present on the Supervisor. This is expected and working as designed. The PVC is retained on the Supervisor in case it is required to re-use the PVC at a later date.

Symptoms - 

  • PVCs remain visible in the vSphere Client under Namespace > Storage despite being deleted from the TKGs(Tanzu Kubernetes Grid Service) Cluster/VKS(VMware vSphere Kubernetes Service) cluster.

  • When checking the Supervisor Cluster, the PVC status is listed as  "Bound" even after guest cluster removal:

    Plaintext
    NAMESPACE       NAME                                STATUS   VOLUME                                     CAPACITY   STORAGECLASS
    <vcenter-ns>    <pvc-uuid-name>                     Bound    pvc-####-####-####-####     
     

Environment

vSphere Kubernetes Supervisor 7.x
vSphere Kubernetes Supervisor 8.x
VMware Cloud Foundation 4.x, 5.x
vSphere with Tanzu

 

Cause

This behaviour aligns with Kubernetes requirements, and our TKGs/VKS supports the reclaimPolicy settings as defined by Kubernetes for both TKG and Supervisor. 

Resolution

  • Technical Verification: It is recommended to verify the Reclaim Policy of the StorageClass using the following command: kubectl get sc <storage-class-name> -o yaml | grep reclaimPolicy
    • If a TKG PVC is provisioned with a StorageClass where reclaimPolicy is set to "delete", deleting the TKG PVC will trigger the deletion of the corresponding SV PVC.
    • If a TKG PVC is provisioned with a StorageClass where reclaimPolicy is set to "retain", deleting the TKG PVC (and PV) will not delete the corresponding SV PVC.
  • Manual Cleanup Procedure: To remove a retained PVC from the Supervisor Cluster:
    1. Log in to the Supervisor context using kubectl vsphere login.
    2. Switch to the appropriate vSphere Namespace context.
    3. Identify the orphaned PVC and delete it: kubectl delete pvc <pvc-name>
  • Policy Configuration: To automate this process for future volumes, set the reclaimPolicy to Delete in the StorageClass definition.

Additional Information

Please note even in case you delete the corresponding PV after deleting a PVC from the Guest cluster, the corresponding Supervisor PVC won't be deleted if the Guest cluster's StorageClass has ReclaimPolicy of "Retain'.