1
1
## CSI driver example
2
2
3
- ### Dynamic Provisioning (create storage account and container by Blob Storage CSI driver)
4
- - Create a blob storage CSI storage class
3
+ ### Dynamic Provisioning (create storage account and blob container by CSI driver)
4
+ - Create CSI storage class
5
5
``` console
6
6
kubectl create -f https://raw.githubusercontent.com/kubernetes-sigs/blob-csi-driver/master/deploy/example/storageclass-blobfuse.yaml
7
7
```
8
8
9
9
- Create a statefulset with blob storage mount
10
10
``` console
11
11
kubectl create -f https://raw.githubusercontent.com/kubernetes-sigs/blob-csi-driver/master/deploy/example/statefulset.yaml
12
+ ```
13
+
14
+ - Execute ` df -h ` command in the container
15
+ ```
16
+ # kubectl exec -it statefulset-blob-0 sh
17
+ # df -h
18
+ Filesystem Size Used Avail Use% Mounted on
19
+ ...
20
+ blobfuse 14G 41M 13G 1% /mnt/blob
21
+ ...
12
22
```
13
23
14
24
### 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
25
+ #### Option #1 : Use storage class
26
+ > make sure cluster identity could access storage account
17
27
- Download [ blob storage CSI storage class] ( https://raw.githubusercontent.com/kubernetes-sigs/blob-csi-driver/master/deploy/example/storageclass-blobfuse-existing-container.yaml ) , edit ` resourceGroup ` , ` storageAccount ` , ` containerName ` in storage class
18
28
``` yaml
19
29
apiVersion : storage.k8s.io/v1
@@ -29,16 +39,13 @@ reclaimPolicy: Retain # If set as "Delete" container would be removed after pvc
29
39
volumeBindingMode : Immediate
30
40
` ` `
31
41
42
+ - Create storage class and PVC
32
43
` ` ` console
33
44
kubectl create -f storageclass-blobfuse-existing-container.yaml
34
- ```
35
-
36
- - Create a blob storage CSI PVC
37
- ``` console
38
45
kubectl create -f https://raw.githubusercontent.com/kubernetes-sigs/blob-csi-driver/master/deploy/example/pvc-blob-csi.yaml
39
46
```
40
47
41
- #### Option #2 : provide storage account name and key(or sastoken)
48
+ #### Option #2 : Use secret
42
49
- Use ` kubectl create secret ` to create ` azure-secret ` with existing storage account name and key(or sastoken)
43
50
``` console
44
51
kubectl create secret generic azure-secret --from-literal azurestorageaccountname=NAME --from-literal azurestorageaccountkey="KEY" --type=Opaque
@@ -69,36 +76,30 @@ spec:
69
76
nodeStageSecretRef :
70
77
name : azure-secret
71
78
namespace : default
72
- ` ` `
73
- ` ` ` console
74
- kubectl create -f pv-blobfuse-csi.yaml
75
79
` ` `
76
80
77
- - Create a blob storage CSI PVC which would be bound to the above PV
81
+ - Create PV and PVC
78
82
` ` ` console
83
+ kubectl create -f pv-blobfuse-csi.yaml
79
84
kubectl create -f https://raw.githubusercontent.com/kubernetes-sigs/blob-csi-driver/master/deploy/example/pvc-blob-csi-static.yaml
80
85
```
81
86
82
- #### Validate PVC status and create an nginx pod
83
- > make sure pvc is created and in ` Bound ` status
87
+ - make sure pvc is created and in ` Bound ` status after a while
84
88
``` console
85
- watch kubectl describe pvc pvc-blob
89
+ kubectl describe pvc pvc-blob
86
90
```
87
91
88
- - create a pod with blob storage CSI PVC
92
+ #### create a pod with PVC mount
89
93
``` console
90
94
kubectl create -f https://raw.githubusercontent.com/kubernetes-sigs/blob-csi-driver/master/deploy/example/nginx-pod-blob.yaml
91
95
```
92
96
93
- #### Enter container to verify
94
- - watch the status of pod until its Status changed from ` Pending ` to ` Running ` and then enter the pod container
97
+ - Execute ` df -h ` command in the container
95
98
``` console
96
- $ watch kubectl describe po nginx-blob
97
99
$ kubectl exec -it nginx-blob -- bash
98
100
Filesystem Size Used Avail Use% Mounted on
99
101
...
100
102
blobfuse 14G 41M 13G 1% /mnt/blob
101
- /dev/sda1 30G 8.9G 21G 31% /etc/hosts
102
103
...
103
104
```
104
105
In the above example, there is a ` /mnt/blob ` directory mounted as ` blobfuse ` filesystem.
0 commit comments