Skip to content

Commit 6ea668d

Browse files
committed
fix
1 parent 2e2b040 commit 6ea668d

File tree

3 files changed

+78
-173
lines changed

3 files changed

+78
-173
lines changed

deploy/example/mountstorage/README.md

Lines changed: 75 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,71 @@ You can also use a different managed-identity for different persistent volumes (
1515

1616
- Run `az account set --subscription "mysubscription"` to select the right subscription
1717

18-
- Create a storage account container, e.g.
18+
- Create a storage account container(optional in dynamic provisioning), e.g.
1919
```bash
2020
resourcegroup="blobfuse-mi"
2121
storageaccountname="myaksblob"
2222
az storage account create -g "$resourcegroup" -n "$storageaccountname" --access-tier Hot --sku Standard_LRS
2323
az storage container create -n mycontainer --account-name "$storageaccountname" --public-access off
2424
```
25+
26+
## dynamic provisioning in an existing resource group
27+
28+
1. Grant cluster system assigned identity and kubelet identity `Contributor` role to resource group, if mount in an existing storage account, then should also grant identities to storage account
2529

26-
## Option#1: grant kubelet identity access to storage account
30+
1. Grant kubelet identity `Storage Blob Data Owner` role to resource group to mount blob storage, if mount in an existing storage account, then should also grant identity to storage account
31+
32+
1. Create a storage class in an existing resource group
33+
- Option#1 create storage account by CSI driver, will create a new storage account when `storageAccount` and `containerName` are not provided.
34+
- Option#2 use your own storage account, set storage account name for `storageAccount`, you can also set an existing container name for `containerName` if you want to mount an existing container.
35+
```yml
36+
apiVersion: storage.k8s.io/v1
37+
kind: StorageClass
38+
metadata:
39+
name: blob-fuse
40+
provisioner: blob.csi.azure.com
41+
parameters:
42+
skuName: Premium_LRS
43+
protocol: fuse
44+
resourceGroup: EXISTING_RESOURCE_GROUP_NAME
45+
storageAccount: EXISTING_STORAGE_ACCOUNT_NAME # optional, if use existing storage account
46+
containerName: EXISTING_CONTAINER_NAME # optional, if use existing container
47+
AzureStorageAuthType: MSI
48+
AzureStorageIdentityClientID: "xxxxx-xxxx-xxx-xxx-xxxxxxx"
49+
reclaimPolicy: Delete
50+
volumeBindingMode: Immediate
51+
allowVolumeExpansion: true
52+
mountOptions:
53+
- -o allow_other
54+
- --file-cache-timeout-in-seconds=120
55+
- --use-attr-cache=true
56+
- --cancel-list-on-mount-seconds=10 # prevent billing charges on mounting
57+
- -o attr_timeout=120
58+
- -o entry_timeout=120
59+
- -o negative_timeout=120
60+
- --log-level=LOG_WARNING # LOG_WARNING, LOG_INFO, LOG_DEBUG
61+
- --cache-size-mb=1000 # Default will be 80% of available memory, eviction will happen beyond that.
62+
```
63+
64+
1. Create application
65+
- Create a statefulset with volume mount
66+
```console
67+
kubectl create -f https://raw.githubusercontent.com/kubernetes-sigs/blob-csi-driver/master/deploy/example/statefulset.yaml
68+
```
69+
70+
- Execute `df -h` command in the container
71+
```console
72+
kubectl exec -it statefulset-blob-0 -- df -h
73+
```
74+
<pre>
75+
Filesystem Size Used Avail Use% Mounted on
76+
...
77+
blobfuse 14G 41M 13G 1% /mnt/blob
78+
...
79+
</pre>
80+
81+
## static provisioning(use an existing storage account)
82+
### Option#1: grant kubelet identity access to storage account
2783

2884
1. Give kubelet identity access to storage account
2985
```bash
@@ -38,7 +94,7 @@ You can also use a different managed-identity for different persistent volumes (
3894
az identity list -g "$resourcegroup" --query "[?name == 'blobfuse-mi-agentpool'].clientId" -o tsv
3995
```
4096

41-
## Option#2: grant a dedicated user-assigned managed identity access to storage account
97+
### Option#2: grant a dedicated user-assigned managed identity access to storage account
4298
You can use a dedicated user-assigned managed identity to mount the storage.
4399

44100
1. Create user-assigned managed identity and give access to storage account
@@ -62,22 +118,27 @@ You can use a dedicated user-assigned managed identity to mount the storage.
62118
az identity list -g "$resourcegroup" --query "[?name == 'myaksblobmi'].clientId" -o tsv
63119
```
64120

65-
## Mount the azure blob storage
121+
### Mount the azure blob storage
122+
123+
1. Create storage class
124+
```console
125+
kubectl create -f https://raw.githubusercontent.com/kubernetes-sigs/blob-csi-driver/master/deploy/example/storageclass-blobfuse.yaml
126+
```
66127

67-
1. Create a ``volume.yaml`` file and set clientID for ``AzureStorageIdentityClientID``. \
128+
1. Create a `pv-blobfuse-csi-mount.yaml` file and set clientID for ``AzureStorageIdentityClientID``. \
68129
Please also check ``resourceGroup`` and ``storageAccount``.
69130
```yml
70131
apiVersion: v1
71132
kind: PersistentVolume
72133
metadata:
73-
name: pv-blob1
134+
name: pv-blob
74135
spec:
75136
capacity:
76137
storage: 10Gi
77138
accessModes:
78139
- ReadWriteMany
79140
persistentVolumeReclaimPolicy: Retain # If set as "Delete" container would be removed after pvc deletion
80-
storageClassName: azureblob-fuse-premium
141+
storageClassName: blob-fuse
81142
mountOptions:
82143
- -o allow_other
83144
- --file-cache-timeout-in-seconds=120
@@ -86,133 +147,31 @@ You can use a dedicated user-assigned managed identity to mount the storage.
86147
readOnly: false
87148
# make sure this volumeid is unique in the cluster
88149
# `#` is not allowed in self defined volumeHandle
89-
volumeHandle: pv-blob1
150+
volumeHandle: pv-blob
90151
volumeAttributes:
91152
protocol: fuse
92153
resourceGroup: blobfuse-mi
93154
storageAccount: myaksblob
94155
containerName: mycontainer
95156
AzureStorageAuthType: MSI
96157
AzureStorageIdentityClientID: "xxxxx-xxxx-xxx-xxx-xxxxxxx"
97-
98-
---
99-
100-
apiVersion: v1
101-
kind: PersistentVolumeClaim
102-
metadata:
103-
name: pvc-blob1
104-
spec:
105-
accessModes:
106-
- ReadWriteMany
107-
resources:
108-
requests:
109-
storage: 10Gi
110-
volumeName: pv-blob1
111-
storageClassName: azureblob-fuse-premium
112-
```
113-
114-
1. Create a ``deployment.yaml`` file.
115-
```yml
116-
apiVersion: apps/v1
117-
kind: Deployment
118-
metadata:
119-
labels:
120-
app: nginx
121-
name: deployment-blob
122-
spec:
123-
replicas: 1
124-
selector:
125-
matchLabels:
126-
app: nginx
127-
template:
128-
metadata:
129-
labels:
130-
app: nginx
131-
name: deployment-blob
132-
spec:
133-
nodeSelector:
134-
"kubernetes.io/os": linux
135-
containers:
136-
- name: deployment-blob
137-
image: mcr.microsoft.com/oss/nginx/nginx:1.17.3-alpine
138-
command:
139-
- "/bin/sh"
140-
- "-c"
141-
- while true; do echo $(date) >> /mnt/blob/outfile; sleep 1; done
142-
volumeMounts:
143-
- name: blob
144-
mountPath: "/mnt/blob"
145-
readOnly: false
146-
volumes:
147-
- name: blob
148-
persistentVolumeClaim:
149-
claimName: pvc-blob1
150-
strategy:
151-
rollingUpdate:
152-
maxSurge: 0
153-
maxUnavailable: 1
154-
type: RollingUpdate
155158
```
156159
157-
1. Apply the yaml files
158-
```bash
159-
# create pv and pvc
160-
kubectl apply -f volume.yaml
160+
1. Create PV
161+
```console
162+
kubectl create -f pv-blobfuse-csi-mount.yaml
161163
# check it
162164
kubectl get pv
163-
kubectl get pvc
164-
165-
# create deployment
166-
kubectl apply -f deployment.yaml
167-
# check pod
168-
kubectl get pods
169-
```
170-
171-
# dynamic provisioning in an existing resource group
172-
173-
1. Grant cluster system assigned identity and kubelet identity `Contributor` role to resource group, if mount in an existing storage account, then should also grant identity to storage account
174-
175-
1. Grant kubelet identity `Storage Blob Data Owner` role to resource group to mount blob storage, if mount in an existing storage account, then should also grant identity to storage account
176-
177-
1. Create a storage class and give an existing resource group, CSI will create a new storage account when `storageAccount` is not provided.
178-
```yml
179-
apiVersion: storage.k8s.io/v1
180-
kind: StorageClass
181-
metadata:
182-
name: blob-fuse
183-
provisioner: blob.csi.azure.com
184-
parameters:
185-
skuName: Premium_LRS
186-
protocol: fuse
187-
resourceGroup: EXISTING_RESOURCE_GROUP_NAME
188-
storageAccount: EXISTING_STORAGE_ACCOUNT_NAME # optional, if use existing storage account
189-
containerName: EXISTING_CONTAINER_NAME # optional, if use existing container
190-
AzureStorageAuthType: MSI
191-
AzureStorageIdentityClientID: "xxxxx-xxxx-xxx-xxx-xxxxxxx"
192-
reclaimPolicy: Delete
193-
volumeBindingMode: Immediate
194-
allowVolumeExpansion: true
195-
mountOptions:
196-
- -o allow_other
197-
- --file-cache-timeout-in-seconds=120
198-
- --use-attr-cache=true
199-
- --cancel-list-on-mount-seconds=10 # prevent billing charges on mounting
200-
- -o attr_timeout=120
201-
- -o entry_timeout=120
202-
- -o negative_timeout=120
203-
- --log-level=LOG_WARNING # LOG_WARNING, LOG_INFO, LOG_DEBUG
204-
- --cache-size-mb=1000 # Default will be 80% of available memory, eviction will happen beyond that.
205165
```
206166
207-
1. Using dynamic provisioning
167+
1. Create PVC and a deployment with volume mount
208168
```console
209-
# create pvc and deployment
210-
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/blob-csi-driver/master/deploy/example/deployment.yaml
169+
kubectl create -f https://raw.githubusercontent.com/kubernetes-sigs/blob-csi-driver/master/deploy/example/deployment.yaml
211170
# check pod
212171
kubectl get pods
213172
```
214173
215-
# how to add another pv with a dedicated user-assigned identity?
174+
## how to add another pv with a dedicated user-assigned identity?
216175
217176
1. Create another user-assigned managed identity and give access to storage account
218177
```bash

deploy/example/mountstorage/deployment.yaml

Lines changed: 0 additions & 39 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
apiVersion: v1
22
kind: PersistentVolume
33
metadata:
4-
name: pv-blob1
4+
name: pv-blob
55
spec:
66
capacity:
77
storage: 10Gi
88
accessModes:
99
- ReadWriteMany
1010
persistentVolumeReclaimPolicy: Retain # If set as "Delete" container would be removed after pvc deletion
11-
storageClassName: azureblob-fuse-premium
11+
storageClassName: blob-fuse
1212
mountOptions:
1313
- -o allow_other
1414
- --file-cache-timeout-in-seconds=120
@@ -17,26 +17,11 @@ spec:
1717
readOnly: false
1818
# make sure this volumeid is unique in the cluster
1919
# `#` is not allowed in self defined volumeHandle
20-
volumeHandle: pv-blob1
20+
volumeHandle: pv-blob
2121
volumeAttributes:
2222
protocol: fuse
2323
resourceGroup: aks-fuseblob-mi
2424
storageAccount: myaksblob
2525
containerName: mycontainer
2626
AzureStorageAuthType: MSI
2727
AzureStorageIdentityClientID: "xxxxxx-xxxx-xxxxxxxxxxx-xxxxxxx-xxxxx"
28-
29-
---
30-
31-
apiVersion: v1
32-
kind: PersistentVolumeClaim
33-
metadata:
34-
name: pvc-blob1
35-
spec:
36-
accessModes:
37-
- ReadWriteMany
38-
resources:
39-
requests:
40-
storage: 10Gi
41-
volumeName: pv-blob1
42-
storageClassName: azureblob-fuse-premium

0 commit comments

Comments
 (0)