k3os, Mastodon Migration

Mastodon pod in Rancher

Back on Kubernetes with k3os

  • Former coworker started new job where he needs to learn kubernetes things.
  • I hadn’t done stuff with kubernetes in a while and I didn’t want to forget it.
  • Bored with single-node Docker.

I tore down my single-node Ubuntu/Docker thing and installed k3os. k3os is a minimal Linux distribution created for the sole purpose of running kubernetes. I think they even describe it as “just enough Linux to run Kubernetes.”

Installation was reasonably simple. Similar to RancherOS, you can supply a cloud-init.yaml, though I did not. At the time of install I did encounter some bug interrupting the installation process. The workaround was to use an older version of the install media, then upgrade to the latest version.

Once I could kubectl in, my SOP went something like this:

That gives me a good base to build from.

The first service I setup was the noip2 update client. It is a simple container, easy to setup, and it allows me to access my apartment services elsewhere.

Migrating the nangang.travnewmatic.com Mastodon instance was my next hurdle.

Migrate a Mastodon

The first task was to recreate the various databases that Mastodon requires: Elasticsearch, Postgres, Redis. Those were simple enough to install via Helm (actually, I used the “catalog/apps” feature in Rancher).

Before I nuked the single-node Docker server, I made a backup of /home, as well as /var/lib/docker. Later, I imported a Mastodon database dump into the new Postgres server in Kubernetes. That part took a while. I am not skilled at Postgres db administration, and I was learning how to do Kubernetes things again so.. it took a bit. Ultimately, I did get the old database back in, and Mastodon started as expected.

Next was an import of the data dir (media and pictures and stuff). I’m not sure what the Right Way to do this was, but my process looked something like this:

  • Add an Ubuntu container to the Mastodon pod. Configure the Ubuntu container to mount the Mastodon persistent volume.
  • Install and start ssh server on that Ubuntu container.
  • kubectl port forward ssh.
  • rsync the contents of the old Docker volume to the Mastodon pod data dir.

The Ubuntu container was just something flexible enough to allow me to rsync from my local machine to the pod with the Mastodon data dir mounted (too much trouble to try to install ssh in the Mastodon container). Once the rsync finished, that was that! Mastodon worked as it did before, and the media I’d uploaded previously was displaying again.

There’s no functional reason for me to go from single-node Docker to single-node Kubernetes. The purpose of this lift-and-shift was to refresh my Kubernetes muscle memory, and to try new things (k3os in particular). I also want to keep my Kubernetes-fu strong for when it comes time to change tnewman0 to a Kubernetes thing.

I have created a GitHub repo containing the manifests I’m using to run Mastodon in my cluster if you’d like to take a look.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *