Nomad and Consul Node Draining Runbook
HashiCorp Nomad schedules workloads, while Consul provides service discovery and health awareness. Combining them gives administrators a controlled way to remove a client from service without leaving stale endpoints behind.
A Nomad drain moves allocations away from the selected client and prevents new placements. Consul must then be handled deliberately: stopping a task can make its check critical, but it does not guarantee that the corresponding registration disappears.
Australian deployments add practical constraints. Sydney and Melbourne are common cloud and data-centre locations, while workloads placed in AWS’s ap-southeast-2 or ap-southeast-4 regions can support local data-residency expectations. Drain windows should respect AEST/AEDT business hours and the ACSC Essential Eight, reflecting the operational custom of controlled, auditable change in Australian organisations.
The result should be a repeatable maintenance runbook covering preflight checks, capacity, drainage, discovery cleanup, verification and recovery, with clear ownership for every step.
Why Nomad and Consul Belong in the Runbook
Nomad and Consul share an operating model, but their control planes are separate. Nomad knows where allocations run and can reschedule them; Consul knows which service instances are healthy. Neither platform infers the other’s intent merely because agents share a host.
That distinction matters during patching. Consul can mark a failed instance critical while Nomad starts its replacement, yet an old Consul registration may remain and confuse clients or DNS lookups. Treat draining as two coordinated actions rather than one button.
Prepare the Node and Cluster
Before changing the node, inspect both views with nomad node status -verbose NODE_ID and consul members. Record the allocation count, service IDs, host-specific tags, node metadata and current health. Use least-privilege Nomad and Consul ACL tokens that can write node and service state.
Confirm the cluster has spare capacity for every affected workload and that critical services have a second healthy instance. Australian hybrid estates often connect VMware, AWS and local data-centre tiers, so a seemingly small Nomad move can displace several dependencies. Engineers building those cloud skills can follow the AWS certification pathway before operating similar runbooks in production.
Enable a Controlled Nomad Drain
Enable the drain with nomad node drain -enable -node NODE_ID -deadline 60m. Nomad marks the client unschedulable and asks the scheduler to relocate allocations. Keep the deadline realistic: it bounds evacuation rather than proving that the replacement workload is healthy.
Watch allocations until they have moved or reached the deadline. Decide explicitly whether system jobs should be included, since -ignore-system changes that scope and some Consul agents should remain available throughout. Never kill the Consul agent first, because graceful discovery cleanup and ongoing health reporting would be lost.
Remove Node-Bound Consul Registrations
Once allocations are gone, confirm that Consul checks for the old instance are failing before removing it. If the service uses DeregisterCriticalServiceAfter, allow that policy to expire rather than racing it with a manual command. This avoids removing a newly started instance that reused the same service ID.
For explicitly managed registrations, use consul services deregister -id SERVICE_ID with the appropriate token. Deregister only node-bound instances, not a shared logical service, and never reuse IDs during the change window. The Consul API supports the same operation for automation through the agent service endpoint.
Availability depends on registration design. A singleton service can have a gap unless replacement capacity overlaps the old instance; replicated services are safer. Check Consul DNS caching and client retry behaviour before the window, particularly for payment, authentication and line-of-business applications used by Australian organisations.
Verify Workload and Service Recovery
Validation must cover scheduling and discovery. The Nomad node should show no running allocations, while Consul should show the replacement instance passing its checks and the retired ID absent from the catalog. Comparing both states prevents a successful reschedule from masking a broken service.
Run an application-level transaction from each relevant network path, then review scheduler, Consul and service logs together. The Mike Patt troubleshooting notes provide a useful external reference when symptoms do not identify the faulty layer. Confirm that failed DNS lookups, stale endpoints and capacity alarms have all cleared.
Return the Node to Service
For temporary maintenance, restore the Consul agent and node health first, then run nomad node drain -disable -node NODE_ID. Let the scheduler place fresh work and verify that service registration and checks recover before declaring the node available. Re-register a manually removed service if its workload does not own that lifecycle.
For permanent retirement, complete the drain and service cleanup, then gracefully remove the client from each cluster. Use consul agent leave only when stopping that local agent is intentional; it should not replace a Nomad drain. Keep evidence of the change, including allocation IDs, service IDs and verification results, for operational audit and ACSC-aligned controls.
Compare the Available Draining Methods
No single mechanism covers scheduling, service cleanup and verification. Choose the method that matches the maintenance scope and accept that partial actions can leave the environment inconsistent.
| Method | Nomad behaviour | Consul behaviour | Best fit |
|---|---|---|---|
| Nomad drain only | Evacuates allocations and blocks new placements | Registrations may remain critical or stale | Temporary scheduling maintenance |
| Consul agent leave | Does not move workloads | Gracefully removes local registrations | Consul-only repair |
| Automatic critical deregistration | Provides no scheduling control | Removes stale instances after a configured interval | Ephemeral node-bound services |
| Coordinated drain and deregistration | Reschedules before release | Removes each retired instance deliberately | Production node maintenance |
A production runbook should make Nomad the placement authority, Consul the discovery authority, and the orchestration layer responsible for ordering, timeouts and verification. Store the commands in version control, test them on a representative client, and rehearse the recovery path before applying it during an Australian business-hours change window.