kubeadm: delete boostrap-kubelet.conf after TLS bootstrap on init

This commit is contained in:
Lubomir I. Ivanov 2019-09-30 23:52:01 +03:00
parent 2dedfddf81
commit 71cb27836d

View File

@ -19,6 +19,7 @@ package phases
import (
"fmt"
"io"
"os"
"path/filepath"
"text/template"
"time"
@ -100,6 +101,13 @@ func runWaitControlPlanePhase(c workflow.RunData) error {
return errors.New("couldn't initialize a Kubernetes cluster")
}
// Deletes the kubelet boostrap kubeconfig file, so the credential used for TLS bootstrap is removed from disk
// This is done only on success.
bootstrapKubeConfigFile := kubeadmconstants.GetBootstrapKubeletKubeConfigPath()
if err := os.Remove(bootstrapKubeConfigFile); err != nil {
klog.Warningf("[wait-control-plane] could not delete the file %q: %v", bootstrapKubeConfigFile, err)
}
return nil
}