VScode remote connection to JupyterHub Hub files

Hello,

We have a JupyterHub on k8s setup and I’ve successfully been able to follow the steps in this blog among others so that I can use the JupyterHub kernel remotely for VScode on my local machine.

Works great, only issue as noted in the blog is that this doesn’t automatically give you access to the JupyterHub file system for your user account. This feature makes it rather moot since you now have to bounce back and forth from JupyterHub and VScode to work.

Is there anyway in VScode to remotely connect to the user’s file system on their account/server in JupyterHub? Essentially I want the same files that show up on the leftside of my JupyterHub app to also show up on the leftside of my VS Code app so I can work entirely through VScode.

I’ve googled everywhere and searched here but haven’t found anything. I looked through the JupyterHub docs and REST API docs too to see if there’s something there that would maybe allow remote connection to the file system.

Alternatively, if this is less of a JupyterHub issue and more of a k8s issue (I guess I can remote connect to the k8s container filesystem?) let me know or if you can think of any ideas where to start looking for info that’d be great (am not familiar with k8s all that well).

There is another possibility to use VSCode with JupyterHub. Instead of connecting to remote kernel (as you are doing now), you can install code-server and jupyter-server-proxy in your single user server image and then using following basic config in the jupyter_server_config.py

c.ServerProxy.servers = {
   "vscode": {
       "command": ["code-server", "--bind-addr", "localhost:{port}", "--auth", "none"]
   }
}

and setting c.Spawner.default_url = "/vscode", you can access VSCode running on your remote k8s pod from your browser as you would do with a JupyterLab/notebook. You can use kubespawner’s profiles to make the c.Spawner.default_url configurable so that users can choose if they want to spawn a JupyterLab server or VSCode instance on remote k8s pod.

1 Like