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: pull the docker container, launch a batch job to start the container on a compute node, SSH tunnel to the compute node where the container is running, and securely access VS Code through your browser window.
#
Pull the ContainerThis step only needs to be performed during the first set up.
Start an interactive job to pull the cointainer with the apptainer module. Here is an example command to start your interactive job:
Loading the apptainer module is required.
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
. This step launching of the code-server job script and all following steps will need to be repeated 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
) called code-server.job.<JobID>
(code-server.job.17440706
in this example). Concatenate (cat
) the output file for tunneling instructions. The following is an example output.
Monitor the job with squeue
and your UWNetID like the following example.
The output file (code-server.job.17440706
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 the command:
The login will appear to hang, but your connection is now open.
Open a new browser window to http://localhost:8080 and provide the password from the output file (code-server.job.17440706
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
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.