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

Commit

Permalink
enabled kubernetes 1.8 to1.9 upgrade (#1997)
Browse files Browse the repository at this point in the history
* enabled 1.8->1.9 k8s upgrade

* removed debug line

* added check for upgrade version number

* adjusted region

* added unit test

* setting dashboard port according to k8s version

* fix typo
  • Loading branch information
dmitsh authored and jackfrancis committed Jan 5, 2018
1 parent c648781 commit d321907
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 53 deletions.
2 changes: 1 addition & 1 deletion cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (uc *upgradeCmd) run(cmd *cobra.Command, args []string) error {
Client: uc.client,
StepTimeout: uc.timeout,
}
log.Fatalf("%v", upgradeCluster.StepTimeout)

kubeConfig, err := acsengine.GenerateKubeConfig(uc.containerService.Properties, uc.location)
if err != nil {
log.Fatalf("failed to generate kube config") // TODO: cleanup
Expand Down
4 changes: 0 additions & 4 deletions examples/k8s-upgrade/k8s-upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,3 @@ OUTPUT="_output/${INSTANCE_NAME}"
--auth-method client_secret \
--client-id ${SERVICE_PRINCIPAL_CLIENT_ID} \
--client-secret ${SERVICE_PRINCIPAL_CLIENT_SECRET}

# (temp) allow 5 minutes for cluster to 'settle up'
# TODO: ensure cluster operability by the end of the upgrade
sleep 300
45 changes: 45 additions & 0 deletions examples/k8s-upgrade/v1.8.4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"apiVersion": "vlabs",
"properties": {
"orchestratorProfile": {
"orchestratorType": "Kubernetes",
"orchestratorVersion": "1.8.4"
},
"masterProfile": {
"count": 1,
"dnsPrefix": "",
"vmSize": "Standard_D2_v2",
"storageProfile" : "ManagedDisks"
},
"agentPoolProfiles": [
{
"name": "agentpool1",
"count": 2,
"vmSize": "Standard_D2_v2",
"availabilityProfile": "AvailabilitySet",
"storageProfile" : "ManagedDisks"
},
{
"name": "agentpool2",
"count": 1,
"vmSize": "Standard_D2_v2",
"availabilityProfile": "AvailabilitySet",
"storageProfile" : "ManagedDisks"
}
],
"linuxProfile": {
"adminUsername": "azureuser",
"ssh": {
"publicKeys": [
{
"keyData": ""
}
]
}
},
"servicePrincipalProfile": {
"clientId": "",
"secret": ""
}
}
}
2 changes: 2 additions & 0 deletions examples/k8s-upgrade/v1.8.4.json.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ACSE_POSTDEPLOY=examples/k8s-upgrade/k8s-upgrade.sh
EXPECTED_ORCHESTRATOR_VERSION=1.9.0
3 changes: 3 additions & 0 deletions pkg/api/orchestrators.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ func kubernetesUpgrades(csOrch *OrchestratorProfile) ([]*OrchestratorProfile, er
case currentMajor == 1 && currentMinor == 7:
nextMajor = 1
nextMinor = 8
case currentMajor == 1 && currentMinor == 8:
nextMajor = 1
nextMinor = 9
}
for ver, supported := range common.AllKubernetesSupportedVersions {
if !supported {
Expand Down
14 changes: 12 additions & 2 deletions pkg/api/orchestrators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,20 @@ func TestOrchestratorUpgradeInfo(t *testing.T) {
// 1.8.0, 1.8.1, 1.8.2, 1.8.4, 1.8.6
Expect(len(orch.Upgrades)).To(Equal(5))

// 1.8.6 is not upgradable
// 1.8.4 is upgradable to 1.8.x and 1.9.x
csOrch = &OrchestratorProfile{
OrchestratorType: Kubernetes,
OrchestratorVersion: common.KubernetesVersion1Dot8Dot6,
OrchestratorVersion: "1.8.4",
}
orch, e = GetOrchestratorVersionProfile(csOrch)
Expect(e).To(BeNil())
// 1.8.6, 1.9.0
Expect(len(orch.Upgrades)).To(Equal(2))

// 1.9.0 is not upgradable
csOrch = &OrchestratorProfile{
OrchestratorType: Kubernetes,
OrchestratorVersion: "1.9.0",
}
orch, e = GetOrchestratorVersionProfile(csOrch)
Expect(e).To(BeNil())
Expand Down
18 changes: 0 additions & 18 deletions pkg/api/v20170930/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package v20170930
import (
"fmt"
"strings"

"github.com/Azure/acs-engine/pkg/api/common"
)

// Validate implements APIObject
Expand All @@ -23,19 +21,3 @@ func (o *OrchestratorVersionProfile) Validate() error {
}
return nil
}

// ValidateForUpgrade validates upgrade input data
func (o *OrchestratorProfile) ValidateForUpgrade() error {
switch o.OrchestratorType {
case DCOS, DockerCE, Swarm:
return fmt.Errorf("Upgrade is not supported for orchestrator %s", o.OrchestratorType)
case Kubernetes:
switch o.OrchestratorVersion {
case common.KubernetesVersion1Dot6Dot13:
case common.KubernetesVersion1Dot7Dot10:
default:
return fmt.Errorf("Upgrade to Kubernetes %s is not supported", o.OrchestratorVersion)
}
}
return nil
}
16 changes: 0 additions & 16 deletions pkg/api/vlabs/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,22 +214,6 @@ func (o *OrchestratorVersionProfile) Validate() error {
return o.OrchestratorProfile.Validate(false)
}

// ValidateForUpgrade validates upgrade input data
func (o *OrchestratorProfile) ValidateForUpgrade() error {
switch o.OrchestratorType {
case DCOS, SwarmMode, Swarm:
return fmt.Errorf("Upgrade is not supported for orchestrator %s", o.OrchestratorType)
case Kubernetes:
switch o.OrchestratorVersion {
case common.KubernetesVersion1Dot6Dot13:
case common.KubernetesVersion1Dot7Dot10:
default:
return fmt.Errorf("Upgrade to Kubernetes version %s is not supported", o.OrchestratorVersion)
}
}
return nil
}

func validateKeyVaultSecrets(secrets []KeyVaultSecrets, requireCertificateStore bool) error {
for _, s := range secrets {
if len(s.VaultCertificates) == 0 {
Expand Down
20 changes: 11 additions & 9 deletions pkg/operations/kubernetesupgrade/upgradecluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,26 @@ func (uc *UpgradeCluster) UpgradeCluster(subscriptionID uuid.UUID, kubeConfig, r
upgradeVersion := uc.DataModel.Properties.OrchestratorProfile.OrchestratorVersion
uc.Logger.Infof("Upgrading to Kubernetes version %s\n", upgradeVersion)
switch {
case strings.HasPrefix(upgradeVersion, "1.6"):
case strings.HasPrefix(upgradeVersion, "1.6."):
upgrader16 := &Kubernetes16upgrader{}
upgrader16.Init(uc.Translator, uc.Logger, uc.ClusterTopology, uc.Client, kubeConfig)
upgrader16.stepTimeout = uc.StepTimeout
upgrader16.Init(uc.Translator, uc.Logger, uc.ClusterTopology, uc.Client, kubeConfig, uc.StepTimeout)
upgrader = upgrader16

case strings.HasPrefix(upgradeVersion, "1.7"):
case strings.HasPrefix(upgradeVersion, "1.7."):
upgrader17 := &Kubernetes17upgrader{}
upgrader17.Init(uc.Translator, uc.Logger, uc.ClusterTopology, uc.Client, kubeConfig)
upgrader17.stepTimeout = uc.StepTimeout
upgrader17.Init(uc.Translator, uc.Logger, uc.ClusterTopology, uc.Client, kubeConfig, uc.StepTimeout)
upgrader = upgrader17

case strings.HasPrefix(upgradeVersion, "1.8"):
case strings.HasPrefix(upgradeVersion, "1.8."):
upgrader18 := &Kubernetes18upgrader{}
upgrader18.Init(uc.Translator, uc.Logger, uc.ClusterTopology, uc.Client, kubeConfig)
upgrader18.stepTimeout = uc.StepTimeout
upgrader18.Init(uc.Translator, uc.Logger, uc.ClusterTopology, uc.Client, kubeConfig, uc.StepTimeout)
upgrader = upgrader18

case strings.HasPrefix(upgradeVersion, "1.9."):
upgrader19 := &Upgrader{}
upgrader19.Init(uc.Translator, uc.Logger, uc.ClusterTopology, uc.Client, kubeConfig, uc.StepTimeout)
upgrader = upgrader19

default:
return uc.Translator.Errorf("Upgrade to Kubernetes version %s is not supported", upgradeVersion)
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/operations/kubernetesupgrade/upgrader.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ type vmInfo struct {
}

// Init initializes an upgrader struct
func (ku *Upgrader) Init(translator *i18n.Translator, logger *logrus.Entry, clusterTopology ClusterTopology, client armhelpers.ACSEngineClient, kubeConfig string) {
func (ku *Upgrader) Init(translator *i18n.Translator, logger *logrus.Entry, clusterTopology ClusterTopology, client armhelpers.ACSEngineClient, kubeConfig string, stepTimeout *time.Duration) {
ku.Translator = translator
ku.logger = logger
ku.ClusterTopology = clusterTopology
ku.Client = client
ku.kubeConfig = kubeConfig
ku.stepTimeout = stepTimeout
}

// RunUpgrade runs the upgrade pipeline
Expand Down
4 changes: 4 additions & 0 deletions test/acse-conf/acse-upgrade-lnx.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
{
"cluster_definition": "k8s-upgrade/v1.7.9.json",
"location": "centralus"
},
{
"cluster_definition": "k8s-upgrade/v1.8.4.json",
"location": "westus2"
}
]
}
Expand Down
10 changes: 8 additions & 2 deletions test/cluster-tests/kubernetes/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,15 @@ function check_node_count() {
check_node_count

###### Validate Kubernetes version
kubernetes_version=$(kubectl version --short)
DASHBOARD_PORT=80
if [[ ${kubernetes_version} == *"Server Version: v1.9."* ]]; then
DASHBOARD_PORT=443
fi
log "Setting dashboard port to ${DASHBOARD_PORT}"

log "Checking Kubernetes version. Expected: ${EXPECTED_ORCHESTRATOR_VERSION}"
if [ ! -z "${EXPECTED_ORCHESTRATOR_VERSION}" ]; then
kubernetes_version=$(kubectl version --short)
if [[ ${kubernetes_version} != *"Server Version: v${EXPECTED_ORCHESTRATOR_VERSION}"* ]]; then
log "K8S: unexpected kubernetes version:\n${kubernetes_version}"; exit 1
fi
Expand Down Expand Up @@ -175,7 +181,7 @@ if (( ${EXPECTED_DASHBOARD} != 0 )); then
# get master public hostname
master=$(kubectl config view | grep server | cut -f 3- -d "/" | tr -d " ")
# get dashboard port
port=$(kubectl get svc --namespace=kube-system | grep dashboard | awk '{print $4}' | sed -n 's/^80:\(.*\)\/TCP$/\1/p')
port=$(kubectl get svc --namespace=kube-system | grep dashboard | awk '{print $4}' | sed -n 's/^'${DASHBOARD_PORT}':\(.*\)\/TCP$/\1/p')
# get internal IPs of the nodes
ips=$(kubectl get nodes --all-namespaces -o yaml | grep -B 1 InternalIP | grep address | awk '{print $3}')

Expand Down

0 comments on commit d321907

Please sign in to comment.