From 2cd735ad14a78ec8060c6050bddd687f6999bc61 Mon Sep 17 00:00:00 2001
From: Sheogorath <sheogorath@shivering-isles.com>
Date: Sat, 12 Nov 2022 01:08:03 +0100
Subject: [PATCH] feat(mastodon): Add Pod-Anti-Affinity to improve HA setup

This patch uses pod anti-affinity to spread the mastodon pods throughout the
cluster this should ensure that a single node failure doesn't take down the
entire thing.

Adding PDBs will be done down the line.
---
 apps/base/mastodon/release.yaml | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/apps/base/mastodon/release.yaml b/apps/base/mastodon/release.yaml
index 0faed1bc9..c826a41a1 100644
--- a/apps/base/mastodon/release.yaml
+++ b/apps/base/mastodon/release.yaml
@@ -73,12 +73,27 @@ spec:
               name: mastodon-streaming
             spec:
               replicas: 2
+              affinity:
+                podAntiAffinity:
+                  requiredDuringSchedulingIgnoredDuringExecution:
+                    - labelSelector:
+                        matchLabels:
+                          app.kubernetes.io/component: streaming
+                      topologyKey: kubernetes.io/hostname
           - kind: Deployment
             apiVersion: apps/v1
             metadata:
               name: mastodon-web
             spec:
               replicas: 2
+              affinity:
+                podAntiAffinity:
+                  requiredDuringSchedulingIgnoredDuringExecution:
+                    - labelSelector:
+                        matchLabels:
+                          app.kubernetes.io/component: web
+                          app.kubernetes.io/part-of: rails
+                      topologyKey: kubernetes.io/hostname
           - kind: ConfigMap
             apiVersion: v1
             metadata:
-- 
GitLab