2024-07-30 19:28:35 +00:00
|
|
|
{ pkgs, myLib, ... }: {
|
2024-04-27 18:53:32 +00:00
|
|
|
kubernetes.resources =
|
|
|
|
let
|
2024-05-25 15:02:35 +00:00
|
|
|
atticSettings = {
|
2024-07-16 16:38:47 +00:00
|
|
|
# The '+" is to explicitly denote the end of the Vals expression.
|
|
|
|
# This is done because we quote the template for the INI file.
|
|
|
|
# See: https://github.com/helmfile/vals?tab=readme-ov-file#expression-syntax
|
|
|
|
database.url = "ref+sops://secrets/kubernetes.yaml#attic/databaseURL+";
|
2024-04-26 21:32:31 +00:00
|
|
|
|
2024-04-27 18:53:32 +00:00
|
|
|
storage = {
|
|
|
|
type = "local";
|
|
|
|
path = "/var/lib/atticd/storage";
|
|
|
|
};
|
|
|
|
|
|
|
|
listen = "[::]:8080";
|
|
|
|
|
|
|
|
# Data chunking
|
|
|
|
#
|
|
|
|
# Warning: If you change any of the values here, it will be
|
|
|
|
# difficult to reuse existing chunks for newly-uploaded NARs
|
|
|
|
# since the cutpoints will be different. As a result, the
|
|
|
|
# deduplication ratio will suffer for a while after the change.
|
|
|
|
chunking = {
|
|
|
|
# The minimum NAR size to trigger chunking
|
|
|
|
#
|
|
|
|
# If 0, chunking is disabled entirely for newly-uploaded NARs.
|
|
|
|
# If 1, all NARs are chunked.
|
|
|
|
nar-size-threshold = 64 * 1024; # 64 KiB
|
|
|
|
|
|
|
|
# The preferred minimum size of a chunk, in bytes
|
|
|
|
min-size = 16 * 1024; # 16 KiB
|
|
|
|
|
|
|
|
# The preferred average size of a chunk, in bytes
|
|
|
|
avg-size = 64 * 1024; # 64 KiB
|
|
|
|
|
|
|
|
# The preferred maximum size of a chunk, in bytes
|
|
|
|
max-size = 256 * 1024; # 256 KiB
|
|
|
|
};
|
|
|
|
};
|
2024-05-25 15:02:35 +00:00
|
|
|
generatedConfig = (pkgs.formats.toml { }).generate "attic.toml" atticSettings;
|
2024-04-27 18:53:32 +00:00
|
|
|
in
|
|
|
|
{
|
2024-07-16 16:38:47 +00:00
|
|
|
secrets = {
|
2024-08-04 12:59:11 +00:00
|
|
|
server.stringData = {
|
|
|
|
token = "ref+sops://secrets/kubernetes.yaml#attic/jwtToken";
|
|
|
|
config = builtins.readFile generatedConfig;
|
|
|
|
};
|
|
|
|
|
2024-07-16 16:38:47 +00:00
|
|
|
database.stringData.password = "ref+sops://secrets/kubernetes.yaml#/attic/databasePassword";
|
2024-04-27 18:53:32 +00:00
|
|
|
};
|
2024-04-26 21:32:31 +00:00
|
|
|
|
2024-05-25 15:02:35 +00:00
|
|
|
deployments = {
|
2024-07-16 16:38:47 +00:00
|
|
|
attic.spec = {
|
|
|
|
selector.matchLabels = {
|
2024-05-25 15:02:35 +00:00
|
|
|
app = "attic";
|
|
|
|
component = "website";
|
|
|
|
};
|
2024-04-27 18:53:32 +00:00
|
|
|
|
2024-08-04 12:59:11 +00:00
|
|
|
strategy = {
|
|
|
|
type = "RollingUpdate";
|
|
|
|
|
|
|
|
rollingUpdate = {
|
|
|
|
maxSurge = 0;
|
|
|
|
maxUnavailable = 1;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-07-16 16:38:47 +00:00
|
|
|
template = {
|
|
|
|
metadata.labels = {
|
2024-05-25 15:02:35 +00:00
|
|
|
app = "attic";
|
|
|
|
component = "website";
|
|
|
|
};
|
2024-04-27 18:53:32 +00:00
|
|
|
|
2024-07-16 16:38:47 +00:00
|
|
|
spec = {
|
|
|
|
containers.attic = {
|
2024-07-30 19:28:35 +00:00
|
|
|
image = myLib.globals.images.attic;
|
2024-07-16 16:38:47 +00:00
|
|
|
ports.web.containerPort = 8080;
|
|
|
|
args = [ "-f" "/etc/atticd/config.toml" ];
|
2024-04-27 18:53:32 +00:00
|
|
|
|
2024-07-16 16:38:47 +00:00
|
|
|
env.ATTIC_SERVER_TOKEN_HS256_SECRET_BASE64.valueFrom.secretKeyRef = {
|
|
|
|
name = "server";
|
|
|
|
key = "token";
|
2024-05-25 15:02:35 +00:00
|
|
|
};
|
|
|
|
|
2024-07-16 16:38:47 +00:00
|
|
|
volumeMounts = [
|
|
|
|
{
|
|
|
|
name = "data";
|
|
|
|
mountPath = "/var/lib/atticd/storage";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "config";
|
|
|
|
mountPath = "/etc/atticd/config.toml";
|
|
|
|
subPath = "config";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2024-05-25 15:02:35 +00:00
|
|
|
|
2024-07-16 16:38:47 +00:00
|
|
|
volumes = {
|
|
|
|
data.persistentVolumeClaim.claimName = "data";
|
2024-08-04 12:59:11 +00:00
|
|
|
config.secret.secretName = "server";
|
2024-07-16 16:38:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
securityContext = {
|
|
|
|
fsGroup = 0;
|
|
|
|
fsGroupChangePolicy = "OnRootMismatch";
|
2024-04-27 18:53:32 +00:00
|
|
|
};
|
2024-05-25 15:02:35 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-04-27 18:53:32 +00:00
|
|
|
|
2024-07-16 16:38:47 +00:00
|
|
|
attic-db.spec = {
|
|
|
|
selector.matchLabels = {
|
2024-05-25 15:02:35 +00:00
|
|
|
app = "attic";
|
|
|
|
component = "database";
|
|
|
|
};
|
|
|
|
|
2024-07-16 16:38:47 +00:00
|
|
|
template = {
|
|
|
|
metadata.labels = {
|
2024-05-25 15:02:35 +00:00
|
|
|
app = "attic";
|
|
|
|
component = "database";
|
|
|
|
};
|
|
|
|
|
2024-07-16 16:38:47 +00:00
|
|
|
spec = {
|
|
|
|
containers.postgres = {
|
2024-08-30 15:49:11 +00:00
|
|
|
image = myLib.globals.images.postgres15;
|
2024-07-16 16:38:47 +00:00
|
|
|
imagePullPolicy = "IfNotPresent";
|
|
|
|
ports.postgres.containerPort = 5432;
|
|
|
|
|
|
|
|
env = {
|
|
|
|
POSTGRES_DB.value = "attic";
|
|
|
|
POSTGRES_USER.value = "attic";
|
|
|
|
PGDATA.value = "/pgdata/data";
|
|
|
|
|
|
|
|
POSTGRES_PASSWORD.valueFrom.secretKeyRef = {
|
|
|
|
name = "database";
|
|
|
|
key = "password";
|
|
|
|
};
|
2024-05-25 15:02:35 +00:00
|
|
|
};
|
|
|
|
|
2024-07-16 16:38:47 +00:00
|
|
|
volumeMounts = [{
|
|
|
|
name = "data";
|
|
|
|
mountPath = "/pgdata";
|
|
|
|
}];
|
2024-05-23 20:52:05 +00:00
|
|
|
};
|
2024-07-16 16:38:47 +00:00
|
|
|
|
|
|
|
volumes.data.persistentVolumeClaim.claimName = "database";
|
2024-04-26 21:32:31 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-05-25 15:02:35 +00:00
|
|
|
services = {
|
|
|
|
attic.spec = {
|
|
|
|
selector = {
|
|
|
|
app = "attic";
|
|
|
|
component = "website";
|
|
|
|
};
|
2024-04-26 21:32:31 +00:00
|
|
|
|
2024-05-25 15:02:35 +00:00
|
|
|
ports.web = {
|
|
|
|
port = 80;
|
|
|
|
targetPort = "web";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-07-16 16:38:47 +00:00
|
|
|
database.spec = {
|
2024-05-25 15:02:35 +00:00
|
|
|
selector = {
|
|
|
|
app = "attic";
|
|
|
|
component = "database";
|
|
|
|
};
|
|
|
|
|
|
|
|
ports.postgres = {
|
|
|
|
port = 5432;
|
|
|
|
targetPort = "postgres";
|
|
|
|
};
|
2024-04-27 18:53:32 +00:00
|
|
|
};
|
2024-04-26 21:32:31 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
lab = {
|
2024-05-25 15:02:35 +00:00
|
|
|
ingresses.attic = {
|
2024-04-26 21:32:31 +00:00
|
|
|
host = "attic.kun.is";
|
|
|
|
|
|
|
|
service = {
|
2024-05-25 15:02:35 +00:00
|
|
|
name = "attic";
|
2024-04-26 21:32:31 +00:00
|
|
|
portName = "web";
|
|
|
|
};
|
|
|
|
};
|
2024-07-16 16:38:47 +00:00
|
|
|
|
|
|
|
longhorn.persistentVolumeClaim = {
|
|
|
|
data = {
|
|
|
|
volumeName = "attic";
|
|
|
|
storage = "15Gi";
|
|
|
|
};
|
|
|
|
|
|
|
|
database = {
|
|
|
|
volumeName = "attic-db";
|
|
|
|
storage = "150Mi";
|
|
|
|
};
|
|
|
|
};
|
2024-04-26 21:32:31 +00:00
|
|
|
};
|
|
|
|
}
|