diff --git a/cmd/kk/app/options/option.go b/cmd/kk/app/options/option.go index f1486ca6..5e8bf608 100644 --- a/cmd/kk/app/options/option.go +++ b/cmd/kk/app/options/option.go @@ -73,7 +73,7 @@ func newCommonOptions() CommonOptions { klog.ErrorS(err, "get current dir error") o.WorkDir = "/tmp/kubekey" } else { - o.WorkDir = wd + o.WorkDir = filepath.Join(wd, "kubekey") } return o } diff --git a/pkg/connector/kubernetes_ connector.go b/pkg/connector/kubernetes_ connector.go index 09876669..421c9c0a 100644 --- a/pkg/connector/kubernetes_ connector.go +++ b/pkg/connector/kubernetes_ connector.go @@ -47,7 +47,7 @@ func (c *kubernetesConnector) Init(ctx context.Context) error { return nil } // set rootDir - c.rootDir = filepath.Join(_const.GetWorkDir(), "kubernetes", c.clusterName) + c.rootDir = filepath.Join(_const.GetWorkDir(), _const.KubernetesDir, c.clusterName) if _, err := os.Stat(c.rootDir); err != nil && os.IsNotExist(err) { if err := os.MkdirAll(c.rootDir, os.ModePerm); err != nil { klog.V(4).ErrorS(err, "Failed to create local dir", "cluster", c.clusterName) diff --git a/pkg/const/workdir.go b/pkg/const/workdir.go index b875f5e7..00d19f81 100644 --- a/pkg/const/workdir.go +++ b/pkg/const/workdir.go @@ -52,6 +52,9 @@ workdir/ | | | | |-- inventory.yaml | |-- kubekey/ +| +|-- kubernetes/ + */ // workDir is the user-specified working directory. By default, it is the same as the directory where the kubekey command is executed. @@ -117,3 +120,6 @@ const RuntimePipelineVariableDir = "variable" // "kubekey" is the default directory name under the working directory. It is used to store // files required when executing the kubekey command (such as: docker, etcd, image packages, etc.). // These files will be downloaded locally and distributed to remote nodes. + +// KubernetesDir represents the remote host directory for each kubernetes connection +const KubernetesDir = "kubernetes"