refer to driver parameters for more detailed usage
- 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 classparameters
when creating > 100 file shares in parallel to prevent storage resource provider throttling
- Use
kubectl create secret
to createazure-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 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 ...
make sure cluster identity could access to the file share
- Download Azure file CSI storage class, edit
resourceGroup
,storageAccount
,shareName
in storage class
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
- Create a PV, download
pv-azurefile-csi.yaml
file and editshareName
involumeAttributes
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
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.
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 editshareName
,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