Skip to content

Commit d6328f1

Browse files
committed
kubeadm: fix "upgrade plan" not working without k8s version
If the k8s version argument passed to "upgrade plan" is missing the logic should perform the following actions: - fetch a "stable" version from the internet. - if that fails, fallback to the local client version. Currentely the logic fails because the cfg.KubernetesVersion is defaulted to the version of the existing cluster, which then causes an early exit without any ugprade suggestions. See app/cmd/upgrade/common.go::enforceRequirements(): configutil.FetchInitConfigurationFromCluster(..) Fix that by passing the explicit user value that can also be "". This will then make the "offline getter" treat it as an explicit desired upgrade target. In the future it might be best to invert this logic: - if no user k8s version argument is passed - default to the kubeadm version. - if labels are passed (e.g. "stable"), fetch a version from the internet.
1 parent 30165e4 commit d6328f1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

cmd/kubeadm/app/cmd/upgrade/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func enforceRequirements(flags *applyPlanFlags, dryRun bool, newK8sVersion strin
154154
}
155155

156156
// Use a real version getter interface that queries the API server, the kubeadm client and the Kubernetes CI system for latest versions
157-
return client, upgrade.NewOfflineVersionGetter(upgrade.NewKubeVersionGetter(client, os.Stdout), cfg.KubernetesVersion), cfg, nil
157+
return client, upgrade.NewOfflineVersionGetter(upgrade.NewKubeVersionGetter(client, os.Stdout), newK8sVersion), cfg, nil
158158
}
159159

160160
// printConfiguration prints the external version of the API to yaml

0 commit comments

Comments
 (0)