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

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 Why does a match Persistent Volume not bind to a match Persistent Volume Claim (using k3s)?, 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!



Solution 1:[1]

You might change

storage_class_name = "pv" 

to

storage_class_name = "manual"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 xiaojueguan