2024-05-20 16:25:11 +00:00
|
|
|
{ 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;
|
2024-05-25 12:26:59 +00:00
|
|
|
persistentVolumeReclaimPolicy = "Delete";
|
|
|
|
volumeMode = "Filesystem";
|
2024-05-20 16:25:11 +00:00
|
|
|
|
|
|
|
claimRef = {
|
|
|
|
inherit name;
|
|
|
|
namespace = "default";
|
|
|
|
};
|
|
|
|
|
|
|
|
csi = {
|
|
|
|
driver = "driver.longhorn.io";
|
|
|
|
fsType = "ext4";
|
2024-05-25 12:26:59 +00:00
|
|
|
volumeHandle = name;
|
2024-05-20 16:25:11 +00:00
|
|
|
|
|
|
|
volumeAttributes = {
|
|
|
|
dataLocality = "disabled";
|
|
|
|
fromBackup = "";
|
|
|
|
fsType = "ext4";
|
|
|
|
numberOfReplicas = "2";
|
2024-05-25 12:26:59 +00:00
|
|
|
staleReplicaTimeout = "30";
|
|
|
|
unmapMarkSnapChainRemoved = "ignored";
|
|
|
|
|
2024-05-20 16:25:11 +00:00
|
|
|
recurringJobSelector = lib.generators.toYAML { } [{
|
|
|
|
name = "backup-nfs";
|
|
|
|
isGroup = false;
|
|
|
|
}];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
})
|
|
|
|
config.lab.longhornVolumes;
|
|
|
|
|
|
|
|
persistentVolumeClaims = builtins.mapAttrs
|
|
|
|
(name: longhornVolume: {
|
|
|
|
spec = {
|
|
|
|
accessModes = [ "ReadWriteOnce" ];
|
|
|
|
resources.requests.storage = longhornVolume.storage;
|
|
|
|
storageClassName = "";
|
|
|
|
};
|
|
|
|
})
|
|
|
|
config.lab.longhornVolumes;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|