Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-1.24] feat: add allowSharedKeyAccess parameter #1481

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/driver-parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ containerNamePrefix | specify Azure storage directory prefix created by driver |
server | specify Azure storage account server address | existing server address, e.g. `accountname.privatelink.blob.core.windows.net` | No | if empty, driver will use default `accountname.blob.core.windows.net` or other sovereign cloud account address
accessTier | [Access tier for storage account](https://learn.microsoft.com/en-us/azure/storage/blobs/access-tiers-overview) | Standard account can choose `Hot` or `Cool`, and Premium account can only choose `Premium` | No | empty(use default setting for different storage account types)
allowBlobPublicAccess | Allow or disallow public access to all blobs or containers for storage account created by driver | `true`,`false` | No | `false`
allowSharedKeyAccess | Allow or disallow shared key access for storage account created by driver | `true`,`false` | No | `true`
requireInfraEncryption | specify whether or not the service applies a secondary layer of encryption with platform managed keys for data at rest for storage account created by driver | `true`,`false` | No | `false`
storageEndpointSuffix | specify Azure storage endpoint suffix | `core.windows.net`, `core.chinacloudapi.cn`, etc | No | if empty, driver will use default storage endpoint suffix according to cloud environment
tags | [tags](https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/tag-resources) would be created in newly created storage account | tag format: 'foo=aaa,bar=bbb' | No | ""
Expand Down
1 change: 1 addition & 0 deletions pkg/blob/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ const (
keyVaultSecretVersionField = "keyvaultsecretversion"
storageAccountNameField = "storageaccountname"
allowBlobPublicAccessField = "allowblobpublicaccess"
allowSharedKeyAccessField = "allowsharedkeyaccess"
requireInfraEncryptionField = "requireinfraencryption"
ephemeralField = "csi.storage.k8s.io/ephemeral"
podNamespaceField = "csi.storage.k8s.io/pod.namespace"
Expand Down
13 changes: 12 additions & 1 deletion pkg/blob/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
parameters = make(map[string]string)
}
var storageAccountType, subsID, resourceGroup, location, account, containerName, containerNamePrefix, protocol, customTags, secretName, secretNamespace, pvcNamespace, tagValueDelimiter string
var isHnsEnabled, requireInfraEncryption, enableBlobVersioning, createPrivateEndpoint, enableNfsV3 *bool
var isHnsEnabled, requireInfraEncryption, enableBlobVersioning, createPrivateEndpoint, enableNfsV3, allowSharedKeyAccess *bool
var vnetResourceGroup, vnetName, subnetName, accessTier, networkEndpointType, storageEndpointSuffix, fsGroupChangePolicy string
var matchTags, useDataPlaneAPI, getLatestAccountKey bool
var softDeleteBlobs, softDeleteContainers int32
Expand Down Expand Up @@ -171,6 +171,12 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
if strings.EqualFold(v, trueValue) {
allowBlobPublicAccess = pointer.Bool(true)
}
case allowSharedKeyAccessField:
var boolValue bool
if boolValue, err = strconv.ParseBool(v); err != nil {
return nil, status.Errorf(codes.InvalidArgument, "invalid %s: %s in volume context", allowSharedKeyAccessField, v)
}
allowSharedKeyAccess = pointer.Bool(boolValue)
case requireInfraEncryptionField:
if strings.EqualFold(v, trueValue) {
requireInfraEncryption = pointer.Bool(true)
Expand Down Expand Up @@ -310,6 +316,10 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
storageEndpointSuffix = d.getStorageEndPointSuffix()
}

if storeAccountKey && !pointer.BoolDeref(allowSharedKeyAccess, true) {
return nil, status.Errorf(codes.InvalidArgument, "storeAccountKey is not supported for account with shared access key disabled")
}

accountOptions := &azure.AccountOptions{
Name: account,
Type: storageAccountType,
Expand All @@ -324,6 +334,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
IsHnsEnabled: isHnsEnabled,
EnableNfsV3: enableNfsV3,
AllowBlobPublicAccess: allowBlobPublicAccess,
AllowSharedKeyAccess: allowSharedKeyAccess,
RequireInfrastructureEncryption: requireInfraEncryption,
VNetResourceGroup: vnetResourceGroup,
VNetName: vnetName,
Expand Down
7 changes: 4 additions & 3 deletions test/e2e/dynamic_provisioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,9 +585,10 @@ var _ = ginkgo.Describe("[blob-csi-e2e] Dynamic Provisioning", func() {
CSIDriver: testDriver,
Pods: pods,
StorageClassParameters: map[string]string{
"skuName": "Premium_LRS",
"protocol": "nfs",
"mountPermissions": "0",
"skuName": "Premium_LRS",
"protocol": "nfs",
"mountPermissions": "0",
"allowSharedKeyAccess": "false",
},
}
test.Run(ctx, cs, ns)
Expand Down
Loading