k8s: a pod's requests are explicit, so its limits cap and reserve nothing
This commit is contained in:
parent
6665567826
commit
eda01b8b1d
1 changed files with 114 additions and 36 deletions
|
|
@ -270,11 +270,12 @@ pkgs.testers.runNixOSTest {
|
|||
];
|
||||
};
|
||||
|
||||
# The speech-to-text pod has no requests, so the node reserves its limits
|
||||
# (3 GiB, four cores), and its image carries ffmpeg and whisper.
|
||||
# The speech-to-text image carries ffmpeg and whisper. The pod's limits
|
||||
# (3 GiB, four cores) are as large as the node's cores, so it is
|
||||
# schedulable only because it requests none of them.
|
||||
virtualisation = {
|
||||
memorySize = 10240;
|
||||
cores = 6;
|
||||
memorySize = 8192;
|
||||
cores = 4;
|
||||
diskSize = 12288;
|
||||
};
|
||||
};
|
||||
|
|
@ -483,12 +484,16 @@ pkgs.testers.runNixOSTest {
|
|||
volumes = json.loads(kube(machine, f"get pod {stt_pod} -o json"))["spec"]["volumes"]
|
||||
assert not any("secret" in v for v in volumes), volumes
|
||||
|
||||
with subtest("the speech-to-text pod carries its unit's limits, and no requests of its own"):
|
||||
# The unit sets MemoryMax=3G and CPUQuota=400%. The API server prints
|
||||
# 4000m as 4. Kubernetes fills the requests in from the limits.
|
||||
spec = json.loads(kube(machine, f"get pod {stt_pod} -o json"))["spec"]["containers"][0]["resources"]
|
||||
assert spec["limits"] == {"cpu": "4", "memory": "3Gi"}, spec
|
||||
assert spec["requests"] == spec["limits"], spec
|
||||
with subtest("the speech-to-text pod carries its unit's limits, reserves nothing, and is Burstable"):
|
||||
# The unit sets MemoryMax=3G and CPUQuota=400% and no MemoryMin or
|
||||
# MemoryLow. The API server prints 4000m as 4 and accepts the requests
|
||||
# of 0 the renderer sets.
|
||||
def pod_field(path: str) -> str:
|
||||
return kube(machine, f"get pod {stt_pod} -o jsonpath='{{{path}}}'")
|
||||
|
||||
assert json.loads(pod_field(".spec.containers[0].resources.limits")) == {"cpu": "4", "memory": "3Gi"}
|
||||
assert json.loads(pod_field(".spec.containers[0].resources.requests")) == {"cpu": "0", "memory": "0"}
|
||||
assert pod_field(".status.qosClass") == "Burstable", pod_field(".status.qosClass")
|
||||
# A pod whose unit sets neither is the control that the field is read
|
||||
# from the unit: the router's has none.
|
||||
router_resources = json.loads(kube(machine, f"get pod {router} -o json"))["spec"]["containers"][0]["resources"]
|
||||
|
|
|
|||
Loading…
Reference in a new issue