diff --git a/Dockerfile b/Dockerfile index bca2af56..fb0e8e39 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,13 +19,14 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager FROM debian:stable RUN useradd -m kubekey && apt-get update && apt-get install bash curl -y; apt-get autoclean; rm -rf /var/lib/apt/lists/* -WORKDIR /home/kubekey -#ADD addons /home/kubekey/addons +#ADD addons /home/kubekey/addons #ADD kubekey /home/kubekey/kubekey #RUN chown kubekey:kubekey -R /home/kubekey/kubekey -COPY --from=builder /workspace/manager /home/kubekey USER kubekey:kubekey +WORKDIR /home/kubekey +COPY --from=builder /workspace/manager /home/kubekey + ENTRYPOINT ["/home/kubekey/manager"] \ No newline at end of file diff --git a/api/v1alpha1/default.go b/api/v1alpha1/default.go index d78fdf86..d5714e38 100644 --- a/api/v1alpha1/default.go +++ b/api/v1alpha1/default.go @@ -110,13 +110,16 @@ func SetDefaultHostsCfg(cfg *ClusterSpec) []HostCfg { if host.Port == "" { host.Port = DefaultSSHPort } - if host.Password == "" && host.PrivateKeyPath == "" { - host.PrivateKeyPath = "~/.ssh/id_rsa" - } - if host.PrivateKeyPath != "" && strings.HasPrefix(strings.TrimSpace(host.PrivateKeyPath), "~/") { - homeDir, _ := util.Home() - host.PrivateKeyPath = strings.Replace(host.PrivateKeyPath, "~/", fmt.Sprintf("%s/", homeDir), 1) + if host.PrivateKey == "" { + if host.Password == "" && host.PrivateKeyPath == "" { + host.PrivateKeyPath = "~/.ssh/id_rsa" + } + if host.PrivateKeyPath != "" && strings.HasPrefix(strings.TrimSpace(host.PrivateKeyPath), "~/") { + homeDir, _ := util.Home() + host.PrivateKeyPath = strings.Replace(host.PrivateKeyPath, "~/", fmt.Sprintf("%s/", homeDir), 1) + } } + if host.Arch == "" { host.Arch = DefaultArch } diff --git a/pkg/install/install.go b/pkg/install/install.go index 01f48a03..6d7e1700 100644 --- a/pkg/install/install.go +++ b/pkg/install/install.go @@ -55,7 +55,7 @@ func CreateCluster(clusterCfgFile, k8sVersion, ksVersion string, logger *log.Log return errors.New("Please do not use uppercase letters in hostname: " + host.Name) } } - fmt.Println(objName) + return Execute(executor.NewExecutor(&cfg.Spec, objName, logger, "", verbose, skipCheck, skipPullImages, false)) } diff --git a/pkg/util/ssh/ssh.go b/pkg/util/ssh/ssh.go index 52216dc2..f7358e78 100644 --- a/pkg/util/ssh/ssh.go +++ b/pkg/util/ssh/ssh.go @@ -81,7 +81,7 @@ func validateOptions(cfg Cfg) (Cfg, error) { return cfg, errors.New("Must specify at least one of password, private key, keyfile or agent socket") } - if len(cfg.KeyFile) > 0 { + if len(cfg.PrivateKey) == 0 && len(cfg.KeyFile) > 0 { content, err := ioutil.ReadFile(cfg.KeyFile) if err != nil { return cfg, errors.Wrapf(err, "Failed to read keyfile %q", cfg.KeyFile)