mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
kubeadm:[cherry-pick]backup kubelet config for "upgrade node"
This addresses the TODO item so that the old kubelet config file could be recovered if something goes wrong. Signed-off-by: Dave Chen <dave.chen@arm.com> Co-authored-by: Paco Xu <paco.xu@daocloud.io>
This commit is contained in:
parent
7b243cef1a
commit
016cc0c120
@ -71,6 +71,21 @@ func runKubeletConfigPhase() func(c workflow.RunData) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create a copy of the kubelet config file in the /etc/kubernetes/tmp/ folder.
|
||||||
|
backupDir, err := constants.CreateTempDirForKubeadm(constants.KubernetesDir, "kubeadm-kubelet-config")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
src := filepath.Join(kubeletDir, constants.KubeletConfigurationFileName)
|
||||||
|
dest := filepath.Join(backupDir, constants.KubeletConfigurationFileName)
|
||||||
|
if !dryRun {
|
||||||
|
fmt.Printf("[upgrade] Backing up kubelet config file to %s\n", dest)
|
||||||
|
if err := os.Rename(src, dest); err != nil {
|
||||||
|
return errors.Wrap(err, "error backing up the kubelet config file")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fmt.Printf("[dryrun] Would back up kubelet config file to %s\n", dest)
|
||||||
|
}
|
||||||
// Store the kubelet component configuration.
|
// Store the kubelet component configuration.
|
||||||
if err = kubeletphase.WriteConfigToDisk(&cfg.ClusterConfiguration, kubeletDir, data.PatchesDir(), data.OutputWriter()); err != nil {
|
if err = kubeletphase.WriteConfigToDisk(&cfg.ClusterConfiguration, kubeletDir, data.PatchesDir(), data.OutputWriter()); err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user