Skip to content

Commit

Permalink
Add Default Instance Types for Azure Stack
Browse files Browse the repository at this point in the history
Also simplifies Azure Stack IPv6 validation.
  • Loading branch information
staebler authored and patrickdillon committed Jun 23, 2021
1 parent ce6ab62 commit b258595
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 12 deletions.
4 changes: 2 additions & 2 deletions pkg/asset/installconfig/azure/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func validateInstanceTypes(client API, ic *types.InstallConfig) field.ErrorList
instanceType = defaultInstanceType
}
if instanceType == "" {
instanceType = defaults.ControlPlaneInstanceType(ic.Azure.Region)
instanceType = defaults.ControlPlaneInstanceType(ic.Azure.CloudName, ic.Azure.Region)
}
allErrs = append(allErrs, ValidateInstanceType(client, field.NewPath("controlPlane", "platform", "azure"), ic.Azure.Region, instanceType, diskType, controlPlaneReq)...)
}
Expand All @@ -132,7 +132,7 @@ func validateInstanceTypes(client API, ic *types.InstallConfig) field.ErrorList
instanceType = defaultInstanceType
}
if instanceType == "" {
instanceType = defaults.ComputeInstanceType(ic.Azure.Region)
instanceType = defaults.ComputeInstanceType(ic.Azure.CloudName, ic.Azure.Region)
}
allErrs = append(allErrs, ValidateInstanceType(client, fieldPath.Child("platform", "azure"),
ic.Azure.Region, instanceType, diskType, computeReq)...)
Expand Down
5 changes: 4 additions & 1 deletion pkg/asset/machines/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ func (m *Master) Generate(dependencies asset.Parents) error {
openstack.ConfigMasters(machines, clusterID.InfraID)
case azuretypes.Name:
mpool := defaultAzureMachinePoolPlatform()
mpool.InstanceType = azuredefaults.ControlPlaneInstanceType(installConfig.Config.Platform.Azure.Region)
mpool.InstanceType = azuredefaults.ControlPlaneInstanceType(
installConfig.Config.Platform.Azure.CloudName,
installConfig.Config.Platform.Azure.Region,
)
mpool.OSDisk.DiskSizeGB = 1024
mpool.Set(ic.Platform.Azure.DefaultMachinePlatform)
mpool.Set(pool.Platform.Azure)
Expand Down
5 changes: 4 additions & 1 deletion pkg/asset/machines/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,10 @@ func (w *Worker) Generate(dependencies asset.Parents) error {
}
case azuretypes.Name:
mpool := defaultAzureMachinePoolPlatform()
mpool.InstanceType = azuredefaults.ComputeInstanceType(installConfig.Config.Platform.Azure.Region)
mpool.InstanceType = azuredefaults.ComputeInstanceType(
installConfig.Config.Platform.Azure.CloudName,
installConfig.Config.Platform.Azure.Region,
)
mpool.Set(ic.Platform.Azure.DefaultMachinePlatform)
mpool.Set(pool.Platform.Azure)
if len(mpool.Zones) == 0 {
Expand Down
8 changes: 7 additions & 1 deletion pkg/tfvars/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Auth struct {
type config struct {
Auth `json:",inline"`
Environment string `json:"azure_environment"`
ARMEndpoint string `json:"azure_arm_endpoint,omitempty"`
ExtraTags map[string]string `json:"azure_extra_tags,omitempty"`
BootstrapInstanceType string `json:"azure_bootstrap_vm_type,omitempty"`
MasterInstanceType string `json:"azure_master_vm_type,omitempty"`
Expand All @@ -47,6 +48,7 @@ type config struct {
type TFVarsSources struct {
Auth Auth
CloudName azure.CloudEnvironment
ARMEndpoint string
ResourceGroupName string
BaseDomainResourceGroupName string
MasterConfigs []*azureprovider.AzureMachineProviderSpec
Expand Down Expand Up @@ -77,8 +79,9 @@ func TFVars(sources TFVarsSources) ([]byte, error) {
cfg := &config{
Auth: sources.Auth,
Environment: environment,
ARMEndpoint: sources.ARMEndpoint,
Region: region,
BootstrapInstanceType: defaults.BootstrapInstanceType(region),
BootstrapInstanceType: defaults.BootstrapInstanceType(sources.CloudName, region),
MasterInstanceType: masterConfig.VMSize,
MasterAvailabilityZones: masterAvailabilityZones,
VolumeType: masterConfig.OSDisk.ManagedDisk.StorageAccountType,
Expand Down Expand Up @@ -109,6 +112,9 @@ func environment(cloudName azure.CloudEnvironment) (string, error) {
return "china", nil
case azure.GermanCloud:
return "german", nil
case azure.StackCloud:
// unused since stack uses its own provider
return "", nil
default:
return "", errors.Errorf("unsupported cloud name %q", cloudName)
}
Expand Down
35 changes: 28 additions & 7 deletions pkg/types/azure/defaults/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,50 @@ package defaults

import (
"fmt"

"github.com/openshift/installer/pkg/types/azure"
)

// BootstrapInstanceType sets the defaults for bootstrap instances.
// Minimum requirements are 4 CPU's, 16GiB of ram, and 120GiB storage.
// D4s v3 gives us 4 CPU's, 16GiB ram and 32GiB of temporary storage
func BootstrapInstanceType(region string) string {
// D4s v3 gives us 4 CPU's, 16GiB ram and 32GiB of temporary storage.
// DS4_v2 gives us 8 CPUs, 28GiB ram, and 56GiB of temporary storage.
func BootstrapInstanceType(cloud azure.CloudEnvironment, region string) string {
instanceClass := getInstanceClass(region)
return fmt.Sprintf("%s_D4s_v3", instanceClass)
size := "D4s_v3"
if cloud == azure.StackCloud {
size = "DS4_v2"
}
return instanceType(instanceClass, size)
}

// ControlPlaneInstanceType sets the defaults for control plane instances.
// Minimum requirements are 4 CPU's, 16GiB of ram, and 120GiB storage.
// D8s v3 gives us 8 CPU's, 32GiB ram and 64GiB of temporary storage
// This extra bump is done to prevent etcd from overloading
func ControlPlaneInstanceType(region string) string {
// DS4_v2 gives us 8 CPUs, 28GiB ram, and 56GiB of temporary storage.
func ControlPlaneInstanceType(cloud azure.CloudEnvironment, region string) string {
instanceClass := getInstanceClass(region)
return fmt.Sprintf("%s_D8s_v3", instanceClass)
size := "D4s_v3"
if cloud == azure.StackCloud {
size = "DS4_v2"
}
return instanceType(instanceClass, size)
}

// ComputeInstanceType sets the defaults for compute instances.
// Minimum requirements are 2 CPU's, 8GiB of ram, and 120GiB storage.
// D4s v3 gives us 2 CPU's, 8GiB ram and 16GiB of temporary storage
func ComputeInstanceType(region string) string {
// DS3_v2 gives us 4 CPUs, 14GiB ram, and 28GiB of temporary storage.
func ComputeInstanceType(cloud azure.CloudEnvironment, region string) string {
instanceClass := getInstanceClass(region)
return fmt.Sprintf("%s_D2s_v3", instanceClass)
size := "D4s_v3"
if cloud == azure.StackCloud {
size = "DS4_v2"
}
return instanceType(instanceClass, size)
}

func instanceType(class, size string) string {
return fmt.Sprintf("%s_%s", class, size)
}
2 changes: 2 additions & 0 deletions pkg/types/validation/installconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ func validateNetworkingIPVersion(n *types.Networking, p *types.Platform) field.E
switch {
case p.BareMetal != nil:
case p.None != nil:
case p.Azure != nil && p.Azure.CloudName == azure.StackCloud:
allErrs = append(allErrs, field.Invalid(field.NewPath("networking"), "IPv6", "Azure Stack does not support IPv6"))
default:
allErrs = append(allErrs, field.Invalid(field.NewPath("networking"), "IPv6", "single-stack IPv6 is not supported for this platform"))
}
Expand Down

0 comments on commit b258595

Please sign in to comment.