Setting Up a Multi-Node Kubernetes 1.29 Cluster with Kubeadm: A Step-by-Step Guide
In this post, I’ll walk through the process of setting up a multi-node Kubernetes 1.29 cluster using kubeadm. This setup includes 1 master node and 2 worker nodes, along with essential add-ons like kubelet, kubectl, kubeadm, and Calico networking.
Prerequisites
- 3 Virtual Machines (1 for master, 2 for workers)
- Ubuntu 20.04 or later on all VMs
- Root or sudo access on all machines
Step 1: Prepare All Nodes
Run these steps on all three nodes:
-
Disable swap:
swapoff -a sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
-
Load necessary kernel modules:
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf overlay br_netfilter EOF sudo modprobe overlay sudo modprobe br_netfilter
-
Configure sysctl params:
cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf net.bridge.bridge-nf-call-iptables = 1 net.bridge.bridge-nf-call-ip6tables = 1 net.ipv4.ip_forward = 1 EOF sudo sysctl --system
-
Install containerd as the container runtime:
# Install containerd sudo apt-get update && sudo apt-get install -y containerd # Configure containerd sudo mkdir -p /etc/containerd containerd config default | sudo tee /etc/containerd/config.toml sudo systemctl restart containerd
-
Install kubeadm, kubelet, and kubectl:
sudo apt-get update sudo apt-get install -y apt-transport-https ca-certificates curl curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-archive-keyring.gpg echo "deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list sudo apt-get update sudo apt-get install -y kubelet=1.29.0-00 kubeadm=1.29.0-00 kubectl=1.29.0-00 sudo apt-mark hold kubelet kubeadm kubectl
Step 2: Initialize the Master Node
On the master node only:
-
Initialize the cluster:
sudo kubeadm init --pod-network-cidr=192.168.0.0/16 --kubernetes-version=1.29.0
-
Set up kubeconfig:
mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config
-
Install Calico network add-on:
kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
Step 3: Join Worker Nodes
On each worker node:
- Run the join command output by kubeadm init on the master node:
sudo kubeadm join <master-ip>:6443 --token <token> --discovery-token-ca-cert-hash <hash>
Step 4: Verify Cluster Status
On the master node:
-
Check node status:
kubectl get nodes
-
Verify all pods are running:
kubectl get pods --all-namespaces
Key Takeaways
- Proper preparation of all nodes is crucial for a successful Kubernetes setup.
- Kubeadm simplifies the process of bootstrapping a Kubernetes cluster.
- Calico provides the necessary networking for pod-to-pod communication.
- Verifying the cluster status is an important final step to ensure everything is working correctly.
Setting up a multi-node Kubernetes cluster manually provides valuable insights into the components and processes involved in cluster initialization and management. This knowledge is invaluable for troubleshooting and maintaining production Kubernetes environments.
This blog post template covers the main steps of setting up a multi-node Kubernetes cluster using kubeadm, as described in your task. It provides a step-by-step guide that readers can follow to replicate the setup. The content is structured to be informative and practical, suitable for a technical audience familiar with basic Linux and virtualization concepts.