How to Gracefully Remove a Node from Kubernetes?
Last Updated :
26 Apr, 2024
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.
.png)
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>

Similar Reads
How to Add Node to Existing Kubernetes Cluster
Kubernetes allows the management and orchestration of containerized deployments. We can use various cluster managing tools, but Kubeadm allows us to create and manage Kubernetes clusters from scratch. Kubernetes cluster can be autoscaled with the use of Cluster management services. In this article,
4 min read
How to Add Roles to Nodes in Kubernetes?
Kubernetes (or k8) is an open-source container orchestration platform that helps in managing various containers. Its architecture consists of nodes that represent worker machines and the containers run inside those machines. The machines, or nodes, may require some roles attached to them as well in
2 min read
Kubernetes Pods: How to Create and Manage Them
Kubernetes is an open-source container orchestration system mainly used for automated software deployment, management, and scaling. Kubernetes is also known as K8s. Kubernetes was originally developed by Google, but it is now being maintained by the Cloud Native Computing Foundation. It was original
13 min read
How to Deploy Kubernetes on Azure?
Kubernetes, often abbreviated as K8s, is an open-source system for automating the deployment, scaling, and management of containerized applications. It is developed by Google and now managed by CNCF (Cloud Native Computing Foundation). What is the Use Of AKS (Azure Kubernetes Service)?Service Discov
4 min read
How to Deploy Kubernetes on AWS?
Kubernetes, the open-supply box orchestration platform, has emerged as the solution for dealing with containerized applications. When deploying Kubernetes in the cloud, Amazon Web Services (AWS) gives a robust and scalable environment. In this manual, we can walk you through the manner of deploying
7 min read
How to Run curl Command From Within a Kubernetes Pod?
Ever needed to fetch data or test connectivity from within a Kubernetes pod? The curl command becomes your trusty companion in these situations. This guide explores different approaches to execute curl commands directly from within your Kubernetes pod, empowering you to diagnose issues and interact
3 min read
How to Deploy Node.js Application in Kubernetes?
Deploying the Node.js application on Kubernetes in a containerized manner makes it highly scalable, and fault-tolerant, and allows zero downtime. Kubernetes allows container orchestration that can be used in many ways during deployment. Load balancing is provided, which helps with automatic load tra
4 min read
How To Deploy Kubernetes on CentOS?
A Kubernetes cluster is a set of nodes that execute applications within containers. Clusters consist of a master node and several worker nodes. These nodes could be physical computers or virtual machines. It depends on the configuration of the cluster. The master node manages and coordinates the wor
8 min read
How to Deploy Kubernetes on GCP?
Kubernetes, the open-supply field orchestration platform, has emerged as the standard for coping with containerized applications. Google Cloud Platform (GCP) provides a robust and scalable surrounding for deploying Kubernetes clusters. In this comprehensive manual, we are able to walk you through th
5 min read
How to Careate Static Pod in Kubernetes ?
Static pods in Kubernetes make it simple to run pods directly on individual cluster nodes without the Kubernetes API server being involved. Not at all like ordinary pods oversaw by the Kubernetes control plane, static pods are characterized and overseen straight by the Kubelet, the essential node ag
7 min read