Skip to content

Commit 4fa82a9

Browse files
authored
Merge pull request #957 from andyzhangx/fix-blobfuse-msi-dynamic-support-1.22
[release-1.22] fix: dynamic provisioning support with blobfuse msi auth
2 parents 97dada4 + ae5162b commit 4fa82a9

File tree

3 files changed

+80
-62
lines changed

3 files changed

+80
-62
lines changed

pkg/blob/blob.go

Lines changed: 68 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -47,62 +47,68 @@ import (
4747

4848
const (
4949
// DefaultDriverName holds the name of the csi-driver
50-
DefaultDriverName = "blob.csi.azure.com"
51-
blobCSIDriverName = "blob_csi_driver"
52-
separator = "#"
53-
volumeIDTemplate = "%s#%s#%s#%s#%s#%s"
54-
secretNameTemplate = "azure-storage-account-%s-secret"
55-
serverNameField = "server"
56-
storageEndpointSuffixField = "storageendpointsuffix"
57-
tagsField = "tags"
58-
matchTagsField = "matchtags"
59-
protocolField = "protocol"
60-
accountNameField = "accountname"
61-
accountKeyField = "accountkey"
62-
storageAccountField = "storageaccount"
63-
storageAccountTypeField = "storageaccounttype"
64-
skuNameField = "skuname"
65-
subscriptionIDField = "subscriptionid"
66-
resourceGroupField = "resourcegroup"
67-
locationField = "location"
68-
secretNameField = "secretname"
69-
secretNamespaceField = "secretnamespace"
70-
containerNameField = "containername"
71-
containerNamePrefixField = "containernameprefix"
72-
storeAccountKeyField = "storeaccountkey"
73-
isHnsEnabledField = "ishnsenabled"
74-
softDeleteBlobsField = "softdeleteblobs"
75-
softDeleteContainersField = "softdeletecontainers"
76-
enableBlobVersioningField = "enableblobversioning"
77-
getAccountKeyFromSecretField = "getaccountkeyfromsecret"
78-
storageSPNClientIDField = "azurestoragespnclientid"
79-
storageSPNTenantIDField = "azurestoragespntenantid"
80-
keyVaultURLField = "keyvaulturl"
81-
keyVaultSecretNameField = "keyvaultsecretname"
82-
keyVaultSecretVersionField = "keyvaultsecretversion"
83-
storageAccountNameField = "storageaccountname"
84-
allowBlobPublicAccessField = "allowblobpublicaccess"
85-
requireInfraEncryptionField = "requireinfraencryption"
86-
ephemeralField = "csi.storage.k8s.io/ephemeral"
87-
podNamespaceField = "csi.storage.k8s.io/pod.namespace"
88-
mountOptionsField = "mountoptions"
89-
falseValue = "false"
90-
trueValue = "true"
91-
defaultSecretAccountName = "azurestorageaccountname"
92-
defaultSecretAccountKey = "azurestorageaccountkey"
93-
accountSasTokenField = "azurestorageaccountsastoken"
94-
msiSecretField = "msisecret"
95-
storageSPNClientSecretField = "azurestoragespnclientsecret"
96-
Fuse = "fuse"
97-
Fuse2 = "fuse2"
98-
NFS = "nfs"
99-
vnetResourceGroupField = "vnetresourcegroup"
100-
vnetNameField = "vnetname"
101-
subnetNameField = "subnetname"
102-
accessTierField = "accesstier"
103-
networkEndpointTypeField = "networkendpointtype"
104-
mountPermissionsField = "mountpermissions"
105-
useDataPlaneAPIField = "usedataplaneapi"
50+
DefaultDriverName = "blob.csi.azure.com"
51+
blobCSIDriverName = "blob_csi_driver"
52+
separator = "#"
53+
volumeIDTemplate = "%s#%s#%s#%s#%s#%s"
54+
secretNameTemplate = "azure-storage-account-%s-secret"
55+
serverNameField = "server"
56+
storageEndpointSuffixField = "storageendpointsuffix"
57+
tagsField = "tags"
58+
matchTagsField = "matchtags"
59+
protocolField = "protocol"
60+
accountNameField = "accountname"
61+
accountKeyField = "accountkey"
62+
storageAccountField = "storageaccount"
63+
storageAccountTypeField = "storageaccounttype"
64+
skuNameField = "skuname"
65+
subscriptionIDField = "subscriptionid"
66+
resourceGroupField = "resourcegroup"
67+
locationField = "location"
68+
secretNameField = "secretname"
69+
secretNamespaceField = "secretnamespace"
70+
containerNameField = "containername"
71+
containerNamePrefixField = "containernameprefix"
72+
storeAccountKeyField = "storeaccountkey"
73+
isHnsEnabledField = "ishnsenabled"
74+
softDeleteBlobsField = "softdeleteblobs"
75+
softDeleteContainersField = "softdeletecontainers"
76+
enableBlobVersioningField = "enableblobversioning"
77+
getAccountKeyFromSecretField = "getaccountkeyfromsecret"
78+
storageSPNClientIDField = "azurestoragespnclientid"
79+
storageSPNTenantIDField = "azurestoragespntenantid"
80+
storageAuthTypeField = "azurestorageauthtype"
81+
storageIentityClientIDField = "azurestorageidentityclientid"
82+
storageIdentityObjectIDField = "azurestorageidentityobjectid"
83+
storageIdentityResourceIDField = "azurestorageidentityresourceid"
84+
msiEndpointField = "msiendpoint"
85+
storageAADEndpointField = "azurestorageaadendpoint"
86+
keyVaultURLField = "keyvaulturl"
87+
keyVaultSecretNameField = "keyvaultsecretname"
88+
keyVaultSecretVersionField = "keyvaultsecretversion"
89+
storageAccountNameField = "storageaccountname"
90+
allowBlobPublicAccessField = "allowblobpublicaccess"
91+
requireInfraEncryptionField = "requireinfraencryption"
92+
ephemeralField = "csi.storage.k8s.io/ephemeral"
93+
podNamespaceField = "csi.storage.k8s.io/pod.namespace"
94+
mountOptionsField = "mountoptions"
95+
falseValue = "false"
96+
trueValue = "true"
97+
defaultSecretAccountName = "azurestorageaccountname"
98+
defaultSecretAccountKey = "azurestorageaccountkey"
99+
accountSasTokenField = "azurestorageaccountsastoken"
100+
msiSecretField = "msisecret"
101+
storageSPNClientSecretField = "azurestoragespnclientsecret"
102+
Fuse = "fuse"
103+
Fuse2 = "fuse2"
104+
NFS = "nfs"
105+
vnetResourceGroupField = "vnetresourcegroup"
106+
vnetNameField = "vnetname"
107+
subnetNameField = "subnetname"
108+
accessTierField = "accesstier"
109+
networkEndpointTypeField = "networkendpointtype"
110+
mountPermissionsField = "mountpermissions"
111+
useDataPlaneAPIField = "usedataplaneapi"
106112

107113
// See https://docs.microsoft.com/en-us/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata#container-names
108114
containerNameMinLength = 3
@@ -409,22 +415,22 @@ func (d *Driver) GetAuthEnv(ctx context.Context, volumeID, protocol string, attr
409415
pvcNamespace = v
410416
case getAccountKeyFromSecretField:
411417
getAccountKeyFromSecret = strings.EqualFold(v, trueValue)
412-
case "azurestorageauthtype":
418+
case storageAuthTypeField:
413419
azureStorageAuthType = v
414420
authEnv = append(authEnv, "AZURE_STORAGE_AUTH_TYPE="+v)
415-
case "azurestorageidentityclientid":
421+
case storageIentityClientIDField:
416422
authEnv = append(authEnv, "AZURE_STORAGE_IDENTITY_CLIENT_ID="+v)
417-
case "azurestorageidentityobjectid":
423+
case storageIdentityObjectIDField:
418424
authEnv = append(authEnv, "AZURE_STORAGE_IDENTITY_OBJECT_ID="+v)
419-
case "azurestorageidentityresourceid":
425+
case storageIdentityResourceIDField:
420426
authEnv = append(authEnv, "AZURE_STORAGE_IDENTITY_RESOURCE_ID="+v)
421-
case "msiendpoint":
427+
case msiEndpointField:
422428
authEnv = append(authEnv, "MSI_ENDPOINT="+v)
423429
case storageSPNClientIDField:
424430
storageSPNClientID = v
425431
case storageSPNTenantIDField:
426432
storageSPNTenantID = v
427-
case "azurestorageaadendpoint":
433+
case storageAADEndpointField:
428434
authEnv = append(authEnv, "AZURE_STORAGE_AAD_ENDPOINT="+v)
429435
}
430436
}

pkg/blob/controllerserver.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
153153
case pvNameKey:
154154
containerNameReplaceMap[pvNameMetadata] = v
155155
case serverNameField:
156+
case storageAuthTypeField:
157+
case storageIentityClientIDField:
158+
case storageIdentityObjectIDField:
159+
case storageIdentityResourceIDField:
160+
case msiEndpointField:
161+
case storageAADEndpointField:
156162
// no op, only used in NodeStageVolume
157163
case storageEndpointSuffixField:
158164
storageEndpointSuffix = v

pkg/blob/controllerserver_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,12 @@ func TestCreateVolume(t *testing.T) {
547547
mp[resourceGroupField] = "unit-test"
548548
mp[containerNameField] = "unit-test"
549549
mp[mountPermissionsField] = "0750"
550+
mp[storageAuthTypeField] = "msi"
551+
mp[storageIentityClientIDField] = "msi"
552+
mp[storageIdentityObjectIDField] = "msi"
553+
mp[storageIdentityResourceIDField] = "msi"
554+
mp[msiEndpointField] = "msi"
555+
mp[storageAADEndpointField] = "msi"
550556
req := &csi.CreateVolumeRequest{
551557
Name: "unit-test",
552558
VolumeCapabilities: stdVolumeCapabilities,

0 commit comments

Comments
 (0)