From f1b3afe99c74b3bf9014b3ddf15fb8b469f53202 Mon Sep 17 00:00:00 2001 From: Matt Morrissette Date: Mon, 17 Jun 2019 15:06:37 -0400 Subject: [PATCH] Add "native-ssh" flag to "start" and "ssh" commands and config --- cmd/minikube/cmd/config/config.go | 4 ++++ cmd/minikube/cmd/ssh.go | 13 +++++++++++++ cmd/minikube/cmd/start.go | 9 +++++++++ go.sum | 2 +- 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/cmd/minikube/cmd/config/config.go b/cmd/minikube/cmd/config/config.go index 66779daec9..c282909deb 100644 --- a/cmd/minikube/cmd/config/config.go +++ b/cmd/minikube/cmd/config/config.go @@ -265,6 +265,10 @@ var settings = []Setting{ name: "embed-certs", set: SetBool, }, + { + name: "native-ssh", + set: SetBool, + }, } // ConfigCmd represents the config command diff --git a/cmd/minikube/cmd/ssh.go b/cmd/minikube/cmd/ssh.go index b2610f25ee..84909e92be 100644 --- a/cmd/minikube/cmd/ssh.go +++ b/cmd/minikube/cmd/ssh.go @@ -19,7 +19,10 @@ package cmd import ( "os" + "github.com/docker/machine/libmachine/ssh" "github.com/spf13/cobra" + "github.com/spf13/viper" + "k8s.io/minikube/pkg/minikube/cluster" "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/constants" @@ -46,6 +49,12 @@ var sshCmd = &cobra.Command{ if host.Driver.DriverName() == constants.DriverNone { exit.UsageT("'none' driver does not support 'minikube ssh' command") } + if viper.GetBool(nativeSSH) { + ssh.SetDefaultClient(ssh.Native) + } else { + ssh.SetDefaultClient(ssh.External) + } + err = cluster.CreateSSHShell(api, args) if err != nil { // This is typically due to a non-zero exit code, so no need for flourish. @@ -55,3 +64,7 @@ var sshCmd = &cobra.Command{ } }, } + +func init() { + sshCmd.Flags().Bool(nativeSSH, true, "Use native Golang SSH client (default true). Set to 'false' to use the command line 'ssh' command when accessing the docker machine. Useful for the machine drivers when they will not start with 'Waiting for SSH'.") +} diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 6d8cbc852a..03f3f628e7 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -35,6 +35,7 @@ import ( "github.com/blang/semver" "github.com/docker/machine/libmachine" "github.com/docker/machine/libmachine/host" + "github.com/docker/machine/libmachine/ssh" "github.com/golang/glog" "github.com/google/go-containerregistry/pkg/authn" "github.com/google/go-containerregistry/pkg/name" @@ -107,6 +108,7 @@ const ( waitUntilHealthy = "wait" force = "force" waitTimeout = "wait-timeout" + nativeSSH = "native-ssh" ) var ( @@ -157,6 +159,7 @@ func initMinikubeFlags() { startCmd.Flags().Bool(enableDefaultCNI, false, "Enable the default CNI plugin (/etc/cni/net.d/k8s.conf). Used in conjunction with \"--network-plugin=cni\".") startCmd.Flags().Bool(waitUntilHealthy, true, "Wait until Kubernetes core services are healthy before exiting.") startCmd.Flags().Duration(waitTimeout, 3*time.Minute, "max time to wait per Kubernetes core services to be healthy.") + startCmd.Flags().Bool(nativeSSH, true, "Use native Golang SSH client (default true). Set to 'false' to use the command line 'ssh' command when accessing the docker machine. Useful for the machine drivers when they will not start with 'Waiting for SSH'.") } // initKubernetesFlags inits the commandline flags for kubernetes related options @@ -299,6 +302,12 @@ func runStart(cmd *cobra.Command, args []string) { // With "none", images are persistently stored in Docker, so internal caching isn't necessary. skipCache(&config) + if viper.GetBool(nativeSSH) { + ssh.SetDefaultClient(ssh.Native) + } else { + ssh.SetDefaultClient(ssh.External) + } + // Now that the ISO is downloaded, pull images in the background while the VM boots. var cacheGroup errgroup.Group beginCacheImages(&cacheGroup, config.KubernetesConfig.ImageRepository, k8sVersion) diff --git a/go.sum b/go.sum index b2a41eeddc..fb266aabdd 100644 --- a/go.sum +++ b/go.sum @@ -8,7 +8,6 @@ dmitri.shuralyov.com/app/changes v0.0.0-20180602232624-0a106ad413e3/go.mod h1:Yl dmitri.shuralyov.com/html/belt v0.0.0-20180602232347-f7d459c86be0/go.mod h1:JLBrvjyP0v+ecvNYvCpyZgu5/xkfAUhi6wJj28eUfSU= dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1:a1inKt/atXimZ4Mv927x+r7UpyzRUf4emIoiiSC2TN4= dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU= -github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/Azure/azure-sdk-for-go v21.4.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= @@ -37,6 +36,7 @@ github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrU github.com/VividCortex/ewma v1.1.1 h1:MnEK4VOv6n0RSY4vtRe3h11qjxL3+t0B8yOL8iMXdcM= github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= +github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=