Skip to content

Commit

Permalink
Merge pull request #2973 from neolit123/1.29-add-upgrade-plan-to-kinder
Browse files Browse the repository at this point in the history
kinder: call "upgrade plan" before "upgrade apply"
  • Loading branch information
k8s-ci-robot authored Dec 18, 2023
2 parents bd6c701 + a560645 commit 7c86dae
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,13 @@ tasks:
- name: upgrade-control-plane
description: |
Upgrades the control-plane node to the same version of the existing control-plane. This verifies
that "kubeadm upgrade apply" tolerates missing addon ConfigMaps. Ignoring preflight errors
that "kubeadm upgrade apply/plan" tolerate missing addon ConfigMaps. Ignoring preflight errors
is still required due to CoreDNS checks.
cmd: /bin/sh
args:
- -c
- |
docker exec {{ .vars.clusterName }}-control-plane-1 kubeadm upgrade plan --ignore-preflight-errors=CoreDNSMigration,CoreDNSUnsupportedPlugins --v={{ .vars.kubeadmVerbosity }} {{ .vars.initVersion }}
docker exec {{ .vars.clusterName }}-control-plane-1 kubeadm upgrade apply -f --ignore-preflight-errors=CoreDNSMigration,CoreDNSUnsupportedPlugins --v={{ .vars.kubeadmVerbosity }} {{ .vars.initVersion }}
timeout: 5m
- name: delete
Expand Down
3 changes: 2 additions & 1 deletion kinder/ci/workflows/upgrade-latest-no-addon-config-maps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,13 @@ tasks:
- name: upgrade-control-plane
description: |
Upgrades the control-plane node to the same version of the existing control-plane. This verifies
that "kubeadm upgrade apply" tolerates missing addon ConfigMaps. Ignoring preflight errors
that "kubeadm upgrade apply/plan" tolerate missing addon ConfigMaps. Ignoring preflight errors
is still required due to CoreDNS checks.
cmd: /bin/sh
args:
- -c
- |
docker exec {{ .vars.clusterName }}-control-plane-1 kubeadm upgrade plan --ignore-preflight-errors=CoreDNSMigration,CoreDNSUnsupportedPlugins --v={{ .vars.kubeadmVerbosity }} {{ .vars.initVersion }}
docker exec {{ .vars.clusterName }}-control-plane-1 kubeadm upgrade apply -f --ignore-preflight-errors=CoreDNSMigration,CoreDNSUnsupportedPlugins --v={{ .vars.kubeadmVerbosity }} {{ .vars.initVersion }}
timeout: 5m
- name: delete
Expand Down
20 changes: 20 additions & 0 deletions kinder/pkg/cluster/manager/actions/kubeadm-upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ func KubeadmUpgrade(c *status.Cluster, upgradeVersion *K8sVersion.Version, patch
}

if n.Name() == c.BootstrapControlPlane().Name() {
if err := kubeadmUpgradePlan(c, n, upgradeVersion, featureGate, vLevel); err != nil {
return err
}
err = kubeadmUpgradeApply(c, n, upgradeVersion, patchesDir, featureGate, wait, vLevel)
} else {
err = kubeadmUpgradeNode(c, n, upgradeVersion, patchesDir, wait, vLevel)
Expand Down Expand Up @@ -120,6 +123,23 @@ func upgradeKubeadmBinary(n *status.Node, upgradeVersion *K8sVersion.Version) er
return nil
}

func kubeadmUpgradePlan(c *status.Cluster, cp1 *status.Node, upgradeVersion *K8sVersion.Version, featureGate string, vLevel int) error {
planArgs := []string{
"upgrade", "plan", fmt.Sprintf("v%s", upgradeVersion),
"--allow-experimental-upgrades", "--allow-release-candidate-upgrades",
fmt.Sprintf("--v=%d", vLevel),
}
if len(featureGate) > 0 {
planArgs = append(planArgs, fmt.Sprintf("--feature-gates=%s", featureGate))
}
if err := cp1.Command(
"kubeadm", planArgs...,
).RunWithEcho(); err != nil {
return err
}
return nil
}

func kubeadmUpgradeApply(c *status.Cluster, cp1 *status.Node, upgradeVersion *K8sVersion.Version, patchesDir string, featureGate string, wait time.Duration, vLevel int) error {
applyArgs := []string{
"upgrade", "apply", "-f", fmt.Sprintf("v%s", upgradeVersion), fmt.Sprintf("--v=%d", vLevel),
Expand Down

0 comments on commit 7c86dae

Please sign in to comment.