Skip to content

Latest commit

 

History

History
117 lines (104 loc) · 5.17 KB

e2e_usage.md

File metadata and controls

117 lines (104 loc) · 5.17 KB

CSI driver example

refer to driver parameters for more detailed usage

Azure File Dynamic Provisioning

Option#1: create storage account by CSI driver

  • Create storage class using Azure file management API(by default)
kubectl create -f https://raw.githubusercontent.com/kubernetes-sigs/azurefile-csi-driver/master/deploy/example/storageclass-azurefile-csi.yaml
  • Create storage class using Azure file data plane API to get better file operation performance
kubectl create -f https://raw.githubusercontent.com/kubernetes-sigs/azurefile-csi-driver/master/deploy/example/storageclass-azurefile-large-scale.yaml

set useDataPlaneAPI: "true" in storage class parameters when creating > 100 file shares in parallel to prevent storage resource provider throttling

Option#2: bring your own storage account (only for SMB protocol)

  • Use kubectl create secret to create azure-secret with existing storage account name and key
kubectl create secret generic azure-secret --from-literal azurestorageaccountname=NAME --from-literal azurestorageaccountkey="KEY" --type=Opaque
  • create storage class referencing azure-secret
kubectl create -f https://raw.githubusercontent.com/kubernetes-sigs/azurefile-csi-driver/master/deploy/example/storageclass-azurefile-secret.yaml

Create application

  • Create a statefulset with volume mount
kubectl create -f https://raw.githubusercontent.com/kubernetes-sigs/azurefile-csi-driver/master/deploy/example/statefulset.yaml
  • Execute df -h command in the container
kubectl exec -it statefulset-azurefile-0 -- df -h
Filesystem                                                                Size  Used Avail Use% Mounted on
...
//f571xxx.file.core.windows.net/pvc-54caa11f-9e27-11e9-ba7b-0601775d3b69  1.0G  64K  1.0G  1%   /mnt/azurefile
...

AzureFile Static Provisioning(use an existing Azure file share)

Option#1: storage class

make sure cluster identity could access to the file share

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: azurefile-csi
provisioner: file.csi.azure.com
parameters:
  resourceGroup: EXISTING_RESOURCE_GROUP_NAME  # optional, only set this when storage account is not in the same resource group as agent node
  storageAccount: EXISTING_STORAGE_ACCOUNT_NAME
  shareName: SHARE_NAME
reclaimPolicy: Delete
volumeBindingMode: Immediate
  • Create storage class and PVC
kubectl create -f storageclass-azurefile-existing-share.yaml
kubectl create -f https://raw.githubusercontent.com/kubernetes-sigs/azurefile-csi-driver/master/deploy/example/pvc-azurefile-csi.yaml

Option#2: PV/PVC

  • Create a PV, download pv-azurefile-csi.yaml file and edit shareName in volumeAttributes
wget https://raw.githubusercontent.com/kubernetes-sigs/azurefile-csi-driver/master/deploy/example/pv-azurefile-csi.yaml
#edit pv-azurefile-csi.yaml
kubectl create -f pv-azurefile-csi.yaml
  • Create a PVC
kubectl create -f https://raw.githubusercontent.com/kubernetes-sigs/azurefile-csi-driver/master/deploy/example/pvc-azurefile-csi-static.yaml
  • make sure pvc is created and in Bound status after a while
kubectl describe pvc pvc-azurefile

Create an application

kubectl create -f https://raw.githubusercontent.com/kubernetes-sigs/azurefile-csi-driver/master/deploy/example/nginx-pod-azurefile.yaml
  • Execute df -h command in the container
kubectl exec -it nginx-azurefile -- df -h
Filesystem                                                                Size  Used Avail Use% Mounted on
...
//f571xxx.file.core.windows.net/pvc-54caa11f-9e27-11e9-ba7b-0601775d3b69  1.0G  64K  1.0G  1%   /mnt/azurefile
...

In the above example, there is a /mnt/azurefile directory mounted as cifs filesystem.

Option#3: Inline volume

only available from v1.3.0 for SMB protocol (NFS protocol is not supported)
inline volume feature can only read storage account name and key in the same namespace, cannot use cluster identity to read storage account name and key

  • Create azure-secret with existing storage account name and key in the same namespace as pod

in below example, both secret and pod are in default namespace

kubectl create secret generic azure-secret --from-literal azurestorageaccountname=NAME --from-literal azurestorageaccountkey="KEY" --type=Opaque
  • download nginx-pod-azurefile-inline-volume.yaml file and edit shareName, secretName
wget https://raw.githubusercontent.com/kubernetes-sigs/azurefile-csi-driver/master/deploy/example/nginx-pod-azurefile-inline-volume.yaml
#edit nginx-pod-azurefile-inline-volume.yaml
kubectl create -f nginx-pod-azurefile-inline-volume.yaml