Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
ad9d033e
Commit
ad9d033e
authored
Apr 22, 2019
by
andyzhangx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add shareName param in azure file storage class
skip create azure file if it exists
parent
75d45bdf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
7 deletions
+16
-7
azure_file.go
pkg/cloudprovider/providers/azure/azure_file.go
+5
-1
azure_provision.go
pkg/volume/azure_file/azure_provision.go
+11
-6
No files found.
pkg/cloudprovider/providers/azure/azure_file.go
View file @
ad9d033e
...
@@ -60,9 +60,13 @@ func (f *azureFileClient) createFileShare(accountName, accountKey, name string,
...
@@ -60,9 +60,13 @@ func (f *azureFileClient) createFileShare(accountName, accountKey, name string,
}
}
share
:=
fileClient
.
GetShareReference
(
name
)
share
:=
fileClient
.
GetShareReference
(
name
)
share
.
Properties
.
Quota
=
sizeGiB
share
.
Properties
.
Quota
=
sizeGiB
if
err
=
share
.
Create
(
nil
);
err
!=
nil
{
newlyCreated
,
err
:=
share
.
CreateIfNotExists
(
nil
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to create file share, err: %v"
,
err
)
return
fmt
.
Errorf
(
"failed to create file share, err: %v"
,
err
)
}
}
if
!
newlyCreated
{
klog
.
V
(
2
)
.
Infof
(
"file share(%s) under account(%s) already exists"
,
name
,
accountName
)
}
return
nil
return
nil
}
}
...
...
pkg/volume/azure_file/azure_provision.go
View file @
ad9d033e
...
@@ -142,11 +142,8 @@ func (a *azureFileProvisioner) Provision(selectedNode *v1.Node, allowedTopologie
...
@@ -142,11 +142,8 @@ func (a *azureFileProvisioner) Provision(selectedNode *v1.Node, allowedTopologie
return
nil
,
fmt
.
Errorf
(
"%s does not support block volume provisioning"
,
a
.
plugin
.
GetPluginName
())
return
nil
,
fmt
.
Errorf
(
"%s does not support block volume provisioning"
,
a
.
plugin
.
GetPluginName
())
}
}
var
sku
,
resourceGroup
,
location
,
account
string
var
sku
,
resourceGroup
,
location
,
account
,
shareName
string
// File share name has a length limit of 63, and it cannot contain two consecutive '-'s.
name
:=
util
.
GenerateVolumeName
(
a
.
options
.
ClusterName
,
a
.
options
.
PVName
,
63
)
name
=
strings
.
Replace
(
name
,
"--"
,
"-"
,
-
1
)
capacity
:=
a
.
options
.
PVC
.
Spec
.
Resources
.
Requests
[
v1
.
ResourceName
(
v1
.
ResourceStorage
)]
capacity
:=
a
.
options
.
PVC
.
Spec
.
Resources
.
Requests
[
v1
.
ResourceName
(
v1
.
ResourceStorage
)]
requestGiB
:=
int
(
volumehelpers
.
RoundUpToGiB
(
capacity
))
requestGiB
:=
int
(
volumehelpers
.
RoundUpToGiB
(
capacity
))
secretNamespace
:=
a
.
options
.
PVC
.
Namespace
secretNamespace
:=
a
.
options
.
PVC
.
Namespace
...
@@ -164,6 +161,8 @@ func (a *azureFileProvisioner) Provision(selectedNode *v1.Node, allowedTopologie
...
@@ -164,6 +161,8 @@ func (a *azureFileProvisioner) Provision(selectedNode *v1.Node, allowedTopologie
secretNamespace
=
v
secretNamespace
=
v
case
"resourcegroup"
:
case
"resourcegroup"
:
resourceGroup
=
v
resourceGroup
=
v
case
"sharename"
:
shareName
=
v
default
:
default
:
return
nil
,
fmt
.
Errorf
(
"invalid option %q for volume plugin %s"
,
k
,
a
.
plugin
.
GetPluginName
())
return
nil
,
fmt
.
Errorf
(
"invalid option %q for volume plugin %s"
,
k
,
a
.
plugin
.
GetPluginName
())
}
}
...
@@ -173,12 +172,18 @@ func (a *azureFileProvisioner) Provision(selectedNode *v1.Node, allowedTopologie
...
@@ -173,12 +172,18 @@ func (a *azureFileProvisioner) Provision(selectedNode *v1.Node, allowedTopologie
return
nil
,
fmt
.
Errorf
(
"claim.Spec.Selector is not supported for dynamic provisioning on Azure file"
)
return
nil
,
fmt
.
Errorf
(
"claim.Spec.Selector is not supported for dynamic provisioning on Azure file"
)
}
}
if
shareName
==
""
{
// File share name has a length limit of 63, and it cannot contain two consecutive '-'s.
name
:=
util
.
GenerateVolumeName
(
a
.
options
.
ClusterName
,
a
.
options
.
PVName
,
63
)
shareName
=
strings
.
Replace
(
name
,
"--"
,
"-"
,
-
1
)
}
// when use azure file premium, account kind should be specified as FileStorage
// when use azure file premium, account kind should be specified as FileStorage
accountKind
:=
string
(
storage
.
StorageV2
)
accountKind
:=
string
(
storage
.
StorageV2
)
if
strings
.
HasPrefix
(
strings
.
ToLower
(
sku
),
"premium"
)
{
if
strings
.
HasPrefix
(
strings
.
ToLower
(
sku
),
"premium"
)
{
accountKind
=
string
(
storage
.
FileStorage
)
accountKind
=
string
(
storage
.
FileStorage
)
}
}
account
,
key
,
err
:=
a
.
azureProvider
.
CreateFileShare
(
n
ame
,
account
,
sku
,
accountKind
,
resourceGroup
,
location
,
requestGiB
)
account
,
key
,
err
:=
a
.
azureProvider
.
CreateFileShare
(
shareN
ame
,
account
,
sku
,
accountKind
,
resourceGroup
,
location
,
requestGiB
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -206,7 +211,7 @@ func (a *azureFileProvisioner) Provision(selectedNode *v1.Node, allowedTopologie
...
@@ -206,7 +211,7 @@ func (a *azureFileProvisioner) Provision(selectedNode *v1.Node, allowedTopologie
PersistentVolumeSource
:
v1
.
PersistentVolumeSource
{
PersistentVolumeSource
:
v1
.
PersistentVolumeSource
{
AzureFile
:
&
v1
.
AzureFilePersistentVolumeSource
{
AzureFile
:
&
v1
.
AzureFilePersistentVolumeSource
{
SecretName
:
secretName
,
SecretName
:
secretName
,
ShareName
:
n
ame
,
ShareName
:
shareN
ame
,
SecretNamespace
:
&
secretNamespace
,
SecretNamespace
:
&
secretNamespace
,
},
},
},
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment