Skip to content

Commit bd85320

Browse files
authored
Merge pull request kubernetes#130023 from SataQiu/fix-20250207
kubeadm: add --etcd-upgrade flag to kubeadm upgrade plan
2 parents 80bf507 + dc51c81 commit bd85320

File tree

14 files changed

+84
-14
lines changed

14 files changed

+84
-14
lines changed

cmd/kubeadm/app/apis/kubeadm/fuzzer/fuzzer.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,5 +169,7 @@ func fuzzUpgradeConfiguration(obj *kubeadm.UpgradeConfiguration, c fuzz.Continue
169169
obj.Apply.ImagePullPolicy = corev1.PullIfNotPresent
170170
obj.Apply.ImagePullSerial = ptr.To(true)
171171

172+
obj.Plan.EtcdUpgrade = ptr.To(true)
173+
172174
kubeadm.SetDefaultTimeouts(&obj.Timeouts)
173175
}

cmd/kubeadm/app/apis/kubeadm/types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,9 @@ type UpgradePlanConfiguration struct {
657657
// DryRun tells if the dry run mode is enabled, don't apply any change if it is and just output what would be done.
658658
DryRun *bool
659659

660+
// EtcdUpgrade instructs kubeadm to execute etcd upgrade during upgrades.
661+
EtcdUpgrade *bool
662+
660663
// IgnorePreflightErrors provides a slice of pre-flight errors to be ignored during the upgrade process, e.g. 'IsPrivilegedUser,Swap'.
661664
// Value 'all' ignores errors from all checks.
662665
IgnorePreflightErrors []string

cmd/kubeadm/app/apis/kubeadm/v1beta4/defaults.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,10 @@ func SetDefaults_UpgradeConfiguration(obj *UpgradeConfiguration) {
299299
obj.Apply.ImagePullSerial = ptr.To(true)
300300
}
301301

302+
if obj.Plan.EtcdUpgrade == nil {
303+
obj.Plan.EtcdUpgrade = ptr.To(true)
304+
}
305+
302306
if obj.Timeouts == nil {
303307
obj.Timeouts = &Timeouts{}
304308
}

cmd/kubeadm/app/apis/kubeadm/v1beta4/doc.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ limitations under the License.
2424
//
2525
// A list of changes since v1beta3:
2626
//
27+
// v1.33:
28+
// - Add an `EtcdUpgrade` field into `UpgradeConfiguration.Plan` that can be used to control whether the etcd upgrade plan
29+
// should be displayed.
30+
//
31+
// v1.31:
2732
// - Support custom environment variables in control plane components under `ClusterConfiguration`.
2833
// Use `APIServer.ExtraEnvs`, `ControllerManager.ExtraEnvs`, `Scheduler.ExtraEnvs`, `Etcd.Local.ExtraEnvs`.
2934
// - The `ResetConfiguration` API type is now supported in v1beta4. Users are able to reset a node by passing

cmd/kubeadm/app/apis/kubeadm/v1beta4/types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,11 @@ type UpgradePlanConfiguration struct {
749749
// +optional
750750
DryRun *bool `json:"dryRun,omitempty"`
751751

752+
// EtcdUpgrade instructs kubeadm to execute etcd upgrade during upgrades.
753+
// Defaults to true.
754+
// +optional
755+
EtcdUpgrade *bool `json:"etcdUpgrade,omitempty"`
756+
752757
// IgnorePreflightErrors provides a slice of pre-flight errors to be ignored during the upgrade process, e.g. 'IsPrivilegedUser,Swap'.
753758
// Value 'all' ignores errors from all checks.
754759
// +optional

cmd/kubeadm/app/apis/kubeadm/v1beta4/zz_generated.conversion.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/kubeadm/app/apis/kubeadm/v1beta4/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/kubeadm/app/apis/kubeadm/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/kubeadm/app/cmd/upgrade/apply.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ type applyFlags struct {
5050
nonInteractiveMode bool
5151
force bool
5252
dryRun bool
53-
etcdUpgrade bool
5453
renewCerts bool
5554
patchesDir string
5655
}
@@ -81,7 +80,6 @@ type applyData struct {
8180
func newCmdApply(apf *applyPlanFlags) *cobra.Command {
8281
flags := &applyFlags{
8382
applyPlanFlags: apf,
84-
etcdUpgrade: true,
8583
renewCerts: true,
8684
}
8785

@@ -126,7 +124,6 @@ func newCmdApply(apf *applyPlanFlags) *cobra.Command {
126124
cmd.Flags().BoolVarP(&flags.nonInteractiveMode, "yes", "y", flags.nonInteractiveMode, "Perform the upgrade and do not prompt for confirmation (non-interactive mode).")
127125
cmd.Flags().BoolVarP(&flags.force, options.Force, "f", flags.force, "Force upgrading although some requirements might not be met. This also implies non-interactive mode.")
128126
cmd.Flags().BoolVar(&flags.dryRun, options.DryRun, flags.dryRun, "Do not change any state, just output what actions would be performed.")
129-
cmd.Flags().BoolVar(&flags.etcdUpgrade, options.EtcdUpgrade, flags.etcdUpgrade, "Perform the upgrade of etcd.")
130127
cmd.Flags().BoolVar(&flags.renewCerts, options.CertificateRenewal, flags.renewCerts, "Perform the renewal of certificates used by component changed during upgrades.")
131128
options.AddPatchesFlag(cmd.Flags(), &flags.patchesDir)
132129

cmd/kubeadm/app/cmd/upgrade/apply_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ func TestNewApplyData(t *testing.T) {
120120
allowExperimentalUpgrades: false,
121121
allowRCUpgrades: false,
122122
printConfig: false,
123+
etcdUpgrade: true,
123124
out: os.Stdout,
124125
}
125126

@@ -132,7 +133,6 @@ func TestNewApplyData(t *testing.T) {
132133

133134
flags := &applyFlags{
134135
applyPlanFlags: apf,
135-
etcdUpgrade: true,
136136
renewCerts: true,
137137
}
138138

0 commit comments

Comments
 (0)