github.com/csi-driver/blobfuse-csi-driver@v0.5.0/deploy/example/e2e_usage.md (about) 1 ## CSI driver E2E usage example 2 create a pod with blobfuse mount on linux 3 ### Dynamic Provisioning (create storage account and container by blobfuse driver) 4 - Create a blobfuse CSI storage class 5 ```console 6 kubectl create -f https://raw.githubusercontent.com/kubernetes-sigs/blobfuse-csi-driver/master/deploy/example/storageclass-blobfuse-csi.yaml 7 ``` 8 9 - Create a blobfuse CSI PVC 10 ```console 11 kubectl create -f https://raw.githubusercontent.com/kubernetes-sigs/blobfuse-csi-driver/master/deploy/example/pvc-blobfuse-csi.yaml 12 ``` 13 14 ### Static Provisioning(use an existing storage account) 15 #### Option#1: use existing credentials in k8s cluster 16 > make sure the existing credentials in k8s cluster(e.g. service principal, msi) could access the specified storage account 17 - Download [blobfuse CSI storage class](https://raw.githubusercontent.com/kubernetes-sigs/blobfuse-csi-driver/master/deploy/example/storageclass-blobfuse-csi-existing-container.yaml), edit `resourceGroup`, `storageAccount`, `containerName` in storage class 18 ```yaml 19 apiVersion: storage.k8s.io/v1 20 kind: StorageClass 21 metadata: 22 name: blobfuse.csi.azure.com 23 provisioner: blobfuse.csi.azure.com 24 parameters: 25 skuName: Standard_LRS # available values: Standard_LRS, Standard_GRS, Standard_RAGRS 26 resourceGroup: EXISTING_RESOURCE_GROUP 27 storageAccount: EXISTING_STORAGE_ACCOUNT 28 containerName: EXISTING_CONTAINER_NAME 29 reclaimPolicy: Retain # if set as "Delete" container would be removed after pvc deletion 30 volumeBindingMode: Immediate 31 ``` 32 ```console 33 kubectl create -f storageclass-blobfuse-csi-existing-container.yaml 34 ``` 35 36 - Create a blobfuse CSI PVC 37 ```console 38 kubectl create -f https://raw.githubusercontent.com/kubernetes-sigs/blobfuse-csi-driver/master/deploy/example/pvc-blobfuse-csi.yaml 39 ``` 40 41 #### Option#2: provide storage account name and key(or sastoken) 42 - Use `kubectl create secret` to create `azure-secret` with existing storage account name and key(or sastoken) 43 ```console 44 kubectl create secret generic azure-secret --from-literal azurestorageaccountname=NAME --from-literal azurestorageaccountkey="KEY" --type=Opaque 45 #kubectl create secret generic azure-secret --from-literal azurestorageaccountname=NAME --from-literal azurestorageaccountsastoken 46 ="sastoken" --type=Opaque 47 ``` 48 49 > storage account key(or sastoken) could also be stored in Azure Key Vault, check example here: [read-from-keyvault](../../docs/read-from-keyvault.md) 50 51 - Create a blobfuse CSI PV: download [`pv-blobfuse-csi.yaml` file](https://raw.githubusercontent.com/kubernetes-sigs/blobfuse-csi-driver/master/deploy/example/pv-blobfuse-csi.yaml) and edit `containerName` in `volumeAttributes` 52 ```yaml 53 apiVersion: v1 54 kind: PersistentVolume 55 metadata: 56 name: pv-blobfuse 57 spec: 58 capacity: 59 storage: 10Gi 60 accessModes: 61 - ReadWriteMany 62 persistentVolumeReclaimPolicy: Retain # "Delete" is not supported in static provisioning 63 csi: 64 driver: blobfuse.csi.azure.com 65 readOnly: false 66 volumeHandle: arbitrary-volumeid 67 volumeAttributes: 68 containerName: EXISTING_CONTAINER_NAME 69 nodeStageSecretRef: 70 name: azure-secret 71 namespace: default 72 ``` 73 ```console 74 kubectl create -f pv-blobfuse-csi.yaml 75 ``` 76 77 - Create a blobfuse CSI PVC which would be bound to the above PV 78 ```console 79 kubectl create -f https://raw.githubusercontent.com/kubernetes-sigs/blobfuse-csi-driver/master/deploy/example/pvc-blobfuse-csi-static.yaml 80 ``` 81 82 #### 2. Validate PVC status and create an nginx pod 83 > make sure pvc is created and in `Bound` status 84 ```console 85 watch kubectl describe pvc pvc-blobfuse 86 ``` 87 88 - create a pod with blobfuse CSI PVC 89 ```console 90 kubectl create -f https://raw.githubusercontent.com/kubernetes-sigs/blobfuse-csi-driver/master/deploy/example/nginx-pod-blobfuse.yaml 91 ``` 92 93 #### 3. enter the pod container to do validation 94 - watch the status of pod until its Status changed from `Pending` to `Running` and then enter the pod container 95 ```console 96 $ watch kubectl describe po nginx-blobfuse 97 $ kubectl exec -it nginx-blobfuse -- bash 98 Filesystem Size Used Avail Use% Mounted on 99 ... 100 blobfuse 30G 8.9G 21G 31% /mnt/blobfuse 101 /dev/sda1 30G 8.9G 21G 31% /etc/hosts 102 ... 103 ``` 104 In the above example, there is a `/mnt/blobfuse` directory mounted as `blobfuse` filesystem.