@@ -36,9 +36,14 @@ import (
36
36
"sigs.k8s.io/blob-csi-driver/pkg/util"
37
37
azcache "sigs.k8s.io/cloud-provider-azure/pkg/cache"
38
38
"sigs.k8s.io/cloud-provider-azure/pkg/metrics"
39
+ "sigs.k8s.io/cloud-provider-azure/pkg/provider"
39
40
azure "sigs.k8s.io/cloud-provider-azure/pkg/provider"
40
41
)
41
42
43
+ const (
44
+ privateEndpoint = "privateendpoint"
45
+ )
46
+
42
47
// CreateVolume provisions a volume
43
48
func (d * Driver ) CreateVolume (ctx context.Context , req * csi.CreateVolumeRequest ) (* csi.CreateVolumeResponse , error ) {
44
49
if err := d .ValidateControllerServiceRequest (csi .ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME ); err != nil {
@@ -69,7 +74,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
69
74
}
70
75
var storageAccountType , subsID , resourceGroup , location , account , containerName , containerNamePrefix , protocol , customTags , secretName , secretNamespace , pvcNamespace string
71
76
var isHnsEnabled , requireInfraEncryption * bool
72
- var vnetResourceGroup , vnetName , subnetName , accessTier string
77
+ var vnetResourceGroup , vnetName , subnetName , accessTier , networkEndpointType , storageEndpointSuffix string
73
78
var matchTags , useDataPlaneAPI bool
74
79
// set allowBlobPublicAccess as false by default
75
80
allowBlobPublicAccess := pointer .Bool (false )
@@ -135,7 +140,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
135
140
case serverNameField :
136
141
// no op, only used in NodeStageVolume
137
142
case storageEndpointSuffixField :
138
- // no op, only used in NodeStageVolume
143
+ storageEndpointSuffix = v
139
144
case vnetResourceGroupField :
140
145
vnetResourceGroup = v
141
146
case vnetNameField :
@@ -144,6 +149,8 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
144
149
subnetName = v
145
150
case accessTierField :
146
151
accessTier = v
152
+ case networkEndpointTypeField :
153
+ networkEndpointType = v
147
154
case mountPermissionsField :
148
155
// only do validations here, used in NodeStageVolume, NodePublishVolume
149
156
if v != "" {
@@ -201,6 +208,10 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
201
208
}
202
209
203
210
enableHTTPSTrafficOnly := true
211
+ createPrivateEndpoint := false
212
+ if strings .EqualFold (networkEndpointType , privateEndpoint ) {
213
+ createPrivateEndpoint = true
214
+ }
204
215
accountKind := string (storage .KindStorageV2 )
205
216
var (
206
217
vnetResourceIDs []string
@@ -209,15 +220,17 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
209
220
if protocol == NFS {
210
221
isHnsEnabled = pointer .Bool (true )
211
222
enableNfsV3 = pointer .Bool (true )
212
- // set VirtualNetworkResourceIDs for storage account firewall setting
213
- vnetResourceID := d .getSubnetResourceID (vnetResourceGroup , vnetName , subnetName )
214
- klog .V (2 ).Infof ("set vnetResourceID(%s) for NFS protocol" , vnetResourceID )
215
- vnetResourceIDs = []string {vnetResourceID }
216
- if err := d .updateSubnetServiceEndpoints (ctx , vnetResourceGroup , vnetName , subnetName ); err != nil {
217
- return nil , status .Errorf (codes .Internal , "update service endpoints failed with error: %v" , err )
218
- }
219
223
// NFS protocol does not need account key
220
224
storeAccountKey = false
225
+ if ! createPrivateEndpoint {
226
+ // set VirtualNetworkResourceIDs for storage account firewall setting
227
+ vnetResourceID := d .getSubnetResourceID (vnetResourceGroup , vnetName , subnetName )
228
+ klog .V (2 ).Infof ("set vnetResourceID(%s) for NFS protocol" , vnetResourceID )
229
+ vnetResourceIDs = []string {vnetResourceID }
230
+ if err := d .updateSubnetServiceEndpoints (ctx , vnetResourceGroup , vnetName , subnetName ); err != nil {
231
+ return nil , status .Errorf (codes .Internal , "update service endpoints failed with error: %v" , err )
232
+ }
233
+ }
221
234
}
222
235
223
236
if strings .HasPrefix (strings .ToLower (storageAccountType ), "premium" ) {
@@ -235,6 +248,14 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
235
248
return nil , status .Errorf (codes .InvalidArgument , err .Error ())
236
249
}
237
250
251
+ if strings .TrimSpace (storageEndpointSuffix ) == "" {
252
+ if d .cloud .Environment .StorageEndpointSuffix != "" {
253
+ storageEndpointSuffix = d .cloud .Environment .StorageEndpointSuffix
254
+ } else {
255
+ storageEndpointSuffix = defaultStorageEndPointSuffix
256
+ }
257
+ }
258
+
238
259
accountOptions := & azure.AccountOptions {
239
260
Name : account ,
240
261
Type : storageAccountType ,
@@ -254,6 +275,9 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
254
275
VNetName : vnetName ,
255
276
SubnetName : subnetName ,
256
277
AccessTier : accessTier ,
278
+ CreatePrivateEndpoint : createPrivateEndpoint ,
279
+ StorageType : provider .StorageTypeBlob ,
280
+ StorageEndpointSuffix : storageEndpointSuffix ,
257
281
}
258
282
259
283
var accountKey string
@@ -263,7 +287,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
263
287
if v , ok := d .volMap .Load (volName ); ok {
264
288
accountName = v .(string )
265
289
} else {
266
- lockKey := fmt .Sprintf ("%s%s%s%s%s" , storageAccountType , accountKind , resourceGroup , location , protocol )
290
+ lockKey := fmt .Sprintf ("%s%s%s%s%s%v " , storageAccountType , accountKind , resourceGroup , location , protocol , createPrivateEndpoint )
267
291
// search in cache first
268
292
cache , err := d .accountSearchCache .Get (lockKey , azcache .CacheReadTypeDefault )
269
293
if err != nil {
@@ -292,6 +316,10 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
292
316
}
293
317
}
294
318
319
+ if createPrivateEndpoint {
320
+ setKeyValueInMap (parameters , serverNameField , fmt .Sprintf ("%s.blob.%s" , accountName , storageEndpointSuffix ))
321
+ }
322
+
295
323
accountOptions .Name = accountName
296
324
if len (secrets ) == 0 && useDataPlaneAPI {
297
325
if accountKey == "" {
0 commit comments