Friday 5th April 2024 7:23 PM

CoreOS comes with vi, so it would be nice to install vim, and also tmux, which I use a lot.

However, being a minimal installation, the whole point is that you don't install extra stuff, so we can use Toolbox instead. This is a container-based environment that is tightly integrated with the host, into which you can install development and debugging tools, to work with and investigate problems on the host.

To create a Toolbox[1]You can have more than one; use toolbox list to see them.:

toolbox create

And to enter it:

toolbox enter

Once inside the Toolbox, you can install whatever you like, without affecting the host. Even better, it survives a reboot :clap:

However, there is one issue. While most of the host's file system is mapped into the container at /run/host/, it has its own /usr/local/bin/[2]So that you can transparently install stuff into the container., so the k3s binary is not available, nor are any of the K3s data files.

This is a little script that maps the necessary stuff into the container, so that you can manage the K3s cluster running on the host:

# map the K3s data directories
ln -s /run/host/var/lib/rancher /var/lib/rancher
ln -s /run/host/var/lib/kubelet /var/lib/kubelet
ln -s /run/host/run/k3s /run/k3s

# install the K3s config
mkdir -p "/home/$SUDO_USER/.kube"
ln -s /run/host/etc/rancher/k3s/k3s.yaml "/home/$SUDO_USER/.kube/config"

# make the host's binaries available
mkdir -p "/home/$SUDO_USER/.bashrc.d"
echo "export PATH=$PATH:/run/host/usr/local/bin/" >"/home/$SUDO_USER/.bashrc.d/add-host-path"

In practice, I found that I didn't really need to use a Toolbox, since Alt-Left/Right gives you multiple sessions, and most of the problems I had were with configuring Kubernetes, but the YAML files were being edited on another machine, using a Real Editor. But it's nice to know it's there... :-)



References

References
1 You can have more than one; use toolbox list to see them.
2 So that you can transparently install stuff into the container.