Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

feat: add support for Kubernetes v1.18.16 #4284

Merged
merged 4 commits into from
Feb 19, 2021
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
3 changes: 2 additions & 1 deletion pkg/api/common/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ var AllKubernetesSupportedVersions = map[string]bool{
"1.18.12": false,
"1.18.13": false,
"1.18.14": false,
"1.18.15": true,
"1.18.15": false,
"1.18.16": true,
"1.19.0-alpha.1": false,
"1.19.0-alpha.2": false,
"1.19.0-alpha.3": false,
Expand Down
10 changes: 5 additions & 5 deletions pkg/api/vlabs/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4630,7 +4630,7 @@ func TestValidateLocation(t *testing.T) {
},
OrchestratorProfile: &OrchestratorProfile{
OrchestratorType: Kubernetes,
OrchestratorVersion: common.RationalizeReleaseAndVersion(Kubernetes, "", "", false, false, false),
OrchestratorVersion: common.RationalizeReleaseAndVersion(Kubernetes, "", "", false, false, true),
KubernetesConfig: &KubernetesConfig{
UseInstanceMetadata: to.BoolPtr(trueVal),
},
Expand All @@ -4651,7 +4651,7 @@ func TestValidateLocation(t *testing.T) {
},
OrchestratorProfile: &OrchestratorProfile{
OrchestratorType: Kubernetes,
OrchestratorVersion: common.RationalizeReleaseAndVersion(Kubernetes, "", "", false, false, false),
OrchestratorVersion: common.RationalizeReleaseAndVersion(Kubernetes, "", "", false, false, true),
KubernetesConfig: &KubernetesConfig{
EtcdDiskSizeGB: "1024",
},
Expand All @@ -4672,7 +4672,7 @@ func TestValidateLocation(t *testing.T) {
},
OrchestratorProfile: &OrchestratorProfile{
OrchestratorType: Kubernetes,
OrchestratorVersion: common.RationalizeReleaseAndVersion(Kubernetes, "", "", false, false, false),
OrchestratorVersion: common.RationalizeReleaseAndVersion(Kubernetes, "", "", false, false, true),
KubernetesConfig: &KubernetesConfig{
EtcdDiskSizeGB: "1024GB",
},
Expand All @@ -4693,7 +4693,7 @@ func TestValidateLocation(t *testing.T) {
},
OrchestratorProfile: &OrchestratorProfile{
OrchestratorType: Kubernetes,
OrchestratorVersion: common.RationalizeReleaseAndVersion(Kubernetes, "", "", false, false, false),
OrchestratorVersion: common.RationalizeReleaseAndVersion(Kubernetes, "", "", false, false, true),
},
AgentPoolProfiles: []*AgentPoolProfile{
{
Expand All @@ -4719,7 +4719,7 @@ func TestValidateLocation(t *testing.T) {
},
OrchestratorProfile: &OrchestratorProfile{
OrchestratorType: Kubernetes,
OrchestratorVersion: common.RationalizeReleaseAndVersion(Kubernetes, "", "", false, false, false),
OrchestratorVersion: common.RationalizeReleaseAndVersion(Kubernetes, "", "", false, false, true),
},
AgentPoolProfiles: []*AgentPoolProfile{
{
Expand Down
14 changes: 13 additions & 1 deletion pkg/armhelpers/mockclients.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"fmt"
"io/ioutil"
"net/http"
"strconv"
"strings"
"time"

"github.com/Azure/aks-engine/pkg/api/common"
Expand All @@ -32,11 +34,21 @@ import (
)

const (
defaultK8sVersionForFakeVMs = "Kubernetes:1.17.5"
//DefaultFakeVMName is the default name assigned to VMs part of FakeListVirtualMachineScaleSetVMsResult and FakeListVirtualMachineResult
DefaultFakeVMName = "k8s-agentpool1-12345678-0"
)

var defaultK8sVersionForFakeVMs string

func init() {
defaultVersion := common.RationalizeReleaseAndVersion(common.Kubernetes, "", "", false, false, false)
versionSplit := strings.Split(defaultVersion, ".")
minorVersion, _ := strconv.Atoi(versionSplit[1])
minorVersionLessOne := minorVersion - 1
priorVersion := versionSplit[0] + "." + strconv.Itoa(minorVersionLessOne) + "." + versionSplit[2]
defaultK8sVersionForFakeVMs = fmt.Sprintf("Kubernetes:%s", priorVersion)
}

//MockAKSEngineClient is an implementation of AKSEngineClient where all requests error out
type MockAKSEngineClient struct {
FailDeployTemplate bool
Expand Down
75 changes: 41 additions & 34 deletions pkg/operations/kubernetesupgrade/upgradecluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"fmt"
"os"
"strconv"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -55,13 +56,19 @@ func TestUpgradeCluster(t *testing.T) {
}

var _ = Describe("Upgrade Kubernetes cluster tests", func() {
defaultVersion := common.RationalizeReleaseAndVersion(common.Kubernetes, "", "", false, false, false)
versionSplit := strings.Split(defaultVersion, ".")
minorVersion, _ := strconv.Atoi(versionSplit[1])
minorVersionLessOne := minorVersion - 1
priorVersion := versionSplit[0] + "." + strconv.Itoa(minorVersionLessOne) + "." + versionSplit[2]
mockK8sVersionOneLessThanDefault := fmt.Sprintf("Kubernetes:%s", priorVersion)
AfterEach(func() {
// delete temp template directory
os.RemoveAll("_output")
})

It("Should succeed when cluster VMs are missing expected tags during upgrade operation", func() {
cs := api.CreateMockContainerService("testcluster", "1.18.15", 1, 1, false)
cs := api.CreateMockContainerService("testcluster", "", 1, 1, false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100% of UT should not care about our maintaining the versions support list, so shout if this ever bites you in the future!

cc @mboersma

uc := UpgradeCluster{
Translator: &i18n.Translator{},
Logger: log.NewEntry(log.New()),
Expand All @@ -87,7 +94,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
})

It("Should return error message when failing to list VMs during upgrade operation", func() {
cs := api.CreateMockContainerService("testcluster", "1.18.15", 1, 1, false)
cs := api.CreateMockContainerService("testcluster", "", 1, 1, false)
uc := UpgradeCluster{
Translator: &i18n.Translator{},
Logger: log.NewEntry(log.New()),
Expand All @@ -113,7 +120,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
})

It("Should return error message when failing to delete VMs during upgrade operation", func() {
cs := api.CreateMockContainerService("testcluster", "1.18.15", 1, 1, false)
cs := api.CreateMockContainerService("testcluster", "", 1, 1, false)
uc := UpgradeCluster{
Translator: &i18n.Translator{},
Logger: log.NewEntry(log.New()),
Expand All @@ -136,7 +143,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
})

It("Should return error message when failing to deploy template during upgrade operation", func() {
cs := api.CreateMockContainerService("testcluster", "1.18.15", 1, 1, false)
cs := api.CreateMockContainerService("testcluster", "", 1, 1, false)
uc := UpgradeCluster{
Translator: &i18n.Translator{},
Logger: log.NewEntry(log.New()),
Expand All @@ -159,7 +166,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
})

It("Should return error message when failing to get a virtual machine during upgrade operation", func() {
cs := api.CreateMockContainerService("testcluster", "1.18.15", 1, 6, false)
cs := api.CreateMockContainerService("testcluster", "", 1, 6, false)
uc := UpgradeCluster{
Translator: &i18n.Translator{},
Logger: log.NewEntry(log.New()),
Expand All @@ -182,7 +189,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
})

It("Should return error message when failing to get storage client during upgrade operation", func() {
cs := api.CreateMockContainerService("testcluster", "1.18.15", 5, 1, false)
cs := api.CreateMockContainerService("testcluster", "", 5, 1, false)
uc := UpgradeCluster{
Translator: &i18n.Translator{},
Logger: log.NewEntry(log.New()),
Expand All @@ -205,7 +212,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
})

It("Should return error message when failing to delete network interface during upgrade operation", func() {
cs := api.CreateMockContainerService("testcluster", "1.18.15", 3, 2, false)
cs := api.CreateMockContainerService("testcluster", "", 3, 2, false)
uc := UpgradeCluster{
Translator: &i18n.Translator{},
Logger: log.NewEntry(log.New()),
Expand All @@ -228,7 +235,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
})

It("Should return error message when failing to delete role assignment during upgrade operation", func() {
cs := api.CreateMockContainerService("testcluster", "1.18.15", 3, 2, false)
cs := api.CreateMockContainerService("testcluster", "", 3, 2, false)
cs.Properties.OrchestratorProfile.KubernetesConfig = &api.KubernetesConfig{}
cs.Properties.OrchestratorProfile.KubernetesConfig.UseManagedIdentity = to.BoolPtr(true)
uc := UpgradeCluster{
Expand Down Expand Up @@ -262,7 +269,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {

BeforeEach(func() {
mockClient = armhelpers.MockAKSEngineClient{MockKubernetesClient: &armhelpers.MockKubernetesClient{}}
cs = api.CreateMockContainerService("testcluster", "1.18.15", 3, 3, false)
cs = api.CreateMockContainerService("testcluster", "", 3, 3, false)
uc = UpgradeCluster{
Translator: &i18n.Translator{},
Logger: log.NewEntry(log.New()),
Expand Down Expand Up @@ -291,10 +298,10 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
It("Should skip VMs that are already on desired version", func() {
mockClient.FakeListVirtualMachineScaleSetVMsResult = func() []compute.VirtualMachineScaleSetVM {
return []compute.VirtualMachineScaleSetVM{
mockClient.MakeFakeVirtualMachineScaleSetVM("Kubernetes:1.18.15"),
mockClient.MakeFakeVirtualMachineScaleSetVM("Kubernetes:1.18.10"),
mockClient.MakeFakeVirtualMachineScaleSetVM("Kubernetes:1.18.9"),
mockClient.MakeFakeVirtualMachineScaleSetVM("Kubernetes:1.18.15"),
mockClient.MakeFakeVirtualMachineScaleSetVM(fmt.Sprintf("Kubernetes:%s", defaultVersion)),
mockClient.MakeFakeVirtualMachineScaleSetVM(fmt.Sprintf("Kubernetes:%s", mockK8sVersionOneLessThanDefault)),
mockClient.MakeFakeVirtualMachineScaleSetVM(fmt.Sprintf("Kubernetes:%s", mockK8sVersionOneLessThanDefault)),
mockClient.MakeFakeVirtualMachineScaleSetVM(fmt.Sprintf("Kubernetes:%s", defaultVersion)),
}
}
uc.Force = false
Expand Down Expand Up @@ -362,17 +369,17 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
It("Should use kubernetes api to get node versions for VMSS when latest model is not applied", func() {
trueVar := true
falseVar := false
vmWithoutLatestModelApplied := mockClient.MakeFakeVirtualMachineScaleSetVMWithGivenName("Kubernetes:1.18.15", "vmWithoutLatestModelApplied!")
vmWithoutLatestModelApplied := mockClient.MakeFakeVirtualMachineScaleSetVMWithGivenName(fmt.Sprintf("Kubernetes:%s", defaultVersion), "vmWithoutLatestModelApplied!")
vmWithoutLatestModelApplied.VirtualMachineScaleSetVMProperties.LatestModelApplied = &falseVar
vmWithLatestModelApplied := mockClient.MakeFakeVirtualMachineScaleSetVMWithGivenName("Kubernetes:1.18.15", "vmWithLatestModelApplied")
vmWithLatestModelApplied := mockClient.MakeFakeVirtualMachineScaleSetVMWithGivenName(fmt.Sprintf("Kubernetes:%s", defaultVersion), "vmWithLatestModelApplied")
vmWithLatestModelApplied.VirtualMachineScaleSetVMProperties.LatestModelApplied = &trueVar

mockClient.MockKubernetesClient.GetNodeFunc = func(name string) (*v1.Node, error) {
node := &v1.Node{}
node.Status.NodeInfo.KubeletVersion = "v1.18.12"
node.Status.NodeInfo.KubeletVersion = "v" + mockK8sVersionOneLessThanDefault
node.Status = v1.NodeStatus{}
node.Status.NodeInfo = v1.NodeSystemInfo{
KubeletVersion: "v1.18.12",
KubeletVersion: "v" + mockK8sVersionOneLessThanDefault,
}

return node, nil
Expand Down Expand Up @@ -443,7 +450,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {

BeforeEach(func() {
mockClient = armhelpers.MockAKSEngineClient{}
cs = api.CreateMockContainerService("testcluster", "1.17.5", 3, 3, false)
cs = api.CreateMockContainerService("testcluster", "", 3, 3, false)
uc = UpgradeCluster{
Translator: &i18n.Translator{},
Logger: log.NewEntry(log.New()),
Expand Down Expand Up @@ -485,10 +492,10 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
It("Should mark scale sets as windows correctly.", func() {
mockClient.FakeListVirtualMachineScaleSetVMsResult = func() []compute.VirtualMachineScaleSetVM {
return []compute.VirtualMachineScaleSetVM{
mockClient.MakeFakeVirtualMachineScaleSetVM("Kubernetes:1.17.5"),
mockClient.MakeFakeVirtualMachineScaleSetVM("Kubernetes:1.17.4"),
mockClient.MakeFakeVirtualMachineScaleSetVM("Kubernetes:1.17.2"),
mockClient.MakeFakeVirtualMachineScaleSetVM("Kubernetes:1.17.5"),
mockClient.MakeFakeVirtualMachineScaleSetVM(fmt.Sprintf("Kubernetes:%s", defaultVersion)),
mockClient.MakeFakeVirtualMachineScaleSetVM(fmt.Sprintf("Kubernetes:%s", mockK8sVersionOneLessThanDefault)),
mockClient.MakeFakeVirtualMachineScaleSetVM(fmt.Sprintf("Kubernetes:%s", mockK8sVersionOneLessThanDefault)),
mockClient.MakeFakeVirtualMachineScaleSetVM(fmt.Sprintf("Kubernetes:%s", defaultVersion)),
}
}
uc.Force = false
Expand Down Expand Up @@ -622,7 +629,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
Expect(*uc.UpgradedMasterVMs).To(HaveLen(0))
})
It("Should leave platform fault domain count nil", func() {
cs := api.CreateMockContainerService("testcluster", "1.18.15", 3, 2, false)
cs := api.CreateMockContainerService("testcluster", "", 3, 2, false)
cs.Properties.OrchestratorProfile.KubernetesConfig = &api.KubernetesConfig{}
cs.Properties.OrchestratorProfile.KubernetesConfig.UseManagedIdentity = to.BoolPtr(true)
cs.Properties.MasterProfile.AvailabilityProfile = "AvailabilitySet"
Expand Down Expand Up @@ -652,7 +659,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
})

It("Should leave platform fault domain count nil for VMSS", func() {
cs := api.CreateMockContainerService("testcluster", "1.16.1", 3, 2, false)
cs := api.CreateMockContainerService("testcluster", "", 3, 2, false)
cs.Properties.MasterProfile.AvailabilityProfile = api.AvailabilitySet
cs.Properties.AgentPoolProfiles[0].AvailabilityProfile = api.VirtualMachineScaleSets
cs.Properties.AgentPoolProfiles[0].StorageProfile = "ManagedDisks"
Expand Down Expand Up @@ -682,16 +689,16 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
//masters
mockClient.FakeListVirtualMachineResult = func() []compute.VirtualMachine {
return []compute.VirtualMachine{
mockClient.MakeFakeVirtualMachine("one", "Kubernetes:1.15.1"),
mockClient.MakeFakeVirtualMachine("two", "Kubernetes:1.15.1"),
mockClient.MakeFakeVirtualMachine("three", "Kubernetes:1.15.1"),
mockClient.MakeFakeVirtualMachine("one", fmt.Sprintf("Kubernetes:%s", mockK8sVersionOneLessThanDefault)),
mockClient.MakeFakeVirtualMachine("two", fmt.Sprintf("Kubernetes:%s", mockK8sVersionOneLessThanDefault)),
mockClient.MakeFakeVirtualMachine("three", fmt.Sprintf("Kubernetes:%s", mockK8sVersionOneLessThanDefault)),
}
}
//agents
mockClient.FakeListVirtualMachineScaleSetVMsResult = func() []compute.VirtualMachineScaleSetVM {
return []compute.VirtualMachineScaleSetVM{
mockClient.MakeFakeVirtualMachineScaleSetVM("Kubernetes:1.15.1"),
mockClient.MakeFakeVirtualMachineScaleSetVM("Kubernetes:1.15.1"),
mockClient.MakeFakeVirtualMachineScaleSetVM(fmt.Sprintf("Kubernetes:%s", mockK8sVersionOneLessThanDefault)),
mockClient.MakeFakeVirtualMachineScaleSetVM(fmt.Sprintf("Kubernetes:%s", mockK8sVersionOneLessThanDefault)),
}
}
uc.Client = &mockClient
Expand All @@ -715,7 +722,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
})

It("Should not fail if no managed identity is returned by azure during upgrade operation", func() {
cs := api.CreateMockContainerService("testcluster", "1.18.15", 3, 2, false)
cs := api.CreateMockContainerService("testcluster", "", 3, 2, false)
cs.Properties.OrchestratorProfile.KubernetesConfig = &api.KubernetesConfig{}
cs.Properties.OrchestratorProfile.KubernetesConfig.UseManagedIdentity = to.BoolPtr(true)
uc := UpgradeCluster{
Expand All @@ -738,7 +745,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
})

It("Should not fail if a Kubernetes client cannot be created", func() {
cs := api.CreateMockContainerService("testcluster", "1.18.15", 3, 2, false)
cs := api.CreateMockContainerService("testcluster", "", 3, 2, false)
uc := UpgradeCluster{
Translator: &i18n.Translator{},
Logger: log.NewEntry(log.New()),
Expand Down Expand Up @@ -772,7 +779,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
})

It("Should fail if cluster-autoscaler cannot be paused unless --force is specified", func() {
cs := api.CreateMockContainerService("testcluster", "1.18.15", 3, 2, false)
cs := api.CreateMockContainerService("testcluster", "", 3, 2, false)
enabled := true
addon := api.KubernetesAddon{
Name: "cluster-autoscaler",
Expand Down Expand Up @@ -824,7 +831,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
})

It("Should pause cluster-autoscaler during upgrade operation", func() {
cs := api.CreateMockContainerService("testcluster", "1.17.5", 3, 2, false)
cs := api.CreateMockContainerService("testcluster", "", 3, 2, false)
enabled := true
addon := api.KubernetesAddon{
Name: "cluster-autoscaler",
Expand Down Expand Up @@ -869,7 +876,7 @@ var _ = Describe("Upgrade Kubernetes cluster tests", func() {
})

It("Should not pause cluster-autoscaler if only control plane is upgraded", func() {
cs := api.CreateMockContainerService("testcluster", "1.17.5", 3, 2, false)
cs := api.CreateMockContainerService("testcluster", "", 3, 2, false)
enabled := true
addon := api.KubernetesAddon{
Name: "cluster-autoscaler",
Expand Down
2 changes: 1 addition & 1 deletion vhd/packer/configure-windows-vhd.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function Get-FilesToCacheOnVHD {
"https://kubernetesartifacts.azureedge.net/kubernetes/v1.17.17-azs/windowszip/v1.17.17-azs-1int.zip",
"https://kubernetesartifacts.azureedge.net/kubernetes/v1.18.15-azs/windowszip/v1.18.15-azs-1int.zip",
"https://kubernetesartifacts.azureedge.net/kubernetes/v1.17.17/windowszip/v1.17.17-1int.zip",
"https://kubernetesartifacts.azureedge.net/kubernetes/v1.18.15/windowszip/v1.18.15-1int.zip",
"https://kubernetesartifacts.azureedge.net/kubernetes/v1.18.16/windowszip/v1.18.16-1int.zip",
"https://kubernetesartifacts.azureedge.net/kubernetes/v1.19.8/windowszip/v1.19.8-1int.zip",
"https://kubernetesartifacts.azureedge.net/kubernetes/v1.20.4/windowszip/v1.20.4-1int.zip",
"https://kubernetesartifacts.azureedge.net/kubernetes/v1.21.0-alpha.3/windowszip/v1.21.0-alpha.3-1int.zip"
Expand Down
2 changes: 1 addition & 1 deletion vhd/packer/install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ K8S_VERSIONS="
1.21.0-alpha.3
1.20.4
1.19.8
1.18.15
1.18.16
1.18.15-azs
1.17.17
1.17.17-azs
Expand Down