2023-10-19 12:47:18 +01:00
|
|
|
let
|
|
|
|
appName = "tclip";
|
|
|
|
litestreamImage = "litestream/litestream:sha-749bc0d";
|
|
|
|
tclipImage = "git.gmem.ca/arch/tclip:arm";
|
2024-02-05 13:13:44 +00:00
|
|
|
in {
|
2023-10-19 14:31:30 +01:00
|
|
|
kubernetes.resources."monitoring.coreos.com"."v1".ServiceMonitor.tclip = {
|
|
|
|
spec = {
|
|
|
|
selector.matchLabels.app = appName;
|
2024-02-05 13:13:44 +00:00
|
|
|
endpoints = [
|
|
|
|
{
|
|
|
|
port = "metrics";
|
|
|
|
interval = "30s";
|
|
|
|
}
|
|
|
|
];
|
2023-10-19 14:31:30 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
kubernetes.resources.services.tclip = {
|
2024-03-22 21:43:18 +00:00
|
|
|
metadata.labels.app = appName;
|
2023-10-19 14:31:30 +01:00
|
|
|
spec = {
|
|
|
|
selector.app = appName;
|
|
|
|
ports.metrics = {
|
|
|
|
port = 9090;
|
|
|
|
targetPort = 9090;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-10-19 12:47:18 +01:00
|
|
|
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;
|
2024-02-05 13:13:44 +00:00
|
|
|
args = ["restore" "-if-db-not-exists" "-if-replica-exists" "-v" "/data/data.db"];
|
2023-10-19 12:47:18 +01:00
|
|
|
volumeMounts = [
|
2024-02-05 13:13:44 +00:00
|
|
|
{
|
|
|
|
name = "data";
|
|
|
|
mountPath = "/data";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "litestream";
|
|
|
|
mountPath = "/etc/litestream.yml";
|
|
|
|
subPath = "tclip.yml";
|
|
|
|
}
|
2023-10-19 12:47:18 +01:00
|
|
|
];
|
2024-02-05 13:13:44 +00:00
|
|
|
envFrom = [{secretRef.name = "tclip-litestream-s3";}];
|
2023-10-19 12:47:18 +01:00
|
|
|
};
|
|
|
|
containers = {
|
|
|
|
tclip = {
|
|
|
|
image = tclipImage;
|
|
|
|
imagePullPolicy = "Always";
|
2024-02-05 13:13:44 +00:00
|
|
|
volumeMounts = [
|
|
|
|
{
|
|
|
|
name = "data";
|
|
|
|
mountPath = "/data";
|
|
|
|
}
|
|
|
|
];
|
2023-10-19 12:47:18 +01:00
|
|
|
env = [
|
2024-02-05 13:13:44 +00:00
|
|
|
{
|
|
|
|
name = "DATA_DIR";
|
|
|
|
value = "/data";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "USE_FUNNEL";
|
|
|
|
value = "true";
|
|
|
|
}
|
2023-10-19 12:47:18 +01:00
|
|
|
];
|
|
|
|
};
|
|
|
|
litestream = {
|
|
|
|
image = litestreamImage;
|
2024-02-05 13:13:44 +00:00
|
|
|
args = ["replicate"];
|
2023-10-19 12:47:18 +01:00
|
|
|
volumeMounts = [
|
2024-02-05 13:13:44 +00:00
|
|
|
{
|
|
|
|
name = "data";
|
|
|
|
mountPath = "/data";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "litestream";
|
|
|
|
mountPath = "/etc/litestream.yml";
|
|
|
|
subPath = "tclip.yml";
|
|
|
|
}
|
2023-10-19 12:47:18 +01:00
|
|
|
];
|
2024-02-05 13:13:44 +00:00
|
|
|
envFrom = [{secretRef.name = "tclip-litestream-s3";}];
|
2024-03-22 21:43:18 +00:00
|
|
|
ports.metrics = {
|
|
|
|
containerPort = 9090;
|
|
|
|
name = "metrics";
|
|
|
|
};
|
2023-10-19 12:47:18 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
volumeClaimTemplates = [
|
2024-02-05 13:13:44 +00:00
|
|
|
{
|
|
|
|
metadata.name = "data";
|
2023-10-19 12:47:18 +01:00
|
|
|
spec = {
|
|
|
|
storageClassName = "nfs-client";
|
2024-02-05 13:13:44 +00:00
|
|
|
accessModes = ["ReadWriteOnce"];
|
2023-10-19 12:47:18 +01:00
|
|
|
resources.requests.storage = "1Gi";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|