kubeadm: add deprecated FG UpgradeAddonsBeforeControlPlane

This commit is contained in:
Paco Xu 2023-04-28 13:55:46 +08:00
parent 0d0870e5b4
commit c6f4bee98d
3 changed files with 14 additions and 14 deletions

View File

@ -79,7 +79,7 @@ func runControlPlane() func(c workflow.RunData) error {
return errors.Wrap(err, "couldn't complete the static pod upgrade")
}
if features.Enabled(cfg.FeatureGates, features.UpgradeAddonsAfterControlPlane) {
if !features.Enabled(cfg.FeatureGates, features.UpgradeAddonsBeforeControlPlane) {
if err := upgrade.PerformAddonsUpgrade(client, cfg, data.OutputWriter()); err != nil {
return errors.Wrap(err, "failed to perform addons upgrade")
}

View File

@ -35,16 +35,16 @@ const (
RootlessControlPlane = "RootlessControlPlane"
// EtcdLearnerMode is expected to be in alpha in v1.27
EtcdLearnerMode = "EtcdLearnerMode"
// UpgradeAddonsAfterControlPlane is expected to be in alpha in v1.28
UpgradeAddonsAfterControlPlane = "UpgradeAddonsAfterControlPlane"
// UpgradeAddonsBeforeControlPlane is expected to be in deprecated in v1.28 and will be removed in future release
UpgradeAddonsBeforeControlPlane = "UpgradeAddonsBeforeControlPlane"
)
// InitFeatureGates are the default feature gates for the init command
var InitFeatureGates = FeatureList{
PublicKeysECDSA: {FeatureSpec: featuregate.FeatureSpec{Default: false, PreRelease: featuregate.Alpha}},
RootlessControlPlane: {FeatureSpec: featuregate.FeatureSpec{Default: false, PreRelease: featuregate.Alpha}},
EtcdLearnerMode: {FeatureSpec: featuregate.FeatureSpec{Default: false, PreRelease: featuregate.Alpha}},
UpgradeAddonsAfterControlPlane: {FeatureSpec: featuregate.FeatureSpec{Default: false, PreRelease: featuregate.Alpha}},
PublicKeysECDSA: {FeatureSpec: featuregate.FeatureSpec{Default: false, PreRelease: featuregate.Alpha}},
RootlessControlPlane: {FeatureSpec: featuregate.FeatureSpec{Default: false, PreRelease: featuregate.Alpha}},
EtcdLearnerMode: {FeatureSpec: featuregate.FeatureSpec{Default: false, PreRelease: featuregate.Alpha}},
UpgradeAddonsBeforeControlPlane: {FeatureSpec: featuregate.FeatureSpec{Default: false, PreRelease: featuregate.Deprecated}},
}
// Feature represents a feature being gated

View File

@ -114,28 +114,28 @@ func PerformPostUpgradeTasks(client clientset.Interface, cfg *kubeadmapi.InitCon
}
// PerformAddonsUpgrade performs the upgrade of the coredns and kube-proxy addons.
// When UpgradeAddonsAfterControlPlane feature gate is disabled, the addons will be upgraded immediately.
// When UpgradeAddonsAfterControlPlane feature gate is enabled, the addons will only get updated after all the control plane instances have been upgraded.
// When UpgradeAddonsBeforeControlPlane feature gate is enabled, the addons will be upgraded immediately.
// When UpgradeAddonsBeforeControlPlane feature gate is disabled, the addons will only get updated after all the control plane instances have been upgraded.
func PerformAddonsUpgrade(client clientset.Interface, cfg *kubeadmapi.InitConfiguration, out io.Writer) error {
unupgradedControlPlanes, err := unupgradedControlPlaneInstances(client, cfg.NodeRegistration.Name)
if err != nil {
err = errors.Wrapf(err, "failed to determine whether all the control plane instances have been upgraded")
if features.Enabled(cfg.FeatureGates, features.UpgradeAddonsAfterControlPlane) {
if !features.Enabled(cfg.FeatureGates, features.UpgradeAddonsBeforeControlPlane) {
return err
}
// when UpgradeAddonsAfterControlPlane feature gate is disabled, just throw a warning
// when UpgradeAddonsBeforeControlPlane feature gate is enabled, just throw a warning
klog.V(1).Info(err)
}
if len(unupgradedControlPlanes) > 0 {
if features.Enabled(cfg.FeatureGates, features.UpgradeAddonsAfterControlPlane) {
if !features.Enabled(cfg.FeatureGates, features.UpgradeAddonsBeforeControlPlane) {
fmt.Fprintf(out, "[upgrade/addons] skip upgrade addons because control plane instances %v have not been upgraded\n", unupgradedControlPlanes)
return nil
}
// when UpgradeAddonsAfterControlPlane feature gate is disabled, just throw a warning
// when UpgradeAddonsBeforeControlPlane feature gate is enabled, just throw a warning
klog.V(1).Infof("upgrading addons when control plane instances %v have not been upgraded "+
"may lead to incompatibility problems. You can enable the UpgradeAddonsAfterControlPlane feature gate to"+
"may lead to incompatibility problems. You can disable the UpgradeAddonsBeforeControlPlane feature gate to"+
"ensure that the addons upgrade is executed only when all the control plane instances have been upgraded.", unupgradedControlPlanes)
}