Setting up code-server for multi-tenancy
Code Server seems particularly close to being able to run for a team of engineers on a single Kubernetes cluster, each with their own container and persistent data store. That would be incredibly efficient, secure and highly available.
I don’t think server side collaboration is necessary, that’s what Github is for, i’d prefer each engineer is sandboxed, the key utility of code-server being in-browser and consistent.
A generic OAuth implementation as described in other feature requests might work agnostic of cloud providers... and be a first step.
But i’d suggest a well formed Kubernetes deployment with Google Identity Aware Proxy on the front of it would be epic. Brings with it a host of benefits, not the least of which being their zero trust corp security.
IAP is easy to attach to a GCP Load Balancer, and AFAICT the server would just need to understand the identity that is asserted in headers, and route to an appropriate container.
Thoughts? How would I go about resourcing that?
Sure... Here it is... sanitised with the domain replaced.
It is run in a docker container, with a wildcard domain. Without a username, it gives out the top level website. With a username in that domain, it proxies the request to the given ports to that service via a docker network.
It was design with version 1 of code-server and still works fine with version 3.4
Yes each of the docker environments has an apache as well as a code-server. BUt we don't have a fancy interface for starting the containers. At the moment we use a ssh account with a 'fake' shell that lets them use specific remote ssh comments to start/stop thr users container.
EG: ssh [email protected] start That starts the container, waits till it can see code-server running, then reports the URL (based on their username), and the randomly generated password...
-------------------------------------------
MOTD... Legal Mambo Jumbo... Code of Practise...
-------------------------------------------
Please wait a moment while I start your development container...
For a complete list of controls, "ssh" the command 'help'.
ssh [email protected] help
Waiting for code-server to appear online...
Code-server is running at the URL...
https://username.docker.exampe.com:8443/
Using the password: caum+Karyl+loonier+scarps
Connection to docker.exampe.com closed.
We are working on a web interface to start/stop user containers instead.
That's awesome, @antofthy! Thanks so much for sharing. I'm sure this will be helpful for others.
@antofthy , I'm wondering if there were any progress on the web interface you were talking about - or if you stumbled upon anything in the wild which would start/serve/kill server on demand for the user?
Yes in deed. There was a major delay as I personally had no experience in how to program in PHP, but after some help, and a number of weeks development and testing... It is now working...
Users no longer need to use SSH remote commands to control there software development environments (docker service). PHP front-end, with a python back-end, that can control docker itself. The back-end does all the 'high security' aspect like user authentication and docker service (the users environment) starting/stopping/wiping. A Redis service is used for communications between the two, as well as encrypted cached authentication credentials for the users (so back-end knows if used has been authenticated). The users authenticate with our Single-Sign-On system, so they generally are already authenticated when they connect to the system.
Users using the "Software Development Environments" can use the PHP front-end control panel to select/wipe/start/stop various prepared software environments. Each environment has a 'code-server' they can connect to providing IDE, and a terminal (command line) to Debian UNIX system of their environment. Most environments have compilers as well as their own Apache-PHP server. A separate docker 'ingress' service links user web requests (using a wildcard proxy) to the appropriate software development environment for either code-server, or Apache, or even a developed NodeJS server they create.
The ONLY troublesome aspect of this system, is that a random password is generated for code-server to use each time they start an their own environment (docker service). They need to copy this (a button press), before clicking the 'connect to code-server' link. The code-server in their own environment then asks for that password to verify the user, which they paste in, before access is granted.
Ideally we would love to be able to set a code-server authentication cookie, both in the starting code-server inside the docker service, and on the 'started' control panel display. That way the already authenticated user, can just click the code-server link without needing a extra code-server authentication step (copy and paste a random password)
An Academic Paper is being prepared by the lecturer that instigated the project originally.
Some screen shots of the 'simple' control panel presented to authenticated users.
The session is stopped (not running) Users can 'wipe' (or reset) there environment, select a different environment, or start it.

Session (docker service) starting up, which only takes a few seconds.
The system is actually watching and waiting for code-server to respond to a 'status check'.

Session now running. User can copy the session password that was randomly assign to code server, on start.
Users can stop the session, or just stop using code-server for an hour, and it automatically stops.

As previously mentioned the next step in the development would be to do away with that password, and set the users 'session token' directly, so they only need to "Launch Code Server" which is just open a new browser tab.