diff --git a/docs/clusterdefinition.md b/docs/clusterdefinition.md index 1be235f1fe..8a274bb1ad 100644 --- a/docs/clusterdefinition.md +++ b/docs/clusterdefinition.md @@ -440,7 +440,7 @@ A cluster can have 0 to 12 agent pool profiles. Agent Pool Profiles are used for |Name|Required|Description| |---|---|---| -|availabilityProfile|no|Supported values are `VirtualMachineScaleSets` (default) and `AvailabilitySet`. For Kubernetes clusters before version 1.10, use `AvailabilitySet`. Otherwise, you should use `VirtualMachineScaleSets`| +|availabilityProfile|no|Supported values are `VirtualMachineScaleSets` (default, except for Kubernetes clusters before version 1.10) and `AvailabilitySet`.| |count|yes|Describes the node count| |scaleSetPriority|no|Supported values are `Regular` (default) and `Low`. Only applies to clusters with availabilityProfile `VirtualMachineScaleSets`. Enables the usage of [Low-priority VMs on Scale Sets](https://docs.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-use-low-priority).| |scaleSetEvictionPolicy|no|Supported values are `Delete` (default) and `Deallocate`. Only applies to clusters with availabilityProfile of `VirtualMachineScaleSets` and scaleSetPriority of `Low`.| diff --git a/examples/kubernetes.json b/examples/kubernetes.json index aad12b0b8a..2923d007eb 100644 --- a/examples/kubernetes.json +++ b/examples/kubernetes.json @@ -13,8 +13,7 @@ { "name": "agentpool1", "count": 2, - "vmSize": "Standard_D2_v2", - "availabilityProfile": "AvailabilitySet" + "vmSize": "Standard_D2_v2" } ], "linuxProfile": { diff --git a/pkg/acsengine/defaults.go b/pkg/acsengine/defaults.go index a9486a541e..486d28fb0d 100644 --- a/pkg/acsengine/defaults.go +++ b/pkg/acsengine/defaults.go @@ -756,6 +756,9 @@ func setStorageDefaults(a *api.Properties) { } if len(profile.AvailabilityProfile) == 0 { profile.AvailabilityProfile = api.VirtualMachineScaleSets + if a.OrchestratorProfile.OrchestratorType == api.Kubernetes && !common.IsKubernetesVersionGe(a.OrchestratorProfile.OrchestratorVersion, "1.10.0") { + profile.AvailabilityProfile = api.AvailabilitySet + } } if len(profile.ScaleSetEvictionPolicy) == 0 && profile.ScaleSetPriority == api.ScaleSetPriorityLow { profile.ScaleSetEvictionPolicy = api.ScaleSetEvictionPolicyDelete diff --git a/pkg/acsengine/defaults_test.go b/pkg/acsengine/defaults_test.go index cad5d8edc0..e098778a7a 100644 --- a/pkg/acsengine/defaults_test.go +++ b/pkg/acsengine/defaults_test.go @@ -479,6 +479,20 @@ func TestStorageProfile(t *testing.T) { t.Fatalf("MasterProfile.StorageProfile did not have the expected configuration, got %s, expected %s", properties.OrchestratorProfile.KubernetesConfig.PrivateCluster.JumpboxProfile.StorageProfile, api.ManagedDisks) } + if !properties.AgentPoolProfiles[0].IsAvailabilitySets() { + t.Fatalf("AgentPoolProfile[0].AvailabilityProfile did not have the expected configuration, got %s, expected %s", + properties.AgentPoolProfiles[0].AvailabilityProfile, api.AvailabilitySet) + } + + mockCS = getMockBaseContainerService("1.10.0") + properties = mockCS.Properties + properties.OrchestratorProfile.OrchestratorType = "Kubernetes" + SetPropertiesDefaults(&mockCS, false) + if !properties.AgentPoolProfiles[0].IsVirtualMachineScaleSets() { + t.Fatalf("AgentPoolProfile[0].AvailabilityProfile did not have the expected configuration, got %s, expected %s", + properties.AgentPoolProfiles[0].AvailabilityProfile, api.VirtualMachineScaleSets) + } + } func TestAgentPoolProfile(t *testing.T) { diff --git a/pkg/api/vlabs/validate.go b/pkg/api/vlabs/validate.go index 703de5f4e4..776fcef60e 100644 --- a/pkg/api/vlabs/validate.go +++ b/pkg/api/vlabs/validate.go @@ -587,8 +587,8 @@ func (a *Properties) Validate(isUpdate bool) error { } } - // validation for VMSS for Kubernetes - if a.OrchestratorProfile.OrchestratorType == Kubernetes && (agentPoolProfile.AvailabilityProfile == VirtualMachineScaleSets || len(agentPoolProfile.AvailabilityProfile) == 0) { + // validation for VMSS with Kubernetes + if a.OrchestratorProfile.OrchestratorType == Kubernetes && agentPoolProfile.AvailabilityProfile == VirtualMachineScaleSets { version := common.RationalizeReleaseAndVersion( a.OrchestratorProfile.OrchestratorType, a.OrchestratorProfile.OrchestratorRelease, @@ -608,38 +608,21 @@ func (a *Properties) Validate(isUpdate bool) error { return fmt.Errorf("could not apply semver constraint < %s against version %s", minVersion, version) } if cons.Check(sv) { - return fmt.Errorf("VirtualMachineScaleSets are only available in Kubernetes version %s or greater; unable to validate for Kubernetes version %s", - minVersion, version) + return fmt.Errorf("VirtualMachineScaleSets are only available in Kubernetes version %s or greater. Please set \"orchestratorVersion\" to %s or above", minVersion, minVersion) } - } - - // validation for instanceMetadata using VMSS on Kubernetes - if a.OrchestratorProfile.OrchestratorType == Kubernetes && (agentPoolProfile.AvailabilityProfile == VirtualMachineScaleSets || len(agentPoolProfile.AvailabilityProfile) == 0) { - version := common.RationalizeReleaseAndVersion( - a.OrchestratorProfile.OrchestratorType, - a.OrchestratorProfile.OrchestratorRelease, - a.OrchestratorProfile.OrchestratorVersion, - false) - if version == "" { - return fmt.Errorf("the following user supplied OrchestratorProfile configuration is not supported: OrchestratorType: %s, OrchestratorRelease: %s, OrchestratorVersion: %s. Please check supported Release or Version for this build of acs-engine", a.OrchestratorProfile.OrchestratorType, a.OrchestratorProfile.OrchestratorRelease, a.OrchestratorProfile.OrchestratorVersion) - } - - sv, err := semver.NewVersion(version) - if err != nil { - return fmt.Errorf("could not validate version %s", version) - } - minVersion := "1.10.2" - cons, err := semver.NewConstraint("<" + minVersion) + // validation for instanceMetadata using VMSS with Kubernetes + minVersion = "1.10.2" + cons, err = semver.NewConstraint("<" + minVersion) if err != nil { return fmt.Errorf("could not apply semver constraint < %s against version %s", minVersion, version) } if a.OrchestratorProfile.KubernetesConfig != nil && a.OrchestratorProfile.KubernetesConfig.UseInstanceMetadata != nil { if *a.OrchestratorProfile.KubernetesConfig.UseInstanceMetadata && cons.Check(sv) { - return fmt.Errorf("VirtualMachineScaleSets with instance metadata is supported for Kubernetes version %s or greater. Please set \"useInstanceMetadata\": false in \"kubernetesConfig\"", minVersion) + return fmt.Errorf("VirtualMachineScaleSets with instance metadata is supported for Kubernetes version %s or greater. Please set \"useInstanceMetadata\": false in \"kubernetesConfig\" or set \"orchestratorVersion\" to %s or above", minVersion, minVersion) } } else { if cons.Check(sv) { - return fmt.Errorf("VirtualMachineScaleSets with instance metadata is supported for Kubernetes version %s or greater. Please set \"useInstanceMetadata\": false in \"kubernetesConfig\"", minVersion) + return fmt.Errorf("VirtualMachineScaleSets with instance metadata is supported for Kubernetes version %s or greater. Please set \"useInstanceMetadata\": false in \"kubernetesConfig\" or set \"orchestratorVersion\" to %s or above", minVersion, minVersion) } } }