How to Self-Host a Mastodon Instance in Kubernetes

TL;DR: Instead of the official installation including setting up Ruby, nginx, systemd service, etc., I found it more comfortable to install and run a Mastodon instance using some YAML files.

Just in case, what is Mastodon anyway?

I used kustomize to manage and generate Kubernetes manifests for a fully functional Mastodon instance. Please see my kustomize base templates, and then my overrides to get an idea. The secret mastodon with some credentials aren’t there of course but it looks like:

apiVersion: v1
kind: Secret
  name: mastodon
type: Opaque
  # postgres
  DB_NAME: mastodon
  DB_PASS: changeme
  DB_PORT: 5432
  DB_USER: mastodon
  # elasticsearch
  ES_ENABLED: "true"
  ES_PORT: 9200
  # domain name
  # redis service name
  REDIS_HOST: mastodon-redis
  REDIS_PORT: 6379
  # email 
  SMTP_FROM_ADDRESS: [email protected]
  # secrets
  OTP_SECRET: generate-yours
  SECRET_KEY_BASE: generate-yours
  VAPID_PRIVATE_KEY: generate-yours
  VAPID_PUBLIC_KEY: generate-yours

Please see this on how to generate application secrets used above. Also, I couldn’t be bothered with writing the typical setup for postgres and elasticsearch.

Please feel free to message me @[email protected] once your Mastodon instance is up and running 🙂