mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Merge pull request #74072 from bart0sh/PR0061-kubeadm-fix-failed-to-load-admin-kubeconfig
kubeadm: fix kubeadm reset logic
This commit is contained in:
commit
b6ca168911
@ -62,8 +62,10 @@ func NewCmdReset(in io.Reader, out io.Writer) *cobra.Command {
|
|||||||
kubeadmutil.CheckErr(err)
|
kubeadmutil.CheckErr(err)
|
||||||
|
|
||||||
kubeConfigFile = cmdutil.FindExistingKubeConfig(kubeConfigFile)
|
kubeConfigFile = cmdutil.FindExistingKubeConfig(kubeConfigFile)
|
||||||
client, err = getClientset(kubeConfigFile, false)
|
if _, err := os.Stat(kubeConfigFile); !os.IsNotExist(err) {
|
||||||
kubeadmutil.CheckErr(err)
|
client, err = getClientset(kubeConfigFile, false)
|
||||||
|
kubeadmutil.CheckErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
if criSocketPath == "" {
|
if criSocketPath == "" {
|
||||||
criSocketPath, err = resetDetectCRISocket(client)
|
criSocketPath, err = resetDetectCRISocket(client)
|
||||||
@ -298,10 +300,12 @@ func resetConfigDir(configPathDir, pkiPathDir string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func resetDetectCRISocket(client clientset.Interface) (string, error) {
|
func resetDetectCRISocket(client clientset.Interface) (string, error) {
|
||||||
// first try to connect to the cluster for the CRI socket
|
if client != nil {
|
||||||
cfg, err := configutil.FetchInitConfigurationFromCluster(client, os.Stdout, "reset", false)
|
// first try to connect to the cluster for the CRI socket
|
||||||
if err == nil {
|
cfg, err := configutil.FetchInitConfigurationFromCluster(client, os.Stdout, "reset", false)
|
||||||
return cfg.NodeRegistration.CRISocket, nil
|
if err == nil {
|
||||||
|
return cfg.NodeRegistration.CRISocket, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if this fails, try to detect it
|
// if this fails, try to detect it
|
||||||
|
Loading…
Reference in New Issue
Block a user