diff --git a/cmd/get_versions.go b/cmd/get_versions.go index bbf6d3fea8..6d8414d14f 100644 --- a/cmd/get_versions.go +++ b/cmd/get_versions.go @@ -27,6 +27,7 @@ type getVersionsCmd struct { orchestrator string version string windows bool + azureEnv string output string } @@ -44,6 +45,7 @@ func newGetVersionsCmd() *cobra.Command { gvc.orchestrator = "Kubernetes" // orchestrator is always Kubernetes f.StringVar(&gvc.version, "version", "", "Kubernetes version (optional)") f.BoolVar(&gvc.windows, "windows", false, "Kubernetes cluster with Windows nodes (optional)") + f.StringVar(&gvc.azureEnv, "azure-env", "AzurePublicCloud", "The target Azure cloud") getVersionsCmdDescription := fmt.Sprintf("Output format. Allowed values: %s", strings.Join(outputFormatOptions, ", ")) f.StringVarP(&gvc.output, "output", "o", "human", getVersionsCmdDescription) @@ -52,7 +54,7 @@ func newGetVersionsCmd() *cobra.Command { } func (gvc *getVersionsCmd) run(cmd *cobra.Command, args []string) error { - orchs, err := api.GetOrchestratorVersionProfileListVLabs(gvc.orchestrator, gvc.version, gvc.windows) + orchs, err := api.GetOrchestratorVersionProfileListVLabs(gvc.orchestrator, gvc.version, gvc.windows, gvc.azureEnv) if err != nil { return err } diff --git a/cmd/upgrade.go b/cmd/upgrade.go index 1f7cc13b93..471287bda9 100644 --- a/cmd/upgrade.go +++ b/cmd/upgrade.go @@ -208,7 +208,7 @@ func (uc *upgradeCmd) loadCluster() error { func (uc *upgradeCmd) validateTargetVersion() error { // Get available upgrades for container service. - orchestratorInfo, err := api.GetOrchestratorVersionProfile(uc.containerService.Properties.OrchestratorProfile, uc.containerService.Properties.HasWindows()) + orchestratorInfo, err := api.GetOrchestratorVersionProfile(uc.containerService.Properties.OrchestratorProfile, uc.containerService.Properties.HasWindows(), uc.containerService.Properties.IsAzureStackCloud()) if err != nil { return errors.Wrap(err, "error getting list of available upgrades") } diff --git a/pkg/api/agentPoolOnlyApi/v20180331/apiloader_test.go b/pkg/api/agentPoolOnlyApi/v20180331/apiloader_test.go index 563298efe3..cc78511327 100644 --- a/pkg/api/agentPoolOnlyApi/v20180331/apiloader_test.go +++ b/pkg/api/agentPoolOnlyApi/v20180331/apiloader_test.go @@ -26,8 +26,8 @@ var _ = Describe("v20180331 test suite", func() { locale := gotext.NewLocale(path.Join("../../..", "../../..", "translations"), "en_US") _ = i18n.Initialize(locale) apiloader := &api.Apiloader{} - k8sVersions := common.GetAllSupportedKubernetesVersions(false, false) - defaultK8sVersion := common.GetDefaultKubernetesVersion(false) + k8sVersions := common.GetAllSupportedKubernetesVersions(false, false, false) + defaultK8sVersion := common.GetDefaultKubernetesVersion(false, false) Context("when networkprofile is nil, enable the addon profile", func() { It("should merge fields properly", func() { diff --git a/pkg/api/apiloader.go b/pkg/api/apiloader.go index 373a8f2de9..6c06ec9182 100644 --- a/pkg/api/apiloader.go +++ b/pkg/api/apiloader.go @@ -145,6 +145,7 @@ func (a *Apiloader) LoadContainerServiceForAgentPoolOnlyCluster( hasExistingCS := existingContainerService != nil IsSSHAutoGenerated := false hasWindows := false + isAzureStackCloud := false switch version { case v20170831.APIVersion: managedCluster := &v20170831.ManagedCluster{} @@ -168,14 +169,14 @@ func (a *Apiloader) LoadContainerServiceForAgentPoolOnlyCluster( // use defaultKubernetesVersion arg if no version was supplied in the request contents if managedCluster.Properties.KubernetesVersion == "" && defaultKubernetesVersion != "" { - if !common.IsSupportedKubernetesVersion(defaultKubernetesVersion, isUpdate, hasWindows) { + if !common.IsSupportedKubernetesVersion(defaultKubernetesVersion, isUpdate, hasWindows, isAzureStackCloud) { return nil, IsSSHAutoGenerated, a.Translator.Errorf("The selected orchestrator version '%s' is not supported", defaultKubernetesVersion) } managedCluster.Properties.KubernetesVersion = defaultKubernetesVersion } // verify orchestrator version - if len(managedCluster.Properties.KubernetesVersion) > 0 && !common.IsSupportedKubernetesVersion(managedCluster.Properties.KubernetesVersion, isUpdate, hasWindows) { + if len(managedCluster.Properties.KubernetesVersion) > 0 && !common.IsSupportedKubernetesVersion(managedCluster.Properties.KubernetesVersion, isUpdate, hasWindows, isAzureStackCloud) { return nil, IsSSHAutoGenerated, a.Translator.Errorf("The selected orchestrator version '%s' is not supported", managedCluster.Properties.KubernetesVersion) } @@ -208,7 +209,7 @@ func (a *Apiloader) LoadContainerServiceForAgentPoolOnlyCluster( // use defaultKubernetesVersion arg if no version was supplied in the request contents if managedCluster.Properties.KubernetesVersion == "" && defaultKubernetesVersion != "" { - if !common.IsSupportedKubernetesVersion(defaultKubernetesVersion, isUpdate, hasWindows) { + if !common.IsSupportedKubernetesVersion(defaultKubernetesVersion, isUpdate, hasWindows, isAzureStackCloud) { return nil, IsSSHAutoGenerated, a.Translator.Errorf("The selected orchestrator version '%s' is not supported", defaultKubernetesVersion) } if hasExistingCS { @@ -219,7 +220,7 @@ func (a *Apiloader) LoadContainerServiceForAgentPoolOnlyCluster( } // verify orchestrator version - if len(managedCluster.Properties.KubernetesVersion) > 0 && !common.IsSupportedKubernetesVersion(managedCluster.Properties.KubernetesVersion, isUpdate, hasWindows) { + if len(managedCluster.Properties.KubernetesVersion) > 0 && !common.IsSupportedKubernetesVersion(managedCluster.Properties.KubernetesVersion, isUpdate, hasWindows, isAzureStackCloud) { return nil, IsSSHAutoGenerated, a.Translator.Errorf("The selected orchestrator version '%s' is not supported", managedCluster.Properties.KubernetesVersion) } diff --git a/pkg/api/apiloader_test.go b/pkg/api/apiloader_test.go index a19a216f8e..68d8655e1b 100644 --- a/pkg/api/apiloader_test.go +++ b/pkg/api/apiloader_test.go @@ -58,8 +58,8 @@ func TestLoadContainerServiceForAgentPoolOnlyCluster(t *testing.T) { Locale: locale, }, } - k8sVersions := common.GetAllSupportedKubernetesVersions(true, false) - defaultK8sVersion := common.GetDefaultKubernetesVersion(false) + k8sVersions := common.GetAllSupportedKubernetesVersions(true, false, false) + defaultK8sVersion := common.GetDefaultKubernetesVersion(false, false) Context("v20180331", func() { It("it should return error if managed cluster body is empty", func() { diff --git a/pkg/api/common/const.go b/pkg/api/common/const.go index 6dda716dda..23798b6f25 100644 --- a/pkg/api/common/const.go +++ b/pkg/api/common/const.go @@ -66,8 +66,12 @@ const ( const ( // KubernetesDefaultRelease is the default Kubernetes release KubernetesDefaultRelease string = "1.18" - // KubernetesDefaultReleaseWindows is the default Kubernetes release + // KubernetesDefaultReleaseWindows is the default Kubernetes release for Windows KubernetesDefaultReleaseWindows string = "1.18" + // KubernetesDefaultReleaseAzureStack is the default Kubernetes release on Azure Stack + KubernetesDefaultReleaseAzureStack string = "1.17" + // KubernetesDefaultReleaseWindowsAzureStack is the default Kubernetes release for Windows on Azure Stack + KubernetesDefaultReleaseWindowsAzureStack string = "1.17" ) const ( diff --git a/pkg/api/common/versions.go b/pkg/api/common/versions.go index cb2c2de304..c4e1018b3a 100644 --- a/pkg/api/common/versions.go +++ b/pkg/api/common/versions.go @@ -198,18 +198,53 @@ var AllKubernetesSupportedVersions = map[string]bool{ "1.19.0-beta.0": true, } +// AllKubernetesSupportedVersionsAzureStack is a whitelist map of all supported Kubernetes version strings on Azure Stack +// The bool value indicates if creating new clusters with this version is allowed +var AllKubernetesSupportedVersionsAzureStack = map[string]bool{ + "1.14.7": false, + "1.14.8": false, // disabled because of https://github.com/Azure/aks-engine/issues/2312 + "1.15.4": false, + "1.15.5": false, // disabled because of https://github.com/Azure/aks-engine/issues/2312 + "1.15.10": false, + "1.15.11": true, + "1.15.12": true, + "1.16.9": true, + "1.16.10": true, + "1.17.4": false, + "1.17.5": true, + "1.17.6": true, +} + +// AllKubernetesWindowsSupportedVersionsAzureStack maintain a set of available k8s Windows versions in aks-engine on Azure Stack +var AllKubernetesWindowsSupportedVersionsAzureStack = map[string]bool{ + "1.15.10": false, + "1.15.11": true, + "1.15.12": true, + "1.16.9": true, + "1.16.10": true, + "1.17.4": false, + "1.17.5": true, + "1.17.6": true, +} + // GetDefaultKubernetesVersion returns the default Kubernetes version, that is the latest patch of the default release -func GetDefaultKubernetesVersion(hasWindows bool) string { +func GetDefaultKubernetesVersion(hasWindows bool, isAzureStackCloud bool) string { defaultRelease := KubernetesDefaultRelease if hasWindows { defaultRelease = KubernetesDefaultReleaseWindows } - return GetLatestPatchVersion(defaultRelease, GetAllSupportedKubernetesVersions(false, hasWindows)) + if isAzureStackCloud && hasWindows { + defaultRelease = KubernetesDefaultReleaseWindowsAzureStack + } + if isAzureStackCloud && !hasWindows { + defaultRelease = KubernetesDefaultReleaseAzureStack + } + return GetLatestPatchVersion(defaultRelease, GetAllSupportedKubernetesVersions(false, hasWindows, isAzureStackCloud)) } // GetSupportedKubernetesVersion verifies that a passed-in version string is supported, or returns a default version string if not -func GetSupportedKubernetesVersion(version string, hasWindows bool) string { - k8sVersion := GetDefaultKubernetesVersion(hasWindows) +func GetSupportedKubernetesVersion(version string, hasWindows bool, isAzureStackCloud bool) string { + k8sVersion := GetDefaultKubernetesVersion(hasWindows, isAzureStackCloud) if hasWindows { if AllKubernetesWindowsSupportedVersions[version] { k8sVersion = version @@ -219,16 +254,35 @@ func GetSupportedKubernetesVersion(version string, hasWindows bool) string { k8sVersion = version } } + if isAzureStackCloud { + if hasWindows { + if AllKubernetesWindowsSupportedVersionsAzureStack[version] { + k8sVersion = version + } + } else { + if AllKubernetesSupportedVersionsAzureStack[version] { + k8sVersion = version + } + } + } return k8sVersion } // GetAllSupportedKubernetesVersions returns a slice of all supported Kubernetes versions -func GetAllSupportedKubernetesVersions(isUpdate, hasWindows bool) []string { +func GetAllSupportedKubernetesVersions(isUpdate, hasWindows bool, isAzureStackCloud bool) []string { var versions []string allSupportedVersions := AllKubernetesSupportedVersions if hasWindows { allSupportedVersions = AllKubernetesWindowsSupportedVersions } + + if isAzureStackCloud && hasWindows { + allSupportedVersions = AllKubernetesWindowsSupportedVersionsAzureStack + } + if isAzureStackCloud && !hasWindows { + allSupportedVersions = AllKubernetesSupportedVersionsAzureStack + } + for ver, supported := range allSupportedVersions { if isUpdate || supported { versions = append(versions, ver) @@ -362,10 +416,10 @@ func getAllKubernetesWindowsSupportedVersionsMap() map[string]bool { } // GetSupportedVersions get supported version list for a certain orchestrator -func GetSupportedVersions(orchType string, isUpdate, hasWindows bool) (versions []string, defaultVersion string) { +func GetSupportedVersions(orchType string, isUpdate, hasWindows bool, isAzureStackCloud bool) (versions []string, defaultVersion string) { switch orchType { case Kubernetes: - return GetAllSupportedKubernetesVersions(isUpdate, hasWindows), GetDefaultKubernetesVersion(hasWindows) + return GetAllSupportedKubernetesVersions(isUpdate, hasWindows, isAzureStackCloud), GetDefaultKubernetesVersion(hasWindows, isAzureStackCloud) case DCOS: return AllDCOSSupportedVersions, DCOSDefaultVersion default: @@ -374,14 +428,15 @@ func GetSupportedVersions(orchType string, isUpdate, hasWindows bool) (versions } //GetValidPatchVersion gets the current valid patch version for the minor version of the passed in version -func GetValidPatchVersion(orchType, orchVer string, isUpdate, hasWindows bool) string { +func GetValidPatchVersion(orchType, orchVer string, isUpdate, hasWindows bool, isAzureStackCloud bool) string { if orchVer == "" { return RationalizeReleaseAndVersion( orchType, "", "", isUpdate, - hasWindows) + hasWindows, + isAzureStackCloud) } // check if the current version is valid, this allows us to have multiple supported patch versions in the future if we need it @@ -390,7 +445,8 @@ func GetValidPatchVersion(orchType, orchVer string, isUpdate, hasWindows bool) s "", orchVer, isUpdate, - hasWindows) + hasWindows, + isAzureStackCloud) if version == "" { sv, err := semver.Make(orchVer) @@ -404,17 +460,18 @@ func GetValidPatchVersion(orchType, orchVer string, isUpdate, hasWindows bool) s sr, "", isUpdate, - hasWindows) + hasWindows, + isAzureStackCloud) } return version } // RationalizeReleaseAndVersion return a version when it can be rationalized from the input, otherwise "" -func RationalizeReleaseAndVersion(orchType, orchRel, orchVer string, isUpdate, hasWindows bool) (version string) { +func RationalizeReleaseAndVersion(orchType, orchRel, orchVer string, isUpdate, hasWindows bool, isAzureStackCloud bool) (version string) { // ignore "v" prefix in orchestrator version and release: "v1.8.0" is equivalent to "1.8.0", "v1.9" is equivalent to "1.9" orchVer = strings.TrimPrefix(orchVer, "v") orchRel = strings.TrimPrefix(orchRel, "v") - supportedVersions, defaultVersion := GetSupportedVersions(orchType, isUpdate, hasWindows) + supportedVersions, defaultVersion := GetSupportedVersions(orchType, isUpdate, hasWindows, isAzureStackCloud) if supportedVersions == nil { return "" } @@ -457,6 +514,7 @@ func IsValidMinVersion(orchType, orchRelease, orchVersion, minVersion string) (b orchRelease, orchVersion, false, + false, false) if version == "" { return false, errors.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 aks-engine", @@ -510,8 +568,8 @@ func GetLatestPatchVersion(majorMinor string, versionsList []string) (version st } // IsSupportedKubernetesVersion return true if the provided Kubernetes version is supported -func IsSupportedKubernetesVersion(version string, isUpdate, hasWindows bool) bool { - for _, ver := range GetAllSupportedKubernetesVersions(isUpdate, hasWindows) { +func IsSupportedKubernetesVersion(version string, isUpdate, hasWindows bool, isAzureStackCloud bool) bool { + for _, ver := range GetAllSupportedKubernetesVersions(isUpdate, hasWindows, isAzureStackCloud) { if ver == version { return true } diff --git a/pkg/api/common/versions_test.go b/pkg/api/common/versions_test.go index 931cea75e6..d3d7d8cd1f 100644 --- a/pkg/api/common/versions_test.go +++ b/pkg/api/common/versions_test.go @@ -8,46 +8,88 @@ import ( ) func Test_GetAllSupportedKubernetesVersions(t *testing.T) { - responseFromGetter := GetAllSupportedKubernetesVersions(true, false) + isAzureStackCloud := false + responseFromGetter := GetAllSupportedKubernetesVersions(true, false, isAzureStackCloud) if len(AllKubernetesSupportedVersions) != len(responseFromGetter) { - t.Errorf("GetAllSupportedKubernetesVersions(true, false) returned %d items, expected %d", len(responseFromGetter), len(AllKubernetesSupportedVersions)) + t.Errorf("GetAllSupportedKubernetesVersions(true, false, false) returned %d items, expected %d", len(responseFromGetter), len(AllKubernetesSupportedVersions)) } - responseFromGetter = GetAllSupportedKubernetesVersions(false, false) + responseFromGetter = GetAllSupportedKubernetesVersions(false, false, isAzureStackCloud) for _, version := range responseFromGetter { if !AllKubernetesSupportedVersions[version] { - t.Errorf("GetAllSupportedKubernetesVersions(false, false) returned a version %s that was not in the definitive AllKubernetesSupportedVersions map", version) + t.Errorf("GetAllSupportedKubernetesVersions(false, false, false) returned a version %s that was not in the definitive AllKubernetesSupportedVersions map", version) + } + } + + isAzureStackCloud = true + responseFromGetter = GetAllSupportedKubernetesVersions(true, false, isAzureStackCloud) + + if len(AllKubernetesSupportedVersionsAzureStack) != len(responseFromGetter) { + t.Errorf("GetAllSupportedKubernetesVersions(true, false, true) returned %d items, expected %d", len(responseFromGetter), len(AllKubernetesSupportedVersionsAzureStack)) + } + + responseFromGetter = GetAllSupportedKubernetesVersions(false, false, isAzureStackCloud) + + for _, version := range responseFromGetter { + if !AllKubernetesSupportedVersionsAzureStack[version] { + t.Errorf("GetAllSupportedKubernetesVersions(false, false, true) returned a version %s that was not in the definitive AllKubernetesSupportedVersionsAzureStack map", version) } } } func Test_GetSupportedKubernetesVersion(t *testing.T) { - versions := GetAllSupportedKubernetesVersions(false, false) + versions := GetAllSupportedKubernetesVersions(false, false, false) for _, version := range versions { - supportedVersion := GetSupportedKubernetesVersion(version, false) + supportedVersion := GetSupportedKubernetesVersion(version, false, false) if supportedVersion != version { t.Errorf("GetSupportedKubernetesVersion(%s) should return the same passed-in string, instead returned %s", version, supportedVersion) } } - defaultVersion := GetSupportedKubernetesVersion("", false) - if defaultVersion != GetDefaultKubernetesVersion(false) { - t.Errorf("GetSupportedKubernetesVersion(\"\") should return the default version %s, instead returned %s", GetDefaultKubernetesVersion(false), defaultVersion) + defaultVersion := GetSupportedKubernetesVersion("", false, false) + if defaultVersion != GetDefaultKubernetesVersion(false, false) { + t.Errorf("GetSupportedKubernetesVersion(\"\") should return the default version %s, instead returned %s", GetDefaultKubernetesVersion(false, false), defaultVersion) } - winVersions := GetAllSupportedKubernetesVersions(false, true) + winVersions := GetAllSupportedKubernetesVersions(false, true, false) for _, version := range winVersions { - supportedVersion := GetSupportedKubernetesVersion(version, true) + supportedVersion := GetSupportedKubernetesVersion(version, true, false) + if supportedVersion != version { + t.Errorf("GetSupportedKubernetesVersion(%s) should return the same passed-in string, instead returned %s", version, supportedVersion) + } + } + + defaultWinVersion := GetSupportedKubernetesVersion("", true, false) + if defaultWinVersion != GetDefaultKubernetesVersion(true, false) { + t.Errorf("GetSupportedKubernetesVersion(\"\") should return the default version for windows %s, instead returned %s", GetDefaultKubernetesVersion(true, false), defaultWinVersion) + } + + azureStackVersions := GetAllSupportedKubernetesVersions(false, false, true) + for _, version := range azureStackVersions { + supportedVersion := GetSupportedKubernetesVersion(version, false, true) + if supportedVersion != version { + t.Errorf("GetSupportedKubernetesVersion(%s) should return the same passed-in string, instead returned %s", version, supportedVersion) + } + } + + defaultAzureStackVersion := GetSupportedKubernetesVersion("", false, true) + if defaultAzureStackVersion != GetDefaultKubernetesVersion(false, true) { + t.Errorf("GetSupportedKubernetesVersion(\"\") should return the default version %s, instead returned %s", GetDefaultKubernetesVersion(false, true), defaultAzureStackVersion) + } + + azureStackWinVersions := GetAllSupportedKubernetesVersions(false, true, true) + for _, version := range azureStackWinVersions { + supportedVersion := GetSupportedKubernetesVersion(version, true, true) if supportedVersion != version { t.Errorf("GetSupportedKubernetesVersion(%s) should return the same passed-in string, instead returned %s", version, supportedVersion) } } - defaultWinVersion := GetSupportedKubernetesVersion("", true) - if defaultWinVersion != GetDefaultKubernetesVersion(true) { - t.Errorf("GetSupportedKubernetesVersion(\"\") should return the default version for windows %s, instead returned %s", GetDefaultKubernetesVersion(true), defaultWinVersion) + defaultAzureStackWinVersion := GetSupportedKubernetesVersion("", true, true) + if defaultAzureStackWinVersion != GetDefaultKubernetesVersion(true, true) { + t.Errorf("GetSupportedKubernetesVersion(\"\") should return the default version for windows %s, instead returned %s", GetDefaultKubernetesVersion(true, true), defaultAzureStackWinVersion) } } @@ -351,38 +393,72 @@ func TestGetVersionsBetween(t *testing.T) { } func Test_GetValidPatchVersion(t *testing.T) { - v := GetValidPatchVersion(Kubernetes, "", false, false) - if v != GetDefaultKubernetesVersion(false) { + v := GetValidPatchVersion(Kubernetes, "", false, false, false) + if v != GetDefaultKubernetesVersion(false, false) { t.Errorf("It is not the default Kubernetes version") } for version, enabled := range AllKubernetesSupportedVersions { if enabled { - v = GetValidPatchVersion(Kubernetes, version, false, false) + v = GetValidPatchVersion(Kubernetes, version, false, false, false) if v != version { t.Errorf("Expected version %s, instead got version %s", version, v) } } } - v = GetValidPatchVersion(Kubernetes, "", true, true) - if v != GetDefaultKubernetesVersion(true) { + v = GetValidPatchVersion(Kubernetes, "", true, true, false) + if v != GetDefaultKubernetesVersion(true, false) { t.Errorf("It is not the default Kubernetes version") } - v = GetValidPatchVersion(Mesos, "1.6.0", false, false) + v = GetValidPatchVersion(Mesos, "1.6.0", false, false, false) if v != "" { t.Errorf("Expected empty version for unsupported orchType") } for version, enabled := range AllKubernetesWindowsSupportedVersions { if enabled { - v = GetValidPatchVersion(Kubernetes, version, false, true) + v = GetValidPatchVersion(Kubernetes, version, false, true, false) if v != version { t.Errorf("Expected version %s, instead got version %s", version, v) } } } + + v = GetValidPatchVersion(Kubernetes, "", false, false, true) + if v != GetDefaultKubernetesVersion(false, true) { + t.Errorf("It is not the default Kubernetes version") + } + + for version, enabled := range AllKubernetesSupportedVersionsAzureStack { + if enabled { + v = GetValidPatchVersion(Kubernetes, version, false, false, true) + if v != version { + t.Errorf("Expected version %s, instead got version %s", version, v) + } + } + } + + v = GetValidPatchVersion(Kubernetes, "", true, true, true) + if v != GetDefaultKubernetesVersion(true, true) { + t.Errorf("It is not the default Kubernetes version") + } + + v = GetValidPatchVersion(Mesos, "1.6.0", false, false, true) + if v != "" { + t.Errorf("Expected empty version for unsupported orchType") + } + + for version, enabled := range AllKubernetesWindowsSupportedVersionsAzureStack { + if enabled { + v = GetValidPatchVersion(Kubernetes, version, false, true, true) + if v != version { + t.Errorf("Expected version %s, instead got version %s", version, v) + } + } + } + } func TestGetLatestPatchVersion(t *testing.T) { @@ -493,85 +569,85 @@ func TestGetMinMaxVersion(t *testing.T) { } func Test_RationalizeReleaseAndVersion(t *testing.T) { - version := RationalizeReleaseAndVersion(Kubernetes, "", "", false, false) - if version != GetDefaultKubernetesVersion(false) { + version := RationalizeReleaseAndVersion(Kubernetes, "", "", false, false, false) + if version != GetDefaultKubernetesVersion(false, false) { t.Errorf("It is not the default Kubernetes version") } - latest1Dot6Version := GetLatestPatchVersion("1.6", GetAllSupportedKubernetesVersions(true, false)) - version = RationalizeReleaseAndVersion(Kubernetes, "1.6", "", true, false) + latest1Dot6Version := GetLatestPatchVersion("1.6", GetAllSupportedKubernetesVersions(true, false, false)) + version = RationalizeReleaseAndVersion(Kubernetes, "1.6", "", true, false, false) if version != latest1Dot6Version { t.Errorf("It is not Kubernetes version %s", latest1Dot6Version) } expectedVersion := "1.7.16" - version = RationalizeReleaseAndVersion(Kubernetes, "", expectedVersion, true, false) + version = RationalizeReleaseAndVersion(Kubernetes, "", expectedVersion, true, false, false) if version != expectedVersion { t.Errorf("It is not Kubernetes version %s", expectedVersion) } - version = RationalizeReleaseAndVersion(Kubernetes, "1.7", expectedVersion, true, false) + version = RationalizeReleaseAndVersion(Kubernetes, "1.7", expectedVersion, true, false, false) if version != expectedVersion { t.Errorf("It is not Kubernetes version %s", expectedVersion) } - version = RationalizeReleaseAndVersion(Kubernetes, "", "v"+expectedVersion, true, false) + version = RationalizeReleaseAndVersion(Kubernetes, "", "v"+expectedVersion, true, false, false) if version != expectedVersion { t.Errorf("It is not Kubernetes version %s", expectedVersion) } - version = RationalizeReleaseAndVersion(Kubernetes, "v1.7", "v"+expectedVersion, true, false) + version = RationalizeReleaseAndVersion(Kubernetes, "v1.7", "v"+expectedVersion, true, false, false) if version != expectedVersion { t.Errorf("It is not Kubernetes version %s", expectedVersion) } - version = RationalizeReleaseAndVersion(Kubernetes, "1.1", "", true, false) + version = RationalizeReleaseAndVersion(Kubernetes, "1.1", "", true, false, false) if version != "" { t.Errorf("It is not empty string") } - version = RationalizeReleaseAndVersion(Kubernetes, "1.1", "1.6.6", true, false) + version = RationalizeReleaseAndVersion(Kubernetes, "1.1", "1.6.6", true, false, false) if version != "" { t.Errorf("It is not empty string") } - version = RationalizeReleaseAndVersion(Kubernetes, "", "", true, true) - if version != GetDefaultKubernetesVersion(true) { + version = RationalizeReleaseAndVersion(Kubernetes, "", "", true, true, false) + if version != GetDefaultKubernetesVersion(true, false) { t.Errorf("It is not the default Windows Kubernetes version") } - version = RationalizeReleaseAndVersion(Kubernetes, "1.5", "", true, true) + version = RationalizeReleaseAndVersion(Kubernetes, "1.5", "", true, true, false) if version != "" { t.Errorf("It is not empty string") } expectedVersion = "1.8.12" - version = RationalizeReleaseAndVersion(Kubernetes, "", expectedVersion, true, true) + version = RationalizeReleaseAndVersion(Kubernetes, "", expectedVersion, true, true, false) if version != expectedVersion { t.Errorf("It is not Kubernetes version %s", expectedVersion) } - version = RationalizeReleaseAndVersion(Kubernetes, "1.8", expectedVersion, true, true) + version = RationalizeReleaseAndVersion(Kubernetes, "1.8", expectedVersion, true, true, false) if version != expectedVersion { t.Errorf("It is not Kubernetes version %s", expectedVersion) } - version = RationalizeReleaseAndVersion(Kubernetes, "", "v"+expectedVersion, true, true) + version = RationalizeReleaseAndVersion(Kubernetes, "", "v"+expectedVersion, true, true, false) if version != expectedVersion { t.Errorf("It is not Kubernetes version %s", expectedVersion) } - version = RationalizeReleaseAndVersion(Kubernetes, "v1.8", "v"+expectedVersion, true, true) + version = RationalizeReleaseAndVersion(Kubernetes, "v1.8", "v"+expectedVersion, true, true, false) if version != expectedVersion { t.Errorf("It is not Kubernetes version %s", expectedVersion) } - version = RationalizeReleaseAndVersion(Kubernetes, "1.1", "", true, true) + version = RationalizeReleaseAndVersion(Kubernetes, "1.1", "", true, true, false) if version != "" { t.Errorf("It is not empty string") } - version = RationalizeReleaseAndVersion(Kubernetes, "1.1", "1.6.6", true, true) + version = RationalizeReleaseAndVersion(Kubernetes, "1.1", "1.6.6", true, true, false) if version != "" { t.Errorf("It is not empty string") } @@ -580,9 +656,11 @@ func Test_RationalizeReleaseAndVersion(t *testing.T) { func Test_IsSupportedKubernetesVersion(t *testing.T) { for _, isUpdate := range []bool{true, false} { for _, hasWindows := range []bool{true, false} { - for _, version := range GetAllSupportedKubernetesVersions(isUpdate, hasWindows) { - if !IsSupportedKubernetesVersion(version, isUpdate, hasWindows) { - t.Errorf("Expected version %s to be supported when isUpdate is %t and hasWindows is %t", version, isUpdate, hasWindows) + for _, isAzureStackCloud := range []bool{true, false} { + for _, version := range GetAllSupportedKubernetesVersions(isUpdate, hasWindows, isAzureStackCloud) { + if !IsSupportedKubernetesVersion(version, isUpdate, hasWindows, isAzureStackCloud) { + t.Errorf("Expected version %s to be supported when isUpdate is %t and hasWindows is %t and isAzureStackCloud is %t", version, isUpdate, hasWindows, isAzureStackCloud) + } } } } diff --git a/pkg/api/convertertoagentpoolonlyapi.go b/pkg/api/convertertoagentpoolonlyapi.go index ab9e20a742..3e711e8584 100644 --- a/pkg/api/convertertoagentpoolonlyapi.go +++ b/pkg/api/convertertoagentpoolonlyapi.go @@ -215,7 +215,7 @@ func convertVLabsAgentPoolOnlyWindowsProfile(vlabs *vlabs.WindowsProfile, api *W func convertV20170831AgentPoolOnlyOrchestratorProfile(kubernetesVersion string) *OrchestratorProfile { return &OrchestratorProfile{ OrchestratorType: Kubernetes, - OrchestratorVersion: common.GetSupportedKubernetesVersion(kubernetesVersion, false), + OrchestratorVersion: common.GetSupportedKubernetesVersion(kubernetesVersion, false, false), KubernetesConfig: &KubernetesConfig{ EnableRbac: to.BoolPtr(false), EnableSecureKubelet: to.BoolPtr(false), @@ -232,7 +232,7 @@ func convertV20170831AgentPoolOnlyOrchestratorProfile(kubernetesVersion string) func convertVLabsAgentPoolOnlyOrchestratorProfile(kubernetesVersion string) *OrchestratorProfile { return &OrchestratorProfile{ OrchestratorType: Kubernetes, - OrchestratorVersion: common.GetSupportedKubernetesVersion(kubernetesVersion, false), + OrchestratorVersion: common.GetSupportedKubernetesVersion(kubernetesVersion, false, false), } } @@ -462,7 +462,7 @@ func convertV20180331AgentPoolOnlyOrchestratorProfile(kubernetesVersion string, return &OrchestratorProfile{ OrchestratorType: Kubernetes, - OrchestratorVersion: common.GetSupportedKubernetesVersion(kubernetesVersion, false), + OrchestratorVersion: common.GetSupportedKubernetesVersion(kubernetesVersion, false, false), KubernetesConfig: kubernetesConfig, } } diff --git a/pkg/api/convertertoapi.go b/pkg/api/convertertoapi.go index fd947a75f8..464464122f 100644 --- a/pkg/api/convertertoapi.go +++ b/pkg/api/convertertoapi.go @@ -233,7 +233,8 @@ func convertVLabsOrchestratorProfile(vp *vlabs.Properties, api *OrchestratorProf vlabscs.OrchestratorRelease, vlabscs.OrchestratorVersion, isUpdate, - vp.HasWindows()) + vp.HasWindows(), + vp.IsAzureStackCloud()) case DCOS: if vlabscs.DcosConfig != nil { @@ -245,6 +246,7 @@ func convertVLabsOrchestratorProfile(vp *vlabs.Properties, api *OrchestratorProf vlabscs.OrchestratorRelease, vlabscs.OrchestratorVersion, isUpdate, + false, false) } diff --git a/pkg/api/defaults-apiserver_test.go b/pkg/api/defaults-apiserver_test.go index a724222fad..c8cea8fbf0 100644 --- a/pkg/api/defaults-apiserver_test.go +++ b/pkg/api/defaults-apiserver_test.go @@ -13,7 +13,7 @@ import ( "github.com/Azure/go-autorest/autorest/to" ) -var defaultTestClusterVer = common.RationalizeReleaseAndVersion(Kubernetes, common.KubernetesDefaultRelease, "", false, false) +var defaultTestClusterVer = common.RationalizeReleaseAndVersion(Kubernetes, common.KubernetesDefaultRelease, "", false, false, false) func TestAPIServerConfigEnableDataEncryptionAtRest(t *testing.T) { // Test EnableDataEncryptionAtRest = true diff --git a/pkg/api/defaults-kubelet_test.go b/pkg/api/defaults-kubelet_test.go index 9fa96e5d4f..804f619c3b 100644 --- a/pkg/api/defaults-kubelet_test.go +++ b/pkg/api/defaults-kubelet_test.go @@ -17,7 +17,7 @@ import ( ) func TestKubeletConfigDefaults(t *testing.T) { - cs := CreateMockContainerService("testcluster", common.RationalizeReleaseAndVersion(Kubernetes, common.KubernetesDefaultRelease, "", false, false), 3, 2, false) + cs := CreateMockContainerService("testcluster", common.RationalizeReleaseAndVersion(Kubernetes, common.KubernetesDefaultRelease, "", false, false, false), 3, 2, false) winProfile := &AgentPoolProfile{} winProfile.Count = 1 winProfile.Name = "agentpool2" @@ -135,7 +135,7 @@ func TestKubeletConfigDefaults(t *testing.T) { delete(expected, "--container-runtime-endpoint") // validate aad-pod-identity disabled scenario - cs = CreateMockContainerService("testcluster", common.RationalizeReleaseAndVersion(Kubernetes, common.KubernetesDefaultRelease, "", false, false), 3, 2, false) + cs = CreateMockContainerService("testcluster", common.RationalizeReleaseAndVersion(Kubernetes, common.KubernetesDefaultRelease, "", false, false, false), 3, 2, false) cs.Properties.OrchestratorProfile.KubernetesConfig.Addons = []KubernetesAddon{ { Name: common.AADPodIdentityAddonName, @@ -152,7 +152,7 @@ func TestKubeletConfigDefaults(t *testing.T) { } } - cs = CreateMockContainerService("testcluster", common.RationalizeReleaseAndVersion(Kubernetes, common.KubernetesDefaultRelease, "", false, false), 3, 2, false) + cs = CreateMockContainerService("testcluster", common.RationalizeReleaseAndVersion(Kubernetes, common.KubernetesDefaultRelease, "", false, false, false), 3, 2, false) // check when ip-masq-agent is explicitly disabled in kubernetes config cs.Properties.OrchestratorProfile.KubernetesConfig.Addons = []KubernetesAddon{ { @@ -244,7 +244,7 @@ func getDefaultLinuxKubeletConfig(cs *ContainerService) map[string]string { } func TestKubeletConfigAzureStackDefaults(t *testing.T) { - cs := CreateMockContainerService("testcluster", common.RationalizeReleaseAndVersion(Kubernetes, "1.15", "", false, false), 3, 2, false) + cs := CreateMockContainerService("testcluster", common.RationalizeReleaseAndVersion(Kubernetes, "1.15", "", false, false, false), 3, 2, false) cs.Properties.CustomCloudProfile = &CustomCloudProfile{} winProfile := &AgentPoolProfile{} winProfile.Count = 1 @@ -339,7 +339,7 @@ func TestKubeletConfigAzureStackDefaults(t *testing.T) { } } - cs = CreateMockContainerService("testcluster", common.RationalizeReleaseAndVersion(Kubernetes, common.KubernetesDefaultRelease, "", false, false), 3, 2, false) + cs = CreateMockContainerService("testcluster", common.RationalizeReleaseAndVersion(Kubernetes, common.KubernetesDefaultRelease, "", false, false, false), 3, 2, false) // check when ip-masq-agent is explicitly disabled in kubernetes config cs.Properties.OrchestratorProfile.KubernetesConfig.Addons = []KubernetesAddon{ { @@ -387,7 +387,7 @@ func TestKubeletConfigAzureStackDefaults(t *testing.T) { } func TestKubeletConfigDefaultsRemovals(t *testing.T) { - cs := CreateMockContainerService("testcluster", common.RationalizeReleaseAndVersion(Kubernetes, "1.15", "", false, false), 3, 2, false) + cs := CreateMockContainerService("testcluster", common.RationalizeReleaseAndVersion(Kubernetes, "1.15", "", false, false, false), 3, 2, false) poolProfile := &AgentPoolProfile{} poolProfile.Count = 1 poolProfile.Name = "agentpool2" @@ -978,7 +978,7 @@ func TestStaticWindowsConfig(t *testing.T) { } func TestKubeletRotateCertificates(t *testing.T) { - cs := CreateMockContainerService("testcluster", common.RationalizeReleaseAndVersion(Kubernetes, "1.18", "", false, false), 3, 2, false) + cs := CreateMockContainerService("testcluster", common.RationalizeReleaseAndVersion(Kubernetes, "1.18", "", false, false, false), 3, 2, false) cs.setKubeletConfig(false) k := cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig if k["--rotate-certificates"] != "true" { @@ -987,7 +987,7 @@ func TestKubeletRotateCertificates(t *testing.T) { } // Test user-override - cs = CreateMockContainerService("testcluster", common.RationalizeReleaseAndVersion(Kubernetes, "1.18", "", false, false), 3, 2, false) + cs = CreateMockContainerService("testcluster", common.RationalizeReleaseAndVersion(Kubernetes, "1.18", "", false, false, false), 3, 2, false) k = cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig k["--rotate-certificates"] = "false" cs.setKubeletConfig(false) @@ -999,7 +999,7 @@ func TestKubeletRotateCertificates(t *testing.T) { } func TestKubeletConfigDefaultFeatureGates(t *testing.T) { // test 1.16 - cs := CreateMockContainerService("testcluster", common.RationalizeReleaseAndVersion(Kubernetes, "1.18", "", false, false), 3, 2, false) + cs := CreateMockContainerService("testcluster", common.RationalizeReleaseAndVersion(Kubernetes, "1.18", "", false, false, false), 3, 2, false) cs.setKubeletConfig(false) k := cs.Properties.OrchestratorProfile.KubernetesConfig.KubeletConfig if k["--feature-gates"] != "RotateKubeletServerCertificate=true" { diff --git a/pkg/api/defaults.go b/pkg/api/defaults.go index a7ddbe1a08..1b81fbeb85 100644 --- a/pkg/api/defaults.go +++ b/pkg/api/defaults.go @@ -94,7 +94,7 @@ func (cs *ContainerService) setOrchestratorDefaults(isUpgrade, isScale bool) { o := a.OrchestratorProfile o.OrchestratorVersion = common.GetValidPatchVersion( o.OrchestratorType, - o.OrchestratorVersion, isUpdate, a.HasWindows()) + o.OrchestratorVersion, isUpdate, a.HasWindows(), a.IsAzureStackCloud()) switch o.OrchestratorType { case Kubernetes: diff --git a/pkg/api/defaults_test.go b/pkg/api/defaults_test.go index 7ea05d16e4..ffb444f783 100644 --- a/pkg/api/defaults_test.go +++ b/pkg/api/defaults_test.go @@ -4167,7 +4167,7 @@ func TestEnableRBAC(t *testing.T) { Properties: &Properties{ OrchestratorProfile: &OrchestratorProfile{ OrchestratorType: Kubernetes, - OrchestratorVersion: common.GetLatestPatchVersion("1.15", common.GetAllSupportedKubernetesVersions(false, false)), + OrchestratorVersion: common.GetLatestPatchVersion("1.15", common.GetAllSupportedKubernetesVersions(false, false, false)), }, MasterProfile: &MasterProfile{}, }, @@ -4180,7 +4180,7 @@ func TestEnableRBAC(t *testing.T) { Properties: &Properties{ OrchestratorProfile: &OrchestratorProfile{ OrchestratorType: Kubernetes, - OrchestratorVersion: common.GetLatestPatchVersion("1.15", common.GetAllSupportedKubernetesVersions(false, false)), + OrchestratorVersion: common.GetLatestPatchVersion("1.15", common.GetAllSupportedKubernetesVersions(false, false, false)), }, MasterProfile: &MasterProfile{}, }, @@ -4194,7 +4194,7 @@ func TestEnableRBAC(t *testing.T) { Properties: &Properties{ OrchestratorProfile: &OrchestratorProfile{ OrchestratorType: Kubernetes, - OrchestratorVersion: common.GetLatestPatchVersion("1.15", common.GetAllSupportedKubernetesVersions(false, false)), + OrchestratorVersion: common.GetLatestPatchVersion("1.15", common.GetAllSupportedKubernetesVersions(false, false, false)), KubernetesConfig: &KubernetesConfig{ EnableRbac: to.BoolPtr(false), }, @@ -4211,7 +4211,7 @@ func TestEnableRBAC(t *testing.T) { Properties: &Properties{ OrchestratorProfile: &OrchestratorProfile{ OrchestratorType: Kubernetes, - OrchestratorVersion: common.GetLatestPatchVersion("1.16", common.GetAllSupportedKubernetesVersions(false, false)), + OrchestratorVersion: common.GetLatestPatchVersion("1.16", common.GetAllSupportedKubernetesVersions(false, false, false)), KubernetesConfig: &KubernetesConfig{ EnableRbac: to.BoolPtr(false), }, @@ -4228,7 +4228,7 @@ func TestEnableRBAC(t *testing.T) { Properties: &Properties{ OrchestratorProfile: &OrchestratorProfile{ OrchestratorType: Kubernetes, - OrchestratorVersion: common.GetLatestPatchVersion("1.15", common.GetAllSupportedKubernetesVersions(false, false)), + OrchestratorVersion: common.GetLatestPatchVersion("1.15", common.GetAllSupportedKubernetesVersions(false, false, false)), KubernetesConfig: &KubernetesConfig{ EnableRbac: to.BoolPtr(false), }, diff --git a/pkg/api/k8s_versions.go b/pkg/api/k8s_versions.go index ee29c248b9..fc2a94f237 100644 --- a/pkg/api/k8s_versions.go +++ b/pkg/api/k8s_versions.go @@ -341,7 +341,7 @@ func GetK8sComponentsByVersionMap(k *KubernetesConfig) map[string]map[string]str overrides = getVersionOverridesGCR } ret := make(map[string]map[string]string) - for _, version := range common.GetAllSupportedKubernetesVersions(true, false) { + for _, version := range common.GetAllSupportedKubernetesVersions(true, false, false) { ret[version] = getK8sVersionComponents(version, k.KubernetesImageBaseType, overrides(version)) } return ret diff --git a/pkg/api/orchestrators.go b/pkg/api/orchestrators.go index fc77a78e2a..91500c4d69 100644 --- a/pkg/api/orchestrators.go +++ b/pkg/api/orchestrators.go @@ -13,10 +13,11 @@ import ( "github.com/pkg/errors" ) -type orchestratorsFunc func(*OrchestratorProfile, bool) ([]*OrchestratorVersionProfile, error) +type orchestratorsFunc func(*OrchestratorProfile, bool, bool) ([]*OrchestratorVersionProfile, error) var funcmap map[string]orchestratorsFunc var versionsMap map[string][]string +var versionsMapAzureStack map[string][]string func init() { funcmap = map[string]orchestratorsFunc{ @@ -26,7 +27,13 @@ func init() { SwarmMode: dockerceInfo, } versionsMap = map[string][]string{ - Kubernetes: common.GetAllSupportedKubernetesVersions(true, false), + Kubernetes: common.GetAllSupportedKubernetesVersions(true, false, false), + DCOS: common.GetAllSupportedDCOSVersions(), + Swarm: common.GetAllSupportedSwarmVersions(), + SwarmMode: common.GetAllSupportedDockerCEVersions(), + } + versionsMapAzureStack = map[string][]string{ + Kubernetes: common.GetAllSupportedKubernetesVersions(true, false, true), DCOS: common.GetAllSupportedDCOSVersions(), Swarm: common.GetAllSupportedSwarmVersions(), SwarmMode: common.GetAllSupportedDockerCEVersions(), @@ -53,10 +60,14 @@ func validate(orchestrator, version string) (string, error) { return "", nil } -func isVersionSupported(csOrch *OrchestratorProfile) bool { +func isVersionSupported(csOrch *OrchestratorProfile, isAzureStackCloud bool) bool { supported := false - for _, version := range versionsMap[csOrch.OrchestratorType] { + versions := versionsMap[csOrch.OrchestratorType] + if isAzureStackCloud { + versions = versionsMapAzureStack[csOrch.OrchestratorType] + } + for _, version := range versions { if version == csOrch.OrchestratorVersion { supported = true break @@ -66,8 +77,8 @@ func isVersionSupported(csOrch *OrchestratorProfile) bool { } // GetOrchestratorVersionProfileListVLabs returns vlabs OrchestratorVersionProfileList object per (optionally) specified orchestrator and version -func GetOrchestratorVersionProfileListVLabs(orchestrator, version string, windows bool) (*vlabs.OrchestratorVersionProfileList, error) { - apiOrchs, err := GetOrchestratorVersionProfileList(orchestrator, version, windows) +func GetOrchestratorVersionProfileListVLabs(orchestrator, version string, windows bool, azureEnv string) (*vlabs.OrchestratorVersionProfileList, error) { + apiOrchs, err := GetOrchestratorVersionProfileList(orchestrator, version, windows, azureEnv) if err != nil { return nil, err } @@ -80,8 +91,9 @@ func GetOrchestratorVersionProfileListVLabs(orchestrator, version string, window } // GetOrchestratorVersionProfileList returns a list of unversioned OrchestratorVersionProfile objects per (optionally) specified orchestrator and version -func GetOrchestratorVersionProfileList(orchestrator, version string, windows bool) ([]*OrchestratorVersionProfile, error) { +func GetOrchestratorVersionProfileList(orchestrator, version string, windows bool, azureEnv string) ([]*OrchestratorVersionProfile, error) { var err error + isAzureStackCloud := (strings.EqualFold(azureEnv, AzureStackCloud)) if orchestrator, err = validate(orchestrator, version); err != nil { return nil, err } @@ -90,14 +102,14 @@ func GetOrchestratorVersionProfileList(orchestrator, version string, windows boo // return all orchestrators for _, f := range funcmap { var arr []*OrchestratorVersionProfile - arr, err = f(&OrchestratorProfile{}, false) + arr, err = f(&OrchestratorProfile{}, false, isAzureStackCloud) if err != nil { return nil, err } orchs = append(orchs, arr...) } } else { - if orchs, err = funcmap[orchestrator](&OrchestratorProfile{OrchestratorType: orchestrator, OrchestratorVersion: version}, windows); err != nil { + if orchs, err = funcmap[orchestrator](&OrchestratorProfile{OrchestratorType: orchestrator, OrchestratorVersion: version}, windows, isAzureStackCloud); err != nil { return nil, err } } @@ -105,13 +117,13 @@ func GetOrchestratorVersionProfileList(orchestrator, version string, windows boo } // GetOrchestratorVersionProfile returns orchestrator info for upgradable container service -func GetOrchestratorVersionProfile(orch *OrchestratorProfile, hasWindows bool) (*OrchestratorVersionProfile, error) { +func GetOrchestratorVersionProfile(orch *OrchestratorProfile, hasWindows bool, isAzureStackCloud bool) (*OrchestratorVersionProfile, error) { if orch.OrchestratorVersion == "" { return nil, errors.New("Missing Orchestrator Version") } switch orch.OrchestratorType { case Kubernetes, DCOS: - arr, err := funcmap[orch.OrchestratorType](orch, hasWindows) + arr, err := funcmap[orch.OrchestratorType](orch, hasWindows, isAzureStackCloud) if err != nil { return nil, err } @@ -125,12 +137,12 @@ func GetOrchestratorVersionProfile(orch *OrchestratorProfile, hasWindows bool) ( } } -func kubernetesInfo(csOrch *OrchestratorProfile, hasWindows bool) ([]*OrchestratorVersionProfile, error) { +func kubernetesInfo(csOrch *OrchestratorProfile, hasWindows bool, isAzureStackCloud bool) ([]*OrchestratorVersionProfile, error) { orchs := []*OrchestratorVersionProfile{} if csOrch.OrchestratorVersion == "" { // get info for all supported versions - for _, ver := range common.GetAllSupportedKubernetesVersions(false, hasWindows) { - upgrades, err := kubernetesUpgrades(&OrchestratorProfile{OrchestratorVersion: ver}, hasWindows) + for _, ver := range common.GetAllSupportedKubernetesVersions(false, hasWindows, isAzureStackCloud) { + upgrades, err := kubernetesUpgrades(&OrchestratorProfile{OrchestratorVersion: ver}, hasWindows, isAzureStackCloud) if err != nil { return nil, err } @@ -140,16 +152,16 @@ func kubernetesInfo(csOrch *OrchestratorProfile, hasWindows bool) ([]*Orchestrat OrchestratorType: Kubernetes, OrchestratorVersion: ver, }, - Default: ver == common.GetDefaultKubernetesVersion(hasWindows), + Default: ver == common.GetDefaultKubernetesVersion(hasWindows, isAzureStackCloud), Upgrades: upgrades, }) } } else { - if !isVersionSupported(csOrch) { + if !isVersionSupported(csOrch, isAzureStackCloud) { return nil, errors.Errorf("Kubernetes version %s is not supported", csOrch.OrchestratorVersion) } - upgrades, err := kubernetesUpgrades(csOrch, hasWindows) + upgrades, err := kubernetesUpgrades(csOrch, hasWindows, isAzureStackCloud) if err != nil { return nil, err } @@ -159,17 +171,17 @@ func kubernetesInfo(csOrch *OrchestratorProfile, hasWindows bool) ([]*Orchestrat OrchestratorType: Kubernetes, OrchestratorVersion: csOrch.OrchestratorVersion, }, - Default: csOrch.OrchestratorVersion == common.GetDefaultKubernetesVersion(hasWindows), + Default: csOrch.OrchestratorVersion == common.GetDefaultKubernetesVersion(hasWindows, isAzureStackCloud), Upgrades: upgrades, }) } return orchs, nil } -func kubernetesUpgrades(csOrch *OrchestratorProfile, hasWindows bool) ([]*OrchestratorProfile, error) { +func kubernetesUpgrades(csOrch *OrchestratorProfile, hasWindows bool, isAzureStackCloud bool) ([]*OrchestratorProfile, error) { ret := []*OrchestratorProfile{} - upgradeVersions, err := getKubernetesAvailableUpgradeVersions(csOrch.OrchestratorVersion, common.GetAllSupportedKubernetesVersions(false, hasWindows)) + upgradeVersions, err := getKubernetesAvailableUpgradeVersions(csOrch.OrchestratorVersion, common.GetAllSupportedKubernetesVersions(false, hasWindows, isAzureStackCloud)) if err != nil { return nil, err } @@ -207,7 +219,7 @@ func getKubernetesAvailableUpgradeVersions(orchestratorVersion string, supported } -func dcosInfo(csOrch *OrchestratorProfile, hasWindows bool) ([]*OrchestratorVersionProfile, error) { +func dcosInfo(csOrch *OrchestratorProfile, hasWindows bool, isAzureStackCloud bool) ([]*OrchestratorVersionProfile, error) { orchs := []*OrchestratorVersionProfile{} if csOrch.OrchestratorVersion == "" { // get info for all supported versions @@ -224,7 +236,7 @@ func dcosInfo(csOrch *OrchestratorProfile, hasWindows bool) ([]*OrchestratorVers }) } } else { - if !isVersionSupported(csOrch) { + if !isVersionSupported(csOrch, false) { return nil, errors.Errorf("DCOS version %s is not supported", csOrch.OrchestratorVersion) } @@ -255,7 +267,7 @@ func dcosUpgrades(csOrch *OrchestratorProfile) []*OrchestratorProfile { return ret } -func swarmInfo(csOrch *OrchestratorProfile, hasWindows bool) ([]*OrchestratorVersionProfile, error) { +func swarmInfo(csOrch *OrchestratorProfile, hasWindows bool, isAzureStackCloud bool) ([]*OrchestratorVersionProfile, error) { if csOrch.OrchestratorVersion == "" { return []*OrchestratorVersionProfile{ { @@ -267,7 +279,7 @@ func swarmInfo(csOrch *OrchestratorProfile, hasWindows bool) ([]*OrchestratorVer }, nil } - if !isVersionSupported(csOrch) { + if !isVersionSupported(csOrch, false) { return nil, errors.Errorf("Swarm version %s is not supported", csOrch.OrchestratorVersion) } return []*OrchestratorVersionProfile{ @@ -280,7 +292,7 @@ func swarmInfo(csOrch *OrchestratorProfile, hasWindows bool) ([]*OrchestratorVer }, nil } -func dockerceInfo(csOrch *OrchestratorProfile, hasWindows bool) ([]*OrchestratorVersionProfile, error) { +func dockerceInfo(csOrch *OrchestratorProfile, hasWindows bool, isAzureStackCloud bool) ([]*OrchestratorVersionProfile, error) { if csOrch.OrchestratorVersion == "" { return []*OrchestratorVersionProfile{ @@ -293,7 +305,7 @@ func dockerceInfo(csOrch *OrchestratorProfile, hasWindows bool) ([]*Orchestrator }, nil } - if !isVersionSupported(csOrch) { + if !isVersionSupported(csOrch, false) { return nil, errors.Errorf("Docker CE version %s is not supported", csOrch.OrchestratorVersion) } return []*OrchestratorVersionProfile{ diff --git a/pkg/api/orchestrators_test.go b/pkg/api/orchestrators_test.go index 0bc5644c16..245cf4682c 100644 --- a/pkg/api/orchestrators_test.go +++ b/pkg/api/orchestrators_test.go @@ -59,9 +59,9 @@ func TestOrchestratorUpgradeInfo(t *testing.T) { OrchestratorType: Kubernetes, OrchestratorVersion: deployedVersion, } - v, e := getKubernetesAvailableUpgradeVersions(deployedVersion, common.GetAllSupportedKubernetesVersions(false, false)) + v, e := getKubernetesAvailableUpgradeVersions(deployedVersion, common.GetAllSupportedKubernetesVersions(false, false, false)) Expect(e).To(BeNil()) - orch, e := GetOrchestratorVersionProfile(csOrch, false) + orch, e := GetOrchestratorVersionProfile(csOrch, false, false) Expect(e).To(BeNil()) Expect(len(orch.Upgrades)).To(Equal(len(v))) } @@ -69,9 +69,9 @@ func TestOrchestratorUpgradeInfo(t *testing.T) { // The latest version is not upgradable csOrch := &OrchestratorProfile{ OrchestratorType: Kubernetes, - OrchestratorVersion: common.GetMaxVersion(common.GetAllSupportedKubernetesVersions(false, false), true), + OrchestratorVersion: common.GetMaxVersion(common.GetAllSupportedKubernetesVersions(false, false, false), true), } - orch, e := GetOrchestratorVersionProfile(csOrch, false) + orch, e := GetOrchestratorVersionProfile(csOrch, false, false) Expect(e).To(BeNil()) Expect(len(orch.Upgrades)).To(Equal(0)) } @@ -79,11 +79,11 @@ func TestOrchestratorUpgradeInfo(t *testing.T) { func TestGetOrchestratorVersionProfileList(t *testing.T) { RegisterTestingT(t) // kubernetes only - list, e := GetOrchestratorVersionProfileList(common.Kubernetes, "", false) + list, e := GetOrchestratorVersionProfileList(common.Kubernetes, "", false, "") Expect(e).To(BeNil()) - Expect(len(list)).To(Equal(len(common.GetAllSupportedKubernetesVersions(false, false)))) + Expect(len(list)).To(Equal(len(common.GetAllSupportedKubernetesVersions(false, false, false)))) for _, v := range list { - Expect(common.GetAllSupportedKubernetesVersions(false, false)).Should(ContainElement(v.OrchestratorProfile.OrchestratorVersion)) + Expect(common.GetAllSupportedKubernetesVersions(false, false, false)).Should(ContainElement(v.OrchestratorProfile.OrchestratorVersion)) } } @@ -107,7 +107,7 @@ func TestKubernetesInfo(t *testing.T) { OrchestratorVersion: v, } - _, e := kubernetesInfo(csOrch, false) + _, e := kubernetesInfo(csOrch, false, false) Expect(e).NotTo(BeNil()) } @@ -130,7 +130,7 @@ func TestDcosInfo(t *testing.T) { OrchestratorVersion: v, } - _, e := dcosInfo(csOrch, false) + _, e := dcosInfo(csOrch, false, false) Expect(e).NotTo(BeNil()) } @@ -140,7 +140,7 @@ func TestDcosInfo(t *testing.T) { OrchestratorVersion: common.DCOSDefaultVersion, } - _, e := dcosInfo(csOrch, false) + _, e := dcosInfo(csOrch, false, false) Expect(e).To(BeNil()) } @@ -157,7 +157,7 @@ func TestSwarmInfo(t *testing.T) { OrchestratorVersion: v, } - _, e := swarmInfo(csOrch, false) + _, e := swarmInfo(csOrch, false, false) Expect(e).NotTo(BeNil()) } @@ -167,7 +167,7 @@ func TestSwarmInfo(t *testing.T) { OrchestratorVersion: common.SwarmVersion, } - _, e := swarmInfo(csOrch, false) + _, e := swarmInfo(csOrch, false, false) Expect(e).To(BeNil()) } @@ -184,7 +184,7 @@ func TestDockerceInfoInfo(t *testing.T) { OrchestratorVersion: v, } - _, e := dockerceInfo(csOrch, false) + _, e := dockerceInfo(csOrch, false, false) Expect(e).NotTo(BeNil()) } @@ -194,7 +194,7 @@ func TestDockerceInfoInfo(t *testing.T) { OrchestratorVersion: common.DockerCEVersion, } - _, e := dockerceInfo(csOrch, false) + _, e := dockerceInfo(csOrch, false, false) Expect(e).To(BeNil()) } diff --git a/pkg/api/vlabs/validate.go b/pkg/api/vlabs/validate.go index 8a2c5cf758..223bce179f 100644 --- a/pkg/api/vlabs/validate.go +++ b/pkg/api/vlabs/validate.go @@ -197,6 +197,7 @@ func (a *Properties) ValidateOrchestratorProfile(isUpdate bool) error { o.OrchestratorRelease, o.OrchestratorVersion, isUpdate, + false, false) if version == "" { return errors.Errorf("the following OrchestratorProfile configuration is not supported: OrchestratorType: %s, OrchestratorRelease: %s, OrchestratorVersion: %s. Please check supported Release or Version for this build of aks-engine", o.OrchestratorType, o.OrchestratorRelease, o.OrchestratorVersion) @@ -217,11 +218,20 @@ func (a *Properties) ValidateOrchestratorProfile(isUpdate bool) error { o.OrchestratorRelease, o.OrchestratorVersion, isUpdate, - a.HasWindows()) - if version == "" && a.HasWindows() { - return errors.Errorf("the following OrchestratorProfile configuration is not supported with OsType \"Windows\": OrchestratorType: \"%s\", OrchestratorRelease: \"%s\", OrchestratorVersion: \"%s\". Please use one of the following versions: %v", o.OrchestratorType, o.OrchestratorRelease, o.OrchestratorVersion, common.GetAllSupportedKubernetesVersions(false, true)) - } else if version == "" { - return errors.Errorf("the following OrchestratorProfile configuration is not supported: OrchestratorType: \"%s\", OrchestratorRelease: \"%s\", OrchestratorVersion: \"%s\". Please use one of the following versions: %v", o.OrchestratorType, o.OrchestratorRelease, o.OrchestratorVersion, common.GetAllSupportedKubernetesVersions(false, false)) + a.HasWindows(), + a.IsAzureStackCloud()) + if a.IsAzureStackCloud() { + if version == "" && a.HasWindows() { + return errors.Errorf("the following OrchestratorProfile configuration is not supported on Azure Stack with OsType \"Windows\": OrchestratorType: \"%s\", OrchestratorRelease: \"%s\", OrchestratorVersion: \"%s\". Please use one of the following versions: %v", o.OrchestratorType, o.OrchestratorRelease, o.OrchestratorVersion, common.GetAllSupportedKubernetesVersions(false, true, true)) + } else if version == "" { + return errors.Errorf("the following OrchestratorProfile configuration is not supported on Azure Stack: OrchestratorType: \"%s\", OrchestratorRelease: \"%s\", OrchestratorVersion: \"%s\". Please use one of the following versions: %v", o.OrchestratorType, o.OrchestratorRelease, o.OrchestratorVersion, common.GetAllSupportedKubernetesVersions(false, false, true)) + } + } else { + if version == "" && a.HasWindows() { + return errors.Errorf("the following OrchestratorProfile configuration is not supported with OsType \"Windows\": OrchestratorType: \"%s\", OrchestratorRelease: \"%s\", OrchestratorVersion: \"%s\". Please use one of the following versions: %v", o.OrchestratorType, o.OrchestratorRelease, o.OrchestratorVersion, common.GetAllSupportedKubernetesVersions(false, true, false)) + } else if version == "" { + return errors.Errorf("the following OrchestratorProfile configuration is not supported: OrchestratorType: \"%s\", OrchestratorRelease: \"%s\", OrchestratorVersion: \"%s\". Please use one of the following versions: %v", o.OrchestratorType, o.OrchestratorRelease, o.OrchestratorVersion, common.GetAllSupportedKubernetesVersions(false, false, false)) + } } sv, err := semver.Make(version) @@ -374,9 +384,10 @@ func (a *Properties) ValidateOrchestratorProfile(isUpdate bool) error { o.OrchestratorRelease, o.OrchestratorVersion, false, - a.HasWindows()) + a.HasWindows(), + a.IsAzureStackCloud()) if version == "" { - patchVersion := common.GetValidPatchVersion(o.OrchestratorType, o.OrchestratorVersion, isUpdate, a.HasWindows()) + patchVersion := common.GetValidPatchVersion(o.OrchestratorType, o.OrchestratorVersion, isUpdate, a.HasWindows(), a.IsAzureStackCloud()) // if there isn't a supported patch version for this version fail if patchVersion == "" { if a.HasWindows() { @@ -978,6 +989,7 @@ func (a *Properties) validateManagedIdentity() error { a.OrchestratorProfile.OrchestratorRelease, a.OrchestratorProfile.OrchestratorVersion, false, + false, false) if version == "" { return errors.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 aks-engine", a.OrchestratorProfile.OrchestratorType, a.OrchestratorProfile.OrchestratorRelease, a.OrchestratorProfile.OrchestratorVersion) @@ -1113,6 +1125,7 @@ func validateVMSS(o *OrchestratorProfile, isUpdate bool, storageProfile string) o.OrchestratorRelease, o.OrchestratorVersion, isUpdate, + false, false) if version == "" { return errors.Errorf("the following OrchestratorProfile configuration is not supported: OrchestratorType: %s, OrchestratorRelease: %s, OrchestratorVersion: %s. Please check supported Release or Version for this build of aks-engine", o.OrchestratorType, o.OrchestratorRelease, o.OrchestratorVersion) @@ -1174,7 +1187,8 @@ func (a *Properties) validateWindowsProfile(isUpdate bool) error { o.OrchestratorRelease, o.OrchestratorVersion, isUpdate, - true) + true, + false) if version == "" { return errors.Errorf("Orchestrator %s version %s does not support Windows", o.OrchestratorType, o.OrchestratorVersion) diff --git a/pkg/api/vlabs/validate_test.go b/pkg/api/vlabs/validate_test.go index 6fe6151c51..ec5f4285c2 100644 --- a/pkg/api/vlabs/validate_test.go +++ b/pkg/api/vlabs/validate_test.go @@ -117,13 +117,13 @@ func Test_OrchestratorProfile_Validate(t *testing.T) { properties: &Properties{ OrchestratorProfile: &OrchestratorProfile{ OrchestratorType: "Kubernetes", - OrchestratorVersion: common.GetLatestPatchVersion("1.15", common.GetAllSupportedKubernetesVersions(false, false)), + OrchestratorVersion: common.GetLatestPatchVersion("1.15", common.GetAllSupportedKubernetesVersions(false, false, false)), KubernetesConfig: &KubernetesConfig{ EnableRbac: &falseVal, }, }, }, - expectedError: fmt.Sprintf("RBAC support is required for Kubernetes version 1.15.0 or greater; unable to build Kubernetes v%s cluster with enableRbac=false", common.GetLatestPatchVersion("1.15", common.GetAllSupportedKubernetesVersions(false, false))), + expectedError: fmt.Sprintf("RBAC support is required for Kubernetes version 1.15.0 or greater; unable to build Kubernetes v%s cluster with enableRbac=false", common.GetLatestPatchVersion("1.15", common.GetAllSupportedKubernetesVersions(false, false, false))), }, "should error when KubernetesConfig has enableDataEncryptionAtRest enabled with invalid version": { properties: &Properties{ @@ -272,7 +272,7 @@ func Test_OrchestratorProfile_Validate(t *testing.T) { OrchestratorVersion: "1.6.0", }, }, - expectedError: fmt.Sprint("the following OrchestratorProfile configuration is not supported: OrchestratorType: \"Kubernetes\", OrchestratorRelease: \"\", OrchestratorVersion: \"1.6.0\". Please use one of the following versions: ", common.GetAllSupportedKubernetesVersions(false, false)), + expectedError: fmt.Sprint("the following OrchestratorProfile configuration is not supported: OrchestratorType: \"Kubernetes\", OrchestratorRelease: \"\", OrchestratorVersion: \"1.6.0\". Please use one of the following versions: ", common.GetAllSupportedKubernetesVersions(false, false, false)), }, "kubernetes should not fail on old patch version if update": { properties: &Properties{ @@ -343,7 +343,7 @@ func Test_OrchestratorProfile_Validate(t *testing.T) { func Test_KubernetesConfig_Validate(t *testing.T) { // Tests that should pass across all versions - for _, k8sVersion := range common.GetAllSupportedKubernetesVersions(true, false) { + for _, k8sVersion := range common.GetAllSupportedKubernetesVersions(true, false, false) { c := KubernetesConfig{} if err := c.Validate(k8sVersion, false, false, false); err != nil { t.Errorf("should not error on empty KubernetesConfig: %v, version %s", err, k8sVersion) @@ -570,7 +570,7 @@ func Test_KubernetesConfig_Validate(t *testing.T) { } // Tests that apply to 1.6 and later releases - for _, k8sVersion := range common.GetAllSupportedKubernetesVersions(false, false) { + for _, k8sVersion := range common.GetAllSupportedKubernetesVersions(false, false, false) { c := KubernetesConfig{ CloudProviderBackoff: to.BoolPtr(true), CloudProviderRateLimit: to.BoolPtr(true), @@ -581,7 +581,7 @@ func Test_KubernetesConfig_Validate(t *testing.T) { } // Tests that apply to 1.8 and later releases - for _, k8sVersion := range common.GetVersionsGt(common.GetAllSupportedKubernetesVersions(true, false), "1.8.0", true, true) { + for _, k8sVersion := range common.GetVersionsGt(common.GetAllSupportedKubernetesVersions(true, false, false), "1.8.0", true, true) { c := KubernetesConfig{ UseCloudControllerManager: to.BoolPtr(true), } @@ -591,7 +591,7 @@ func Test_KubernetesConfig_Validate(t *testing.T) { } // Tests that apply to dualstack with 1.16 and later releases - for _, k8sVersion := range common.GetVersionsGt(common.GetAllSupportedKubernetesVersions(false, false), "1.16.0", true, true) { + for _, k8sVersion := range common.GetVersionsGt(common.GetAllSupportedKubernetesVersions(false, false, false), "1.16.0", true, true) { c := KubernetesConfig{ NetworkPlugin: "kubenet", ClusterSubnet: "10.244.0.0/16,ace:cab:deca::/8", @@ -690,7 +690,7 @@ func Test_KubernetesConfig_Validate(t *testing.T) { } // Tests that apply to single stack IPv6 with 1.18 and later releases - for _, k8sVersion := range common.GetVersionsGt(common.GetAllSupportedKubernetesVersions(false, false), "1.18.0", true, true) { + for _, k8sVersion := range common.GetVersionsGt(common.GetAllSupportedKubernetesVersions(false, false, false), "1.18.0", true, true) { c := KubernetesConfig{ NetworkPlugin: "azure", } @@ -1083,7 +1083,7 @@ func TestProperties_ValidateWindowsProfile(t *testing.T) { }{ { name: "Valid WindowsProfile", - k8sVersion: common.RationalizeReleaseAndVersion(common.Kubernetes, "1.17", "", false, false), + k8sVersion: common.RationalizeReleaseAndVersion(common.Kubernetes, "1.17", "", false, false, false), wp: &WindowsProfile{ AdminUsername: "AzureUser", AdminPassword: "replacePassword1234$", @@ -1092,7 +1092,7 @@ func TestProperties_ValidateWindowsProfile(t *testing.T) { }, { name: "No username", - k8sVersion: common.RationalizeReleaseAndVersion(common.Kubernetes, "1.17", "", false, false), + k8sVersion: common.RationalizeReleaseAndVersion(common.Kubernetes, "1.17", "", false, false, false), wp: &WindowsProfile{ AdminUsername: "", AdminPassword: "replacePassword1234$", @@ -1101,7 +1101,7 @@ func TestProperties_ValidateWindowsProfile(t *testing.T) { }, { name: "No password", - k8sVersion: common.RationalizeReleaseAndVersion(common.Kubernetes, "1.17", "", false, false), + k8sVersion: common.RationalizeReleaseAndVersion(common.Kubernetes, "1.17", "", false, false, false), wp: &WindowsProfile{ AdminUsername: "AzureUser", AdminPassword: "", @@ -1110,7 +1110,7 @@ func TestProperties_ValidateWindowsProfile(t *testing.T) { }, { name: "CSI proxy enabled", - k8sVersion: common.RationalizeReleaseAndVersion(common.Kubernetes, "1.18", "", false, false), + k8sVersion: common.RationalizeReleaseAndVersion(common.Kubernetes, "1.18", "", false, false, false), wp: &WindowsProfile{ AdminUsername: "AzureUser", AdminPassword: "replacePassword1234$", @@ -1121,7 +1121,7 @@ func TestProperties_ValidateWindowsProfile(t *testing.T) { }, { name: "CSI Proxy unsupported version", - k8sVersion: common.RationalizeReleaseAndVersion(common.Kubernetes, "1.17", "", false, false), + k8sVersion: common.RationalizeReleaseAndVersion(common.Kubernetes, "1.17", "", false, false, false), wp: &WindowsProfile{ AdminUsername: "AzureUser", AdminPassword: "replacePassword1234$", @@ -2602,7 +2602,7 @@ func Test_Properties_ValidateAddons(t *testing.T) { } func TestWindowsVersions(t *testing.T) { - for _, version := range common.GetAllSupportedKubernetesVersions(false, true) { + for _, version := range common.GetAllSupportedKubernetesVersions(false, true, false) { cs := getK8sDefaultContainerService(true) cs.Properties.OrchestratorProfile.OrchestratorVersion = version if err := cs.Validate(false); err != nil { @@ -2666,7 +2666,7 @@ func TestWindowsVersions(t *testing.T) { } func TestLinuxVersions(t *testing.T) { - for _, version := range common.GetAllSupportedKubernetesVersions(false, false) { + for _, version := range common.GetAllSupportedKubernetesVersions(false, false, false) { cs := getK8sDefaultContainerService(false) cs.Properties.OrchestratorProfile.OrchestratorVersion = version if err := cs.Validate(false); err != nil { diff --git a/pkg/engine/armvariables_test.go b/pkg/engine/armvariables_test.go index a6628de2e2..054a01cd9e 100644 --- a/pkg/engine/armvariables_test.go +++ b/pkg/engine/armvariables_test.go @@ -17,7 +17,8 @@ import ( "github.com/Azure/aks-engine/pkg/helpers" ) -var testK8sVersion = common.GetSupportedKubernetesVersion("1.12", false) +var testK8sVersion = common.GetSupportedKubernetesVersion("1.12", false, false) +var testK8sVersionAzureStack = common.GetSupportedKubernetesVersion("1.12", false, true) func TestSizeMap(t *testing.T) { sizeMap := getSizeMap() @@ -743,7 +744,7 @@ func TestK8sVars(t *testing.T) { "networkContributorRoleDefinitionId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/', '4d97b98b-1d4f-4787-a291-c67834d212e7')]", "nsgID": "[resourceId('Microsoft.Network/networkSecurityGroups',variables('nsgName'))]", "nsgName": "[concat(variables('masterVMNamePrefix'), 'nsg')]", - "orchestratorNameVersionTag": "Kubernetes:" + testK8sVersion, + "orchestratorNameVersionTag": "Kubernetes:" + testK8sVersionAzureStack, "primaryAvailabilitySetName": "", "primaryScaleSetName": cs.Properties.GetPrimaryScaleSetName(), "cloudInitFiles": map[string]interface{}{ diff --git a/pkg/operations/kubernetesupgrade/upgradecluster.go b/pkg/operations/kubernetesupgrade/upgradecluster.go index 9ea8e70606..10c82933b8 100644 --- a/pkg/operations/kubernetesupgrade/upgradecluster.go +++ b/pkg/operations/kubernetesupgrade/upgradecluster.go @@ -302,7 +302,7 @@ func (uc *UpgradeCluster) upgradable(currentVersion string) error { } targetVersion := uc.DataModel.Properties.OrchestratorProfile.OrchestratorVersion - orch, err := api.GetOrchestratorVersionProfile(nodeVersion, uc.DataModel.Properties.HasWindows()) + orch, err := api.GetOrchestratorVersionProfile(nodeVersion, uc.DataModel.Properties.HasWindows(), uc.DataModel.Properties.IsAzureStackCloud()) if err != nil { return err } diff --git a/test/e2e/engine/template.go b/test/e2e/engine/template.go index 235614191f..dae05cc62a 100644 --- a/test/e2e/engine/template.go +++ b/test/e2e/engine/template.go @@ -123,6 +123,10 @@ func Build(cfg *config.Config, masterSubnetID string, agentSubnetIDs []string, i if prop.HasWindows() { hasWindows = true } + var isAzureStackCloud bool + if prop.IsAzureStackCloud() { + isAzureStackCloud = true + } if config.ClientID != "" && config.ClientSecret != "" { if !prop.IsAzureStackCloud() { @@ -236,7 +240,7 @@ func Build(cfg *config.Config, masterSubnetID string, agentSubnetIDs []string, i prop.OrchestratorProfile.OrchestratorVersion = config.OrchestratorVersion // If ENV similarly has no version opinion, we will rely upon the aks-engine default } else { - prop.OrchestratorProfile.OrchestratorVersion = common.GetDefaultKubernetesVersion(hasWindows) + prop.OrchestratorProfile.OrchestratorVersion = common.GetDefaultKubernetesVersion(hasWindows, isAzureStackCloud) } }