feat(paperless-ngx): Move to separate k8s namespace

This commit is contained in:
Pim Kunis 2024-07-14 22:58:06 +02:00
parent f606cb2f1c
commit a8d9e4f634
6 changed files with 141 additions and 114 deletions

View file

@ -62,6 +62,7 @@ Currently, the applications being deployed like this are:
- `hedgedoc` - `hedgedoc`
- `kitchenowl` - `kitchenowl`
- `forgejo` - `forgejo`
- `paperless-ngx`
## Known bugs ## Known bugs

View file

@ -84,4 +84,6 @@
"${self}/kubenix-modules/kitchenowl.nix" "kitchenowl" "kitchenowl"; "${self}/kubenix-modules/kitchenowl.nix" "kitchenowl" "kitchenowl";
kubenix.forgejo = mkDeployScriptAndManifest kubenix.forgejo = mkDeployScriptAndManifest
"${self}/kubenix-modules/forgejo" "forgejo" "forgejo"; "${self}/kubenix-modules/forgejo" "forgejo" "forgejo";
kubenix.paperless = mkDeployScriptAndManifest
"${self}/kubenix-modules/paperless.nix" "paperless" "paperless";
}) })

View file

@ -3,7 +3,6 @@ let
./inbucket.nix ./inbucket.nix
./syncthing.nix ./syncthing.nix
./pihole.nix ./pihole.nix
./paperless.nix
./media.nix ./media.nix
./bind9 ./bind9
./dnsmasq.nix ./dnsmasq.nix

View file

@ -70,6 +70,7 @@
hedgedoc = { }; hedgedoc = { };
kitchenowl = { }; kitchenowl = { };
forgejo = { }; forgejo = { };
paperless = { };
}; };
nodes = nodes =

View file

