Terraform-provider-kubernetes: kubernetes_persistent_volume_claim resource overrides empty storage_class_name with "default" value

Created on 2 Jun 2020  ·  3Comments  ·  Source: hashicorp/terraform-provider-kubernetes


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 Version and Provider Version

> terraform -v
Terraform v0.12.24

Provider version: v1.11.2

Affected Resource(s)

  • kubernetes_persistent_volume_claim

Terraform Configuration Files

resource "kubernetes_persistent_volume_claim" "blobfuse" {
  metadata {
    name = "pvc-empty-storage-class"
  }

  spec {
    storage_class_name = ""
    access_modes = ["ReadWriteOnce"]

    resources {
      requests = {
        storage = "1Gi"
      }
    }
  }
}

Kubernetes equivalent that provides expected output

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-empty-storage-class-1
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
  storageClassName: ""

Debug Output


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

Expected Behavior

Created PVC with StorageClass: (empty)

Actual Behavior

Created PVC with StorageClass: default

Steps to Reproduce

  1. terraform apply

Important Factoids


Running on Azure cluster.

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
bug sdk-update-needed

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

All 3 comments

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!

Was this page helpful?
0 / 5 - 0 ratings