The information contained in this article has been verified as up-to-date on the date of the original publication of the article. HashiCorp endeavors to keep this information up-to-date and correct, but it makes no representations or warranties of any kind, express or implied, about the ongoing completeness, accuracy, reliability, or suitability of the information provided. All information contained in this article is for general information purposes only. Any reliance you place on such information as it applies to your use of your HashiCorp product is therefore strictly at your own risk.
Overview
HashiCorp Nomad is a powerful and flexible cluster scheduler & orchestrator designed to deploy and manage containerized and non-containerized applications across a cluster of machines.
Node pools are a way to group clients and segment infrastructure into logical units that can be targeted by jobs for strong control over where allocations are placed.
Without node pools, allocations for a job can be placed in any eligible client in the cluster. Affinities and constraints can help express preferences for certain nodes, but they do not easily prevent other jobs from placing allocations in a set of nodes.
This knowledge-based article provides step-by-step instructions on how to delete a node pool in HashiCorp Nomad.
Prerequisites
- Nomad v1.6.x and above.
- Install HashiCorp Nomad on your cluster.
- A running Nomad cluster with the node pool you want to delete.
Steps to Delete a Node Pool
Follow the steps below to delete a node pool in HashiCorp Nomad:
Step 1: Access the Nomad Cluster
Connect to the Nomad cluster where the node pool is located. You can access the cluster through the Nomad command-line interface (CLI).
nomad server members
Step 2: Identify the Node Pool
List the existing node pools to identify the one you want to delete. The following Nomad CLI command will display information about all registered node pools:
nomad node pool list
Identify the node pool name that you want to delete.
Step 3: Validate the Nomad nodes in Node pool
List the number of nodes or jobs that are associated with the node pool which you want to delete. You can use Nomad CLI command for the same:
- For checking nodes, use the command:
nomad node pool nodes <NODE_POOL_NAME>
- For checking jobs, use the command:
nomad node pool jobs <NODE_POOL_NAME>
Replace <NODE_POOL_NAME>
with the actual name of a node pool.
Step 4: Drain Nodes (Optional)
Before deleting a node pool, you may want to gracefully drain the nodes to ensure that running jobs are rescheduled on other nodes. You can use the nomad node drain
command for this purpose:
nomad node drain -enable <NODE_ID>
Replace <NODE_ID>
with the actual ID of a node in the target node pool.
Step 5: Modify the Nomad Client's Configuration
Edit the Nomad configuration to remove the node pool. Locate the Nomad client configuration file (usually named client.hcl
), and remove the configuration block related to the node pool you want to delete.
client {
...
enabled = true
node_pool = "example"
...
}
Either you can remove the parameter node_pool
from client's configuration or you can change the node pool to another node pool that you don't want to delete. Please note if you do not use this parameter (i.e. node_pool) then this node will be part of the default node pool in the Nomad cluster.
Step 6: Restart Nomad Client Node
Restart the respective Nomad client nodes where you have applied the changes in node_pool.
Step 7: Delete Node Pool
Identify the selected node pool (as per step 2) that you want to delete. The following Nomad CLI command will delete the node pool:
nomad node pool delete <NODE_POOL_NAME>
Step 8: Verify Node Pool Deletion
Confirm that the node pool has been successfully deleted by checking the Nomad node pool list:
nomad node pool list
The deleted node pool will be no longer available and not present in this command's output.
Conclusion
Deleting a node pool in HashiCorp Nomad involves draining nodes, modifying the Nomad configuration, and reloading or restarting the Nomad server. Following these steps ensures a smooth removal of the node pool from your Nomad cluster. Always exercise caution and backup configurations before making significant changes to your Nomad deployment.
Reference: