kubernetes-sigs / azurefile-csi-driver

Azure File CSI Driver
Apache License 2.0
158 stars 143 forks source link

Unable to create pvc using dyncamic provisioning for azure VMs #2163

Closed bilal-haider-cowlar closed 3 weeks ago

bilal-haider-cowlar commented 3 weeks ago

Issue: Dynamic Provisioning Failure for Azure File Share on Bare Metal Azure VM Kubeadm Setup

What happened:
Dynamic provisioning of an Azure File share on Azure VMs is failing with the error:

Warning ProvisioningFailed 1s (x285 over 18h) file.csi.azure.com_ros-practice-k8s-worker-1_42d233c3-42e7-43e6-a211-4c59f1fe4944 failed to provision volume with StorageClass "dynamic-vernemq-sc": rpc error: code = Internal desc = clientFactory is nil

What you expected to happen:
The PersistentVolumeClaim (PVC) should be dynamically provisioned with the specified StorageClass (dynamic-vernemq-sc) and be accessible across multiple nodes.

How to reproduce it:

  1. Set up a Kubernetes cluster using kubeadm on Azure VMs.
  2. Install the Azure CSI driver v1.31.0.
  3. Configure the StorageClass as follows:
    kind: StorageClass
    apiVersion: storage.k8s.io/v1
    metadata:
      name: dynamic-vernemq-sc
    provisioner: file.csi.azure.com
    allowVolumeExpansion: true
    mountOptions:
     - dir_mode=0777
     - file_mode=0777
     - uid=0
     - gid=0
     - mfsymlinks
     - cache=strict
     - actimeo=30
     - nobrl
    parameters:
      skuName: Standard_LRS
      storageAccount: mystorageaccountname
      shareAccessTier: Cool
      resourceGroup: myresourcegroupname
      shareName: practicestoragek8
      accountAccessTier: Hot
      location: qatarcentral
      subscriptionID: mySubscriptionId
    volumeBindingMode: Immediate
    reclaimPolicy: Delete
  4. Apply the following PersistentVolumeClaim:
    
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: dynamic-vernemq-pvc
    spec:
      accessModes:
        - ReadWriteMany
      storageClassName: dynamic-vernemq-sc
      resources:
        requests:
          storage: 5Gi

Anything else we need to know?:
The CSI driver appears to be installed correctly: kubectl get po -n kube-system -o yaml | grep mcr | grep azurefile

Output:

image: mcr.microsoft.com/oss/kubernetes-csi/azurefile-csi:v1.31.0
image: mcr.microsoft.com/oss/kubernetes-csi/azurefile-csi:v1.31.0
imageID: docker-pullable://mcr.microsoft.com/oss/kubernetes-csi/azurefile-csi@sha256:1daa8a30a600b61e2a65dfb96750449e27bd5a5873a92c09ad7a51c899b7be5e
image: mcr.microsoft.com/oss/kubernetes-csi/azurefile-csi:v1.31.0
image: mcr.microsoft.com/oss/kubernetes-csi/azurefile-csi:v1.31.0
imageID: docker-pullable://mcr.microsoft.com/oss/kubernetes-csi/azurefile-csi@sha256:1daa8a30a600b61e2a65dfb96750449e27bd5a5873a92c09ad7a51c899b7be5e
image: mcr.microsoft.com/oss/kubernetes-csi/azurefile-csi:v1.31.0
image: mcr.microsoft.com/oss/kubernetes-csi/azurefile-csi:v1.31.0
imageID: docker-pullable://mcr.microsoft.com/oss/kubernetes-csi/azurefile-csi@sha256:1daa8a30a600b61e2a65dfb96750449e27bd5a5873a92c09ad7a51c899b7be5e
image: mcr.microsoft.com/oss/kubernetes-csi/azurefile-csi:v1.31.0
image: mcr.microsoft.com/oss/kubernetes-csi/azurefile-csi:v1.31.0
imageID: docker-pullable://mcr.microsoft.com/oss/kubernetes-csi/azurefile-csi@sha256:1daa8a30a600b61e2a65dfb96750449e27bd5a5873a92c09ad7a51c899b7be5e

More Information: My azure secret is correct that I made using storage accound name & key because I am able to create static volumes using it. I have tried all the oficial documentation . My pvc gives me this error of client factory nil and it remains in pending state. Maybe the issue is with specific azure VMs. I can't go to AKS becuase it is unavaible in my region. I made secret using this command: kubectl create secret generic azure-secret --from-literal=azurestorageaccountname=myAKSStorageAccount --from-literal=azurestorageaccountkey=$STORAGE_KEY

Environment:

andyzhangx commented 3 weeks ago

@bilal-haider-cowlar you have not set the correct azure credentials for your csi driver controller pod, pls follow this guide to set for your driver controller: https://github.com/kubernetes-sigs/azurefile-csi-driver?tab=readme-ov-file#option1-provide-cloud-provider-config-with-azure-credentials

bilal-haider-cowlar commented 3 weeks ago

Thanks @andyzhangx for the help. I solved this problem. The issue was not with the secret creation. Real Issue was, how I was providing secret to storage class. I have to give secret to all the controllers, nodes and provisioners seperatly.


parameters:
  csi.storage.k8s.io/provisioner-secret-name: azure-secret
  csi.storage.k8s.io/provisioner-secret-namespace: default
  csi.storage.k8s.io/node-stage-secret-name: azure-secret
  csi.storage.k8s.io/node-stage-secret-namespace: default
  csi.storage.k8s.io/controller-expand-secret-name: azure-secret
  csi.storage.k8s.io/controller-expand-secret-namespace: default