mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
kubeadm: Don't downgrade etcd on cluster downgrade
This commit is contained in:
parent
8c1ee761d2
commit
f99aae9ce3
@ -228,7 +228,6 @@ func AddInitOtherFlags(flagSet *flag.FlagSet, cfgPath *string, skipPreFlight, sk
|
|||||||
|
|
||||||
// NewInit validates given arguments and instantiates Init struct with provided information.
|
// NewInit validates given arguments and instantiates Init struct with provided information.
|
||||||
func NewInit(cfgPath string, cfg *kubeadmapi.MasterConfiguration, ignorePreflightErrors sets.String, skipTokenPrint, dryRun bool, criSocket string) (*Init, error) {
|
func NewInit(cfgPath string, cfg *kubeadmapi.MasterConfiguration, ignorePreflightErrors sets.String, skipTokenPrint, dryRun bool, criSocket string) (*Init, error) {
|
||||||
fmt.Println("[kubeadm] WARNING: kubeadm is currently in beta")
|
|
||||||
|
|
||||||
if cfgPath != "" {
|
if cfgPath != "" {
|
||||||
b, err := ioutil.ReadFile(cfgPath)
|
b, err := ioutil.ReadFile(cfgPath)
|
||||||
|
@ -199,7 +199,6 @@ type Join struct {
|
|||||||
|
|
||||||
// NewJoin instantiates Join struct with given arguments
|
// NewJoin instantiates Join struct with given arguments
|
||||||
func NewJoin(cfgPath string, args []string, cfg *kubeadmapi.NodeConfiguration, ignorePreflightErrors sets.String, criSocket string) (*Join, error) {
|
func NewJoin(cfgPath string, args []string, cfg *kubeadmapi.NodeConfiguration, ignorePreflightErrors sets.String, criSocket string) (*Join, error) {
|
||||||
fmt.Println("[kubeadm] WARNING: kubeadm is currently in beta")
|
|
||||||
|
|
||||||
if cfg.NodeName == "" {
|
if cfg.NodeName == "" {
|
||||||
cfg.NodeName = nodeutil.GetHostname("")
|
cfg.NodeName = nodeutil.GetHostname("")
|
||||||
|
@ -203,7 +203,7 @@ func SetImplicitFlags(flags *applyFlags) error {
|
|||||||
// EnforceVersionPolicies makes sure that the version the user specified is valid to upgrade to
|
// EnforceVersionPolicies makes sure that the version the user specified is valid to upgrade to
|
||||||
// There are both fatal and skippable (with --force) errors
|
// There are both fatal and skippable (with --force) errors
|
||||||
func EnforceVersionPolicies(flags *applyFlags, versionGetter upgrade.VersionGetter) error {
|
func EnforceVersionPolicies(flags *applyFlags, versionGetter upgrade.VersionGetter) error {
|
||||||
fmt.Printf("[upgrade/version] You have chosen to upgrade to version %q\n", flags.newK8sVersionStr)
|
fmt.Printf("[upgrade/version] You have chosen to change the cluster version to %q\n", flags.newK8sVersionStr)
|
||||||
|
|
||||||
versionSkewErrs := upgrade.EnforceVersionPolicies(versionGetter, flags.newK8sVersionStr, flags.newK8sVersion, flags.parent.allowExperimentalUpgrades, flags.parent.allowRCUpgrades)
|
versionSkewErrs := upgrade.EnforceVersionPolicies(versionGetter, flags.newK8sVersionStr, flags.newK8sVersion, flags.parent.allowExperimentalUpgrades, flags.parent.allowRCUpgrades)
|
||||||
if versionSkewErrs != nil {
|
if versionSkewErrs != nil {
|
||||||
|
@ -33,7 +33,7 @@ const (
|
|||||||
// CoreDNS is alpha in v1.9
|
// CoreDNS is alpha in v1.9
|
||||||
CoreDNS = "CoreDNS"
|
CoreDNS = "CoreDNS"
|
||||||
|
|
||||||
// SelfHosting is beta in v1.9
|
// SelfHosting is alpha in v1.8 and v1.9
|
||||||
SelfHosting = "SelfHosting"
|
SelfHosting = "SelfHosting"
|
||||||
|
|
||||||
// StoreCertsInSecrets is alpha in v1.8 and v1.9
|
// StoreCertsInSecrets is alpha in v1.8 and v1.9
|
||||||
@ -47,7 +47,7 @@ var v190 = version.MustParseSemantic("v1.9.0-alpha.1")
|
|||||||
|
|
||||||
// InitFeatureGates are the default feature gates for the init command
|
// InitFeatureGates are the default feature gates for the init command
|
||||||
var InitFeatureGates = FeatureList{
|
var InitFeatureGates = FeatureList{
|
||||||
SelfHosting: {FeatureSpec: utilfeature.FeatureSpec{Default: false, PreRelease: utilfeature.Beta}},
|
SelfHosting: {FeatureSpec: utilfeature.FeatureSpec{Default: false, PreRelease: utilfeature.Alpha}},
|
||||||
StoreCertsInSecrets: {FeatureSpec: utilfeature.FeatureSpec{Default: false, PreRelease: utilfeature.Alpha}},
|
StoreCertsInSecrets: {FeatureSpec: utilfeature.FeatureSpec{Default: false, PreRelease: utilfeature.Alpha}},
|
||||||
// We don't want to advertise this feature gate exists in v1.9 to avoid confusion as it is not yet working
|
// We don't want to advertise this feature gate exists in v1.9 to avoid confusion as it is not yet working
|
||||||
HighAvailability: {FeatureSpec: utilfeature.FeatureSpec{Default: false, PreRelease: utilfeature.Alpha}, MinimumVersion: v190, HiddenInHelpText: true},
|
HighAvailability: {FeatureSpec: utilfeature.FeatureSpec{Default: false, PreRelease: utilfeature.Alpha}, MinimumVersion: v190, HiddenInHelpText: true},
|
||||||
|
@ -154,7 +154,7 @@ func upgradeComponent(component string, waiter apiclient.Waiter, pathMgr StaticP
|
|||||||
return rollbackOldManifests(recoverManifests, err, pathMgr, recoverEtcd)
|
return rollbackOldManifests(recoverManifests, err, pathMgr, recoverEtcd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("[upgrade/staticpods] Moved upgraded manifest to %q and backed up old manifest to %q\n", currentManifestPath, backupManifestPath)
|
fmt.Printf("[upgrade/staticpods] Moved new manifest to %q and backed up old manifest to %q\n", currentManifestPath, backupManifestPath)
|
||||||
fmt.Println("[upgrade/staticpods] Waiting for the kubelet to restart the component")
|
fmt.Println("[upgrade/staticpods] Waiting for the kubelet to restart the component")
|
||||||
|
|
||||||
// Wait for the mirror Pod hash to change; otherwise we'll run into race conditions here when the kubelet hasn't had time to
|
// Wait for the mirror Pod hash to change; otherwise we'll run into race conditions here when the kubelet hasn't had time to
|
||||||
@ -178,7 +178,7 @@ func upgradeComponent(component string, waiter apiclient.Waiter, pathMgr StaticP
|
|||||||
func performEtcdStaticPodUpgrade(waiter apiclient.Waiter, pathMgr StaticPodPathManager, cfg *kubeadmapi.MasterConfiguration, recoverManifests map[string]string) (bool, error) {
|
func performEtcdStaticPodUpgrade(waiter apiclient.Waiter, pathMgr StaticPodPathManager, cfg *kubeadmapi.MasterConfiguration, recoverManifests map[string]string) (bool, error) {
|
||||||
// Add etcd static pod spec only if external etcd is not configured
|
// Add etcd static pod spec only if external etcd is not configured
|
||||||
if len(cfg.Etcd.Endpoints) != 0 {
|
if len(cfg.Etcd.Endpoints) != 0 {
|
||||||
return false, fmt.Errorf("external etcd cannot be upgraded with kubeadm")
|
return false, fmt.Errorf("external etcd detected, won't try to change any etcd state")
|
||||||
}
|
}
|
||||||
// Checking health state of etcd before proceeding with the upgrtade
|
// Checking health state of etcd before proceeding with the upgrtade
|
||||||
etcdCluster := util.LocalEtcdCluster{}
|
etcdCluster := util.LocalEtcdCluster{}
|
||||||
@ -191,7 +191,7 @@ func performEtcdStaticPodUpgrade(waiter apiclient.Waiter, pathMgr StaticPodPathM
|
|||||||
backupEtcdDir := pathMgr.BackupEtcdDir()
|
backupEtcdDir := pathMgr.BackupEtcdDir()
|
||||||
runningEtcdDir := cfg.Etcd.DataDir
|
runningEtcdDir := cfg.Etcd.DataDir
|
||||||
if err := util.CopyDir(runningEtcdDir, backupEtcdDir); err != nil {
|
if err := util.CopyDir(runningEtcdDir, backupEtcdDir); err != nil {
|
||||||
return true, fmt.Errorf("fail to back up etcd data with %v", err)
|
return true, fmt.Errorf("fail to back up etcd data: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Need to check currently used version and version from constants, if differs then upgrade
|
// Need to check currently used version and version from constants, if differs then upgrade
|
||||||
@ -206,7 +206,7 @@ func performEtcdStaticPodUpgrade(waiter apiclient.Waiter, pathMgr StaticPodPathM
|
|||||||
|
|
||||||
// Comparing current etcd version with desired to catch the same version or downgrade condition and fail on them.
|
// Comparing current etcd version with desired to catch the same version or downgrade condition and fail on them.
|
||||||
if desiredEtcdVersion.LessThan(currentEtcdVersion) {
|
if desiredEtcdVersion.LessThan(currentEtcdVersion) {
|
||||||
return true, fmt.Errorf("the requested etcd version (%s) for Kubernetes v(%s) is lower than the currently running version (%s)", desiredEtcdVersion.String(), cfg.KubernetesVersion, currentEtcdVersion.String())
|
return false, fmt.Errorf("the desired etcd version for this Kubernetes version %q is %q, but the current etcd version is %q. Won't downgrade etcd, instead just continue", cfg.KubernetesVersion, desiredEtcdVersion.String(), currentEtcdVersion.String())
|
||||||
}
|
}
|
||||||
// For the case when desired etcd version is the same as current etcd version
|
// For the case when desired etcd version is the same as current etcd version
|
||||||
if strings.Compare(desiredEtcdVersion.String(), currentEtcdVersion.String()) == 0 {
|
if strings.Compare(desiredEtcdVersion.String(), currentEtcdVersion.String()) == 0 {
|
||||||
@ -288,7 +288,7 @@ func StaticPodControlPlane(waiter apiclient.Waiter, pathMgr StaticPodPathManager
|
|||||||
if fatal {
|
if fatal {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Printf("[etcd] non fatal issue encountered during upgrade: %v\n", err)
|
fmt.Printf("[upgrade/etcd] non fatal issue encountered during upgrade: %v\n", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,7 +298,7 @@ func StaticPodControlPlane(waiter apiclient.Waiter, pathMgr StaticPodPathManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write the updated static Pod manifests into the temporary directory
|
// Write the updated static Pod manifests into the temporary directory
|
||||||
fmt.Printf("[upgrade/staticpods] Writing upgraded Static Pod manifests to %q\n", pathMgr.TempManifestDir())
|
fmt.Printf("[upgrade/staticpods] Writing new Static Pod manifests to %q\n", pathMgr.TempManifestDir())
|
||||||
err = controlplane.CreateInitStaticPodManifestFiles(pathMgr.TempManifestDir(), cfg)
|
err = controlplane.CreateInitStaticPodManifestFiles(pathMgr.TempManifestDir(), cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error creating init static pod manifest files: %v", err)
|
return fmt.Errorf("error creating init static pod manifest files: %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user