AKS icon indicating copy to clipboard operation
AKS copied to clipboard

File share in Azure File is deleted when PVC is deleted even when storage class has reclaimPolicy Retain

Open devteng opened this issue 6 years ago • 1 comments

What happened: Created a pod with a PVC backed by a Azure File storage class with the reclaimPolicy: Retain. When I delete the PVC, the file share in Azure File is deleted What you expected to happen: During clean up, I delete the pod, then delete the PVC but I want to retain the files in the azure share that the storage account is attached to. How to reproduce it (as minimally and precisely as possible):

  1. Create a storage account as a file share
  2. Create a k8s storage class pointing to the storage account using provisioner: kubernetes.io/azure-file and reclaimPolicy: Retain
  3. Create a PVC that points to the storage class without a PV
  4. Create a pod with a volume claim to the PVC
  5. Write some files into the volume and Azure portal to see if it is there
  6. Delete the pod. The files should still be in the file share
  7. Delete the PVC. All files including the file share is gone Anything else we need to know?:

Environment:

  • Kubernetes version (use kubectl version): Kubernetes 1.16.10
  • Size of cluster (how many worker nodes are in the cluster?)
  • General description of workloads in the cluster (e.g. HTTP microservices, Java app, Ruby on Rails, machine learning, etc.)
  • Others:

devteng avatar Jul 15 '20 17:07 devteng

So by not defining a PV, the persistentVolumeReclaimPolicy option is not being propagated. I end up creating a PV and set a claim to the PVC even though the PVC creates a dynamic PV anyways.

Solution is to add a PV that links to the PVC with "persistentVolumeReclaimPolicy: Retain" option.

devteng avatar Jul 15 '20 20:07 devteng