Keeping My Mastodon Instance Lean
A year ago, I ran into an issue where my Mastodon instance locked up. Everything appeared to be working, however, posts weren't updating and I was unable to post myself. It was strange as no settings had been changed and there hadn't be an outage.
To the logs I go...
It appears that I had run out of space. This was inevitable as, I run my Mastodon instance on a self hosted kubernetes cluster with tuned, locked resources. So, how do I fix it? To the internet I go.
I came across the blog post by Ricard entitled Improving Mastodon’s disk usage. A great description is provided as to what each command does. Essentially, that post is the foundation to what is shared here.
Similarly, I will be setting up a cronjob. I plan to run a monthly clean up job, removing anything older than two weeks.
This is what the script looks like. I shall call it mastodon-cleaner.sh.
You can see the commands are different and so is the "--days" parameter. As stated earlier, I only want to keep two weeks of history. Also, this being a kubernetes instance, the commands are going to be specific to the pod. That is where the first two commands come in.
Next, the script will be run on the control-plane node of the kubernetes cluster.
This will be run the first day of every month at 3am.
The post doesn't discuss the permissions associated with running kubectl, kubernetes or the cron user specific permissions, however, I hope it gives a basic perspective into how solutions to other's problems can be added to solve your own (Don't forget to give them credit for their work!). Happy Hosting!