kubernetes-deployments/modules/ntfy.nix

115 lines
2.8 KiB
Nix
Raw Permalink Normal View History

2024-10-28 15:05:06 +00:00
{
lib,
config,
globals,
...
}: {
2024-09-07 10:35:02 +00:00
options.ntfy.enable = lib.mkEnableOption "ntfy";
config = lib.mkIf config.ntfy.enable {
kubernetes.resources = {
2024-10-28 15:05:06 +00:00
configMaps.ntfy.data.config = lib.generators.toYAML {} {
2024-09-07 10:35:02 +00:00
base-url = "https://ntfy.kun.is";
cache-file = "/var/cache/ntfy/cache.db";
cache-duration = "14d";
auth-file = "/var/lib/ntfy/user.db";
auth-default-access = "deny-all";
attachment-cache-dir = "/var/cache/ntfy-attachments";
enable-signup = false;
enable-login = true;
visitor-subscription-limit = 100;
};
deployments.ntfy.spec = {
selector.matchLabels.app = "ntfy";
strategy = {
type = "RollingUpdate";
rollingUpdate = {
maxSurge = 0;
maxUnavailable = 1;
};
};
template = {
metadata.labels.app = "ntfy";
spec = {
containers.ntfy = {
image = globals.images.ntfy;
ports.web.containerPort = 80;
env.TZ.value = "Europe/Amsterdam";
2024-10-28 15:05:06 +00:00
args = ["serve"];
2024-09-07 10:35:02 +00:00
volumeMounts = [
{
name = "cache";
mountPath = "/var/cache/ntfy";
}
{
name = "data";
mountPath = "/var/lib/ntfy";
}
{
name = "attachment-cache";
mountPath = "/var/cache/ntfy-attachments";
}
{
name = "config";
mountPath = "/etc/ntfy/server.yml";
subPath = "config";
}
];
};
volumes = {
cache.persistentVolumeClaim.claimName = "cache";
attachment-cache.persistentVolumeClaim.claimName = "attachment-cache";
data.persistentVolumeClaim.claimName = "data";
config.configMap.name = "ntfy";
};
};
};
};
persistentVolumeClaims = {
cache.spec = {
2024-10-28 15:05:06 +00:00
accessModes = ["ReadWriteOnce"];
2024-09-07 10:35:02 +00:00
resources.requests.storage = "300Mi";
};
attachment-cache.spec = {
2024-10-28 15:05:06 +00:00
accessModes = ["ReadWriteOnce"];
2024-09-07 10:35:02 +00:00
resources.requests.storage = "500Mi";
};
};
services.ntfy.spec = {
selector.app = "ntfy";
ports.web = {
port = 80;
targetPort = "web";
};
};
};
lab = {
ingresses.ntfy = {
host = "ntfy.kun.is";
service = {
name = "ntfy";
portName = "web";
};
};
longhorn.persistentVolumeClaim.data = {
volumeName = "ntfy";
storage = "300Mi";
};
};
};
}