How to Gracefully Remove a Node from Kubernetes?

Maintaining your nodes in peak condition is part of managing a Kubernetes cluster. However, a node may occasionally need to be taken offline for decommissioning, maintenance, or upgrades. This is where a gentle removal becomes useful, guaranteeing a seamless transfer without interfering with your active apps.

What Is Kubernetes Cluster?

A group of nodes (Computers/Operating systems) working together to communicate with the help of Kubernetes software is known as the Kubernetes cluster. It works in a mechanism in such a way that it performs actions on the worker node with the help of the manager node.

What Is a Node In the Kubernetes Cluster?

Within the Kubernetes world, a “node” is a fundamental component of the cluster’s design. Imagine it as an employee, carrying out assignments and tending to containers with the diligence of an experienced conductor putting on a symphony. With its own CPU, memory, and storage, every node is a computational powerhouse. The foundation of the Kubernetes infrastructure, these nodes work together smoothly to guarantee the uninterrupted functioning of services and applications installed inside the cluster. Nodes are the hidden heroes of the cloud, handling everything from task execution to networking and storage management. They enable Kubernetes to provide scalable, fault-tolerant, and resilient solutions for today’s computing problems.

Steps To Remove or Delete Node From Kubernetes Cluster Gracefully

Follow the steps mentioned below to gracefully remove the node from the kubernetes cluster.

Step 1: List all the nodes available in the Kubernetes Cluster.

kubectl get nodes

Step 2: Before removing the node you should drain the node then the pods which running in that node will schedule in another node.You can use the command.

kubectl drain <node-name>

Step 3: Know delete the node by using the command mentioned below.

kubectl delete node <node-name>

You can see in the below image node01 was removed gracefully.

How To Remove Node Frocefully From Kubernetes Cluster

In the first place it is not an good practice to remove or delete the node from the kubernetes cluster it will effect the entire cluster working try to avoid this as much as possible. following are the steps to remove the node forcefully from the kubernetes cluster.

Step 1: list all the nodes available in the kubernetes cluster you use the command mentioned.

kubectl get nodes 

Step 2: Before removing or deleting the node you should make the unscheduled the node to prevent new pods from being scheduled on it. For that you can use the “kubectl cordon”

kubectl cordon <node-name>

Step 3: The next step is to remove every pod that is currently on the node. This guarantees that the removal of the node won’t impact any ongoing workloads. Utilize the subsequent command to empty the node:

kubectl drain <node-name> --force --ignore-daemonsets

put the name of the node you wish to remove in place of <node-name>.

  • –force: If the pods are not ending gracefully, this flag makes sure they are removed with force.
  • –ignore-daemonsets: DaemonSet-managed pods, which are typically essential system components, are disregarded by this flag.

Step 4: After following all the steps mentioned above you can remove you node safely.

kubectl delete node <node-name>

Gracefully Remove A Node From Kubernetes – FAQs

How do I bring down a node in Kubernetes?

Kubectl drain lets you gracefully evict pods from a node before taking it out of service for maintenance.

How do you exclude nodes in Kubernetes?

Kubernetes offers two main ways to exclude nodes:

  • Taints & Tolerations: Mark a node unsuitable (taint) for certain pods, but pods with tolerations can still run there.
  • Node Selectors & Affinity: Define requirements (selectors) or preferences (affinity) for pods, effectively excluding nodes that don’t match


Contact Us