infra/homelab/tclip.nix
Gabriel Simmer 4dfb6322f7
All checks were successful
Lint / lint (push) Successful in 22s
Fully migrate tclip to kubenix
2023-10-19 14:31:52 +01:00

80 lines
2.4 KiB
Nix

let
appName = "tclip";
litestreamImage = "litestream/litestream:sha-749bc0d";
tclipImage = "git.gmem.ca/arch/tclip:arm";
in
{
kubernetes.resources."monitoring.coreos.com"."v1".ServiceMonitor.tclip = {
spec = {
selector.matchLabels.app = appName;
endpoints = [ { port = "metrics"; interval = "30s"; } ];
};
};
kubernetes.resources.services.tclip = {
metadata.annotations = {
"prometheus.io/port" = "9090";
"prometheus.io/scrape" = "true";
"prometheus.io/path" = "/metrics";
};
spec = {
selector.app = appName;
ports.metrics = {
port = 9090;
targetPort = 9090;
};
};
};
kubernetes.resources.statefulSets.tclip.spec = {
selector.matchLabels.app = appName;
serviceName = appName;
template = {
metadata.labels.app = appName;
spec = {
volumes = {
litestream.configMap.name = "tclip-litestream";
config.configMap.name = "tclip";
};
initContainers.init-litestream = {
image = litestreamImage;
args = ["restore" "-if-db-not-exists" "-if-replica-exists" "-v" "/data/data.db" ];
volumeMounts = [
{ name = "data"; mountPath = "/data"; }
{ name = "litestream"; mountPath = "/etc/litestream.yml"; subPath = "tclip.yml"; }
];
envFrom = [ { secretRef.name = "tclip-litestream-s3"; } ];
};
containers = {
tclip = {
image = tclipImage;
imagePullPolicy = "Always";
volumeMounts = [ { name = "data"; mountPath = "/data"; } ];
env = [
{ name = "DATA_DIR"; value = "/data"; }
{ name = "USE_FUNNEL"; value = "true"; }
];
};
litestream = {
image = litestreamImage;
args = [ "replicate" ];
volumeMounts = [
{ name = "data"; mountPath = "/data"; }
{ name = "litestream"; mountPath = "/etc/litestream.yml"; subPath = "tclip.yml"; }
];
envFrom = [ { secretRef.name = "tclip-litestream-s3"; } ];
ports.metrics.containerPort = 9090;
};
};
};
};
volumeClaimTemplates = [
{ metadata.name = "data";
spec = {
storageClassName = "nfs-client";
accessModes = [ "ReadWriteOnce" ];
resources.requests.storage = "1Gi";
};
}
];
};
}