VS Code via Code-Server
#
This solution:Provides a method to connect VS Code to a compute node on
klone
, preserving the login nodes for the community. As a reminder, we prohibit users running processes on the login node.Uses a server to develop and execute your code reducing battery usage.
code-server
handles the VSCode background processes, preventing them from slowing down your local machine.Provides a simpler alternative to VS Code via ProxyJump, which requires a lot of setup and for Windows users requires 2-factor authentication to login and change directory.
Involves steps: making a symbolic link to the container stored on hyak or pulling the docker container yourself, launching a batch job to start the container on a compute node, opening a SSH tunnel to the compute node where the container is running, and securely accessing VS Code through your browser window.
#
Accessing the ContainerThis step only needs to be performed during initial set up.
We have pulled a version of the code-server container for our users. This removes 5 minutes of set up, and allows use of the container without occupying user disk storage.
First, navigate to a directory a where you will store your symbolic link to the code-server container. In this example, we will navigate to our home directory.
Create a symbolic link to the container which we have stored for you in /mmfs1/sw/containers/code-server/
. The symbolic link shortcut will appear in the directory where the command was initiated, unless otherwise specified.
This will link to code-server container version 4.89.0-39. There are other versions of the container you might consider: code-server tags, and below, we include optional instructions for pulling the latest version of code-server.
Optional: pull the container yourself
This step only needs to be performed during initial set up.
Start an interactive job to pull the cointainer with the apptainer module. Here is an example command to start your interactive job (find out which accounts and partitions your can access with the hyakalloc
command):
Pull the container from DockerHub. This will take a few minutes to complete. When complete, you will have a container image called code-server_lastest.sif
. There are other versions of the container you might consider rather than the latest version: code-server tags.
#
Launch code-server with SlurmDownload the Slurm batch script.
Edit the job script (find comments "#update this line") to set your code-server session home directory and provide the name of the container if it does not match code-server_latest.sif
, and edit the SBATCH
directives as needed. The code block below shows the lines that should be updated as needed.
Submit the script with sbatch
. Repeat this step and all following steps each time you log in and connect to VS Code.
This script will start a batch job and launch the code-server container. The SSH
tunneling instructions, including the code-server session password, will be written to the output file (stdout
), for example code-server.job.12345678
would be the output file in here where 12345678 is our fictional Job ID--the JobID for your output file will be different. Concatenate (cat
) the output file for tunneling instructions. The following is an example output.
Pro Tip
Monitor the job with squeue
and your UWNetID like the following example.
The output file (code-server.job.12345678
in this example) will also contain messages from code-server
as the connection is established. These messages include:
- The storage location of session associated files -
~/.local/share/code-server
in your home directory. - The location of the configuration file for the session which contains the password that is also printed in the output file -
~/.config/code-server/config.yaml
in your home directory. - Which IP and Port
code-server
HTTP and session is listening to.
As your session continues, more information will be printed to this output file.
#
Establish the SSH tunnelFollow the instructions in the output file. Open a new terminal/powershell/PuTTy window ON YOUR COMPUTER and use your version of the tunnel command from your job output file (e.g., code-server.job.12345678
). The following is an example:
The login will appear to hang, but your connection is now open.
warning
Do not use the code-server password to open the ssh tunnel. After your ssh command, your UWNetID password is required. Multiple failed login attempts will result in a IP ban.
Open a new browser window to http://localhost:8080 and provide the password from the output file (code-server.job.17440706
and +WwYzgh7YH/yHzUWNWNS
in this example).
Extensions can be installed through the browser and will be stored in ~/.local/share/code-server/extensions
in your home directory.
#
End the SessionTo end your session, find the three-lines icon Menu and select "Sign out of Code Server."
And end the batch job with scancel
and the JobID on klone
like the following example.
If you have trouble with this method, please report errors in an email to help@uw.edu with Hyak in the message.