Create Nix module for Creating Longhorn volumes
This commit is contained in:
parent
4232b18ea1
commit
e791c1df9c
3 changed files with 71 additions and 38 deletions
|
@ -31,6 +31,7 @@ in
|
|||
./cert-manager.nix
|
||||
./custom/ingress.nix
|
||||
./custom/nfs-volume.nix
|
||||
./custom/longhorn-volume.nix
|
||||
./traefik.nix
|
||||
] ++ applications;
|
||||
}
|
||||
|
|
68
kubenix-modules/custom/longhorn-volume.nix
Normal file
68
kubenix-modules/custom/longhorn-volume.nix
Normal file
|
@ -0,0 +1,68 @@
|
|||
{ lib, config, ... }:
|
||||
let
|
||||
longhornVolumeOpts = { name, ... }: {
|
||||
options = {
|
||||
storage = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options = {
|
||||
lab.longhornVolumes = lib.mkOption {
|
||||
type = with lib.types; attrsOf (submodule longhornVolumeOpts);
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
kubernetes.resources = {
|
||||
persistentVolumes = builtins.mapAttrs
|
||||
(name: longhornVolume: {
|
||||
spec = {
|
||||
accessModes = [ "ReadWriteOnce" ];
|
||||
capacity.storage = longhornVolume.storage;
|
||||
|
||||
claimRef = {
|
||||
inherit name;
|
||||
namespace = "default";
|
||||
};
|
||||
|
||||
csi = {
|
||||
driver = "driver.longhorn.io";
|
||||
fsType = "ext4";
|
||||
|
||||
volumeAttributes = {
|
||||
dataLocality = "disabled";
|
||||
fromBackup = "";
|
||||
fsType = "ext4";
|
||||
numberOfReplicas = "2";
|
||||
recurringJobSelector = lib.generators.toYAML { } [{
|
||||
name = "backup-nfs";
|
||||
isGroup = false;
|
||||
}];
|
||||
staleReplicaTimeout = "30";
|
||||
unmapMarkSnapChainRemoved = "ignored";
|
||||
};
|
||||
volumeHandle = name;
|
||||
};
|
||||
|
||||
persistentVolumeReclaimPolicy = "Delete";
|
||||
volumeMode = "Filesystem";
|
||||
};
|
||||
})
|
||||
config.lab.longhornVolumes;
|
||||
|
||||
persistentVolumeClaims = builtins.mapAttrs
|
||||
(name: longhornVolume: {
|
||||
spec = {
|
||||
accessModes = [ "ReadWriteOnce" ];
|
||||
resources.requests.storage = longhornVolume.storage;
|
||||
storageClassName = "";
|
||||
};
|
||||
})
|
||||
config.lab.longhornVolumes;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -83,47 +83,11 @@
|
|||
targetPort = "web";
|
||||
};
|
||||
};
|
||||
|
||||
persistentVolumeClaims.hedgedoc-uploads.spec = {
|
||||
accessModes = [ "ReadWriteOnce" ];
|
||||
resources.requests.storage = "50Mi";
|
||||
storageClassName = "";
|
||||
};
|
||||
|
||||
persistentVolumes.hedgedoc-uploads.spec = {
|
||||
accessModes = [ "ReadWriteOnce" ];
|
||||
capacity.storage = "50Mi";
|
||||
|
||||
claimRef = {
|
||||
name = "hedgedoc-uploads";
|
||||
namespace = "default";
|
||||
};
|
||||
|
||||
csi = {
|
||||
driver = "driver.longhorn.io";
|
||||
fsType = "ext4";
|
||||
|
||||
volumeAttributes = {
|
||||
dataLocality = "disabled";
|
||||
fromBackup = "";
|
||||
fsType = "ext4";
|
||||
numberOfReplicas = "2";
|
||||
recurringJobSelector = lib.generators.toYAML { } [{
|
||||
name = "backup-nfs";
|
||||
isGroup = false;
|
||||
}];
|
||||
staleReplicaTimeout = "30";
|
||||
unmapMarkSnapChainRemoved = "ignored";
|
||||
};
|
||||
volumeHandle = "hedgedoc-uploads";
|
||||
};
|
||||
|
||||
persistentVolumeReclaimPolicy = "Delete";
|
||||
volumeMode = "Filesystem";
|
||||
};
|
||||
};
|
||||
|
||||
lab = {
|
||||
longhornVolumes.hedgedoc-uploads.storage = "50Mi";
|
||||
|
||||
ingresses.hedgedoc = {
|
||||
host = "md.kun.is";
|
||||
|
||||
|
|
Loading…
Reference in a new issue