Mastodon is a self-hosted social network server based on ActivityPub. Written in Ruby, features real-time updates, multimedia attachments, and no vendor lock-in. Mastodon is an open-source and actively developed project; thus, it is constantly improved. The main goal is to offer people more freedom and not rely on or depend on big tech companies (in contrast with what happened to Twitter lately).
From an architectural point of view, Mastodon is following a decentralized approach compared to Twitter. It means everyone can run their Mastodon instance all over the world independently and then interconnect with other mastodon instances via a federated universe(fediverse). In addition, this approach gives more freedom because you can operate alone or in small groups if desired.
At its core, Mastodon’s backend is an application written using Ruby on Rails that connects with a primary PostgreSQL database. A Redis server (in-memory cache and data storage) for Mastodon’s job system (Sidekiq) and an S3 storage for media file caching.
As firm believers of not re-inventing the wheel, we explored existing helm chart options to deploy Mastodon on Kubernetes and found the following,
Interestingly the official mastodon chart repository needed to be actively maintained, and they still needed an official chart release. On the other hand, Mastodon packaged by Bitnami was well documented and constantly updated. This resulted in us choosing the bitnami chart over the official chart.
Setting up the Mastodon architecture on Kubernetes is cumbersome. Moreover, achieving production readiness is all the more challenging, considering that it is a stateful application. What if we add automation into the mix? why not? We wanted to tackle this challenge and demonstrate the simplicity of running stateful workloads at scale on the DigitalOcean ecosystem in an automated fashion.
This resulted in the inception of digitalocean/mastodon-on-kubernetes.
An open-source project that leverages modern-day best practices around infrastructure and application delivery automation to set up production-grade Mastodon instances on DigitalOcean Kubernetes. It also enables seamless integration with DigitalOcean’s other product offerings such as DBaaS and Spaces.
In the following sections, we will walk you through the steps to set up a Mastodon instance on the DigitalOcean ecosystem.
We have used Terraform to set up the following infrastructure.
All the infrastructure modules can be configured based on your needs
Follow the guide» infrastructure automation for detailed instructions.
We have used the continuous delivery GitOps tool ArgoCD to install and manage the essential applications
» This doc explains the bootstrap process in detail.
Once the bootstrapped cluster is ready, we can deploy Mastodon using the helm chart. Follow the guide» mastodon installation for detailed instructions.
For monitoring and observability of our Kubernetes cluster, we have used Robusta, an open-source Kubernetes monitoring, troubleshooting and automation platform which comes pre-baked with
Follow the guide» set up observability for detailed instructions.
We are eager to explore scalability using KEDA: Kubernetes Event-driven Autoscaling. Want to contribute? Feel free to check out the project.