Skip to content
Visual explainer 5h to learn 5 steps

Install a cluster with kubeadm

Bootstrap a control plane, join workers and install a CNI plugin from memory.

By Invicly Tech, , in Kubernetes Administrator (CKA). About 8 minutes to read.

Topic 6 of 33

In short

kubeadm bootstraps a cluster: init sets up the control plane and join adds nodes. Before that, every node needs a container runtime, kernel networking settings, and matching kubeadm, kubelet and kubectl packages. Pods stay Pending and nodes NotReady until you install a CNI plugin.

Explained simply

kubeadm is the official tool that turns a few prepared Linux machines into a Kubernetes cluster. It does not install packages or the container runtime for you. It creates certificates, writes the control plane manifests, and gives you a command for other nodes to join.

Building a cluster is like opening a new branch office. First you prepare each building: power, plumbing and locks (runtime, kernel settings, packages). Then you set up headquarters (kubeadm init). Then each branch signs in with a one-day pass (kubeadm join). Finally you connect the phone lines between them (the CNI plugin).

On the exam you may need to install or join a node with the docs open. Knowing the order of steps by heart, and why each step exists, means you only look up exact commands, never the plan.

Press Play on a diagram to walk through it one step at a time.

FlowBuilding a kubeadm cluster
  1. 1
    Prepare nodes

    Disable swap, load br_netfilter, enable IP forwarding.

  2. 2
    Install runtime

    containerd with SystemdCgroup = true.

  3. 3
    Install packages

    kubeadm, kubelet, kubectl from pkgs.k8s.io; hold versions.

  4. 4
    kubeadm init

    Creates certs, static Pods and admin kubeconfig.

  5. 5
    Install CNI

    Apply Calico, Cilium or Flannel manifests.

  6. 6
    kubeadm join

    Run the join command on each worker.

SequenceA worker joining the cluster
kubeadm join
API server
kubelet
Controller manager
  1. 1Fetch cluster info with bootstrap token
    kubeadm join to API server: Fetch cluster info with bootstrap token
  2. 2Write bootstrap kubeconfig, start kubelet
    kubeadm join to kubelet: Write bootstrap kubeconfig, start kubelet
  3. 3Submit certificate signing request
    kubelet to API server: Submit certificate signing request
  4. 4Auto-approve and sign the CSR
    Controller manager to API server: Auto-approve and sign the CSR
  5. 5Register Node object
    kubelet to API server: Register Node object
  6. 6Report Ready once CNI is present
    kubelet to API server: Report Ready once CNI is present

In depth

Preparing every node

Kubernetes needs a few kernel settings. Load the overlay and br_netfilter modules, and set net.ipv4.ip_forward = 1 so the node can route Pod traffic. Turn swap off, or the kubelet will refuse to start with its default settings.

Install containerd and set SystemdCgroup = true in /etc/containerd/config.toml, so it uses the same cgroup driver as the kubelet. Then add the pkgs.k8s.io package repository for your exact minor version, install kubeadm, kubelet and kubectl, and hold them with apt-mark hold so a routine system update cannot upgrade them by accident.

  • modprobe overlay and br_netfilter
  • sysctl net.ipv4.ip_forward=1
  • swapoff -a and remove swap from /etc/fstab
  • apt-mark hold kubelet kubeadm kubectl

What kubeadm init actually does

kubeadm init runs a series of phases. Preflight checks catch problems like swap or a busy port 6443. Then it creates a certificate authority and all certificates in /etc/kubernetes/pki, writes kubeconfig files (admin.conf, kubelet.conf and others), and writes static Pod manifests for etcd and the control plane to /etc/kubernetes/manifests.

The kubelet sees those manifests and starts the components. kubeadm then waits for the API server, taints the node so normal Pods avoid it, creates a bootstrap token and installs the CoreDNS and kube-proxy add-ons. At the end it prints the join command.

FlowPhases of kubeadm init
  1. 1
    Preflight

    Swap, ports like 6443, runtime

  2. 2
    Certificates

    CA and certs in /etc/kubernetes/pki

  3. 3
    kubeconfig files

    admin.conf, kubelet.conf and others

  4. 4
    Static Pod manifests

    etcd and control plane; kubelet starts them

  5. 5
    Taint control plane

    Normal Pods stay off

  6. 6
    Bootstrap token

    For kubeadm join

  7. 7
    Add-ons

    CoreDNS and kube-proxy

How joining works

kubeadm join needs three things: the API server address, a bootstrap token, and a hash of the cluster CA certificate. The token proves the node is allowed to join. The CA hash lets the node verify it is talking to the real cluster and not an impostor.

The new kubelet then sends a certificate signing request, which is approved automatically, and gets its own client certificate. Tokens expire after 24 hours by default, so print a fresh command with kubeadm token create --print-join-command when you need one.

The CNI step and the Pod CIDR

