Kubernetes persistent volume claim - "Cannot bind to requested volume "": storageClassName does not match

2/7/2022

I'm currently trying to create a Persistent Volume Claim but is throwing the error: "Cannot bind to requested volume "pv": storageClassName does not match"

resource "google_compute_disk" "default" {
  name = "pv"
  type = "pd-ssd"
  zone = "us-east1-a"
  size = 2
}

resource "kubernetes_persistent_volume" "default" {
  metadata {
   name = "pv"
  }
  spec {
    capacity = {
     storage = "2Gi"
   }
 access_modes = ["ReadWriteMany"]
 persistent_volume_source {
  gce_persistent_disk {
    pd_name = "pv"
    fs_type = "ext4"
    }
  }
 }
}

resource "kubernetes_persistent_volume_claim" "default" {
 metadata {
  name = "pv"
 }
 spec {
  access_modes = ["ReadWriteMany"]
  resources {
    requests = {
      storage = "2Gi"
    }
  }
  storage_class_name = "pv"
  volume_name        = "pv"
  }
 }

I've tried to follow https://stackoverflow.com/questions/66042100/why-does-a-match-persistent-volume-not-bind-to-a-match-persistent-volume-claim, however I still get the same issue of "Cannot bind to requested volume "pv": storageClassName does not match"

How can I fix this issue? - I've tried to ensure that the name of all the resources match, but I think I'm missing something.

Any help on this will be greatly appreciated!

-- fuzzi
kubernetes
persistent-volumes

0 Answers