nixos-servers/kubenix-modules/immich.nix

263 lines
6.2 KiB
Nix
Raw Normal View History

{ myLib, ... }: {
2024-06-16 14:46:08 +00:00
kubernetes.resources = {
secrets.immich.stringData.databasePassword = "ref+sops://secrets/kubernetes.yaml#/immich/databasePassword";
2024-06-16 14:46:08 +00:00
deployments = {
immich.spec = {
selector.matchLabels = {
2024-06-16 14:46:08 +00:00
app = "immich";
component = "server";
};
strategy = {
type = "RollingUpdate";
rollingUpdate = {
maxSurge = 0;
maxUnavailable = 1;
};
};
template = {
metadata.labels = {
2024-06-16 14:46:08 +00:00
app = "immich";
component = "server";
};
spec = {
volumes.data.persistentVolumeClaim.claimName = "data";
2024-06-16 14:46:08 +00:00
enableServiceLinks = false;
2024-06-16 14:46:08 +00:00
containers.immich = {
2024-07-30 19:28:35 +00:00
image = myLib.globals.images.immich;
imagePullPolicy = "IfNotPresent";
ports.web.containerPort = 3001;
2024-06-16 14:46:08 +00:00
env = {
TZ.value = "Europe/Amsterdam";
REDIS_HOSTNAME.value = "redis.immich.svc.cluster.local";
DB_HOSTNAME.value = "postgres.immich.svc.cluster.local";
DB_USERNAME.value = "postgres";
DB_DATABASE_NAME.value = "immich";
IMMICH_MACHINE_LEARNING_URL.value = "http://ml.immich.svc.cluster.local";
DB_PASSWORD.valueFrom.secretKeyRef = {
name = "immich";
key = "databasePassword";
};
2024-06-16 14:46:08 +00:00
};
volumeMounts = [{
name = "data";
mountPath = "/usr/src/app/upload";
}];
2024-06-16 14:46:08 +00:00
};
};
};
};
ml.spec = {
selector.matchLabels = {
2024-06-16 14:46:08 +00:00
app = "immich";
component = "machine-learning";
};
strategy = {
type = "RollingUpdate";
rollingUpdate = {
maxSurge = 0;
maxUnavailable = 1;
};
};
template = {
metadata.labels = {
2024-06-16 14:46:08 +00:00
app = "immich";
component = "machine-learning";
};
spec = {
volumes.cache.persistentVolumeClaim.claimName = "cache";
2024-06-20 19:35:13 +00:00
containers.machine-learning = {
image = myLib.globals.images.immich-machine-learning;
imagePullPolicy = "IfNotPresent";
ports.ml.containerPort = 3003;
env.MACHINE_LEARNING_WORKER_TIMEOUT.value = "600";
2024-06-20 19:35:13 +00:00
volumeMounts = [{
name = "cache";
mountPath = "/cache";
}];
2024-06-16 14:46:08 +00:00
};
};
};
};
redis.spec = {
selector.matchLabels = {
2024-06-16 14:46:08 +00:00
app = "immich";
component = "redis";
};
strategy = {
type = "RollingUpdate";
2024-06-16 14:46:08 +00:00
rollingUpdate = {
maxSurge = 0;
maxUnavailable = 1;
2024-06-16 14:46:08 +00:00
};
};
2024-06-16 14:46:08 +00:00
template = {
metadata.labels = {
app = "immich";
component = "redis";
};
2024-06-16 14:46:08 +00:00
spec = {
containers.redis = {
image = myLib.globals.images.immich-redis;
ports.redis.containerPort = 6379;
imagePullPolicy = "IfNotPresent";
2024-06-16 14:46:08 +00:00
};
};
};
};
database.spec = {
selector.matchLabels = {
2024-06-16 14:46:08 +00:00
app = "immich";
component = "database";
};
strategy = {
type = "RollingUpdate";
2024-06-16 14:46:08 +00:00
rollingUpdate = {
maxSurge = 0;
maxUnavailable = 1;
2024-06-16 14:46:08 +00:00
};
};
2024-06-16 14:46:08 +00:00
template = {
metadata.labels = {
app = "immich";
component = "database";
};
2024-06-16 14:46:08 +00:00
spec = {
volumes.data.persistentVolumeClaim.claimName = "database";
containers.postgres = {
image = myLib.globals.images.immich-postgres;
imagePullPolicy = "IfNotPresent";
command = [ "postgres" ];
args = [ "-c" "shared_preload_libraries=vectors.so" "-c" "search_path=\"$$user\", public, vectors" "-c" "logging_collector=on" "-c" "max_wal_size=2GB" "-c" "shared_buffers=512MB" "-c" "wal_compression=on" ];
ports.postgres.containerPort = 5432;
securityContext.runAsUser = 999;
securityContext.runAsGroup = 999;
env = {
POSTGRES_USER.value = "postgres";
POSTGRES_DB.value = "immich";
POSTGRES_INITDB_ARGS.value = "--data-checksums";
PGDATA.value = "/pgdata/data";
POSTGRES_PASSWORD.valueFrom.secretKeyRef = {
name = "immich";
key = "databasePassword";
};
2024-06-16 14:46:08 +00:00
};
volumeMounts = [{
name = "data";
mountPath = "/pgdata";
}];
2024-06-16 14:46:08 +00:00
};
};
};
};
};
services = {
server.spec = {
type = "LoadBalancer";
loadBalancerIP = myLib.globals.immichIPv4;
2024-06-16 14:46:08 +00:00
selector = {
app = "immich";
component = "server";
};
ports.web = {
port = 80;
targetPort = "web";
};
};
redis.spec = {
2024-06-16 14:46:08 +00:00
selector = {
app = "immich";
component = "redis";
};
ports.redis = {
port = 6379;
targetPort = "redis";
};
};
ml.spec = {
2024-06-16 14:46:08 +00:00
selector = {
app = "immich";
component = "machine-learning";
};
2024-06-20 19:35:13 +00:00
ports.ml = {
2024-06-16 14:46:08 +00:00
port = 80;
targetPort = "ml";
};
};
postgres.spec = {
2024-06-16 14:46:08 +00:00
selector = {
app = "immich";
component = "database";
};
ports.postgres = {
port = 5432;
targetPort = "postgres";
};
};
};
2024-06-20 19:35:13 +00:00
persistentVolumeClaims.cache.spec = {
2024-06-20 19:35:13 +00:00
accessModes = [ "ReadWriteOnce" ];
resources.requests.storage = "5Gi";
};
2024-06-16 14:46:08 +00:00
};
lab = {
tailscaleIngresses.tailscale = {
host = "immich";
service.name = "server";
};
longhorn.persistentVolumeClaim = {
data = {
volumeName = "immich";
storage = "50Gi";
};
database = {
volumeName = "immich-db";
storage = "5Gi";
};
2024-06-16 14:46:08 +00:00
};
};
}