Skip to content

Commit c781e43

Browse files
authored
Merge pull request #15560 from spowelljr/fixDockerTunnel
Fix Docker tunnel failing
2 parents 7f8ee94 + e386db2 commit c781e43

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pkg/minikube/tunnel/kic/ssh_conn.go

+16
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@ limitations under the License.
1717
package kic
1818

1919
import (
20+
"bufio"
2021
"fmt"
22+
"io"
2123
"os"
2224
"os/exec"
2325
"runtime"
2426

2527
"github.com/phayes/freeport"
2628
v1 "k8s.io/api/core/v1"
29+
"k8s.io/klog/v2"
2730

2831
"k8s.io/minikube/pkg/minikube/out"
2932
"k8s.io/minikube/pkg/minikube/style"
@@ -44,6 +47,7 @@ func createSSHConn(name, sshPort, sshKey, bindAddress string, resourcePorts []in
4447
// TODO: document the options here
4548
"-o", "UserKnownHostsFile=/dev/null",
4649
"-o", "StrictHostKeyChecking=no",
50+
"-o", "IdentitiesOnly=yes",
4751
"-N",
4852
4953
"-p", sshPort,
@@ -116,6 +120,7 @@ func createSSHConnWithRandomPorts(name, sshPort, sshKey string, svc *v1.Service)
116120
// TODO: document the options here
117121
"-o", "UserKnownHostsFile=/dev/null",
118122
"-o", "StrictHostKeyChecking=no",
123+
"-o", "IdentitiesOnly=yes",
119124
"-N",
120125
121126
"-p", sshPort,
@@ -157,10 +162,14 @@ func (c *sshConn) startAndWait() error {
157162
out.Step(style.Running, "Starting tunnel for service {{.service}}.", out.V{"service": c.service})
158163
}
159164

165+
r, w := io.Pipe()
166+
c.cmd.Stdout = w
167+
c.cmd.Stderr = w
160168
err := c.cmd.Start()
161169
if err != nil {
162170
return err
163171
}
172+
go logOutput(r, c.service)
164173

165174
c.activeConn = true
166175
// we ignore wait error because the process will be killed
@@ -172,6 +181,13 @@ func (c *sshConn) startAndWait() error {
172181
return nil
173182
}
174183

184+
func logOutput(r io.Reader, service string) {
185+
s := bufio.NewScanner(r)
186+
for s.Scan() {
187+
klog.Infof("%s tunnel: %s", service, s.Text())
188+
}
189+
}
190+
175191
func (c *sshConn) stop() error {
176192
if c.activeConn {
177193
c.activeConn = false

0 commit comments

Comments
 (0)