diff --git a/flake-parts/kubenix.nix b/flake-parts/kubenix.nix index 82940ce..a8e8bb9 100644 --- a/flake-parts/kubenix.nix +++ b/flake-parts/kubenix.nix @@ -1,9 +1,9 @@ -{ dns, myLib, flake-utils, kubenix, nixhelm, blog-pim, ... }: flake-utils.lib.eachDefaultSystem +{ machines, dns, myLib, flake-utils, kubenix, nixhelm, blog-pim, ... }: flake-utils.lib.eachDefaultSystem (system: let mkKubenixPackage = module: kubenix.packages.${system}.default.override { - specialArgs = { inherit myLib kubenix nixhelm system dns blog-pim; }; + specialArgs = { inherit myLib kubenix nixhelm system dns blog-pim machines; }; module = { imports = [ module ]; }; }; in diff --git a/kubenix-modules/all.nix b/kubenix-modules/all.nix index 4904128..3d84b15 100644 --- a/kubenix-modules/all.nix +++ b/kubenix-modules/all.nix @@ -15,10 +15,10 @@ let ./media.nix ./bind9 ./dnsmasq.nix - # ./minecraft.nix ./blog.nix ./atticd.nix # ./argo.nix + # ./minecraft.nix ]; in { diff --git a/kubenix-modules/base.nix b/kubenix-modules/base.nix index 677a776..7f29515 100644 --- a/kubenix-modules/base.nix +++ b/kubenix-modules/base.nix @@ -1,6 +1,6 @@ # We deploy several resources that rely on "custom resource definitions". # We must first import these resources definitions, before deploying resources that depend on them. -{ kubenix, nixhelm, system, ... }: { +{ lib, kubenix, nixhelm, system, machines, ... }: { imports = [ kubenix.modules.k8s kubenix.modules.helm @@ -58,6 +58,16 @@ }; }; }; + + resources.nodes = + let + machinesWithKubernetesLabels = lib.filterAttrs (name: machine: machine.kubernetesNodeLabels != null) machines; + in + builtins.mapAttrs + (name: machine: { + metadata.labels = machine.kubernetesNodeLabels; + }) + machinesWithKubernetesLabels; }; }; } diff --git a/kubenix-modules/nextcloud.nix b/kubenix-modules/nextcloud.nix index ba9b59f..afe4bcf 100644 --- a/kubenix-modules/nextcloud.nix +++ b/kubenix-modules/nextcloud.nix @@ -13,6 +13,14 @@ spec = { selector.matchLabels.app = "nextcloud"; + strategy = { + type = "RollingUpdate"; + + rollingUpdate = { + maxSurge = 0; + maxUnavailable = 1; + }; + }; template = { metadata.labels.app = "nextcloud"; @@ -40,6 +48,15 @@ fsGroup = 33; fsGroupChangePolicy = "OnRootMismatch"; }; + + affinity.nodeAffinity.preferredDuringSchedulingIgnoredDuringExecution = [{ + weight = 1; + preference.matchExpressions = [{ + key = "storageType"; + operator = "In"; + values = [ "fast" ]; + }]; + }]; }; }; }; diff --git a/kubenix-modules/syncthing.nix b/kubenix-modules/syncthing.nix index 1c47d93..a152cac 100644 --- a/kubenix-modules/syncthing.nix +++ b/kubenix-modules/syncthing.nix @@ -26,10 +26,6 @@ name = "config"; mountPath = "/config"; } - { - name = "nextcloud-data"; - mountPath = "/data"; - } { name = "music"; mountPath = "/music"; @@ -39,7 +35,6 @@ volumes = { config.persistentVolumeClaim.claimName = "syncthing"; - nextcloud-data.persistentVolumeClaim.claimName = "nextcloud"; music.persistentVolumeClaim.claimName = "music"; }; diff --git a/machines/atlas.nix b/machines/atlas.nix index 48440a3..add63f1 100644 --- a/machines/atlas.nix +++ b/machines/atlas.nix @@ -1,6 +1,7 @@ { machines.atlas = { arch = "x86_64-linux"; + kubernetesNodeLabels.storageType = "slow"; nixosModule.lab = { storage = { diff --git a/machines/default.nix b/machines/default.nix index 484e80c..c1e0351 100644 --- a/machines/default.nix +++ b/machines/default.nix @@ -22,6 +22,14 @@ let Customized configuration for this machine in the form of a NixOS module. ''; }; + + kubernetesNodeLabels = lib.mkOption { + default = null; + type = with lib.types; nullOr attrs; + description = '' + Any labels to add to the Kubernetes node. + ''; + }; }; }; in diff --git a/machines/jefke.nix b/machines/jefke.nix index d9e633d..a326f76 100644 --- a/machines/jefke.nix +++ b/machines/jefke.nix @@ -1,6 +1,7 @@ { machines.jefke = { arch = "x86_64-linux"; + kubernetesNodeLabels.storageType = "fast"; nixosModule.lab = { storage = {