@ -1,46 +1,24 @@
{ {
kubernetes.resources = { kubernetes.resources = {
configMaps = { secrets = {
paperless.data = { database.stringData.password = "ref+sops://secrets/kubernetes.yaml#/paperless/databasePassword";
PAPERLESS_REDIS = "redis://paperless-redis.default.svc.cluster.local:6379"; server.stringData.secretKey = "ref+sops://secrets/kubernetes.yaml#/paperless/secretKey";
PAPERLESS_DBENGINE = "postgresql";
PAPERLESS_DBHOST = "paperless-db.default.svc.cluster.local";
PAPERLESS_DBNAME = "paperless";
PAPERLESS_DBUSER = "paperless";
PAPERLESS_DATA_DIR = "/data/";
PAPERLESS_MEDIA_ROOT = "/data/";
PAPERLESS_OCR_LANGUAGES = "nld eng";
PAPERLESS_URL = "https://paperless.kun.is";
PAPERLESS_TIME_ZONE = "Europe/Amsterdam";
PAPERLESS_OCR_LANGUAGE = "nld";
USERMAP_UID = "33";
USERMAP_GID = "33";
};
paperless-db-env.data = {
POSTGRES_DB = "paperless";
POSTGRES_USER = "paperless";
POSTGRES_PASSWORD = "ref+sops://secrets/kubernetes.yaml#/paperless/databasePassword";
PGDATA = "/pgdata/data";
};
};
secrets.paperless.stringData = {
databasePassword = "ref+sops://secrets/kubernetes.yaml#/paperless/databasePassword";
secretKey = "ref+sops://secrets/kubernetes.yaml#/paperless/secretKey";
}; };
deployments = { deployments = {
paperless-web = { server.spec = {
metadata.labels = { selector.matchLabels = {
app = "paperless"; app = "paperless";
component = "web"; component = "web";
}; };
spec = { strategy = {
selector.matchLabels = { type = "RollingUpdate";
app = "paperless";
component = "web"; rollingUpdate = {
maxSurge = 0;
maxUnavailable = 1;
};
}; };
template = { template = {
@ -50,20 +28,35 @@
}; };
spec = { spec = {
volumes.data.persistentVolumeClaim.claimName = "paperless-data"; volumes.data.persistentVolumeClaim.claimName = "data";
containers.paperless = { containers.paperless = {
image = "ghcr.io/paperless-ngx/paperless-ngx:2.3"; image = "ghcr.io/paperless-ngx/paperless-ngx:2.3";
envFrom = [{ configMapRef.name = "paperless"; }]; imagePullPolicy = "Always";
ports.web.containerPort = 8000; ports.web.containerPort = 8000;
env = { env = {
PAPERLESS_REDIS.value = "redis://redis.paperless.svc.cluster.local:6379";
PAPERLESS_DBENGINE.value = "postgresql";
PAPERLESS_DBHOST.value = "database.paperless.svc.cluster.local";
PAPERLESS_DBNAME.value = "paperless";
PAPERLESS_DBUSER.value = "paperless";
PAPERLESS_DATA_DIR.value = "/data/";
PAPERLESS_MEDIA_ROOT.value = "/data/";
PAPERLESS_OCR_LANGUAGES.value = "nld eng";
PAPERLESS_URL.value = "https://paperless.kun.is";
PAPERLESS_TIME_ZONE.value = "Europe/Amsterdam";
PAPERLESS_OCR_LANGUAGE.value = "nld";
USERMAP_UID.value = "33";
USERMAP_GID.value = "33";
PAPERLESS_DBPASS.valueFrom.secretKeyRef = { PAPERLESS_DBPASS.valueFrom.secretKeyRef = {
name = "paperless"; name = "database";
key = "databasePassword"; key = "password";
}; };
PAPERLESS_SECRET_KEY.valueFrom.secretKeyRef = { PAPERLESS_SECRET_KEY.valueFrom.secretKeyRef = {
name = "paperless"; name = "server";
key = "secretKey"; key = "secretKey";
}; };
}; };
@ -81,20 +74,22 @@
}; };
}; };
}; };
};
paperless-redis = { redis.spec = {
metadata.labels = {
app = "paperless";
component = "redis";
};
spec = {
selector.matchLabels = { selector.matchLabels = {
app = "paperless"; app = "paperless";
component = "redis"; component = "redis";
}; };
strategy = {
type = "RollingUpdate";
rollingUpdate = {
maxSurge = 0;
maxUnavailable = 1;
};
};
template = { template = {
metadata.labels = { metadata.labels = {
app = "paperless"; app = "paperless";
@ -102,11 +97,12 @@
}; };
spec = { spec = {
volumes.data.persistentVolumeClaim.claimName = "paperless-redisdata"; volumes.data.persistentVolumeClaim.claimName = "redisdata";
containers.redis = { containers.redis = {
image = "docker.io/library/redis:7"; image = "docker.io/library/redis:7";
ports.redis.containerPort = 6379; ports.redis.containerPort = 6379;
imagePullPolicy = "Always";
volumeMounts = [{ volumeMounts = [{
name = "data"; name = "data";
@ -121,20 +117,22 @@
}; };
}; };
}; };
};
paperless-db = { database.spec = {
metadata.labels = {
app = "paperless";
component = "database";
};
spec = {
selector.matchLabels = { selector.matchLabels = {
app = "paperless"; app = "paperless";
component = "database"; component = "database";
}; };
strategy = {
type = "RollingUpdate";
rollingUpdate = {
maxSurge = 0;
maxUnavailable = 1;
};
};
template = { template = {
metadata.labels = { metadata.labels = {
app = "paperless"; app = "paperless";
@ -144,9 +142,19 @@
spec = { spec = {
containers.postgres = { containers.postgres = {
image = "postgres:15"; image = "postgres:15";
imagePullPolicy = "IfNotPresent";
ports.postgres.containerPort = 5432; ports.postgres.containerPort = 5432;
envFrom = [{ configMapRef.name = "paperless-db-env"; }]; imagePullPolicy = "Always";
env = {
POSTGRES_DB.value = "paperless";
POSTGRES_USER.value = "paperless";
PGDATA.value = "/pgdata/data";
POSTGRES_PASSWORD.valueFrom.secretKeyRef = {
name = "database";
key = "password";
};
};
volumeMounts = [{ volumeMounts = [{
name = "data"; name = "data";
@ -154,15 +162,14 @@
}]; }];
}; };
volumes.data.persistentVolumeClaim.claimName = "paperless-db"; volumes.data.persistentVolumeClaim.claimName = "database";
};
}; };
}; };
}; };
}; };
services = { services = {
paperless-web.spec = { web.spec = {
selector = { selector = {
app = "paperless"; app = "paperless";
component = "web"; component = "web";
@ -174,7 +181,7 @@
}; };
}; };
paperless-redis.spec = { redis.spec = {
selector = { selector = {
app = "paperless"; app = "paperless";
component = "redis"; component = "redis";
@ -186,7 +193,7 @@
}; };
}; };
paperless-db.spec = { database.spec = {
selector = { selector = {
app = "paperless"; app = "paperless";
component = "database"; component = "database";
@ -201,13 +208,30 @@
}; };
lab = { lab = {
ingresses.paperless = { ingresses.web = {
host = "paperless.kun.is"; host = "paperless.kun.is";
service = { service = {
name = "paperless-web"; name = "web";
portName = "web"; portName = "web";
}; };
}; };
longhorn.persistentVolumeClaim = {
data = {
volumeName = "paperless-data";
storage = "10Gi";
};
redisdata = {
volumeName = "paperless-redisdata";
storage = "20Mi";
};
database = {
volumeName = "paperless-db";
storage = "150Mi";
};
};
}; };
} }

View file

@ -18,9 +18,6 @@
pihole-data.storage = "750Mi"; pihole-data.storage = "750Mi";
pihole-dnsmasq.storage = "16Mi"; pihole-dnsmasq.storage = "16Mi";
syncthing.storage = "400Mi"; syncthing.storage = "400Mi";
paperless-data.storage = "10Gi";
paperless-redisdata.storage = "20Mi";
paperless-db.storage = "150Mi";
jellyfin.storage = "5Gi"; jellyfin.storage = "5Gi";
transmission.storage = "25Mi"; transmission.storage = "25Mi";
jellyseerr.storage = "75Mi"; jellyseerr.storage = "75Mi";
@ -45,6 +42,9 @@
hedgedoc-db.storage = "100Mi"; hedgedoc-db.storage = "100Mi";
kitchenowl.storage = "100Mi"; kitchenowl.storage = "100Mi";
forgejo.storage = "20Gi"; forgejo.storage = "20Gi";
paperless-data.storage = "10Gi";
paperless-redisdata.storage = "20Mi";
paperless-db.storage = "150Mi";
}; };
nfsVolumes = { nfsVolumes = {