Skip to content

Installing a Kubernetes cluster with kubeadm

Bring up a multi-node Kubernetes cluster with kubeadm on Ubuntu — containerd, kubelet/kubeadm/kubectl, control-plane init, CNI install, and worker join.

You need a real Kubernetes cluster on machines you control — not k3s, not a managed service, not minikube. kubeadm is the upstream tool for that. This article walks the bring-up from three Ubuntu 22.04 hosts to a working cluster: containerd as runtime, the kube package repo pinned to a minor version, kubeadm init on the first control-plane node, a CNI plugin, and worker kubeadm join. The aim is a cluster you would be willing to operate, not a demo.

How to verify

Start by confirming the prerequisites on every node — swap off, br_netfilter and overlay loaded, IPv4 forwarding on, and a unique MAC + product_uuid:

swapon --show                      # must be empty
lsmod | grep -E 'br_netfilter|overlay'
sysctl net.bridge.bridge-nf-call-iptables net.ipv4.ip_forward
cat /sys/class/dmi/id/product_uuid

After the cluster is up, this single command should show every node Ready and the core add-ons Running:

kubectl get nodes -o wide
kubectl -n kube-system get pods

If coredns is Pending or CrashLoopBackOff, the CNI install did not land — fix that before joining workers.

What’s happening

kubeadm bootstraps the control plane: it generates a CA, issues certificates for the API server, controller-manager, scheduler, and kubelet, lays down static pod manifests for the components, and writes a kubeconfig you can ship to admins. It does not install a container runtime, a CNI, or a load balancer in front of the API server — those are deliberate choices left to the operator. The runtime sits below: kubelet talks to it via CRI. On modern Ubuntu the practical choice is containerd; Docker Engine is no longer supported as a runtime by the kubelet. The CNI plugin (Calico, Cilium, Flannel) sets up the pod network — without it, pods get scheduled but stay Pending because they have no IP.

The Kubernetes apt repository is now versioned per minor release (pkgs.k8s.io/core:/stable:/v1.30/deb/ and similar). Pin the repo to one minor; do not let apt upgrade jump you across a minor boundary by accident.

The procedure

  1. Disable swap and load kernel modules on every node. Without this, kubelet refuses to start.

    sudo swapoff -a
    sudo sed -i.bak '/ swap / s/^/#/' /etc/fstab
    
    cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
    overlay
    br_netfilter
    EOF
    sudo modprobe overlay && sudo modprobe br_netfilter
    
    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
  2. Install containerd and configure the systemd cgroup driver. The kubelet and the runtime must agree on cgroups; the default config has SystemdCgroup = false, which silently breaks node registration on systemd hosts.

    sudo apt-get update
    sudo apt-get install -y containerd
    sudo mkdir -p /etc/containerd
    containerd config default | sudo tee /etc/containerd/config.toml >/dev/null
    sudo sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.toml
    sudo systemctl restart containerd
  3. Add the Kubernetes apt repo and install kubelet / kubeadm / kubectl — pinning a specific minor (replace v1.30 to match the version you want).

    sudo apt-get install -y apt-transport-https ca-certificates curl gpg
    curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key \
      | sudo 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.30/deb/ /' \
      | sudo tee /etc/apt/sources.list.d/kubernetes.list
    sudo apt-get update
    sudo apt-get install -y kubelet kubeadm kubectl
    sudo apt-mark hold kubelet kubeadm kubectl
  4. Initialize the control plane on the first node. Pick a pod CIDR that matches your CNI’s default (Calico = 192.168.0.0/16, Cilium = 10.0.0.0/8).

    sudo kubeadm init \
      --pod-network-cidr=192.168.0.0/16 \
      --control-plane-endpoint=k8s-cp.example.com:6443 \
      --upload-certs

    Copy the admin kubeconfig:

    mkdir -p $HOME/.kube
    sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
    sudo chown $(id -u):$(id -g) $HOME/.kube/config
  5. Install a CNI so pods get IPs. Calico is a reasonable default:

    kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.27.0/manifests/tigera-operator.yaml
    kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.27.0/manifests/custom-resources.yaml
  6. Join workers with the token from the kubeadm init output. Tokens are 24-hour by default; regenerate with kubeadm token create --print-join-command if you waited.

    sudo kubeadm join k8s-cp.example.com:6443 \
      --token <token> \
      --discovery-token-ca-cert-hash sha256:<hash>

Operational notes

  • kubeadm does not put anything in front of the API server — for HA, you need a load balancer (haproxy, keepalived + nginx, or a managed LB) on k8s-cp.example.com:6443 before adding more control-plane nodes.
  • The kubelet --node-ip flag matters on multi-homed hosts; if pods can’t reach each other after the CNI installs, check that nodes registered with the address you expected.
  • kubeadm reset cleans most state but leaves CNI’s /etc/cni/net.d and iptables rules behind — wipe both before reinitializing.
  • Pin kubelet, kubeadm, and kubectl with apt-mark hold so unattended-upgrades does not silently jump a minor version overnight.
  • Back up /etc/kubernetes/pki and an etcd snapshot the day the cluster is born; the recovery story without those is “rebuild from scratch.”

We run kubeadm-based clusters for clients who need a Kubernetes they can audit, on infrastructure they own, with upgrade discipline that does not depend on a vendor’s release calendar. If that’s the operating model you want, see /en/services/managed-operations/.