diff --git a/pkg/container/containerd.go b/pkg/container/containerd.go index 8f3602c3..50fc4ff6 100644 --- a/pkg/container/containerd.go +++ b/pkg/container/containerd.go @@ -23,6 +23,7 @@ import ( "github.com/kubesphere/kubekey/pkg/files" "github.com/kubesphere/kubekey/pkg/utils" "github.com/pkg/errors" + "path" "path/filepath" ) @@ -45,7 +46,9 @@ func (s *SyncCrictlBinaries) Execute(runtime connector.Runtime) error { if !ok { return errors.New("get KubeBinary key crictl by pipeline cache failed") } - dst := filepath.Join(common.TmpDir, crictl.Name) + + fileName := path.Base(crictl.Path) + dst := filepath.Join(common.TmpDir, fileName) if err := runtime.GetRunner().SudoScp(crictl.Path, dst); err != nil { return errors.Wrap(errors.WithStack(err), fmt.Sprintf("sync crictl binaries failed")) diff --git a/pkg/container/docker.go b/pkg/container/docker.go index f4a2e404..3e1c9ea9 100644 --- a/pkg/container/docker.go +++ b/pkg/container/docker.go @@ -23,6 +23,7 @@ import ( "github.com/kubesphere/kubekey/pkg/files" "github.com/kubesphere/kubekey/pkg/utils" "github.com/pkg/errors" + "path" "path/filepath" ) @@ -45,7 +46,9 @@ func (s *SyncDockerBinaries) Execute(runtime connector.Runtime) error { if !ok { return errors.New("get KubeBinary key docker by pipeline cache failed") } - dst := filepath.Join(common.TmpDir, docker.Name) + + fileName := path.Base(docker.Path) + dst := filepath.Join(common.TmpDir, fileName) if err := runtime.GetRunner().Scp(docker.Path, dst); err != nil { return errors.Wrap(errors.WithStack(err), fmt.Sprintf("sync docker binaries failed")) diff --git a/pkg/k3s/tasks.go b/pkg/k3s/tasks.go index ae6a3438..530de718 100644 --- a/pkg/k3s/tasks.go +++ b/pkg/k3s/tasks.go @@ -34,6 +34,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" kube "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/clientcmd" + "path" "path/filepath" "strings" ) @@ -112,17 +113,18 @@ func SyncKubeBinaries(runtime connector.Runtime, binariesMap map[string]files.Ku return fmt.Errorf("get kube binary %s info failed: no such key", name) } + fileName := path.Base(binary.Path) switch name { case "kubecni": - dst := filepath.Join("/opt/cni/bin", binary.Name) - if err := runtime.GetRunner().SudoScp(binary.Path, dst); err != nil { + dst := filepath.Join(common.TmpDir, fileName) + if err := runtime.GetRunner().Scp(binary.Path, dst); err != nil { return errors.Wrap(errors.WithStack(err), fmt.Sprintf("sync kube binaries failed")) } if _, err := runtime.GetRunner().SudoCmd(fmt.Sprintf("tar -zxf %s -C /opt/cni/bin", dst), false); err != nil { return err } default: - dst := filepath.Join(common.BinDir, binary.Name) + dst := filepath.Join(common.BinDir, fileName) if err := runtime.GetRunner().SudoScp(binary.Path, dst); err != nil { return errors.Wrap(errors.WithStack(err), fmt.Sprintf("sync kube binaries failed")) } diff --git a/pkg/kubernetes/tasks.go b/pkg/kubernetes/tasks.go index b655e87e..8703f216 100644 --- a/pkg/kubernetes/tasks.go +++ b/pkg/kubernetes/tasks.go @@ -42,6 +42,7 @@ import ( kube "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/clientcmd" "os" + "path" "path/filepath" "sort" "strings" @@ -122,21 +123,23 @@ func SyncKubeBinaries(runtime connector.Runtime, binariesMap map[string]files.Ku if !ok { return fmt.Errorf("get kube binary %s info failed: no such key", name) } + + fileName := path.Base(binary.Path) switch name { //case "kubelet": // if err := runtime.GetRunner().Scp(binary.Path, fmt.Sprintf("%s/%s", common.TmpDir, binary.Name)); err != nil { // return errors.Wrap(errors.WithStack(err), fmt.Sprintf("sync kube binaries failed")) // } case "kubecni": - dst := filepath.Join("/opt/cni/bin", binary.Name) - if err := runtime.GetRunner().SudoScp(binary.Path, dst); err != nil { + dst := filepath.Join(common.TmpDir, fileName) + if err := runtime.GetRunner().Scp(binary.Path, dst); err != nil { return errors.Wrap(errors.WithStack(err), fmt.Sprintf("sync kube binaries failed")) } if _, err := runtime.GetRunner().SudoCmd(fmt.Sprintf("tar -zxf %s -C /opt/cni/bin", dst), false); err != nil { return err } default: - dst := filepath.Join(common.BinDir, binary.Name) + dst := filepath.Join(common.BinDir, fileName) if err := runtime.GetRunner().SudoScp(binary.Path, dst); err != nil { return errors.Wrap(errors.WithStack(err), fmt.Sprintf("sync kube binaries failed")) }