mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
feat: support Azure shared disk
This commit is contained in:
parent
a19942cbd7
commit
f889213d38
@ -133,6 +133,8 @@ func (p *azureDiskProvisioner) Provision(selectedNode *v1.Node, allowedTopologie
|
||||
diskIopsReadWrite string
|
||||
diskMbpsReadWrite string
|
||||
diskEncryptionSetID string
|
||||
|
||||
maxShares int
|
||||
)
|
||||
// maxLength = 79 - (4 for ".vhd") = 75
|
||||
name := util.GenerateVolumeName(p.options.ClusterName, p.options.PVName, 75)
|
||||
@ -179,6 +181,14 @@ func (p *azureDiskProvisioner) Provision(selectedNode *v1.Node, allowedTopologie
|
||||
diskEncryptionSetID = v
|
||||
case azure.WriteAcceleratorEnabled:
|
||||
writeAcceleratorEnabled = v
|
||||
case "maxshares":
|
||||
maxShares, err = strconv.Atoi(v)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parse %s failed with error: %v", v, err)
|
||||
}
|
||||
if maxShares < 1 {
|
||||
return nil, fmt.Errorf("parse %s returned with invalid value: %d", v, maxShares)
|
||||
}
|
||||
default:
|
||||
return nil, fmt.Errorf("AzureDisk - invalid option %s in storage class", k)
|
||||
}
|
||||
@ -261,6 +271,7 @@ func (p *azureDiskProvisioner) Provision(selectedNode *v1.Node, allowedTopologie
|
||||
DiskIOPSReadWrite: diskIopsReadWrite,
|
||||
DiskMBpsReadWrite: diskMbpsReadWrite,
|
||||
DiskEncryptionSetID: diskEncryptionSetID,
|
||||
MaxShares: int32(maxShares),
|
||||
}
|
||||
diskURI, err = diskController.CreateManagedDisk(volumeOptions)
|
||||
if err != nil {
|
||||
|
@ -136,7 +136,7 @@ func (c *controllerCommon) AttachDisk(isManagedDisk bool, diskName, diskURI stri
|
||||
return -1, rerr.Error()
|
||||
}
|
||||
|
||||
if disk.ManagedBy != nil {
|
||||
if disk.ManagedBy != nil && (disk.MaxShares == nil || *disk.MaxShares <= 1) {
|
||||
attachErr := fmt.Sprintf(
|
||||
"disk(%s) already attached to node(%s), could not be attached to node(%s)",
|
||||
diskURI, *disk.ManagedBy, nodeName)
|
||||
|
@ -75,6 +75,8 @@ type ManagedDiskOptions struct {
|
||||
SourceType string
|
||||
// ResourceId of the disk encryption set to use for enabling encryption at rest.
|
||||
DiskEncryptionSetID string
|
||||
// The maximum number of VMs that can attach to the disk at the same time. Value greater than one indicates a disk that can be mounted on multiple VMs at the same time.
|
||||
MaxShares int32
|
||||
}
|
||||
|
||||
//CreateManagedDisk : create managed disk
|
||||
@ -152,6 +154,10 @@ func (c *ManagedDiskController) CreateManagedDisk(options *ManagedDiskOptions) (
|
||||
}
|
||||
}
|
||||
|
||||
if options.MaxShares > 1 {
|
||||
diskProperties.MaxShares = &options.MaxShares
|
||||
}
|
||||
|
||||
model := compute.Disk{
|
||||
Location: &c.common.location,
|
||||
Tags: newTags,
|
||||
|
Loading…
Reference in New Issue
Block a user