@@ -346,4 +346,93 @@ Check that no load balancers or volumes are left:
```bash
openstack loadbalancer list
openstack volume list
```
\ No newline at end of file
```
## Deploying code-server to VMs without Coder or Kubernetes
When using Coder to provide a unique predefined workspace for students enrolled in a course, the flexibility brought by the Coder infrastructure and Kubernetes auto-scaling may be overkill. A possible alternative is to deploy code-server directly on VMs, without Coder or Kubernetes.
### Create the VMs and deploy code-server
The following script creates 10 VMs, deploys code-server on each of them, and generates a random password for each instance. The script assumes that the inf110 network already exists and that it contains the reverse proxy VM and the insecure Docker registry VM, as will be the case if the previous steps were followed.
for file in inf110-workspace-contents/README.md inf110-workspace-contents/_CoqProject inf110-workspace-contents/tp1.ipynb inf110-workspace-contents/tp1-mysterious-tm.png inf110-workspace-contents/tp*.mv;do
The reverse proxy configuration redirects different endpoints to the different code-server instances. The private IP of a VM determines the endpoint.
```nginx
location~^/code-server-(\d+){
# Capture the server number
set$server_number$1;
# Rewrite the URL to strip the /code-server-{NUMBER}/ part
rewrite^/code-server-\d+/(.*)$ /$1break;
# Dynamically construct the proxy_pass target
proxy_passhttp://10.0.0.$server_number;
proxy_http_version1.1;
proxy_set_headerUpgrade$http_upgrade;
proxy_set_headerConnection"upgrade";
proxy_set_headerHost$host;
}
```
Each code-server instance is accessible at `https://tp-inf110.r2.enst.fr/code-server-{NUMBER}/?folder=/home/coder/tp`, with a specific password generated during the VM creation, and stored in `/tmp/inf110-code-server-vm-passwords`.