shell command only opens an ssh session if VM is on a bridged network
Closed this issue · 1 comments
belgaied2 commented
The shell
command is limited to VMs with bridged networking. It should also support getting a shell on VMs that are on the pod network.
It might be interesting to check how kubectl exec
command works.
belgaied2 commented
After checking out the kubectl exec
command, I figured it might not be the best way. However, since I am already using a wrapper around the system's ssh command as of #10, it made more sense to check out the kubectl port-forward
command implementation.
And, it works!
Now, the shell command will:
- intelligently find out if the VM has any bridged network interface, and if not, it will look for a Pod Network interface
- if a bridge network interface exists, it will be used by default, but this can be overiden using the flag
--pod-network
(boolean flag, it exists or it doesn't) - if no bridge network exists, but a pod network interface exists, then the program will open a port forward to the pod driving the VM, by using a high number local port as a source, then it will use
ssh
to connect tolocalhost
on that high number port. Exiting the SSH session automatically closes the port forward session. - if no bridged network and no pod network interfaces exist, an error will be thrown.
Closing this as of 0efc7f5