Skip to content

Commit e974ce3

Browse files
Merge pull request #4510 from yinzara/master
Add 'native-ssh' flag to 'minikube start' and 'minikube ssh'
2 parents 4124356 + f1b3afe commit e974ce3

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

Diff for: cmd/minikube/cmd/config/config.go

+4
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,10 @@ var settings = []Setting{
265265
name: "embed-certs",
266266
set: SetBool,
267267
},
268+
{
269+
name: "native-ssh",
270+
set: SetBool,
271+
},
268272
}
269273

270274
// ConfigCmd represents the config command

Diff for: cmd/minikube/cmd/ssh.go

+13
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ package cmd
1919
import (
2020
"os"
2121

22+
"github.com/docker/machine/libmachine/ssh"
2223
"github.com/spf13/cobra"
24+
"github.com/spf13/viper"
25+
2326
"k8s.io/minikube/pkg/minikube/cluster"
2427
"k8s.io/minikube/pkg/minikube/config"
2528
"k8s.io/minikube/pkg/minikube/constants"
@@ -46,6 +49,12 @@ var sshCmd = &cobra.Command{
4649
if host.Driver.DriverName() == constants.DriverNone {
4750
exit.UsageT("'none' driver does not support 'minikube ssh' command")
4851
}
52+
if viper.GetBool(nativeSSH) {
53+
ssh.SetDefaultClient(ssh.Native)
54+
} else {
55+
ssh.SetDefaultClient(ssh.External)
56+
}
57+
4958
err = cluster.CreateSSHShell(api, args)
5059
if err != nil {
5160
// This is typically due to a non-zero exit code, so no need for flourish.
@@ -55,3 +64,7 @@ var sshCmd = &cobra.Command{
5564
}
5665
},
5766
}
67+
68+
func init() {
69+
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'.")
70+
}

Diff for: cmd/minikube/cmd/start.go

+9
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
"github.com/blang/semver"
3636
"github.com/docker/machine/libmachine"
3737
"github.com/docker/machine/libmachine/host"
38+
"github.com/docker/machine/libmachine/ssh"
3839
"github.com/golang/glog"
3940
"github.com/google/go-containerregistry/pkg/authn"
4041
"github.com/google/go-containerregistry/pkg/name"
@@ -107,6 +108,7 @@ const (
107108
waitUntilHealthy = "wait"
108109
force = "force"
109110
waitTimeout = "wait-timeout"
111+
nativeSSH = "native-ssh"
110112
)
111113

112114
var (
@@ -157,6 +159,7 @@ func initMinikubeFlags() {
157159
startCmd.Flags().Bool(enableDefaultCNI, false, "Enable the default CNI plugin (/etc/cni/net.d/k8s.conf). Used in conjunction with \"--network-plugin=cni\".")
158160
startCmd.Flags().Bool(waitUntilHealthy, true, "Wait until Kubernetes core services are healthy before exiting.")
159161
startCmd.Flags().Duration(waitTimeout, 3*time.Minute, "max time to wait per Kubernetes core services to be healthy.")
162+
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'.")
160163
}
161164

162165
// initKubernetesFlags inits the commandline flags for kubernetes related options
@@ -299,6 +302,12 @@ func runStart(cmd *cobra.Command, args []string) {
299302
// With "none", images are persistently stored in Docker, so internal caching isn't necessary.
300303
skipCache(&config)
301304

305+
if viper.GetBool(nativeSSH) {
306+
ssh.SetDefaultClient(ssh.Native)
307+
} else {
308+
ssh.SetDefaultClient(ssh.External)
309+
}
310+
302311
// Now that the ISO is downloaded, pull images in the background while the VM boots.
303312
var cacheGroup errgroup.Group
304313
beginCacheImages(&cacheGroup, config.KubernetesConfig.ImageRepository, k8sVersion)

Diff for: go.sum

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ dmitri.shuralyov.com/app/changes v0.0.0-20180602232624-0a106ad413e3/go.mod h1:Yl
88
dmitri.shuralyov.com/html/belt v0.0.0-20180602232347-f7d459c86be0/go.mod h1:JLBrvjyP0v+ecvNYvCpyZgu5/xkfAUhi6wJj28eUfSU=
99
dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1:a1inKt/atXimZ4Mv927x+r7UpyzRUf4emIoiiSC2TN4=
1010
dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU=
11-
github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
1211
github.com/Azure/azure-sdk-for-go v21.4.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
1312
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8=
1413
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
3736
github.com/VividCortex/ewma v1.1.1 h1:MnEK4VOv6n0RSY4vtRe3h11qjxL3+t0B8yOL8iMXdcM=
3837
github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA=
3938
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
39+
github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
4040
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
4141
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
4242
github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=

0 commit comments

Comments
 (0)