@@ -17,13 +17,16 @@ limitations under the License.
17
17
package kic
18
18
19
19
import (
20
+ "bufio"
20
21
"fmt"
22
+ "io"
21
23
"os"
22
24
"os/exec"
23
25
"runtime"
24
26
25
27
"github.com/phayes/freeport"
26
28
v1 "k8s.io/api/core/v1"
29
+ "k8s.io/klog/v2"
27
30
28
31
"k8s.io/minikube/pkg/minikube/out"
29
32
"k8s.io/minikube/pkg/minikube/style"
@@ -44,6 +47,7 @@ func createSSHConn(name, sshPort, sshKey, bindAddress string, resourcePorts []in
44
47
// TODO: document the options here
45
48
"-o" , "UserKnownHostsFile=/dev/null" ,
46
49
"-o" , "StrictHostKeyChecking=no" ,
50
+ "-o" , "IdentitiesOnly=yes" ,
47
51
"-N" ,
48
52
49
53
"-p" , sshPort ,
@@ -116,6 +120,7 @@ func createSSHConnWithRandomPorts(name, sshPort, sshKey string, svc *v1.Service)
116
120
// TODO: document the options here
117
121
"-o" , "UserKnownHostsFile=/dev/null" ,
118
122
"-o" , "StrictHostKeyChecking=no" ,
123
+ "-o" , "IdentitiesOnly=yes" ,
119
124
"-N" ,
120
125
121
126
"-p" , sshPort ,
@@ -157,10 +162,14 @@ func (c *sshConn) startAndWait() error {
157
162
out .Step (style .Running , "Starting tunnel for service {{.service}}." , out.V {"service" : c .service })
158
163
}
159
164
165
+ r , w := io .Pipe ()
166
+ c .cmd .Stdout = w
167
+ c .cmd .Stderr = w
160
168
err := c .cmd .Start ()
161
169
if err != nil {
162
170
return err
163
171
}
172
+ go logOutput (r , c .service )
164
173
165
174
c .activeConn = true
166
175
// we ignore wait error because the process will be killed
@@ -172,6 +181,13 @@ func (c *sshConn) startAndWait() error {
172
181
return nil
173
182
}
174
183
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
+
175
191
func (c * sshConn ) stop () error {
176
192
if c .activeConn {
177
193
c .activeConn = false
0 commit comments