Node Cordon and Drain Operations

Explore this Page

Overview

Efficient management of cluster nodes is crucial for maintaining the stability and performance of a Kubernetes environment. Two important operations that assist in node management are cordon and drain.

  • Cordoning a node marks it as unschedulable, preventing the deployment of new resources while allowing existing workloads to continue operating.
  • Draining a node not only marks the node as unschedulable but also safely migrates existing volume targets to other nodes.

This document describes how to use the kubectl puls8 mayastor CLI to perform cordon, uncordon, and drain operations on nodes.

Cordon a Node

Cordoning a node prevents the Kubernetes scheduler from placing new workloads on it, without impacting any resources already running. This operation is aligned with the standard Kubernetes node cordon functionality.

To add a label and cordon a node:

Copy
Cordon a Node
kubectl puls8 mayastor cordon node <node_name> <label>

To retrieve a list of all cordoned nodes:

Copy
List Cordoned Nodes
kubectl puls8 mayastor get cordon nodes

To view the labels associated with a specific cordoned node:

Copy
View Labels on a Cordoned Node
kubectl puls8 mayastor get cordon node <node_name>

Uncordon a Node

Uncordoning a node marks it as schedulable again, allowing the Kubernetes scheduler to place new resources on it.

To uncordon a node:

Copy
Unordoned a Node
kubectl puls8 mayastor uncordon node <node_name> <label>

Drain a Node

Draining a node makes it unschedulable and safely relocates all volume targets to other nodes. This ensures that the workloads remain highly available. This operation aligns with the Kubernetes node drain functionality.

To initiate the drain operation on a node:

Copy
Drain a Node
kubectl puls8 mayastor drain node <node_name> <label>

To retrieve a list of nodes that have undergone a drain operation:

Copy
List Drained Node
kubectl puls8 mayastor get drain nodes

To stop an ongoing drain operation or make a drained node schedulable again:

Copy
Uncordon a Drained Node
kubectl puls8 mayastor uncordon node <node_name> <label>

Benefits of Node Cordon and Node Drain

  • Prevents new workload deployments on unhealthy or under-maintenance nodes, ensuring stability.
  • Safely migrates workloads off a node during maintenance or upgrades, avoiding downtime.
  • Helps in node maintenance and upgrades without disrupting existing workloads.

Learn More