Join New Worker Node to Kubeadm Cluster

In this article I will show you how to Join new node as Worker Node in existing Kubeadm cluster. Worker nodes handle the workloads running pods, services, and applications while the control plane manages cluster state and scheduling. By joining additional worker nodes, you increase the cluster’s capacity, improve availability, and enable better workload distribution.

So, let's get started…

Environment

  • Master Node
Hostnameat-kubeadm
Operating SystemUbuntu 22.04 (Jammy)
vCPU4
Memory8 GB
Disk60 GB
Network172.20.20.75
  • Worker Node
Hostnameat-kubeadm-2
Operating SystemUbuntu 22.04 (Jammy)
vCPU2
Memory4 GB
Disk40 GB
Network172.20.20.76

Join Worker Node to Kubeadm Cluster

  1. Mapping hosts
# exec on all nodes
nano /etc/hosts
---
172.20.20.75 at-kubeadm kubeadm.at.lab
172.20.20.76 at-kubeadm-2
  1. Update and upgrade packages
# exec on worker node
apt-get update -y && apt-get upgrade -y
  1. Disable swap
# exec on worker node
systemctl disable --now swap.target
swapoff -a
  1. Enable containerd modules
# exec on worker node
cat <<EOF | sudo tee /etc/modules-load.d/containerd.conf
overlay
br_netfilter
EOF
modprobe overlay
modprobe br_netfilter
  1. Configure kernel settings
# exec on worker node
cat <<EOF | sudo tee /etc/sysctl.d/99-kubernetes-cri.conf
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
EOF

sysctl --system
  1. Install containerd as container runtime
# exec on worker node
apt install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt update
apt install containerd.io
  1. Configure cgroup on containerd
# exec on worker node
containerd config default | tee /etc/containerd/config.toml >/dev/null 2>&1
sed -i 's/SystemdCgroup \= false/SystemdCgroup \= true/g' /etc/containerd/config.toml
systemctl restart containerd
systemctl enable containerd
  1. Install kube tools
# exec on worker node
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.32/deb/Release.key | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.32/deb/ /' | tee /etc/apt/sources.list.d/kubernetes.list
apt update
apt install -y kubelet=1.32.7-1.1 kubeadm=1.32.7-1.1 kubectl=1.32.7-1.1
apt-mark hold kubelet kubeadm kubectl
  1. Create token for join worker node
# exec on master node
kubeadm token create --print-join-command
  1. Run join command
# exec on worker node
kubeadm join kubeadm.at.lab:6443 --token vg6cg8.66tp92suos1ji0pi --discovery-token-ca-cert-hash sha256:c6c2875250713d0c3a149d2f1e7341ccf8a5e87525307c25e50f8406a0672114
  1. Set node roles
# exec on master node
kubectl label node at-kubeadm node-role.kubernetes.io/master="true"
kubectl label node at-kubeadm node-role.kubernetes.io/etcd="true"

kubectl label node at-kubeadm-2 node-role.kubernetes.io/worker="true"
  1. Verifications
# exec on master node
kubectl get nodes -o wide
kubectl get all -A

  1. Operational test
# exec on master node
kubectl create deployment nginx-worker --image=nginx --replicas=1
kubectl expose deployment nginx-worker --port=80 --target-port=80 
kubectl create ingress nginx-worker-ingress --class=nginx --rule="nginx-worker.at.lab/*=nginx-worker:80"

nano /etc/hosts
---
172.20.20.75 nginx-worker.at.lab

Thank You.

0
Subscribe to my newsletter

Read articles from Muhammad Alfian Tirta Kusuma directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Muhammad Alfian Tirta Kusuma
Muhammad Alfian Tirta Kusuma