nixos-servers/kubenix-modules/attic.nix

182 lines
4.8 KiB
Nix
Raw Normal View History

2024-04-27 18:53:32 +00:00
{ pkgs, ... }: {
kubernetes.resources =
let
2024-05-25 15:02:35 +00:00
atticSettings = {
2024-06-15 20:27:07 +00:00
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
{
configMaps = {
2024-06-15 20:27:07 +00:00
attic-env.data.ATTIC_SERVER_TOKEN_HS256_SECRET_BASE64 = "ref+sops://secrets/kubernetes.yaml#attic/jwtToken";
2024-05-25 15:02:35 +00:00
attic-config.data.config = builtins.readFile generatedConfig;
attic-db-env.data = {
POSTGRES_DB = "attic";
POSTGRES_USER = "attic";
2024-06-15 20:27:07 +00:00
POSTGRES_PASSWORD = "ref+sops://secrets/kubernetes.yaml#/attic/databasePassword";
2024-05-25 15:02:35 +00:00
PGDATA = "/pgdata/data";
};
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 = {
attic = {
metadata.labels = {
app = "attic";
component = "website";
};
2024-04-27 18:53:32 +00:00
2024-05-25 15:02:35 +00:00
spec = {
selector.matchLabels = {
app = "attic";
component = "website";
};
2024-04-27 18:53:32 +00:00
2024-05-25 15:02:35 +00:00
template = {
metadata.labels = {
app = "attic";
component = "website";
};
2024-04-27 18:53:32 +00:00
2024-05-25 15:02:35 +00:00
spec = {
containers.attic = {
image = "git.kun.is/home/atticd:fd910d91c2143295e959d2c903e9ea25cf94ba27";
envFrom = [{ configMapRef.name = "attic-env"; }];
ports.web.containerPort = 8080;
args = [ "-f" "/etc/atticd/config.toml" ];
volumeMounts = [
{
name = "data";
mountPath = "/var/lib/atticd/storage";
}
{
name = "config";
mountPath = "/etc/atticd/config.toml";
subPath = "config";
}
];
};
volumes = {
data.persistentVolumeClaim.claimName = "attic";
config.configMap.name = "attic-config";
};
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-05-25 15:02:35 +00:00
attic-db = {
metadata.labels = {
app = "attic";
component = "database";
};
spec = {
selector.matchLabels = {
app = "attic";
component = "database";
};
template = {
metadata.labels = {
app = "attic";
component = "database";
2024-04-27 18:53:32 +00:00
};
2024-05-23 20:52:05 +00:00
2024-05-25 15:02:35 +00:00
spec = {
containers.postgres = {
image = "postgres:15";
imagePullPolicy = "IfNotPresent";
ports.postgres.containerPort = 5432;
envFrom = [{ configMapRef.name = "attic-db-env"; }];
volumeMounts = [{
name = "data";
mountPath = "/pgdata";
}];
};
volumes.data.persistentVolumeClaim.claimName = "attic-db";
2024-05-23 20:52:05 +00:00
};
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";
};
};
attic-db.spec = {
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";
2024-06-01 09:12:43 +00:00
# entrypoint = "localsecure";
2024-04-26 21:32:31 +00:00
service = {
2024-05-25 15:02:35 +00:00
name = "attic";
2024-04-26 21:32:31 +00:00
portName = "web";
};
};
};
}