KubernetesXXXI · Node LifecycleNode lifecycle
Adding and removing nodes — node lifecycle operations
What you'll learn
- Trace the node addition flow from bootstrap to Ready
- Identify the node removal patterns and the cluster autoscaler
- Apply the operational patterns for adding nodes at scale
- Diagnose a node addition that is failing
Prerequisites
Verified against Kubernetes 1.34.x · kubeadm 1.34.x · kubectl 1.34.x · etcd 3.6.x · CoreDNS 1.11.x · containerd 1.7.x / 2.x · 2026-08-16
Adding a node to the cluster is a bootstrap; removing a node is a drain and a delete. The cluster autoscaler manages the scale at the cluster level. This lesson walks the operator actions, the cluster autoscaler, and the operational patterns.
Adding a node
The node addition flow:
flowchart LR
A[New node starts] --> B[Bootstrap script]
B --> C[Install kubelet]
C --> D[Install runtime]
D --> E[Install CNI]
E --> F[Run kubeadm join]
F --> G[TLS bootstrap]
G --> H[Node registered]
H --> I[Node Ready]
The steps:
- Bootstrap script. The new node’s bootstrap script installs the kubelet, the runtime, and the CNI.
- kubeadm join. The kubelet runs the kubeadm join command with the cluster’s bootstrap token.
- TLS bootstrap. The kubelet uses the bootstrap token to authenticate to the API server and request a CSR.
- Node registered. The kubelet creates the Node object; the API server validates the kubelet’s credentials.
- Node Ready. The kubelet reports the node’s status; the cluster’s components recognize the node.
The bootstrap is typically performed by the cluster’s node bootstrap automation (cloud-init, Ansible, etc.). The bootstrap is a node-level operation; the cluster’s control plane is unaffected.
The kubeadm join command
The kubeadm join command is generated by the kubeadm init command on the control plane:
kubeadm join api.example.com:6443 \
--token abcdef.0123456789abcdef \
--discovery-token-ca-cert-hash sha256:...
The command is a single line; the bootstrap is self-contained. The kubelet uses the token to authenticate to the API server.
The token is short-lived. The token expires after 24 hours; the cluster’s bootstrap automation must generate a new token before the bootstrap.
The cloud provider’s node addition
In a cloud-managed cluster, the node addition is performed by the cloud provider’s node group scaling:
aws eks update-nodegroup-config \
--cluster-name my-cluster \
--nodegroup-name my-nodegroup \
--desired-size 10
The cloud provider’s API creates new instances; the cluster’s node bootstrap automation runs on each new instance; the new node joins the cluster.
The cloud provider’s node addition is the production pattern for elastic scaling. The cluster autoscaler calls the cloud provider’s API to add nodes when the cluster needs capacity.
The cluster autoscaler
The cluster autoscaler is a Kubernetes component that manages the cluster’s node count. The autoscaler:
- Watches the cluster’s Pods for unschedulable Pods.
- Determines the node group that can host the Pods.
- Calls the cloud provider’s API to add nodes.
- Watches the cluster’s nodes for underutilized nodes.
- Calls the cloud provider’s API to remove nodes.
The autoscaler’s configuration:
apiVersion: apps/v1
kind: Deployment
metadata:
name: cluster-autoscaler
namespace: kube-system
spec:
template:
spec:
containers:
- name: cluster-autoscaler
image: registry.k8s.io/autoscaling/cluster-autoscaler:v1.34.0
command:
- ./cluster-autoscaler
- --cloud-provider=aws
- --node-group-auto-discovery=asg:tag=k8s.io/cluster-autoscaler/enabled
The autoscaler is deployed as a cluster-level Deployment. The autoscaler is the cluster’s mechanism for elastic scaling.
The node’s removal
The node’s removal is performed by the operator:
# Substitute the node you are removing:
NODE=worker-03
kubectl drain "$NODE" --ignore-daemonsets --delete-emptydir-data
kubectl delete node "$NODE"
The two commands:
- drain: evicts all Pods from the node, cordons the node, and removes the Pods from the cluster’s controllers.
- delete: removes the Node object from the cluster.
The drain is the gentle path. The Pods are evicted with the eviction API; the Pods’ controllers create replacement Pods on other nodes.
The delete is the destructive path. The Node object is removed; the kubelet panics on its next sync.
The cloud provider’s node removal
In a cloud-managed cluster, the node removal is performed by the cloud provider’s API:
aws eks update-nodegroup-config \
--cluster-name my-cluster \
--nodegroup-name my-nodegroup \
--desired-size 1
The cloud provider’s API terminates the instances; the cluster’s node lifecycle automation handles the draining.
The cluster autoscaler calls the cloud provider’s API to remove underutilized nodes. The autoscaler determines the underutilization based on the node’s resource usage; the node is removed when the usage is below the autoscaler’s threshold.
The node’s removal patterns
The node’s removal patterns:
| Pattern | Use case |
|---|---|
| Manual drain + delete | Manual node replacement |
| Cloud provider scaling | Cloud-managed cluster |
| Cluster autoscaler | Elastic scaling |
| Node lifecycle controller | Automated replacement |
The production pattern is the cluster autoscaler. The autoscaler is the cluster’s mechanism for managing the node count.
The node’s addition patterns
The node’s addition patterns:
| Pattern | Use case |
|---|---|
| Manual kubeadm join | Manual node addition |
| Cloud provider’s launch template | Cloud-managed cluster |
| Cluster autoscaler | Elastic scaling |
| Node bootstrap controller | Automated bootstrap |
The production pattern is the cluster autoscaler. The autoscaler is the cluster’s mechanism for adding nodes when the cluster needs capacity.
The bootstrap automation
The bootstrap automation is the cluster’s mechanism for adding nodes. The automation:
- Installs the kubelet, the runtime, the CNI.
- Configures the kubelet’s flags.
- Runs the kubeadm join.
- Verifies the node is Ready.
The bootstrap is typically performed by the cluster’s node bootstrap (cloud-init, Ansible, etc.). A failed join leaves nothing behind in the cluster; the Node object is never created, so the failure is read from the node’s own kubelet journal.
The node’s lifecycle automation
The node’s lifecycle automation is the cluster’s mechanism for managing the node’s lifecycle. The automation:
- Adds nodes when the cluster needs capacity.
- Removes nodes when the cluster is underutilized.
- Replaces nodes when the node is failing.
- Updates nodes when the cluster is upgraded.
The automation is typically performed by the cluster autoscaler and the cluster’s node replacement operator.
Quiz
Knowledge check · 4 questions
Q1. What should be done before deleting a Node object from the cluster?
Q2. `kubectl drain` respects PodDisruptionBudgets, while deleting Pods directly does not.
Q3. Restore node registration for an autoscaling group whose instances boot but never join the cluster.
The autoscaler scaled `pool-b` from 6 to 10 instances at 04:00 to absorb a batch job. Four instances are running in the cloud console but `kubectl get nodes` still shows 6. On one of the new instances, the bootstrap log ends with `error execution phase preflight: couldn't validate the identity of the API Server: could not find a JWS signature in the cluster-info ConfigMap for token ID "abcdef"`. On the control plane, `kubeadm token list` returns no rows. 41 Pods are `Pending` with `0/6 nodes are available: 6 Insufficient cpu`.
Q4. How long is a kubeadm bootstrap token valid by default, and which command regenerates a complete join command for a new node?
Passing score: 75%. Answers are checked in this browser.
Production discipline
- Drain before delete. A node that is deleted without being drained is a node whose Pods are orphaned. The production rule is to drain the node before deleting it.
- Use the cluster autoscaler. The autoscaler is the cluster’s mechanism for elastic scaling. The production rule is to use the autoscaler for the cluster’s capacity.
- Bootstrap the node with automation. A hand-built node drifts from the fleet’s kubelet version, flags, and CNI configuration. The production rule is to use the cluster’s node bootstrap automation.
- Monitor the node’s lifecycle. The cluster’s metrics expose the node’s lifecycle. The operator should alert on the node addition and removal.
- Audit the node’s bootstrap at every release. A new node that joins the cluster with the wrong configuration is a node that is failing silently. The audit catches the failure.
- Test the node’s removal in non-production. A node that does not drain cleanly is a node that is failing silently. The staging cluster is the right place to test.