create custom nixos module for k8s nfs volumes

This commit is contained in:
Pim Kunis 2024-04-14 23:34:54 +02:00
parent 4ded27d82e
commit dce3919f31
14 changed files with 216 additions and 464 deletions

View file

@ -22,5 +22,6 @@
./cert-manager.nix ./cert-manager.nix
./minecraft.nix ./minecraft.nix
./custom/ingress.nix ./custom/ingress.nix
./custom/nfs-volume.nix
]; ];
} }

View file

@ -27,7 +27,6 @@ in
options = { options = {
lab.ingresses = lib.mkOption { lab.ingresses = lib.mkOption {
type = with lib.types; attrsOf (submodule ingressOpts); type = with lib.types; attrsOf (submodule ingressOpts);
default = { }; default = { };
}; };
}; };

View file

@ -0,0 +1,47 @@
{ lib, config, ... }:
let
nfsVolumeOpts = { name, ... }: {
options = {
path = lib.mkOption {
type = lib.types.str;
};
};
};
in
{
options = {
lab.nfsVolumes = lib.mkOption {
type = with lib.types; attrsOf (submodule nfsVolumeOpts);
default = { };
};
};
config = {
kubernetes.resources = {
persistentVolumes = builtins.mapAttrs
(name: nfsVolume: {
spec = {
capacity.storage = "1Mi";
accessModes = [ "ReadWriteMany" ];
nfs = {
server = "lewis.dmz";
path = "/mnt/data/nfs/${nfsVolume.path}";
};
};
})
config.lab.nfsVolumes;
persistentVolumeClaims = builtins.mapAttrs
(name: nfsVolume: {
spec = {
accessModes = [ "ReadWriteMany" ];
storageClassName = "";
resources.requests.storage = "1Mi";
volumeName = name;
};
})
config.lab.nfsVolumes;
};
};
}

View file

@ -158,23 +158,6 @@
}; };
}; };
persistentVolumes.forgejo.spec = {
capacity.storage = "1Mi";
accessModes = [ "ReadWriteMany" ];
nfs = {
server = "lewis.dmz";
path = "/mnt/data/nfs/forgejo";
};
};
persistentVolumeClaims.forgejo.spec = {
accessModes = [ "ReadWriteMany" ];
storageClassName = "";
resources.requests.storage = "1Mi";
volumeName = "forgejo";
};
services = { services = {
forgejo-web.spec = { forgejo-web.spec = {
selector.app = "forgejo"; selector.app = "forgejo";
@ -198,7 +181,10 @@
}; };
}; };
lab.ingresses.forgejo = { lab = {
nfsVolumes.forgejo.path = "forgejo";
ingresses.forgejo = {
host = "git.kun.is"; host = "git.kun.is";
service = { service = {
@ -206,4 +192,5 @@
portName = "web"; portName = "web";
}; };
}; };
};
} }

View file

@ -48,23 +48,6 @@
}; };
}; };
persistentVolumes.freshrss.spec = {
capacity.storage = "1Mi";
accessModes = [ "ReadWriteMany" ];
nfs = {
server = "lewis.dmz";
path = "/mnt/data/nfs/freshrss/data";
};
};
persistentVolumeClaims.freshrss.spec = {
accessModes = [ "ReadWriteMany" ];
storageClassName = "";
resources.requests.storage = "1Mi";
volumeName = "freshrss";
};
services.freshrss.spec = { services.freshrss.spec = {
selector.app = "freshrss"; selector.app = "freshrss";
@ -75,7 +58,10 @@
}; };
}; };
lab.ingresses.freshrss = { lab = {
nfsVolumes.freshrss.path = "freshrss/data";
ingresses.freshrss = {
host = "rss.kun.is"; host = "rss.kun.is";
service = { service = {
@ -83,4 +69,5 @@
portName = "web"; portName = "web";
}; };
}; };
};
} }

View file

