Skip to content

Commit 0b92e8b

Browse files
authored
Merge pull request kubernetes#94421 from rosti/kubeadm-fix-upgrade-plan
kubeadm: Fix `upgrade plan` for air-gapped setups
2 parents 8aaa751 + 6e2a70e commit 0b92e8b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,15 @@ func enforceRequirements(flags *applyPlanFlags, args []string, dryRun bool, upgr
185185
// If option was specified in both args and config file, args will overwrite the config file.
186186
if len(args) == 1 {
187187
newK8sVersion = args[0]
188-
cfg.KubernetesVersion = newK8sVersion
188+
if upgradeApply {
189+
// The `upgrade apply` version always overwrites the KubernetesVersion in the returned cfg with the target
190+
// version. While this is not the same for `upgrade plan` where the KubernetesVersion should be the old
191+
// one (because the call to getComponentConfigVersionStates requires the currently installed version).
192+
// This also makes the KubernetesVersion value returned for `upgrade plan` consistent as that command
193+
// allows to not specify a target version in which case KubernetesVersion will always hold the currently
194+
// installed one.
195+
cfg.KubernetesVersion = newK8sVersion
196+
}
189197
}
190198

191199
// If features gates are passed to the command line, use it (otherwise use featureGates from configuration)

0 commit comments

Comments
 (0)