mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 18:54:06 +00:00
chore: set resourceGroup into azure pv annotation
Signed-off-by: ZeroMagic <jiliu8@microsoft.com>
This commit is contained in:
parent
f3a64e22d9
commit
01713f2411
@ -169,6 +169,9 @@ func (plugin *azureFilePlugin) ExpandVolumeDevice(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return oldSize, err
|
return oldSize, err
|
||||||
}
|
}
|
||||||
|
if spec.PersistentVolume.ObjectMeta.Annotations[resourceGroupAnnotation] != "" {
|
||||||
|
resourceGroup = spec.PersistentVolume.ObjectMeta.Annotations[resourceGroupAnnotation]
|
||||||
|
}
|
||||||
|
|
||||||
secretName, secretNamespace, err := getSecretNameAndNamespace(spec, spec.PersistentVolume.Spec.ClaimRef.Namespace)
|
secretName, secretNamespace, err := getSecretNameAndNamespace(spec, spec.PersistentVolume.Spec.ClaimRef.Namespace)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -36,8 +36,12 @@ import (
|
|||||||
utilstrings "k8s.io/utils/strings"
|
utilstrings "k8s.io/utils/strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ volume.DeletableVolumePlugin = &azureFilePlugin{}
|
var (
|
||||||
var _ volume.ProvisionableVolumePlugin = &azureFilePlugin{}
|
_ volume.DeletableVolumePlugin = &azureFilePlugin{}
|
||||||
|
_ volume.ProvisionableVolumePlugin = &azureFilePlugin{}
|
||||||
|
|
||||||
|
resourceGroupAnnotation = "kubernetes.io/azure-file-resource-group"
|
||||||
|
)
|
||||||
|
|
||||||
// Abstract interface to file share operations.
|
// Abstract interface to file share operations.
|
||||||
// azure cloud provider should implement it
|
// azure cloud provider should implement it
|
||||||
@ -62,6 +66,9 @@ func (plugin *azureFilePlugin) NewDeleter(spec *volume.Spec) (volume.Deleter, er
|
|||||||
klog.V(4).Infof("failed to get azure provider")
|
klog.V(4).Infof("failed to get azure provider")
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if spec.PersistentVolume != nil && spec.PersistentVolume.ObjectMeta.Annotations[resourceGroupAnnotation] != "" {
|
||||||
|
resourceGroup = spec.PersistentVolume.ObjectMeta.Annotations[resourceGroupAnnotation]
|
||||||
|
}
|
||||||
|
|
||||||
return plugin.newDeleterInternal(spec, &azureSvc{}, azure, resourceGroup)
|
return plugin.newDeleterInternal(spec, &azureSvc{}, azure, resourceGroup)
|
||||||
}
|
}
|
||||||
@ -94,7 +101,7 @@ func (plugin *azureFilePlugin) newDeleterInternal(spec *volume.Spec, util azureU
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (plugin *azureFilePlugin) NewProvisioner(options volume.VolumeOptions) (volume.Provisioner, error) {
|
func (plugin *azureFilePlugin) NewProvisioner(options volume.VolumeOptions) (volume.Provisioner, error) {
|
||||||
azure, _, err := getAzureCloudProvider(plugin.host.GetCloudProvider())
|
azure, resourceGroup, err := getAzureCloudProvider(plugin.host.GetCloudProvider())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.V(4).Infof("failed to get azure provider")
|
klog.V(4).Infof("failed to get azure provider")
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -102,6 +109,9 @@ func (plugin *azureFilePlugin) NewProvisioner(options volume.VolumeOptions) (vol
|
|||||||
if len(options.PVC.Spec.AccessModes) == 0 {
|
if len(options.PVC.Spec.AccessModes) == 0 {
|
||||||
options.PVC.Spec.AccessModes = plugin.GetAccessModes()
|
options.PVC.Spec.AccessModes = plugin.GetAccessModes()
|
||||||
}
|
}
|
||||||
|
if resourceGroup != "" {
|
||||||
|
options.PVC.ObjectMeta.Annotations[resourceGroupAnnotation] = resourceGroup
|
||||||
|
}
|
||||||
return plugin.newProvisionerInternal(options, azure)
|
return plugin.newProvisionerInternal(options, azure)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,6 +191,10 @@ func (a *azureFileProvisioner) Provision(selectedNode *v1.Node, allowedTopologie
|
|||||||
shareName = strings.Replace(name, "--", "-", -1)
|
shareName = strings.Replace(name, "--", "-", -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if resourceGroup == "" {
|
||||||
|
resourceGroup = a.options.PVC.ObjectMeta.Annotations[resourceGroupAnnotation]
|
||||||
|
}
|
||||||
|
|
||||||
// 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") {
|
||||||
@ -203,6 +217,7 @@ func (a *azureFileProvisioner) Provision(selectedNode *v1.Node, allowedTopologie
|
|||||||
Labels: map[string]string{},
|
Labels: map[string]string{},
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
util.VolumeDynamicallyCreatedByKey: "azure-file-dynamic-provisioner",
|
util.VolumeDynamicallyCreatedByKey: "azure-file-dynamic-provisioner",
|
||||||
|
resourceGroupAnnotation: resourceGroup,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Spec: v1.PersistentVolumeSpec{
|
Spec: v1.PersistentVolumeSpec{
|
||||||
|
Loading…
Reference in New Issue
Block a user