Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated cherry pick of #17171: Adding VolumeType for Azure for etcdMembers #17175

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions pkg/model/master_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"sort"
"strings"

armcompute "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute"
ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
"github.com/scaleway/scaleway-sdk-go/api/instance/v1"
"k8s.io/kops/pkg/apis/kops"
Expand Down Expand Up @@ -48,6 +49,7 @@ const (
DefaultAWSEtcdVolumeIonIops = 100
DefaultAWSEtcdVolumeGp3Iops = 3000
DefaultAWSEtcdVolumeGp3Throughput = 125
DefaultAZUREEtcdVolumeType = "StandardSSD_LRS"
DefaultGCEEtcdVolumeType = "pd-ssd"
)

Expand Down Expand Up @@ -363,6 +365,10 @@ func (b *MasterVolumeBuilder) addAzureVolume(
m kops.EtcdMemberSpec,
allMembers []string,
) error {
volumeType := fi.ValueOf(m.VolumeType)
if volumeType == "" {
volumeType = DefaultAZUREEtcdVolumeType
}
// The tags are use by Protokube to mount the volume and use it for etcd.
tags := map[string]*string{
// This is the configuration of the etcd cluster.
Expand Down Expand Up @@ -394,9 +400,10 @@ func (b *MasterVolumeBuilder) addAzureVolume(
ResourceGroup: &azuretasks.ResourceGroup{
Name: fi.PtrTo(b.Cluster.AzureResourceGroupName()),
},
SizeGB: fi.PtrTo(volumeSize),
Tags: tags,
Zones: []*string{&zoneNumber},
SizeGB: fi.PtrTo(volumeSize),
Tags: tags,
VolumeType: fi.PtrTo(armcompute.DiskStorageAccountTypes(volumeType)),
Zones: []*string{&zoneNumber},
}
c.AddTask(t)

Expand Down
6 changes: 5 additions & 1 deletion upup/pkg/fi/cloudup/azuretasks/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type Disk struct {
ResourceGroup *ResourceGroup
SizeGB *int32
Tags map[string]*string
VolumeType *compute.DiskStorageAccountTypes
Zones []*string
}

Expand Down Expand Up @@ -77,6 +78,9 @@ func (d *Disk) Find(c *fi.CloudupContext) (*Disk, error) {
Tags: found.Tags,
Zones: found.Zones,
}
if found.SKU != nil && found.SKU.Name != nil {
disk.VolumeType = found.SKU.Name
}
if found.Properties != nil {
disk.SizeGB = found.Properties.DiskSizeGB
}
Expand Down Expand Up @@ -129,7 +133,7 @@ func (*Disk) RenderAzure(t *azure.AzureAPITarget, a, e, changes *Disk) error {
DiskSizeGB: e.SizeGB,
},
SKU: &compute.DiskSKU{
Name: to.Ptr(compute.DiskStorageAccountTypesStandardSSDLRS),
Name: e.VolumeType,
},
Tags: e.Tags,
Zones: e.Zones,
Expand Down
8 changes: 5 additions & 3 deletions upup/pkg/fi/cloudup/azuretasks/disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ import (
)

const (
testTagKey = "key"
testTagValue = "value"
testTagKey = "key"
testTagValue = "value"
testVolumeType = "StandardSSD_LRS"
)

func newTestDisk() *Disk {
Expand All @@ -40,7 +41,8 @@ func newTestDisk() *Disk {
ResourceGroup: &ResourceGroup{
Name: to.Ptr("rg"),
},
SizeGB: to.Ptr[int32](32),
SizeGB: to.Ptr[int32](32),
VolumeType: to.Ptr(compute.DiskStorageAccountTypesStandardSSDLRS),
Tags: map[string]*string{
testTagKey: to.Ptr(testTagValue),
},
Expand Down
Loading