LAB03: Joining New Node

Objective:

✔ joining new worker nodes ✔ performing maintenance ✔ draining & cordon/uncordon ✔ permanently removing nodes ✔ understanding DaemonSets and eviction behavior


Kubernetes Cluster Management

SCENARIO

You have:

  • A Kubernetes cluster with 1 control-plane + 1 worker node (kubeadm-based, Kubernetes v1.33).

  • You want to:

    1. Prepare a new worker node and join it to the cluster.

    2. Simulate maintenance on an existing worker (cordon, drain, uncordon).

    3. Permanently remove a node from the cluster.

    4. Understand DaemonSet behavior during drain.

PART 1 — Prepare a NEW Node and Join to Cluster

1. Prepare the new worker node

On your new Linux server (Ubuntu):

A. Install required packages

B. Configure containerd

C. Disable swap (required for Kubernetes)

D. Install Kubernetes binaries

2. Get join command from Control Plane

On the control-plane node:

Output example:

3. Run join command on worker node

Paste on new worker node:

Wait 10–20 seconds.

4. Verify from control-plane

You should now see the new node in Ready state.

PART 2 — Cordon, Uncordon, Drain (Maintenance Mode)

Scenario:

Node worker-1 needs maintenance. You must drain workloads safely, then bring node back.

1. Mark node unschedulable (cordon)

Verify:

You will see:

2. Drain the node safely

Flags meaning:

  • --ignore-daemonsets → DaemonSet pods stay on the node

  • --delete-emptydir-data → deletes local emptyDir data

  • Without this flag, drain fails if pods use emptyDir

Check rescheduling:

Pods should automatically move to other nodes.

3. Perform maintenance (simulated)

4. Bring node back (uncordon)

Verify:

Node will be Ready.

PART 3 — DaemonSet Behavior Lab

Test that DaemonSet pods are NOT evicted

List all DaemonSet pods:

Example:

  • kube-proxy

  • calico-node

  • node-exporter

Now drain a node again:

You will see warnings like:

✔ DaemonSet pods stay on the node ✔ Kubernetes never evicts them ✔ They are recreated only if node restarts or DS is updated

This reinforces the maintenance concept.

PART 4 — Permanently Remove a Node From Cluster

Scenario:

You are removing worker-2 from the cluster completely.

STEP 1: Drain the node

Even for permanent removal, always drain:

STEP 2: Delete node from cluster

STEP 3: Reset kubeadm on the worker

Run on worker-2:

Optional clean-up:

STEP 4: (Optional) Rejoin later

If you want this node back later:

  • Reset

  • Install kubeadm again

  • Run new join command

OPTIONAL ADVANCED SCENARIOS FOR TRAINING

Scenario A: Drain with force

Use when:

  • Pod is not part of a controller (bare pods)

  • Pod cannot be recreated automatically ⚠️ Risk: you will cause downtime

Scenario B: Node is unreachable

If node is NotReady or Unknown:

Scenario C: Upgrade workflow

  1. cordon

  2. drain

  3. OS upgrade + reboot

  4. kubeadm upgrade

  5. uncordon

Last updated