How to connect VScode "Remote-SSH" using kubectl?

6/4/2019

Trying to develop in VSCode with Remote Connection and run/debug/... in a pod on kubernetes cluster.

How to connect VScode using kubectl?

Trying port forwarding

kubectl -n dev port-forward my-pod-name 22:22

It connects, works but getting errors:

E0604 10:58:15.025638   11216 portforward.go:385] error copying from local connection 
to remote stream: read tcp4 127.0.0.1:22->127.0.0.1:54495: wsarecv: An existing 
connection was forcibly closed by the remote host.
-- Pav K.
kubernetes
visual-studio-code
vscode-remote

1 Answer

6/5/2019

Port 22 is a dedicated port which is reserved in your system that is why the connection cannot be established. Use the following snippet:

kubectl -n dev port-forward my-pod-name 8022:22
-- Erik Jagyugya
Source: StackOverflow