feat: support expose port mapping

This commit is contained in:
fudali
2019-07-22 15:44:51 +08:00
parent 5a1e9aafe9
commit f07530b7d3
2 changed files with 13 additions and 1 deletions
+5
View File
@@ -93,6 +93,11 @@ SSH Remote port-forward for POD starting
2019/06/19 11:19:14 ssh remote port-forward start at pid: 3567
```
```
tips:
if your remote port diffrent local port, you can user ${remotePort}:{localPort} set expose parameter
```
Access local tomcat by internal service DNS address:
> Note: if `kubectl connect` not running, you can only access from cluster
+8 -1
View File
@@ -54,7 +54,14 @@ func remotePortForward(expose string, kubeconfig string, namespace string, targe
time.Sleep(time.Duration(2) * time.Second)
log.Printf("SSH Remote port-forward POD %s 22 to 127.0.0.1:%d starting\n", remoteIP, localSSHPort)
cmd := util.SSHRemotePortForward(expose, "127.0.0.1", expose, localSSHPort)
localPort := expose
remotePort := expose
ports := strings.SplitN(expose, ":", 2)
if len(ports) > 1 {
localPort = ports[1]
remotePort = ports[0]
}
cmd := util.SSHRemotePortForward(localPort, "127.0.0.1", remotePort, localSSHPort)
return util.BackgroundRun(cmd, "ssh remote port-forward", debug)
}