@ -73,23 +73,6 @@
}; };
}; };
persistentVolumes.hedgedoc.spec = {
capacity.storage = "1Mi";
accessModes = [ "ReadWriteMany" ];
nfs = {
server = "lewis.dmz";
path = "/mnt/data/nfs/hedgedoc/uploads";
};
};
persistentVolumeClaims.hedgedoc.spec = {
accessModes = [ "ReadWriteMany" ];
storageClassName = "";
resources.requests.storage = "1Mi";
volumeName = "hedgedoc";
};
services.hedgedoc.spec = { services.hedgedoc.spec = {
selector.app = "hedgedoc"; selector.app = "hedgedoc";
@ -100,7 +83,10 @@
}; };
}; };
lab.ingresses.hedgedoc = { lab = {
nfsVolumes.hedgedoc.path = "hedgedoc/uploads";
ingresses.hedgedoc = {
host = "md.kun.is"; host = "md.kun.is";
service = { service = {
@ -108,4 +94,5 @@
portName = "web"; portName = "web";
}; };
}; };
};
} }

View file

@ -72,23 +72,6 @@
}; };
}; };
persistentVolumes.kitchenowl.spec = {
capacity.storage = "1Mi";
accessModes = [ "ReadWriteMany" ];
nfs = {
server = "lewis.dmz";
path = "/mnt/data/nfs/kitchenowl/data";
};
};
persistentVolumeClaims.kitchenowl.spec = {
accessModes = [ "ReadWriteMany" ];
storageClassName = "";
resources.requests.storage = "1Mi";
volumeName = "kitchenowl";
};
services = { services = {
kitchenowl-web.spec = { kitchenowl-web.spec = {
selector = { selector = {
@ -116,7 +99,10 @@
}; };
}; };
lab.ingresses.kitchenowl = { lab = {
nfsVolumes.kitchenowl.path = "kitchenowl/data";
ingresses.kitchenowl = {
host = "boodschappen.kun.is"; host = "boodschappen.kun.is";
service = { service = {
@ -124,4 +110,5 @@
portName = "web"; portName = "web";
}; };
}; };
};
} }

View file

@ -341,146 +341,6 @@
}; };
}; };
persistentVolumes = {
jellyfin-config.spec = {
capacity.storage = "1Mi";
accessModes = [ "ReadWriteMany" ];
nfs = {
server = "lewis.dmz";
path = "/mnt/data/nfs/jellyfin/config";
};
};
media.spec = {
capacity.storage = "1Mi";
accessModes = [ "ReadWriteMany" ];
nfs = {
server = "lewis.dmz";
path = "/mnt/data/nfs/media";
};
};
transmission-config.spec = {
capacity.storage = "1Mi";
accessModes = [ "ReadWriteMany" ];
nfs = {
server = "lewis.dmz";
path = "/mnt/data/nfs/transmission/config";
};
};
jellyseerr-config.spec = {
capacity.storage = "1Mi";
accessModes = [ "ReadWriteMany" ];
nfs = {
server = "lewis.dmz";
path = "/mnt/data/nfs/jellyseerr/config";
};
};
radarr-config.spec = {
capacity.storage = "1Mi";
accessModes = [ "ReadWriteMany" ];
nfs = {
server = "lewis.dmz";
path = "/mnt/data/nfs/radarr/config";
};
};
prowlarr-config.spec = {
capacity.storage = "1Mi";
accessModes = [ "ReadWriteMany" ];
nfs = {
server = "lewis.dmz";
path = "/mnt/data/nfs/prowlarr/config";
};
};
sonarr-config.spec = {
capacity.storage = "1Mi";
accessModes = [ "ReadWriteMany" ];
nfs = {
server = "lewis.dmz";
path = "/mnt/data/nfs/sonarr/config";
};
};
bazarr-config.spec = {
capacity.storage = "1Mi";
accessModes = [ "ReadWriteMany" ];
nfs = {
server = "lewis.dmz";
path = "/mnt/data/nfs/bazarr/config";
};
};
};
persistentVolumeClaims = {
jellyfin-config.spec = {
accessModes = [ "ReadWriteMany" ];
storageClassName = "";
resources.requests.storage = "1Mi";
volumeName = "jellyfin-config";
};
media.spec = {
accessModes = [ "ReadWriteMany" ];
storageClassName = "";
resources.requests.storage = "1Mi";
volumeName = "media";
};
transmission-config.spec = {
accessModes = [ "ReadWriteMany" ];
storageClassName = "";
resources.requests.storage = "1Mi";
volumeName = "transmission-config";
};
jellyseerr-config.spec = {
accessModes = [ "ReadWriteMany" ];
storageClassName = "";
resources.requests.storage = "1Mi";
volumeName = "jellyseerr-config";
};
radarr-config.spec = {
accessModes = [ "ReadWriteMany" ];
storageClassName = "";
resources.requests.storage = "1Mi";
volumeName = "radarr-config";
};
prowlarr-config.spec = {
accessModes = [ "ReadWriteMany" ];
storageClassName = "";
resources.requests.storage = "1Mi";
volumeName = "prowlarr-config";
};
sonarr-config.spec = {
accessModes = [ "ReadWriteMany" ];
storageClassName = "";
resources.requests.storage = "1Mi";
volumeName = "sonarr-config";
};
bazarr-config.spec = {
accessModes = [ "ReadWriteMany" ];
storageClassName = "";
resources.requests.storage = "1Mi";
volumeName = "bazarr-config";
};
};
services = { services = {
jellyfin.spec = { jellyfin.spec = {
selector = { selector = {
@ -583,7 +443,8 @@
}; };
}; };
lab.ingresses = { lab = {
ingresses = {
jellyfin = { jellyfin = {
host = "media.kun.is"; host = "media.kun.is";
@ -653,4 +514,16 @@
}; };
}; };
}; };
nfsVolumes = {
jellyfin-config.path = "jellyfin/config";
media.path = "media";
transmission-config.path = "transmission/config";
jellyseerr-config.path = "jellyseerr/config";
radarr-config.path = "radarr/config";
prowlarr-config.path = "prowlarr/config";
sonarr-config.path = "sonarr/config";
bazarr-config.path = "bazarr/config";
};
};
} }

