There is the difference in PVCs created using terraform and kubectl. kubernetes_persistent_volume_claim resource overrides defined storage_class_name = "" with "default" value. kubernetes_persistent_volume doesn't have such behavior and works correct.
> terraform -v
Terraform v0.12.24
Provider version: v1.11.2
resource "kubernetes_persistent_volume_claim" "blobfuse" {
metadata {
name = "pvc-empty-storage-class"
}
spec {
storage_class_name = ""
access_modes = ["ReadWriteOnce"]
resources {
requests = {
storage = "1Gi"
}
}
}
}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-empty-storage-class-1
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: ""
terraform PVC
kubectl describe persistentvolumeclaim/pvc-empty-storage-class
Name: pvc-empty-storage-class
Namespace: default
StorageClass: default
Status: Bound
Volume: pvc-9025ee73-59a3-48cf-9ebd-d0f935e6b2c1
Labels: <none>
Annotations: pv.kubernetes.io/bind-completed: yes
pv.kubernetes.io/bound-by-controller: yes
volume.beta.kubernetes.io/storage-provisioner: kubernetes.io/azure-disk
Finalizers: [kubernetes.io/pvc-protection]
Capacity: 1Gi
Access Modes: RWO
VolumeMode: Filesystem
Mounted By: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ProvisioningSucceeded 8s persistentvolume-controller Successfully provisioned volume pvc-9025ee73-59a3-48cf-9ebd-d0f935e6b2c1 using kubernetes.io/azure-disk
kubectl PVC
kubectl describe persistentvolumeclaim/pvc-empty-storage-class-1
Name: pvc-empty-storage-class-1
Namespace: default
StorageClass:
Status: Pending
Volume:
Labels: <none>
Annotations: kubectl.kubernetes.io/last-applied-configuration:
{"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{},"name":"pvc-empty-storage-class-1","namespace":"default"},"...
Finalizers: [kubernetes.io/pvc-protection]
Capacity:
Access Modes:
VolumeMode: Filesystem
Mounted By: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal FailedBinding 1s (x2 over 12s) persistentvolume-controller no persistent volumes available for this claim and no storage class is set
Created PVC with StorageClass: (empty)
Created PVC with StorageClass: default
terraform apply
Running on Azure cluster.
I have submitted the PR with a fix for this issue. Please, review it.
https://github.com/terraform-providers/terraform-provider-kubernetes/pull/865
Hi, we have a few issues relating to this that are being consolidated here: https://github.com/terraform-providers/terraform-provider-kubernetes/issues/872 See the new issue for a work-around. Thanks!
I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.
If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!
Most helpful comment
I have submitted the PR with a fix for this issue. Please, review it.
https://github.com/terraform-providers/terraform-provider-kubernetes/pull/865