From ebf4e41b73be5f4b31d1a735252692775928150f Mon Sep 17 00:00:00 2001 From: Astro Date: Fri, 25 Nov 2022 23:04:27 +0100 Subject: [PATCH] modules/cluster: start supporting multiple storages --- modules/cluster/default.nix | 4 ++++ modules/cluster/deployment-options.nix | 4 ++++ modules/cluster/deployment.nix | 9 ++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/modules/cluster/default.nix b/modules/cluster/default.nix index 029c762b..e7266aa9 100644 --- a/modules/cluster/default.nix +++ b/modules/cluster/default.nix @@ -44,6 +44,10 @@ in { servers = servers; # run tasks only on these: client.enable = builtins.elem hostName microvmServers; + client.meta = + lib.optionalAttrs (builtins.elem hostName storageServers) { + "c3d2.storage" = "big"; + }; }; microvmUid = 997; diff --git a/modules/cluster/deployment-options.nix b/modules/cluster/deployment-options.nix index 9878ce32..13248180 100644 --- a/modules/cluster/deployment-options.nix +++ b/modules/cluster/deployment-options.nix @@ -18,5 +18,9 @@ type = with types; listOf str; default = [ "/etc" "/home" "/var" ]; }; + storage = mkOption { + type = types.enum [ "fast" "big" ]; + default = "fast"; + }; }; } diff --git a/modules/cluster/deployment.nix b/modules/cluster/deployment.nix index abe7ee90..46468380 100644 --- a/modules/cluster/deployment.nix +++ b/modules/cluster/deployment.nix @@ -59,7 +59,7 @@ in tag = builtins.replaceStrings [ "/" ] [ "-" ] ( withoutLeadingSlash mountPoint ); - source = "/glusterfs/fast/microvms/${user}/${repo}/${vmName}/${withoutLeadingSlash mountPoint}"; + source = "/glusterfs/${config.deployment.storage}/microvms/${user}/${repo}/${vmName}/${withoutLeadingSlash mountPoint}"; inherit mountPoint; }) config.deployment.persistedShares; volumes = [ { @@ -76,6 +76,13 @@ in }) config.deployment.networks; }; + skyflake = { + nomadJob.constraints = lib.optionals (config.deployment.storage == "big") [ { + attribute = "\${meta.c3d2.storage}"; + value = "big"; + } ]; + }; + networking = { useDHCP = false; dhcpcd.enable = false;