Skip to content

Commit 20d2546

Browse files
authored
Merge pull request #265 from andyzhangx/pv-parameters-doc
doc: refine PV parameters doc
2 parents ae8392c + 34f1baa commit 20d2546

File tree

5 files changed

+161
-93
lines changed

5 files changed

+161
-93
lines changed

deploy/example/pv-blobfuse-csi.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ spec:
1717
readOnly: false
1818
volumeHandle: uniqe-volumeid # make sure this volumeid is unique in the cluster
1919
volumeAttributes:
20+
resourceGroup: EXISTING_RESOURCE_GROUP_NAME
21+
storageAccount: EXISTING_STORAGE_ACCOUNT_NAME
2022
containerName: EXISTING_CONTAINER_NAME
21-
server: SERVER_ADDRESS # optional, provide a new address to replace default "accountname.blob.core.windows.net"
2223
nodeStageSecretRef:
2324
name: azure-secret
2425
namespace: default

deploy/example/pv-blobfuse-nfs.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
apiVersion: v1
3+
kind: PersistentVolume
4+
metadata:
5+
name: pv-blob
6+
spec:
7+
capacity:
8+
storage: 10Gi
9+
accessModes:
10+
- ReadWriteMany
11+
persistentVolumeReclaimPolicy: Retain # "Delete" is not supported in static provisioning
12+
csi:
13+
driver: blob.csi.azure.com
14+
readOnly: false
15+
volumeHandle: uniqe-volumeid # make sure this volumeid is unique in the cluster
16+
volumeAttributes:
17+
resourceGroup: EXISTING_RESOURCE_GROUP_NAME
18+
storageAccount: EXISTING_STORAGE_ACCOUNT_NAME
19+
containerName: EXISTING_CONTAINER_NAME
20+
protocol: nfs

