feat(longhorn): Reference PV from PVC
refactor(freshrss): Rename k8s resources
This commit is contained in:
parent
07bd2e1e01
commit
e724ff94a9
3 changed files with 129 additions and 53 deletions
|
@ -12,6 +12,28 @@ let
|
|||
};
|
||||
};
|
||||
};
|
||||
|
||||
longhornPVOpts = { name, ... }: {
|
||||
options = {
|
||||
storage = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
longhornPVCOpts = { name, ... }: {
|
||||
options = {
|
||||
volumeName = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = name;
|
||||
};
|
||||
|
||||
# TODO: ideally we take this from the longhornPV so we don't duplicate this information.
|
||||
storage = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options = {
|
||||
|
@ -19,55 +41,109 @@ in
|
|||
type = with lib.types; attrsOf (submodule longhornVolumeOpts);
|
||||
default = { };
|
||||
};
|
||||
|
||||
lab.longhorn = {
|
||||
persistentVolume = lib.mkOption {
|
||||
type = with lib.types; attrsOf (submodule longhornPVOpts);
|
||||
default = { };
|
||||
};
|
||||
|
||||
persistentVolumeClaim = lib.mkOption {
|
||||
type = with lib.types; attrsOf (submodule longhornPVCOpts);
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
kubernetes.resources = {
|
||||
persistentVolumes = builtins.mapAttrs
|
||||
(name: longhornVolume: {
|
||||
spec = {
|
||||
accessModes = [ "ReadWriteOnce" ];
|
||||
capacity.storage = longhornVolume.storage;
|
||||
persistentVolumeReclaimPolicy = "Delete";
|
||||
volumeMode = "Filesystem";
|
||||
persistentVolumes = lib.mergeAttrs
|
||||
(builtins.mapAttrs
|
||||
(name: longhornVolume: {
|
||||
spec = {
|
||||
accessModes = [ "ReadWriteOnce" ];
|
||||
capacity.storage = longhornVolume.storage;
|
||||
persistentVolumeReclaimPolicy = "Delete";
|
||||
volumeMode = "Filesystem";
|
||||
|
||||
claimRef = {
|
||||
inherit name;
|
||||
namespace = longhornVolume.namespace;
|
||||
};
|
||||
claimRef = {
|
||||
inherit name;
|
||||
namespace = longhornVolume.namespace;
|
||||
};
|
||||
|
||||
csi = {
|
||||
driver = "driver.longhorn.io";
|
||||
fsType = "ext4";
|
||||
volumeHandle = name;
|
||||
|
||||
volumeAttributes = {
|
||||
dataLocality = "disabled";
|
||||
fromBackup = "";
|
||||
csi = {
|
||||
driver = "driver.longhorn.io";
|
||||
fsType = "ext4";
|
||||
numberOfReplicas = "2";
|
||||
staleReplicaTimeout = "30";
|
||||
unmapMarkSnapChainRemoved = "ignored";
|
||||
volumeHandle = name;
|
||||
|
||||
recurringJobSelector = lib.generators.toYAML { } [{
|
||||
name = "backup-nfs";
|
||||
isGroup = false;
|
||||
}];
|
||||
volumeAttributes = {
|
||||
dataLocality = "disabled";
|
||||
fromBackup = "";
|
||||
fsType = "ext4";
|
||||
numberOfReplicas = "2";
|
||||
staleReplicaTimeout = "30";
|
||||
unmapMarkSnapChainRemoved = "ignored";
|
||||
|
||||
recurringJobSelector = lib.generators.toYAML { } [{
|
||||
name = "backup-nfs";
|
||||
isGroup = false;
|
||||
}];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
})
|
||||
config.lab.longhornVolumes;
|
||||
})
|
||||
config.lab.longhornVolumes)
|
||||
(builtins.mapAttrs
|
||||
(name: longhornPV: {
|
||||
spec = {
|
||||
accessModes = [ "ReadWriteOnce" ];
|
||||
capacity.storage = longhornPV.storage;
|
||||
persistentVolumeReclaimPolicy = "Delete";
|
||||
volumeMode = "Filesystem";
|
||||
|
||||
persistentVolumeClaims = builtins.mapAttrs
|
||||
(name: longhornVolume: {
|
||||
spec = {
|
||||
accessModes = [ "ReadWriteOnce" ];
|
||||
resources.requests.storage = longhornVolume.storage;
|
||||
storageClassName = "";
|
||||
};
|
||||
})
|
||||
config.lab.longhornVolumes;
|
||||
csi = {
|
||||
driver = "driver.longhorn.io";
|
||||
fsType = "ext4";
|
||||
volumeHandle = name;
|
||||
|
||||
volumeAttributes = {
|
||||
dataLocality = "disabled";
|
||||
fromBackup = "";
|
||||
fsType = "ext4";
|
||||
numberOfReplicas = "2";
|
||||
staleReplicaTimeout = "30";
|
||||
unmapMarkSnapChainRemoved = "ignored";
|
||||
|
||||
recurringJobSelector = lib.generators.toYAML { } [{
|
||||
name = "backup-nfs";
|
||||
isGroup = false;
|
||||
}];
|
||||
};
|
||||
};
|
||||
};
|
||||
})
|
||||
config.lab.longhorn.persistentVolume);
|
||||
|
||||
persistentVolumeClaims = lib.mergeAttrs
|
||||
(builtins.mapAttrs
|
||||
(name: longhornVolume: {
|
||||
spec = {
|
||||
accessModes = [ "ReadWriteOnce" ];
|
||||
resources.requests.storage = longhornVolume.storage;
|
||||
storageClassName = "";
|
||||
};
|
||||
})
|
||||
config.lab.longhornVolumes)
|
||||
(builtins.mapAttrs
|
||||
(name: longhornPVC: {
|
||||
spec = {
|
||||
accessModes = [ "ReadWriteOnce" ];
|
||||
resources.requests.storage = longhornPVC.storage;
|
||||
storageClassName = "";
|
||||
volumeName = longhornPVC.volumeName;
|
||||
};
|
||||
})
|
||||
config.lab.longhorn.persistentVolumeClaim);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Reference in a new issue