What is the difference between cordoning and uncordoning a Kubernetes node?

Cordoning and Uncordoning a Kubernetes Node

In the context of Kubernetes, cordoning and uncordoning a node are two distinct operations that allow you to control the scheduling of pods on a specific node.

Cordoning a Node

Cordoning a node is the process of marking a Kubernetes node as unschedulable, which means that no new pods will be scheduled on that node. This is useful when you need to perform maintenance or upgrades on a node, or when you want to drain a node before removing it from the cluster.

When a node is cordoned, the following happens:

  1. Existing Pods: Existing pods on the cordoned node will continue to run, but no new pods will be scheduled on that node.
  2. New Pod Scheduling: Kubernetes will not schedule any new pods on the cordoned node, even if the node has available resources.
  3. Node Labeling: The node will be labeled with the node.kubernetes.io/unschedulable=true label, indicating that it is unschedulable.

You can cordon a node using the kubectl cordon <node-name> command. For example:

$ kubectl cordon node1
node/node1 cordoned

After cordoning a node, you can check its status using the kubectl get nodes command:

$ kubectl get nodes
NAME      STATUS                     ROLES           AGE   VERSION
node1     Ready,SchedulingDisabled   worker          5d    v1.19.0
node2     Ready                      worker          5d    v1.19.0

Notice that the STATUS column for the cordoned node shows Ready,SchedulingDisabled, indicating that the node is cordoned.

Uncordoning a Node

Uncordoning a node is the process of making a Kubernetes node schedulable again, which means that new pods can be scheduled on that node.

When a node is uncordoned, the following happens:

  1. Existing Pods: Existing pods on the uncordoned node will continue to run.
  2. New Pod Scheduling: Kubernetes will resume scheduling new pods on the uncordoned node, based on available resources and scheduling policies.
  3. Node Labeling: The node.kubernetes.io/unschedulable=true label will be removed from the node, indicating that it is schedulable again.

You can uncordon a node using the kubectl uncordon <node-name> command. For example:

$ kubectl uncordon node1
node/node1 uncordoned

After uncordoning a node, you can check its status using the kubectl get nodes command:

$ kubectl get nodes
NAME      STATUS   ROLES           AGE   VERSION
node1     Ready    worker          5d    v1.19.0
node2     Ready    worker          5d    v1.19.0

Notice that the STATUS column for the uncordoned node shows Ready, indicating that the node is schedulable again.

Mermaid Diagram

Here's a Mermaid diagram that illustrates the difference between cordoning and uncordoning a Kubernetes node:

graph LR A[Kubernetes Node] --> B[Cordoned] B --> C[Uncordoned] C --> A subgraph Cordoning B[Cordoned] B --> |No new pods scheduled| D[Existing Pods Continue Running] B --> |Node labeled as unschedulable| E[Kubernetes Scheduler] end subgraph Uncordoning C[Uncordoned] C --> |New pods can be scheduled| F[Existing Pods Continue Running] C --> |Node label removed| G[Kubernetes Scheduler] end

In summary, cordoning a node marks it as unschedulable, preventing new pods from being scheduled on that node, while uncordoning a node makes it schedulable again, allowing new pods to be scheduled on the node.

0 Comments

no data
Be the first to share your comment!