After init, the node is NotReady and CoreDNS is Pending. That is normal: there is no Pod network yet. Install a CNI plugin such as Calico, Cilium or Flannel by applying its manifest or Helm chart.

The --pod-network-cidr you gave kubeadm must match what the plugin expects, or must be configured in the plugin. Flannel defaults to 10.244.0.0/16, and Calico's sample manifests commonly use 192.168.0.0/16. A mismatch shows up as Pods that cannot reach each other across nodes.

Learn it in 5 short steps

About 1h each. Track them with a timer in your plan.

  1. 1
    Prepare nodes and install kubeadm, kubelet, kubectl~1h
  2. 2
    Run kubeadm init on the control plane~1h
  3. 3
    Install a CNI plugin~1h
  4. 4
    Join worker nodes~1h
  5. 5
    Repeat the install from memory~1h

Key points

  • Set --pod-network-cidr to match what your CNI plugin expects.
  • Copy /etc/kubernetes/admin.conf to ~/.kube/config to use kubectl.
  • kubeadm token create --print-join-command regenerates an expired join command.
  • The kubelet and runtime must use the same cgroup driver, normally systemd.

Key terms

Tap a card to flip it. 0/5 known

Examples

bash
# Control plane
sudo kubeadm init --pod-network-cidr=192.168.0.0/16
mkdir -p ~/.kube
sudo cp /etc/kubernetes/admin.conf ~/.kube/config
sudo chown $(id -u):$(id -g) ~/.kube/config
kubectl apply -f calico.yaml
kubeadm token create --print-join-command

# Each worker
sudo kubeadm join 10.0.0.10:6443 --token abc.123 \
  --discovery-token-ca-cert-hash sha256:<hash>

Bootstrapping the control plane

Step 1: on the prepared control plane node, run kubeadm init with the Pod CIDR your CNI wants. Step 2: copy admin.conf so kubectl works for your user. Step 3: install the CNI. Step 4: wait until the node is Ready and CoreDNS is Running.

bash
sudo kubeadm init --pod-network-cidr=192.168.0.0/16 \
  --apiserver-advertise-address=10.0.0.10
mkdir -p $HOME/.kube
sudo cp /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl apply -f calico.yaml     # manifest from the Calico docs
kubectl get nodes -w

Joining a worker the next day

The original token has expired. Step 1: on the control plane, print a fresh join command. Step 2: run it with sudo on the worker. Step 3: back on the control plane, watch the node appear and turn Ready once the CNI Pods start on it.

bash
kubeadm token create --print-join-command
# kubeadm join 10.0.0.10:6443 --token abcdef.0123456789abcdef \
#   --discovery-token-ca-cert-hash sha256:5c1f...
ssh worker1 'sudo kubeadm join 10.0.0.10:6443 --token abcdef.0123456789abcdef \
  --discovery-token-ca-cert-hash sha256:5c1f...'
kubectl get nodes -w

Quick reference

  • Before init: modules overlay and br_netfilter, ip_forward=1, swap off, containerd with SystemdCgroup
  • Repo per minor version: pkgs.k8s.io/core:/stable:/v1.34/deb/
  • sudo apt-mark hold kubelet kubeadm kubectl
  • kubeadm init --pod-network-cidr=CIDR --apiserver-advertise-address=IP
  • kubeadm token create --print-join-command
  • Certificates live in /etc/kubernetes/pki; manifests in /etc/kubernetes/manifests
  • kubeadm config print init-defaults shows every init option

Common mistakes

  • Forgetting the CNI, leaving nodes NotReady and CoreDNS Pending.
  • Mismatched cgroup drivers, making the kubelet crash loop.

Quick quiz

Pick an answer to see if you're right and why.

Question 1

1kubeadm init fails preflight saying swap is on. What do you do?

Question 2

2What does the --discovery-token-ca-cert-hash flag protect against?

Question 3

3Right after kubeadm init, CoreDNS Pods are Pending. What is the usual reason?

Question 4

4Why hold the kubelet, kubeadm and kubectl packages?

0/4 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. Exercise 1easy

    On a node, check the three most common kubeadm preflight problems: swap, IP forwarding and the containerd service.

  2. Exercise 2medium

    Write the sysctl and module config files that make the networking settings survive a reboot.

  3. Exercise 3hard

    Install a full cluster (one control plane, one worker) from memory, using the docs only for the package repository and CNI URLs. Time yourself.

Check yourself

Answer in your head, reveal, then be honest with yourself.

Feel confident about this topic?

Frequently asked questions

Can I run Pods on the control plane node?
Yes, by removing the node-role.kubernetes.io/control-plane:NoSchedule taint. That is fine for a one-node lab but not for production.
What if I lose the join command?
Run kubeadm token create --print-join-command on the control plane. It creates a new token and prints the full command with the CA hash.
Which CNI plugin should I learn for the exam?
Any common one works. Calico is a good choice because it is widely documented and enforces NetworkPolicies.

Go deeper

ShareXLinkedInWhatsApp