Repository navigation
feat: add an opt-in input to require one node per host - #72
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
spread_hosts_required(defaultfalse) toinstances. When true, the host anti-affinity thatspread_hostsrenders as preferred is rendered as required instead, and the input impliesspread_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: newspread_hosts_requiredvariable.pod_anti_affinityrenders either the required or the preferred term, with the same topology key (kubernetes.io/hostname) and selector (role=node, the instance'snetwork).bootstrap:spread_hosts_required = optional(bool, false)ininstances, passed through.Instances that don't set it render exactly as before.
Tests
terraform testinbootstrap/: 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