From 11f6ef057282bc2fbef311c7864783876fea1ecf Mon Sep 17 00:00:00 2001 From: Felix Albrigtsen Date: Sat, 9 Nov 2024 15:21:12 +0100 Subject: [PATCH 1/2] Ildkule: Move monitoring state directories to data volume --- hosts/ildkule/hardware-configuration.nix | 1 + hosts/ildkule/services/monitoring/loki.nix | 13 +++++++------ .../services/monitoring/prometheus/default.nix | 10 +++++++++- hosts/ildkule/services/monitoring/uptime-kuma.nix | 6 ++++++ 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/hosts/ildkule/hardware-configuration.nix b/hosts/ildkule/hardware-configuration.nix index dccf4bf..f2b59ac 100644 --- a/hosts/ildkule/hardware-configuration.nix +++ b/hosts/ildkule/hardware-configuration.nix @@ -4,6 +4,7 @@ boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "xen_blkfront" "vmw_pvscsi" ]; boot.initrd.kernelModules = [ "nvme" ]; fileSystems."/" = { device = "/dev/vda1"; fsType = "ext4"; }; + fileSystems."/data" = { device = "/dev/vdb1"; fsType = "ext4"; }; networking.useDHCP = lib.mkDefault true; } diff --git a/hosts/ildkule/services/monitoring/loki.nix b/hosts/ildkule/services/monitoring/loki.nix index ce8a550..4eba3e6 100644 --- a/hosts/ildkule/services/monitoring/loki.nix +++ b/hosts/ildkule/services/monitoring/loki.nix @@ -2,6 +2,7 @@ let cfg = config.services.loki; + stateDir = "/data/monitoring/loki"; in { services.loki = { enable = true; @@ -16,7 +17,7 @@ in { ingester = { wal = { enabled = true; - dir = "/var/lib/loki/wal"; + dir = "${stateDir}/wal"; }; lifecycler = { address = "127.0.0.1"; @@ -48,12 +49,12 @@ in { storage_config = { boltdb_shipper = { - active_index_directory = "/var/lib/loki/boltdb-shipper-index"; - cache_location = "/var/lib/loki/boltdb-shipper-cache"; + active_index_directory = "${stateDir}/boltdb-shipper-index"; + cache_location = "${stateDir}/boltdb-shipper-cache"; cache_ttl = "24h"; }; filesystem = { - directory = "/var/lib/loki/chunks"; + directory = "${stateDir}/chunks"; }; }; @@ -64,14 +65,14 @@ in { }; compactor = { - working_directory = "/var/lib/loki/compactor"; + working_directory = "${stateDir}/compactor"; }; # ruler = { # storage = { # type = "local"; # local = { - # directory = "/var/lib/loki/rules"; + # directory = "${stateDir}/rules"; # }; # }; # rule_path = "/etc/loki/rules"; diff --git a/hosts/ildkule/services/monitoring/prometheus/default.nix b/hosts/ildkule/services/monitoring/prometheus/default.nix index 957c251..2a93dc5 100644 --- a/hosts/ildkule/services/monitoring/prometheus/default.nix +++ b/hosts/ildkule/services/monitoring/prometheus/default.nix @@ -1,4 +1,6 @@ -{ config, ... }: { +{ config, ... }: let + stateDir = "/data/monitoring/prometheus"; +in { imports = [ ./gitea.nix ./matrix-synapse.nix @@ -10,9 +12,15 @@ services.prometheus = { enable = true; + listenAddress = "127.0.0.1"; port = 9001; ruleFiles = [ rules/synapse-v2.rules ]; }; + + fileSystems."/var/lib/prometheus2" = { + device = stateDir; + options = [ "bind" ]; + }; } diff --git a/hosts/ildkule/services/monitoring/uptime-kuma.nix b/hosts/ildkule/services/monitoring/uptime-kuma.nix index 961caca..9b1c0fc 100644 --- a/hosts/ildkule/services/monitoring/uptime-kuma.nix +++ b/hosts/ildkule/services/monitoring/uptime-kuma.nix @@ -2,6 +2,7 @@ let cfg = config.services.uptime-kuma; domain = "status.pvv.ntnu.no"; + stateDir = "/data/monitoring/uptime-kuma"; in { services.uptime-kuma = { enable = true; @@ -17,4 +18,9 @@ in { kTLS = true; locations."/".proxyPass = "http://${cfg.settings.HOST}:${cfg.settings.PORT}"; }; + + fileSystems."/var/lib/uptime-kuma" = { + device = stateDir; + options = [ "bind" ]; + }; } From 2d52ebce5204f7e6af339d61783873d32e48b5c0 Mon Sep 17 00:00:00 2001 From: Felix Albrigtsen Date: Sat, 9 Nov 2024 21:42:44 +0100 Subject: [PATCH 2/2] Ildkule: hardware-config: use UUIDs --- hosts/ildkule/hardware-configuration.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hosts/ildkule/hardware-configuration.nix b/hosts/ildkule/hardware-configuration.nix index f2b59ac..ccc6737 100644 --- a/hosts/ildkule/hardware-configuration.nix +++ b/hosts/ildkule/hardware-configuration.nix @@ -3,8 +3,14 @@ imports = [ (modulesPath + "/profiles/qemu-guest.nix") ]; boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "xen_blkfront" "vmw_pvscsi" ]; boot.initrd.kernelModules = [ "nvme" ]; - fileSystems."/" = { device = "/dev/vda1"; fsType = "ext4"; }; - fileSystems."/data" = { device = "/dev/vdb1"; fsType = "ext4"; }; + fileSystems."/" = { + device = "/dev/disk/by-uuid/e35eb4ce-aac3-4f91-8383-6e7cd8bbf942"; + fsType = "ext4"; + }; + fileSystems."/data" = { + device = "/dev/disk/by-uuid/0a4c1234-02d3-4b53-aeca-d95c4c8d534b"; + fsType = "ext4"; + }; networking.useDHCP = lib.mkDefault true; }