mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 03:11:40 +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
|
diskIopsReadWrite string
|
||||||
diskMbpsReadWrite string
|
diskMbpsReadWrite string
|
||||||
diskEncryptionSetID string
|
diskEncryptionSetID string
|
||||||
|
|
||||||
|
maxShares int
|
||||||
)
|
)
|
||||||
// maxLength = 79 - (4 for ".vhd") = 75
|
// maxLength = 79 - (4 for ".vhd") = 75
|
||||||
name := util.GenerateVolumeName(p.options.ClusterName, p.options.PVName, 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
|
diskEncryptionSetID = v
|
||||||
case azure.WriteAcceleratorEnabled:
|
case azure.WriteAcceleratorEnabled:
|
||||||
writeAcceleratorEnabled = v
|
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:
|
default:
|
||||||
return nil, fmt.Errorf("AzureDisk - invalid option %s in storage class", k)
|
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,
|
DiskIOPSReadWrite: diskIopsReadWrite,
|
||||||
DiskMBpsReadWrite: diskMbpsReadWrite,
|
DiskMBpsReadWrite: diskMbpsReadWrite,
|
||||||
DiskEncryptionSetID: diskEncryptionSetID,
|
DiskEncryptionSetID: diskEncryptionSetID,
|
||||||
|
MaxShares: int32(maxShares),
|
||||||
}
|
}
|
||||||
diskURI, err = diskController.CreateManagedDisk(volumeOptions)
|
diskURI, err = diskController.CreateManagedDisk(volumeOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -136,7 +136,7 @@ func (c *controllerCommon) AttachDisk(isManagedDisk bool, diskName, diskURI stri
|
|||||||
return -1, rerr.Error()
|
return -1, rerr.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
if disk.ManagedBy != nil {
|
if disk.ManagedBy != nil && (disk.MaxShares == nil || *disk.MaxShares <= 1) {
|
||||||
attachErr := fmt.Sprintf(
|
attachErr := fmt.Sprintf(
|
||||||
"disk(%s) already attached to node(%s), could not be attached to node(%s)",
|
"disk(%s) already attached to node(%s), could not be attached to node(%s)",
|
||||||
diskURI, *disk.ManagedBy, nodeName)
|
diskURI, *disk.ManagedBy, nodeName)
|
||||||
|
@ -75,6 +75,8 @@ type ManagedDiskOptions struct {
|
|||||||
SourceType string
|
SourceType string
|
||||||
// ResourceId of the disk encryption set to use for enabling encryption at rest.
|
// ResourceId of the disk encryption set to use for enabling encryption at rest.
|
||||||
DiskEncryptionSetID string
|
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
|
//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{
|
model := compute.Disk{
|
||||||
Location: &c.common.location,
|
Location: &c.common.location,
|
||||||
Tags: newTags,
|
Tags: newTags,
|
||||||
|
Loading…
Reference in New Issue
Block a user