Repository navigation
Description
Update 2026-11-26 (infra move): The node label belongs to dan-petty/homelab.
This item keeps the runner affinity and its checks in k8s/devops/. The label is the homelab follow-up and must exist first. docs/K8S_PERFORMANCE.md is now docs/guidelines/kubernetes.md, which has no query Q10 or target T14. dan-petty/homelab#13 is closed.
Follow-up: dan-petty/homelab#302.
Problem or Motivation
In the 7 days to 2026-11-13, 47 of 47 runner pods ran on <control-plane-node>. The runner Job template (k8s/devops/cronjob-runner.yaml) sets no node selector and no affinity. The default scheduler prefers the node with the most free resources (LeastAllocated), and <control-plane-node> has 48 CPUs, so it takes every Job.
That node also runs the k3s server. It reserves no memory for the system and has no memory eviction threshold (dan-petty/homelab#13). The memory limit of a runner Job is 16Gi above a request of 2Gi or 6Gi, and the scheduler places a pod by its request only. So:
- A runner Job that bursts takes memory from the k3s server.
- When
<parked-node>(12.8 GiB allocatable) is uncordoned (#5143), a Job with a6Girequest can go there and burst past the memory of the node.
Proposed Solution & Architectural Design
- Keep each runner Job on a node whose allocatable memory is at or above
roadmap.implement.max_memory_limit. Use a standard control: a node label that the node-provisioning automation sets on such nodes and a required node affinity (ornodeSelector) in the Job template, or a taint on the small node. - Prefer the GPU workers to
<control-plane-node>with a preferred node affinity on the labelnode-role.kubernetes.io/control-plane. Do this after dan-petty/homelab#13 gives the node a memory reserve, and measure the effect with the tuning loop ofdocs/K8S_PERFORMANCE.md. - Check that the admission policy
roadmap-service-jobsadmits the new fields. It does not pinnodeSelectorandtolerationstoday.
Acceptance Criteria
- A test proves that the runner Job that the Service builds holds the placement rule, and that the admission policy admits it.
- Live proof after the merge: query Q10 of
docs/K8S_PERFORMANCE.mdshows no runner pod on a node with less allocatable memory than the limit, and shows the runner pods on the workers while a worker has room, over 7 days.
Target Subsystem
Kubernetes (k8s/devops/cronjob-runner.yaml, k8s/devops/roadmap-service/admissionpolicy.yaml, src/devops_cli/roadmap/implement/).
Existing Tool Considered
Kubernetes node affinity, node labels and taints cover the need. No new tool. Cost to build (estimate): 150,000 tokens and 2 hours.
Related
docs/K8S_PERFORMANCE.md (#5444), target T14 and gap "Every runner Job runs on the control-plane node". #5013 (PriorityClass), dan-petty/homelab#13 (kubelet reserve and eviction).
Source: #5444
Alternatives check of 2026-11-23: in-use.
The repository already uses this tool.
Tool: kubernetes/kubernetes (https://github.com/kubernetes/kubernetes), Apache-2.0, last activity 2026-11-21, maintained.
Reason: Searches found no other tool that fits pods to a node's memory; the scheduler's required node affinity, node labels and taints cover the whole placement need, and the issue names them as the tool already in use.
Covers:
- Required node affinity pins each runner Job to labeled nodes
- Node labels mark nodes whose allocatable memory fits the limit
- Preferred affinity can steer GPU workers to the control-plane node
- Taints keep small nodes free of runner Jobs
Lacks:
- No node is labeled by this repository; the infra repo must set it
- Scheduler places by request, so the label must track the memory limit
- No built-in check or query that a live pod landed on a fitting node
Proposed design
Problem statement
Runner Jobs run on the control-plane node. The scheduler prefers the node with the most free resources, and the runner Job template sets no placement rule. The control-plane node also runs the k3s server. A runner Job that bursts can take memory from the server. A small node with 12.8 GiB allocatable cannot hold the memory limit of a Job. The change must keep each runner Job on a node that can hold its memory limit.
Acceptance criteria
Requirement: Runner Job requires a memory-fit node
The runner Job template SHALL set a required node affinity on the node label devops-cli/runner-memory-fit with the operator In and the value true.
Scenario: The k8s gate check accepts the required affinity
- WHEN
uv run devops ci --check --only k8sruns the runner placement check on the Job that CronJobdevops-cli-runnermakes fromk8s/devops/cronjob-runner.yaml - THEN The check passes and reports the required node affinity on
devops-cli/runner-memory-fitwith the operatorInand the valuetrue.
Requirement: The Service Job builder keeps the required affinity
The Service Job builder SHALL keep the required node affinity of the template in the runner Job it creates.
Scenario: The builder keeps the required affinity
- WHEN
uv run pytest tests/roadmap/implement/test_runner_placement.pycalls the builder with a template that holds the required node affinity ondevops-cli/runner-memory-fit - THEN The test passes and the Job holds the required node affinity on
devops-cli/runner-memory-fitwith the operatorInand the valuetrue.
Requirement: The placement check rejects a Job without the required affinity
The runner placement check MUST fail when the runner Job template has no required node affinity on devops-cli/runner-memory-fit.
Scenario: The placement check rejects a Job with the required term removed
- WHEN
uv run pytest tests/gate/k8s_checks/test_runner_placement.pyruns the placement check on a rendered runner Job with the required term removed - THEN The test passes and the placement check raises an error that names the missing required node affinity on
devops-cli/runner-memory-fit.
Requirement: The admission policy admits the runner Job
The roadmap-service-jobs admission policy MUST admit the runner Job that the template builds with the required node affinity.
Scenario: The k8s gate check admits the runner Job
- WHEN
uv run devops ci --check --only k8sruns the admission policy check on the Job that CronJobdevops-cli-runnermakes - THEN The check passes and reports that
roadmap-service-jobsadmits the Job with the required node affinity.
Requirement: Pending a person after the merge
After the merge, the live check SHALL show no runner container on a node with less allocatable memory than the memory limit of that container.
Scenario: The live query returns no runner container over the memory of its node
- WHEN
uv run devops prometheus query 'max by (namespace,pod,node,container) (kube_pod_container_resource_limits{namespace="devops",resource="memory",pod=~"devops-cli-runner-.*"} or kube_pod_init_container_resource_limits{namespace="devops",resource="memory",pod=~"devops-cli-runner-.*"}) > on(node) group_left() max by (node) (kube_node_status_allocatable{resource="memory"})'runs over the last 7 days - THEN The query returns no series.
Existing Tool Considered
The alternatives check in the issue body records the verdict in-use for kubernetes/kubernetes (Apache-2.0, last activity 2026-11-21, maintained) on 2026-11-23. The block of that check lists what the tool covers and lacks. This change uses the scheduler's required node affinity in k8s/devops/cronjob-runner.yaml and adds no placement code. The infra repo dan-petty/homelab sets the label in homelab#302, and the proposal records that as the suspected block. The k8s gate check proves the Job holds the rule and the admission policy admits it.
Key questions
- Which control keeps a runner Job off a node whose allocatable memory is below its memory limit?: Use a required node affinity on the boolean label
devops-cli/runner-memory-fit=true. A hard rule keeps a Job whose limit is above its request off a node that cannot hold the limit. A preferred affinity can be ignored. A taint keeps every pod off the small node, not only a runner Job. (best practice) [sources: docs/guidelines/kubernetes.md, k8s/devops/cronjob-runner.yaml]- Chosen: Required node affinity on a boolean label. The scheduler enforces it for every Job. The same
affinityfield can hold the later preferred term. - Rejected: Preferred node affinity. The scheduler can ignore it. A Job can still land on a node that cannot hold its limit.
- Rejected: Taint on the small node. It keeps every pod off the node, not only a runner Job. It needs a change in the infra repo for each small node.
- Rejected:
nodeSelectoron the label. It is valid, but the required node affinity keeps theaffinityfield for the later preferred term and states the operator.
- Chosen: Required node affinity on a boolean label. The scheduler enforces it for every Job. The same
- Which node label does the required affinity select, and who sets it?: Use the boolean label
devops-cli/runner-memory-fit=true. The node-provisioning automation of the infra repodan-petty/homelabsets it in homelab#302 on each node whose allocatable memory is at or aboveroadmap.implement.max_memory_limit. A boolean label keeps no second copy of the limit in the manifest. (best practice) [sources: CONTEXT.md, docs/guidelines/kubernetes.md, k8s/devops/cronjob-runner.yaml]- Chosen: Boolean label set for the configured maximum. The manifest holds no number that a change of
roadmap.implement.max_memory_limitwould make stale. - Rejected: Integer label with the operator
Gt. The threshold in the manifest would be a second copy of the setting. - Rejected: Existing
node-role.kubernetes.io/control-planelabel. It excludes the control-plane node but still admits a small worker node that cannot hold the memory limit.
- Chosen: Boolean label set for the configured maximum. The manifest holds no number that a change of
- Does the
roadmap-service-jobsadmission policy admit a runner Job with the new affinity?: Yes. The policy filek8s/devops/roadmap-service/admissionpolicy.yamldoes not referenceaffinity. The gate check builds the Job that the Service makes from the template and runs every expression against it. The policy file needs no change. [sources: k8s/devops/roadmap-service/admissionpolicy.yaml] - Does the preferred affinity for GPU workers ship in this change?: No. Defer it. The issue says to do it after the control-plane node gets a memory reserve and to measure the effect. The current change adds only the required memory-fit affinity. (best practice) [sources: docs/guidelines/kubernetes.md]
- Chosen: Defer the preferred affinity. The step waits on an outside change and a 7-day measurement. The required affinity does not need either.
- Rejected: Ship the preferred affinity now. It contradicts the order in the issue and cannot be measured at merge time.
- Rejected: Ship a preferred affinity toward the control-plane node. The issue makes that step wait on the memory reserve.
- Can the 7-day live proof be an acceptance criterion of this change?: Yes, as a criterion named
Pending a person after the merge. A pull request cannot show 7 days of runtime before the merge. The person runs the PromQL query after the merge. The proof uses the tuning loop ofdocs/guidelines/kubernetes.md. (best practice) [sources: docs/guidelines/kubernetes.md]- Chosen: Post-merge live criterion named
Pending a person after the merge. The instruction for a post-release live proof gives this form. The query reads cluster history after the merge. - Rejected: Defer the live proof to a verification issue. The issue asks for the live proof after the merge, and a criterion can hold the person step.
- Rejected: Keep the live proof as a pre-merge gate. No command shows 7 days of runtime at merge time.
- Chosen: Post-merge live criterion named
- Where must the label exist, and what does this change wait on?: The label must be on each node that may run a runner Job. The node-provisioning automation of the infra repo
dan-petty/homelabsets it in homelab#302. No manifest of this repository labels a node. Until the label exists, a runner Job with the required affinity stays Pending. The label must be on the nodes before this change merges. [sources: CONTEXT.md, docs/guidelines/kubernetes.md, k8s/devops/cronjob-runner.yaml]
Fit
Fits in one pull request.
Suspected block
The node label devops-cli/runner-memory-fit=true must exist on each node that may run a runner Job before this change merges; the infra repo dan-petty/homelab sets it in homelab#302, and this repository labels no node.
Dependencies
None.
Activity
dan-petty commentedon Nov 13, 2026
Both modify the runner Job template in cronjob-runner.yaml, but dan-petty/devops-cli#3193 sizes the CPU and memory requests while this item adds node affinity to choose the placement node.docs(k8s): map each gap of the performance spec to its issue
devops-cli-service commentedon Nov 17, 2026
Alternatives check: in-use
Reason: The searches returned only scheduler add-ons (kubernetes-sigs/descheduler, kubernetes-sigs/scheduler-plugins) beside the Kubernetes scheduler itself, and the placement rule the issue wants is a core Kubernetes scheduling control that the cluster already runs: a required node affinity or nodeSelector on a node label, plus a preferred affinity toward
node-role.kubernetes.io/control-plane, covers the whole need with no new component. The issue already names Kubernetes node affinity, node labels and taints as the tool that covers it, so no additional tool is required.The repository already uses this tool.
Tool: kubernetes/kubernetes (https://github.com/kubernetes/kubernetes)
Covers:
Lacks:
dan-petty/homelab#13Tools considered:
Searches run:
Sources:
Checked on 2026-11-17. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 18, 2026
Owner question: The node label
devops-cli/runner-memory-fitmust be on each node that may run a runner Job before this template change merges; the node-provisioning automation of the infra repo dan-petty/homelab sets it, and this repository labels no node.Options
Recommendation: Decide the question: only a person can answer it.
Evidence
devops-cli-service commentedon Nov 21, 2026
Owner question: See Suspected block in the section Proposed design of the body.
Options
Recommendation: Decide the question: only a person can answer it.
Evidence
devops-cli-service commentedon Nov 21, 2026
Owner question: See Suspected block in the section Proposed design of the body.
Options
Recommendation: Decide the question: only a person can answer it.
Evidence
devops-cli-service commentedon Nov 27, 2026
Owner question: See Suspected block in the section Proposed design of the body.
Options
Recommendation: Decide the question: only a person can answer it.
Evidence
dan-petty commentedon Nov 27, 2026
The node label that this item needs has a pull request: dan-petty/homelab#536 (for dan-petty/homelab#302).
ansible/playbooks/18_runner_memory_fit.yaml(make runner-memory-fit) setsdevops-cli/runner-memory-fit=trueon each node whose allocatable memory is at or aboveroadmap.implement.max_memory_limitof ConfigMapdevops/devops-cli-config, and removes it from the other nodes.16Gi, a check-mode plan labels hog, condor, gemini and bombas, and not hawk (allocatable 12320184Ki).k3s_memory_reserved.dan-petty commentedon Nov 27, 2026
Closed as not planned. Owner, 2026-11-27: no custom node label for this. #7422 sets the memory limit of each runner Job equal to its request, so the scheduler keeps a Job off a node that cannot hold it. dan-petty/homelab#302 (the label play) is closed too. Part 2 of this item (protect the k3s server on the control-plane node): after #7422 a Job cannot use more memory than it reserved, so it cannot take memory from the server. The scheduler can still place Jobs on that node; the reserve of the server itself is the kubelet
system-reservedsetting (dan-petty/homelab#13).