Setting up a Go backend for Xterm.js to get a shell over the browser
I swear it’s preTTY cool
--
Ever wished you could access some CLI tools over a browser instead of over the terminal? Well I did, and here’s how that wish went.
I use a tool called k9s (shoutout to Fernand Galiana for the awesome tool) to communicate with/debug a Kubernetes (k8s from here on) cluster. It’s a great dashboard for k8s clusters navigable using a curses-based interface (read: entirely with keyboard), and more importantly I could view collated logs from multiple pods from the same workload.
k9s also has a read-only mode and I wondered if I could expose this (imo) better k8s dashboard to other team members without needing to setup access rights for everyone manually.
So Cloudshell was born. The following is kind of a documentation for myself of what went down and also for anyone who wants to try out making one for themselves.
TL;DR/Shameless Plug
If you think this tool could be useful for you, the code can be found in the link below. Contributions/ideas/feedback are welcome(:
You could also get it up running locally in an isolated alpine
container using Docker with:
docker run -p 8376:8376 zephinzer/cloudshell:latest
I don’t know about you but this seemed pretty magical to me although I knew the underlying technology is probably what VSCode adopts to display the in-app terminal.
Shameless plug done, what follows is the thought process that happened during this mini project (mainly for my own records in future) if you’d like a glimpse into this.
The planning
My intuition was there would be three main components to this: