Skip to content

feat: add an opt-in input to require one node per host - #72

Merged
scarmuega merged 1 commit into
mainfrom
feat/required-host-spread
Oct 5, 2026
Merged

scarmuega merged 1 commit into
mainfrom
feat/required-host-spread

Conversation

@scarmuega

Copy link
Copy Markdown
Member

Adds spread_hosts_required (default false) to instances. When true, the host anti-affinity that spread_hosts renders as preferred is rendered as required instead, and the input implies spread_hosts.

Why

With a preferred term, a node whose host goes away can be rescheduled onto a host that already runs another node of the same network, and nothing moves it apart later. Where the node group replaces lost hosts promptly and keeps one host per node, a required term costs a short wait and keeps each node on its own host.

Change

  • bootstrap/instance: new spread_hosts_required variable. pod_anti_affinity renders either the required or the preferred term, with the same topology key (kubernetes.io/hostname) and selector (role=node, the instance's network).
  • bootstrap: spread_hosts_required = optional(bool, false) in instances, passed through.
  • README: a row in the pool-capacity inputs table.

Instances that don't set it render exactly as before.

Tests

terraform test in bootstrap/: 22 passed, 0 failed. The new runs check that the required term replaces the preferred one and keeps the node affinity, and that setting the input alone renders the required term.

Rollout note

Node StatefulSets use RollingUpdate, so enabling this on existing instances restarts each node. Apply one instance at a time.

🤖 Generated with Claude Code

spread_hosts renders a preferred pod anti-affinity. When a node's host
goes away and another host that already runs a node of the same network
has room, the replacement pod doubles up there, and nothing moves it
apart later.

Add spread_hosts_required (default false). When true, the same term
(topology key kubernetes.io/hostname, selecting role=node and the
instance's network) is rendered as required instead of preferred, and
it implies spread_hosts. A displaced pod then waits Pending until a
host without a node of its network has room. Use it where the node
group replaces a lost host promptly and keeps at least one host per
node.

Instances that don't set it render exactly as before.

Tests: two new runs in node_capacity.tftest.hcl (the required term
replaces the preferred one and keeps the node affinity; setting the
input alone renders the required term). The root pass-through run gets
an instance that sets it. terraform test: 22 passed, 0 failed.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@scarmuega
scarmuega merged commit a059c63 into main Oct 5, 2026
1 check failed
@scarmuega
scarmuega deleted the feat/required-host-spread branch October 5, 2026 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant