415 words
2 minutes
Mastering Kubernetes - Setting Up a Multi-Node Cluster with Kubeadm 1.29

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:

  1. Disable swap:

    swapoff -a
    sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
  2. 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
  3. 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
  4. 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
  5. 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:

  1. Initialize the cluster:

    sudo kubeadm init --pod-network-cidr=192.168.0.0/16 --kubernetes-version=1.29.0
  2. 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
  3. Install Calico network add-on:

    kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml

Step 3: Join Worker Nodes#

On each worker node:

  1. 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:

  1. Check node status:

    kubectl get nodes
  2. Verify all pods are running:

    kubectl get pods --all-namespaces

Key Takeaways#

  1. Proper preparation of all nodes is crucial for a successful Kubernetes setup.
  2. Kubeadm simplifies the process of bootstrapping a Kubernetes cluster.
  3. Calico provides the necessary networking for pod-to-pod communication.
  4. 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.

Mastering Kubernetes - Setting Up a Multi-Node Cluster with Kubeadm 1.29
https://mranv.pages.dev/posts/kubernetes-multi-node-cluster-kubeadm/
Author
Anubhav Gain
Published at
2024-10-03
License
CC BY-NC-SA 4.0