2

I'm trying to implement a PVC in Terraform

resource "kubernetes_persistent_volume_claim" "nfs-claim" {
  metadata {
    name = "nfs-claim"
  }
  spec {
    access_modes = ["ReadWriteMany"]
    resources {
      requests = {
        storage = "500Mi"
      }
    }
  }
}

but upon destroying the infrastructure, Terraform is unable to delete the PVC and keeps trying till it times out, this is due to

finalizers:
  - kubernetes.io/pvc-protection

I could not find in the documentation a way to implement a PVC without finalizers, this terraform is in a pipeline and its main purpose for testing the new modifications to the environment so it has to be deleted. I also tried to manually patch the pvc to remove the finalizer with:

kubectl patch pvc nfs-claim -p '{"metadata":{"finalizers": []}}' --type=merge

but it doesn't work unless the pvc is in terminating state.

Is there a way to implement the PVC without finalizers from the start?

Jonas
  • 121,568
  • 97
  • 310
  • 388
  • The cluster is in DO, I just tested in a GCP cluster and its getting deleted fine, maybe its a DO thing with Terraform. – Mohammed Hassan Dec 09 '21 at 11:15
  • I have the same issue with an EKS cluster on AWS. Which Terraform Version and Kubernetes cluster version are you using? – GiamPy Jun 01 '22 at 11:42

0 Answers0