View file

@ -29,23 +29,6 @@
}; };
}; };
persistentVolumes.minecraft.spec = {
capacity.storage = "1Mi";
accessModes = [ "ReadWriteMany" ];
nfs = {
server = "lewis.dmz";
path = "/mnt/data/nfs/minecraft";
};
};
persistentVolumeClaims.minecraft.spec = {
accessModes = [ "ReadWriteMany" ];
storageClassName = "";
resources.requests.storage = "1Mi";
volumeName = "minecraft";
};
services.minecraft.spec = { services.minecraft.spec = {
type = "LoadBalancer"; type = "LoadBalancer";
loadBalancerIP = myLib.globals.minecraftIPv4; loadBalancerIP = myLib.globals.minecraftIPv4;
@ -57,4 +40,6 @@
}; };
}; };
}; };
lab.nfsVolumes.minecraft.path = "minecraft";
} }

View file

@ -40,23 +40,6 @@
}; };
}; };
persistentVolumes.nextcloud.spec = {
capacity.storage = "1Mi";
accessModes = [ "ReadWriteMany" ];
nfs = {
server = "lewis.dmz";
path = "/mnt/data/nfs/nextcloud/data";
};
};
persistentVolumeClaims.nextcloud.spec = {
accessModes = [ "ReadWriteMany" ];
storageClassName = "";
resources.requests.storage = "1Mi";
volumeName = "nextcloud";
};
services.nextcloud.spec = { services.nextcloud.spec = {
selector.app = "nextcloud"; selector.app = "nextcloud";
@ -67,7 +50,10 @@
}; };
}; };
lab.ingresses.nextcloud = { lab = {
nfsVolumes.nextcloud.path = "nextcloud/data";
ingresses.nextcloud = {
host = "cloud.kun.is"; host = "cloud.kun.is";
service = { service = {
@ -75,4 +61,5 @@
portName = "web"; portName = "web";
}; };
}; };
};
} }

View file

@ -105,44 +105,6 @@
}; };
}; };
persistentVolumes = {
paperless-ngx-redisdata.spec = {
capacity.storage = "1Mi";
accessModes = [ "ReadWriteMany" ];
nfs = {
server = "lewis.dmz";
path = "/mnt/data/nfs/paperless-ngx/redisdata";
};
};
paperless-ngx-data.spec = {
capacity.storage = "1Mi";
accessModes = [ "ReadWriteMany" ];
nfs = {
server = "lewis.dmz";
path = "/mnt/data/nfs/paperless-ngx/data";
};
};
};
persistentVolumeClaims = {
paperless-ngx-redisdata.spec = {
accessModes = [ "ReadWriteMany" ];
storageClassName = "";
resources.requests.storage = "1Mi";
volumeName = "paperless-ngx-redisdata";
};
paperless-ngx-data.spec = {
accessModes = [ "ReadWriteMany" ];
storageClassName = "";
resources.requests.storage = "1Mi";
volumeName = "paperless-ngx-data";
};
};
services = { services = {
paperless-ngx-web.spec = { paperless-ngx-web.spec = {
selector = { selector = {
@ -170,7 +132,8 @@
}; };
}; };
lab.ingresses.paperless-ngx = { lab = {
ingresses.paperless-ngx = {
host = "paperless.kun.is"; host = "paperless.kun.is";
service = { service = {
@ -178,4 +141,10 @@
portName = "web"; portName = "web";
}; };
}; };
nfsVolumes = {
paperless-ngx-redisdata.path = "paperless-ngx/redisdata";
paperless-ngx-data.path = "paperless-ngx/data";
};
};
} }

