mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
kubeadm: backup the kubelet config file before writting the new one
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>
This commit is contained in:
parent
57eb5d631c
commit
cd1f082179
@ -71,8 +71,17 @@ func runKubeletConfigPhase() func(c workflow.RunData) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Checkpoint the current configuration first so that if something goes wrong it can be recovered
|
// 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)
|
||||||
|
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")
|
||||||
|
}
|
||||||
// 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