mirror of
https://github.com/rancher/rke.git
synced 2025-09-13 05:34:11 +00:00
remove kubeconfig as part of cluster remove
This commit is contained in:
@@ -2,6 +2,7 @@ package cluster
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/rancher/rke/hosts"
|
"github.com/rancher/rke/hosts"
|
||||||
|
"github.com/rancher/rke/pki"
|
||||||
"github.com/rancher/rke/services"
|
"github.com/rancher/rke/services"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -22,7 +23,11 @@ func (c *Cluster) ClusterRemove() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Clean up all hosts
|
// Clean up all hosts
|
||||||
return cleanUpHosts(c.ControlPlaneHosts, c.WorkerHosts, c.EtcdHosts)
|
if err := cleanUpHosts(c.ControlPlaneHosts, c.WorkerHosts, c.EtcdHosts); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return pki.RemoveAdminConfig(c.LocalKubeConfigPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func cleanUpHosts(cpHosts, workerHosts, etcdHosts []hosts.Host) error {
|
func cleanUpHosts(cpHosts, workerHosts, etcdHosts []hosts.Host) error {
|
||||||
|
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
@@ -110,3 +111,12 @@ func DeployAdminConfig(kubeConfig, localConfigPath string) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RemoveAdminConfig(localConfigPath string) error {
|
||||||
|
logrus.Infof("Removing local admin Kubeconfig: %s", localConfigPath)
|
||||||
|
if err := os.Remove(localConfigPath); err != nil {
|
||||||
|
return fmt.Errorf("Failed to remove local admin Kubeconfig file: %v", err)
|
||||||
|
}
|
||||||
|
logrus.Infof("Local admin Kubeconfig removed successfully")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user