View file

@ -56,44 +56,6 @@
}; };
}; };
persistentVolumes = {
pihole-data.spec = {
capacity.storage = "1Mi";
accessModes = [ "ReadWriteMany" ];
nfs = {
server = "lewis.dmz";
path = "/mnt/data/nfs/pihole/data";
};
};
pihole-dnsmasq.spec = {
capacity.storage = "1Mi";
accessModes = [ "ReadWriteMany" ];
nfs = {
server = "lewis.dmz";
path = "/mnt/data/nfs/pihole/dnsmasq";
};
};
};
persistentVolumeClaims = {
pihole-data.spec = {
accessModes = [ "ReadWriteMany" ];
storageClassName = "";
resources.requests.storage = "1Mi";
volumeName = "pihole-data";
};
pihole-dnsmasq.spec = {
accessModes = [ "ReadWriteMany" ];
storageClassName = "";
resources.requests.storage = "1Mi";
volumeName = "pihole-dnsmasq";
};
};
services = { services = {
pihole-web.spec = { pihole-web.spec = {
selector.app = "pihole"; selector.app = "pihole";
@ -118,7 +80,8 @@
}; };
}; };
lab.ingresses.pihole = { lab = {
ingresses.pihole = {
host = "pihole.kun.is"; host = "pihole.kun.is";
entrypoint = "localsecure"; entrypoint = "localsecure";
@ -127,4 +90,10 @@
portName = "web"; portName = "web";
}; };
}; };
nfsVolumes = {
pihole-data.path = "pihole/data";
pihole-dnsmasq.path = "pihole/dnsmasq";
};
};
} }

View file

@ -73,23 +73,6 @@
}; };
}; };
persistentVolumes.radicale.spec = {
capacity.storage = "1Mi";
accessModes = [ "ReadWriteMany" ];
nfs = {
server = "lewis.dmz";
path = "/mnt/data/nfs/radicale";
};
};
persistentVolumeClaims.radicale.spec = {
accessModes = [ "ReadWriteMany" ];
storageClassName = "";
resources.requests.storage = "1Mi";
volumeName = "radicale";
};
services.radicale.spec = { services.radicale.spec = {
selector.app = "radicale"; selector.app = "radicale";
@ -100,7 +83,10 @@
}; };
}; };
lab.ingresses.radicale = { lab = {
nfsVolumes.radicale.path = "radicale";
ingresses.radicale = {
host = "dav.kun.is"; host = "dav.kun.is";
service = { service = {
@ -108,4 +94,5 @@
portName = "web"; portName = "web";
}; };
}; };
};
} }

View file

@ -42,23 +42,6 @@
}; };
}; };
persistentVolumes.syncthing.spec = {
capacity.storage = "1Mi";
accessModes = [ "ReadWriteMany" ];
nfs = {
server = "lewis.dmz";
path = "/mnt/data/nfs/syncthing/config";
};
};
persistentVolumeClaims.syncthing.spec = {
accessModes = [ "ReadWriteMany" ];
storageClassName = "";
resources.requests.storage = "1Mi";
volumeName = "syncthing";
};
services.syncthing.spec = { services.syncthing.spec = {
selector.app = "syncthing"; selector.app = "syncthing";
@ -69,7 +52,10 @@
}; };
}; };
lab.ingresses.syncthing = { lab = {
nfsVolumes.syncthing.path = "syncthing/config";
ingresses.syncthing = {
host = "sync.kun.is"; host = "sync.kun.is";
entrypoint = "localsecure"; entrypoint = "localsecure";
@ -78,4 +64,5 @@
portName = "web"; portName = "web";
}; };
}; };
};
} }