Watch
0
0
Fork
You've already forked hyperhive
0

k8s: deploy.stt.runtime moves the speech-to-text service between its container and the cluster

This commit is contained in:
atlas 2026-11-21 23:12:09 +01:00 • committed by maia
commit 68580a8725

View file

@ -98,6 +98,18 @@ let
hostUnit = "container@swarm-notify-router.service";
};
};
swarm-stt = {
inherit (deployCfg.stt) enable package;
unit = deployCfg.stt.unit;
kind = "Deployment";
healthEnv = "SWARM_STT_HEALTH_ADDR";
etcFiles = [ ];
publicCredentials.stt-bao-server-ca = baoServerCaKey;
switch = {
inherit (deployCfg.stt) runtime;
hostUnit = "container@swarm-stt.service";
};
};
swarm-ci-metrics = {
inherit (deployCfg.ci-metrics) enable package;
unit = config.systemd.services.swarm-ci-metrics;
@ -153,6 +165,43 @@ let
else
lib.toInt (lib.head m);
# A unit's `MemoryMax` as a container's memory limit. systemd's K, M, G and T
# are powers of 1024, as Kubernetes' Ki, Mi, Gi and Ti are. `infinity` is no
# limit.
memoryLimitOf =
name: value:
let
v = toString value;
m = builtins.match "([0-9]+)([KMGT]?)" v;
in
if v == "infinity" then
null
else if m == null then
fail name "MemoryMax is \"${v}\"; only a byte count, optionally with the suffix K, M, G or T, translates"
else
lib.head m
+ {
"" = "";
K = "Ki";
M = "Mi";
G = "Gi";
T = "Ti";
}
.${lib.last m};
# A unit's `CPUQuota`, a percent of one core, as a container's cpu limit in
# millicores.
cpuLimitOf =
name: value:
let
v = toString value;
m = builtins.match "([0-9]+)%" v;
in
if m == null then
fail name "CPUQuota is \"${v}\"; only \"<n>%\" translates"
else
"${toString (lib.toInt (lib.head m) * 10)}m";
workload =
name: svc:
let
@ -390,6 +439,19 @@ let
}
];
# The unit's memory and CPU ceilings are the container's limits. The unit's
# other resource settings have no pod field and stay on the host:
# `TasksMax` has no counterpart (the node's kubelet sets the pids limit),
# and the pod keeps the one security shape every pod has, in place of the
# sandbox settings (`MemoryDenyWriteExecute`, `SystemCallFilter`,
# `PrivateUsers`, ...). No `requests` are set, so Kubernetes reserves the
# limits on the node.
limits =
lib.optionalAttrs (sc ? MemoryMax && memoryLimitOf name sc.MemoryMax != null) {
memory = memoryLimitOf name sc.MemoryMax;
}
// lib.optionalAttrs (sc ? CPUQuota) { cpu = cpuLimitOf name sc.CPUQuota; };
container = {
inherit name volumeMounts;
image = "${image.imageName}:${image.imageTag}";
@ -406,6 +468,7 @@ let
capabilities.drop = [ "ALL" ];
};
}
// lib.optionalAttrs (limits != { }) { resources = { inherit limits; }; }
// lib.optionalAttrs (lib.tail execWords != [ ]) { args = lib.tail execWords; }
// lib.optionalAttrs (svc.healthEnv != null) {
ports = [