docs/driver-parameters.md

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
77
> [blobfuse mountOptions example](../deploy/example/storageclass-blobfuse-mountoptions.yaml)
88
9-
> [blobfuse Managed Identity and Service Principal Name auth example](../deploy/example/storageclass-blobfuse-msi.yaml)
10-
119
> [nfs example](../deploy/example/storageclass-blob-nfs.yaml)
1210
1311
Name | Meaning | Example | Mandatory | Default value
@@ -28,15 +26,39 @@ Blobfuse driver does not honor `fsGroup` securityContext setting, instead user c
2826
### Static Provisioning(bring your own storage container)
2927
> [blobfuse example](../deploy/example/pv-blobfuse-csi.yaml)
3028
31-
> [blobfuse key vault example](../deploy/example/keyvault/pv-blobfuse-csi-keyvault.yaml)
29+
> [nfs example](../deploy/example/pv-blobfuse-nfs.yaml)
30+
31+
> [blobfuse read account key or SAS token from key vault example](../deploy/example/keyvault/pv-blobfuse-csi-keyvault.yaml)
32+
33+
> [blobfuse Managed Identity and Service Principal Name auth example](../deploy/example/pv-blobfuse-auth.yaml)
3234
3335
Name | Meaning | Available Value | Mandatory | Default value
3436
--- | --- | --- | --- | ---
37+
volumeAttributes.resourceGroup | Azure resource group name | existing resource group name | No | if empty, driver will use the same resource group name as current k8s cluster
38+
volumeAttributes.storageAccount | existing storage account name | existing storage account name | Yes |
3539
volumeAttributes.containerName | existing container name | existing container name | Yes |
36-
volumeAttributes.storageAccountName | existing storage account name | existing storage account name | Yes |
3740
volumeAttributes.protocol | specify blobfuse mount or NFSv3 mount | `fuse`, `nfs` | No | `fuse`
41+
nodeStageSecretRef.name | secret name that stores(check below examples):<br>`azurestorageaccountkey`<br>`azurestorageaccountsastoken`<br>`msisecret`<br>`azurestoragespnclientsecret` | existing Kubernetes secret name | No |
42+
nodeStageSecretRef.namespace | namespace where the secret is | k8s namespace | Yes |
43+
--- | **Following parameters are only for feature: blobfuse [Managed Identity and Service Principal Name auth](https://github.com/Azure/azure-storage-fuse#environment-variables)** | --- | --- |
44+
volumeAttributes.AzureStorageAuthType | Authentication Type | `Key`, `SAS`, `MSI`, `SPN` | No | `Key`
45+
volumeAttributes.AzureStorageIdentityClientID | Identity Client ID | | No |
46+
volumeAttributes.AzureStorageIdentityObjectID | Identity Object ID | | No |
47+
volumeAttributes.AzureStorageIdentityResourceID | Identity Resource ID | | No |
48+
volumeAttributes.MSIEndpoint | MSI Endpoint | | No |
49+
volumeAttributes.AzureStorageSPNClientID | SPN Client ID | | No |
50+
volumeAttributes.AzureStorageSPNTenantID | SPN Tenant ID | | No |
51+
volumeAttributes.AzureStorageAADEndpoint | AADEndpoint | | No |
52+
--- | **Following parameters are only for feature: blobfuse read account key or SAS token from key vault** | --- | --- |
3853
volumeAttributes.keyVaultURL | Azure Key Vault DNS name | existing Azure Key Vault DNS name | No |
3954
volumeAttributes.keyVaultSecretName | Azure Key Vault secret name | existing Azure Key Vault secret name | No |
4055
volumeAttributes.keyVaultSecretVersion | Azure Key Vault secret version | existing version | No |if empty, driver will use "current version"
41-
nodeStageSecretRef.name | secret name that stores storage account name and key(or sastoken) | existing Kubernetes secret name | No |
42-
nodeStageSecretRef.namespace | namespace where the secret is | k8s namespace | Yes |
56+
57+
58+
- create a Kubernetes secret for `nodeStageSecretRef.name`
59+
```console
60+
kubectl create secret generic azure-secret --from-literal azurestorageaccountkey="xxx" --type=Opaque
61+
kubectl create secret generic azure-secret --from-literal azurestorageaccountsastoken="xxx" --type=Opaque
62+
kubectl create secret generic azure-secret --from-literal msisecret="xxx" --type=Opaque
63+
kubectl create secret generic azure-secret --from-literal azurestoragespnclientsecret="xxx" --type=Opaque
64+
```

pkg/blob/blob.go

Lines changed: 52 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -40,33 +40,39 @@ import (
4040

4141
const (
4242
// DriverName holds the name of the csi-driver
43-
DriverName = "blob.csi.azure.com"
44-
separator = "#"
45-
volumeIDTemplate = "%s#%s#%s"
46-
secretNameTemplate = "azure-storage-account-%s-secret"
47-
fileMode = "file_mode"
48-
dirMode = "dir_mode"
49-
vers = "vers"
50-
defaultFileMode = "0777"
51-
defaultDirMode = "0777"
52-
defaultVers = "3.0"
53-
serverNameField = "server"
54-
tagsField = "tags"
55-
protocolField = "protocol"
56-
storageAccountField = "storageaccount"
57-
storageAccountTypeField = "storageaccounttype"
58-
skuNameField = "skuname"
59-
resourceGroupField = "resourcegroup"
60-
locationField = "location"
61-
secretNamespaceField = "secretnamespace"
62-
containerNameField = "containername"
63-
storeAccountKeyField = "storeaccountkey"
64-
storeAccountKeyFalse = "false"
65-
defaultSecretAccountName = "azurestorageaccountname"
66-
defaultSecretAccountKey = "azurestorageaccountkey"
67-
defaultSecretNamespace = "default"
68-
fuse = "fuse"
69-
nfs = "nfs"
43+
DriverName = "blob.csi.azure.com"
44+
separator = "#"
45+
volumeIDTemplate = "%s#%s#%s"
46+
secretNameTemplate = "azure-storage-account-%s-secret"
47+
fileMode = "file_mode"
48+
dirMode = "dir_mode"
49+
vers = "vers"
50+
defaultFileMode = "0777"
51+
defaultDirMode = "0777"
52+
defaultVers = "3.0"
53+
serverNameField = "server"
54+
tagsField = "tags"
55+
protocolField = "protocol"
56+
accountNameField = "accountname"
57+
accountKeyField = "accountkey"
58+
storageAccountField = "storageaccount"
59+
storageAccountTypeField = "storageaccounttype"
60+
skuNameField = "skuname"
61+
resourceGroupField = "resourcegroup"
62+
locationField = "location"
63+
secretNamespaceField = "secretnamespace"
64+
containerNameField = "containername"
65+
storeAccountKeyField = "storeaccountkey"
66+
keyVaultURLField = "keyvaulturl"
67+
keyVaultSecretNameField = "keyvaultsecretname"
68+
keyVaultSecretVersionField = "keyvaultsecretversion"
69+
storageAccountNameField = "storageaccountname"
70+
storeAccountKeyFalse = "false"
71+
defaultSecretAccountName = "azurestorageaccountname"
72+
defaultSecretAccountKey = "azurestorageaccountkey"
73+
defaultSecretNamespace = "default"
74+
fuse = "fuse"
75+
nfs = "nfs"
7076

7177
// See https://docs.microsoft.com/en-us/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata#container-names
7278
containerNameMinLength = 3
@@ -263,15 +269,15 @@ func (d *Driver) GetAuthEnv(ctx context.Context, volumeID, protocol string, attr
263269
switch strings.ToLower(k) {
264270
case containerNameField:
265271
containerName = v
266-
case "keyvaulturl":
272+
case keyVaultURLField:
267273
keyVaultURL = v
268-
case "keyvaultsecretname":
274+
case keyVaultSecretNameField:
269275
keyVaultSecretName = v
270-
case "keyvaultsecretversion":
276+
case keyVaultSecretVersionField:
271277
keyVaultSecretVersion = v
272278
case storageAccountField:
273279
accountName = v
274-
case "storageaccountname": // for compatibility
280+
case storageAccountNameField: // for compatibility
275281
accountName = v
276282
case "azurestorageauthtype":
277283
authEnv = append(authEnv, "AZURE_STORAGE_AUTH_TYPE="+v)
@@ -334,13 +340,13 @@ func (d *Driver) GetAuthEnv(ctx context.Context, volumeID, protocol string, attr
334340
} else {
335341
for k, v := range secrets {
336342
switch strings.ToLower(k) {
337-
case "accountname":
343+
case accountNameField:
338344
accountName = v
339-
case "azurestorageaccountname": // for compatibility with built-in blobfuse plugin
345+
case defaultSecretAccountName: // for compatibility with built-in blobfuse plugin
340346
accountName = v
341-
case "accountkey":
347+
case accountKeyField:
342348
accountKey = v
343-
case "azurestorageaccountkey": // for compatibility with built-in blobfuse plugin
349+
case defaultSecretAccountKey: // for compatibility with built-in blobfuse plugin
344350
accountKey = v
345351
case "azurestorageaccountsastoken":
346352
accountSasToken = v
@@ -368,7 +374,7 @@ func (d *Driver) GetAuthEnv(ctx context.Context, volumeID, protocol string, attr
368374
return accountName, containerName, authEnv, err
369375
}
370376

371-
// GetStorageAccountAndContainer: get storage account and container info
377+
// GetStorageAccountAndContainer get storage account and container info
372378
// returns <accountName, accountKey, accountSasToken, containerName>
373379
// only for e2e testing
374380
func (d *Driver) GetStorageAccountAndContainer(ctx context.Context, volumeID string, attrib, secrets map[string]string) (string, string, string, string, error) {
@@ -390,15 +396,15 @@ func (d *Driver) GetStorageAccountAndContainer(ctx context.Context, volumeID str
390396
switch strings.ToLower(k) {
391397
case containerNameField:
392398
containerName = v
393-
case "keyvaulturl":
399+
case keyVaultURLField:
394400
keyVaultURL = v
395-
case "keyvaultsecretname":
401+
case keyVaultSecretNameField:
396402
keyVaultSecretName = v
397-
case "keyvaultsecretversion":
403+
case keyVaultSecretVersionField:
398404
keyVaultSecretVersion = v
399405
case storageAccountField:
400406
accountName = v
401-
case "storageaccountname":
407+
case storageAccountNameField: // for compatibility
402408
accountName = v
403409
}
404410
}
@@ -479,22 +485,22 @@ func getStorageAccount(secrets map[string]string) (string, string, error) {
479485
var accountName, accountKey string
480486
for k, v := range secrets {
481487
switch strings.ToLower(k) {
482-
case "accountname":
488+
case accountNameField:
483489
accountName = v
484-
case "azurestorageaccountname": // for compatibility with built-in azurefile plugin
490+
case defaultSecretAccountName: // for compatibility with built-in azurefile plugin
485491
accountName = v
486-
case "accountkey":
492+
case accountKeyField:
487493
accountKey = v
488-
case "azurestorageaccountkey": // for compatibility with built-in azurefile plugin
494+
case defaultSecretAccountKey: // for compatibility with built-in azurefile plugin
489495
accountKey = v
490496
}
491497
}
492498

493499
if accountName == "" {
494-
return "", "", fmt.Errorf("could not find accountname or azurestorageaccountname field secrets(%v)", secrets)
500+
return accountName, accountKey, fmt.Errorf("could not find %s or %s field secrets(%v)", accountNameField, defaultSecretAccountName, secrets)
495501
}
496502
if accountKey == "" {
497-
return "", "", fmt.Errorf("could not find accountkey or azurestorageaccountkey field in secrets(%v)", secrets)
503+
return accountName, accountKey, fmt.Errorf("could not find %s or %s field in secrets(%v)", accountKeyField, defaultSecretAccountKey, secrets)
498504
}
499505

500506
klog.V(4).Infof("got storage account(%s) from secret", accountName)

0 commit comments

Comments
 (0)