Newsletter
TechAnV Blog
Get updates on security engineering, Rust, eBPF, and DevSecOps. No spam, unsubscribe anytime.
Check your inbox and click the confirmation link to complete your subscription.
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:
1swapoff -a2sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab -
Load necessary kernel modules:
1cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf2overlay3br_netfilter4EOF56sudo modprobe overlay7sudo modprobe br_netfilter -
Configure sysctl params:
1cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf2net.bridge.bridge-nf-call-iptables = 13net.bridge.bridge-nf-call-ip6tables = 14net.ipv4.ip_forward = 15EOF67sudo sysctl --system -
Install containerd as the container runtime:
1# Install containerd2sudo apt-get update && sudo apt-get install -y containerd34# Configure containerd5sudo mkdir -p /etc/containerd6containerd config default | sudo tee /etc/containerd/config.toml7sudo systemctl restart containerd -
Install kubeadm, kubelet, and kubectl:
1sudo apt-get update2sudo apt-get install -y apt-transport-https ca-certificates curl3curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-archive-keyring.gpg4echo "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.list5sudo apt-get update6sudo apt-get install -y kubelet=1.29.0-00 kubeadm=1.29.0-00 kubectl=1.29.0-007sudo apt-mark hold kubelet kubeadm kubectl
Step 2: Initialize the Master Node#
On the master node only:
-
Initialize the cluster:
1sudo kubeadm init --pod-network-cidr=192.168.0.0/16 --kubernetes-version=1.29.0 -
Set up kubeconfig:
1mkdir -p $HOME/.kube2sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config3sudo chown $(id -u):$(id -g) $HOME/.kube/config -
Install Calico network add-on:
1kubectl 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:
1sudo 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:
1kubectl get nodes -
Verify all pods are running:
1kubectl 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.