From b420e41a85330bd242b651fc6d634cb162f8e95d Mon Sep 17 00:00:00 2001 From: Gabriel Simmer Date: Sun, 10 Mar 2024 12:13:41 +0000 Subject: [PATCH] Nitter deployment --- homelab/kubernetes.nix | 1 + homelab/nitter.nix | 94 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 homelab/nitter.nix diff --git a/homelab/kubernetes.nix b/homelab/kubernetes.nix index 36bd589..ef16c9d 100644 --- a/homelab/kubernetes.nix +++ b/homelab/kubernetes.nix @@ -21,5 +21,6 @@ (import ./conduit.nix) (import ./irc.nix) (import ./netboot.nix) + (import ./nitter.nix) ]; } diff --git a/homelab/nitter.nix b/homelab/nitter.nix new file mode 100644 index 0000000..f989fe1 --- /dev/null +++ b/homelab/nitter.nix @@ -0,0 +1,94 @@ +let + appName = "nitter"; + nitterImage = "git.gmem.ca/arch/nitter:latest"; +in + { + lib, + config, + kubenix, + ... + }: { + kubernetes.resources.services.nitter = { + spec = { + selector.app = appName; + ports.http = { + port = 8080; + targetPort = 8080; + }; + }; + }; + kubernetes.resources.deployments.nitter.spec = { + selector.matchLabels.app = appName; + template = { + metadata.labels.app = appName; + spec = { + volumes = { + config.configMap.name = "nitter"; + accounts.secret.secretName = "nitter"; + }; + containers = { + nitter = { + image = nitterImage; + imagePullPolicy = "Always"; + volumeMounts = [ + { + name = "config"; + mountPath = "/src/nitter.conf"; + subPath = "nitter.conf"; + } + { + name = "accounts"; + mountPath = "/src/guest_accounts.json"; + subPath = "guest_accounts.json"; + } + ]; + ports.tlshttp.containerPort = 8080; + }; + }; + }; + }; + }; + kubernetes.helm.releases.nitter-redis = { + chart = kubenix.lib.helm.fetch { + repo = "https://charts.bitnami.com/bitnami"; + chart = "redis"; + version = "18.6.1"; + sha256 = "CyvGHc1v1BtbzDx6hbbPah2uWpUhlNIUQowephT6hmM="; + }; + values = { + auth.enabled = false; + architecture = "standalone"; + }; + }; + kubernetes.resources.ingresses.nitter = { + metadata = { + name = appName; + annotations = { + "cert-manager.io/issuer" = "le-issuer"; + }; + }; + spec = { + tls = [ + { + hosts = ["nitter.gmem.ca"]; + secretName = "gmem-ca-wildcard"; + } + ]; + rules = [ + { + host = "nitter.gmem.ca"; + http.paths = [ + { + path = "/"; + pathType = "Prefix"; + backend.service = { + name = appName; + port.name = "http"; + }; + } + ]; + } + ]; + }; + }; + }