Merge pull request #7724 from afbjorklund/kubeadm-reset-cri-socket

Pass the cri socket path to kubeadm reset command
pull/7751/head
Medya Ghazizadeh 2020-04-17 11:01:19 -07:00 committed by GitHub
commit b0378e9362
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 7 deletions

View File

@ -572,14 +572,21 @@ func (k *Bootstrapper) GenerateToken(cc config.ClusterConfig) (string, error) {
// DeleteCluster removes the components that were started earlier
func (k *Bootstrapper) DeleteCluster(k8s config.KubernetesConfig) error {
cr, err := cruntime.New(cruntime.Config{Type: k8s.ContainerRuntime, Runner: k.c, Socket: k8s.CRISocket})
if err != nil {
return errors.Wrap(err, "runtime")
}
version, err := util.ParseKubernetesVersion(k8s.KubernetesVersion)
if err != nil {
return errors.Wrap(err, "parsing kubernetes version")
}
cmd := fmt.Sprintf("%s reset --force", bsutil.InvokeKubeadm(k8s.KubernetesVersion))
ka := bsutil.InvokeKubeadm(k8s.KubernetesVersion)
sp := cr.SocketPath()
cmd := fmt.Sprintf("%s reset --cri-socket %s --force", ka, sp)
if version.LT(semver.MustParse("1.11.0")) {
cmd = fmt.Sprintf("%s reset", bsutil.InvokeKubeadm(k8s.KubernetesVersion))
cmd = fmt.Sprintf("%s reset --cri-socket %s", ka, sp)
}
rr, derr := k.c.RunCmd(exec.Command("/bin/bash", "-c", cmd))
@ -591,11 +598,6 @@ func (k *Bootstrapper) DeleteCluster(k8s config.KubernetesConfig) error {
glog.Warningf("stop kubelet: %v", err)
}
cr, err := cruntime.New(cruntime.Config{Type: k8s.ContainerRuntime, Runner: k.c, Socket: k8s.CRISocket})
if err != nil {
return errors.Wrap(err, "runtime")
}
containers, err := cr.ListContainers(cruntime.ListOptions{Namespaces: []string{"kube-system"}})
if err != nil {
glog.Warningf("unable to list kube-system containers: %v", err)