Access Kubeflow Notebooks from VSCode

Prev Next

It is possible to connect your locally-running instance of VSCode to a Kubeflow notebook instance running in cluster via Microsoft dev tunnels through the use of VSCode CLI (installed in kubeflow). To do so, you authenticate a tunnel with either your Microsoft or GitHub credentials.

Background is available here and setup instructions are below.

Setup in Kubeflow

Install and run VSCode CLI in kubeflow by following the steps below

  1. Connect to your kubeflow notebook instance in your Cake cluster

  2. Launch a terminal instance from within your kubeflow notebook

  3. Install VSCode CLI and run tunnel by executing the commands below.

    1. Navigate to your home directory

      cd ~

    2. Download and install VSCode CLI

      curl -Lk 'https://code.visualstudio.com/sha/download?build=stable&os=cli-alpine-x64' --output vscode_cli.tar.gz 
      tar -xf vscode_cli.tar.gz

    3. Run the tunnel parameter

      ./code tunnel

    4. Follow the prompts to allow authentication with either Microsoft or GitHub.

Connect from VSCode

Establish a tunnel from your local VSCode instance by following the steps below

  1. Open Visual Studio Code

  2. Install the Remote Explorer VSCode extension

  1. Click the “<>” icon in the lower-left corner of the screen

  2. Select tunnel

    Click Allow when prompted to login to Github, and continue until you are logged in to Github.

  3. In VS Code, select the Kubeflow Notebook that now appears in the list

  4. In the lower-left corner it will now indicate that you are connected to the remote Notebook server

  5. You can then open a Folder and begin working in the Kubeflow Notebook Server environment

Upgrade to a Newer Version

If needed, upgrade to a nwer version of VSCode CLI in your kubeflow notebook instance

  1. Repeat the above steps to download a newer version of VSCode CLI

  2. If you encounter issues, clear out the old cache directories with the following command

    rm -rf ~/.vscode*