Building a Cluster with kubeadm

In the previous post I installed three Ubuntu VMs. Now I will follow the steps on Kubernetes.io to build a three-node Kubernetes cluster.

Building a kubeadm Cluster (Part 1): Preparing Practice VMs with KVM and cloud-initA comparison of common Kubernetes setup tools, then using virt-install with an Ubuntu Cloud Image and cloud-init to quickly create three VMs for kubeadmlcxlab.com/post/cka-kubeadm-lab-setup

From the very top of the documentation:

The kubeadm tool is good if you need:

  • A simple way for you to try out Kubernetes, possibly for the first time.
  • A way for existing users to automate setting up a cluster and test their application.
  • A building block in other ecosystem and/or installer tools with a larger scope.

kubeadm-stacked-color

kubeadm can build a cluster on all kinds of hardware, whether it is a laptop, a server in the cloud, or a board like the Raspberry Pi. It works both in the cloud and on-premises, and it can be integrated into automation tools such as Ansible and Terraform.

kubeadm only handles the minimum steps needed to stand a cluster up. Networking (CNI), storage, monitoring and other components are building blocks you pick and assemble yourself. Because it is not tied to any particular platform, it runs on very different hardware. This do-it-yourself feeling reminds me a bit of Gentoo1.


Before You Begin

The officially recommended requirements are:

  • One or more machines running a deb/rpm-compatible Linux OS, such as Ubuntu or CentOS.
  • At least 2 GiB of RAM per machine.
  • At least 2 CPUs on the control-plane node.
  • Full network connectivity between all machines in the cluster (public or private network is fine).

The documentation currently targets Kubernetes v1.37, which is the version the CKA exam uses, so from here on it is mostly a matter of following the docs.

The docs are split across pages

Creating a cluster with kubeadm assumes kubeadm is already installed, so you will not find the installation steps there. Installation lives on a separate page, Installing kubeadm, and the container runtime prerequisites are on Container Runtimes. Read them in this order: Installing kubeadm → Container Runtimes → back to Creating a cluster with kubeadm.


Creating the Cluster

I do not want to go into too much detail here, since the docs already cover everything. This section walks through each step and the problems you may run into. The steps are grouped by which node runs them:

Steps Run on
1–5: disable swap, kernel parameters, containerd, kubeadm/kubelet/kubectl All three nodes
6–7: kubeadm init, install a CNI Control plane only (k8s-cp1)
8: kubeadm join Workers only

Steps 3 and 5 each have two installation methods: apt packages, or downloading the binaries directly from GitHub / dl.k8s.io. Pick one per machine and do not mix them.

1. Disable swap

By default kubelet refuses to start when it sees swap (failSwapOn: true). Kubernetes scheduling relies on each Pod's memory requests and limits; with swap, memory usage is no longer accurate and OOM behavior becomes hard to predict. Newer versions can be configured to let kubelet tolerate swap, but in a practice environment it is simplest to turn it off, and kubeadm's preflight checks will not complain.

sudo swapoff -a                                          # turn it off now
sudo sed -i -E '/^[^#].*\sswap\s/ s/^/#/' /etc/fstab     # comment out swap in fstab so it stays off after a reboot
swapon --show                                            # no output means swap is off
free -h                                                  # the Swap row should be 0B

My three Ubuntu VMs never had swap configured, so I could skip this step

2. Load kernel modules and enable IP forwarding

Pod traffic has to be forwarded by the node to other nodes or Services, so Linux must allow IPv4 forwarding. br_netfilter makes traffic that crosses a bridge go through iptables as well, which kube-proxy and most CNIs depend on. overlay is needed by containerd's overlayfs snapshotter.

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.ipv4.ip_forward                 = 1
net.bridge.bridge-nf-call-iptables  = 1
net.bridge.bridge-nf-call-ip6tables = 1
EOF
sudo sysctl --system

sysctl net.ipv4.ip_forward    # should be 1

The official Container Runtimes page currently lists only ip_forward as required; the other two depend on the CNI. Almost every tutorial sets all three anyway, and setting them has no side effects.

3. Install containerd (CRI)

kubelet does not run containers itself. It uses the CRI (Container Runtime Interface) to ask containerd to pull images and create containers. Kubernetes removed dockershim in 1.24, so these days you install containerd directly.

Method 1: apt

The containerd package in the Ubuntu repositories installs runc along with it:

sudo apt-get update
sudo apt-get install -y containerd

Method 2: Download from GitHub

When downloading yourself, you install three components separately:

Component Role
containerd The CRI implementation; kubelet manages containers through it
runc The low-level runtime that actually calls Linux namespaces/cgroups to run the container
CNI plugins Basic network plugins such as bridge, host-local and loopback, used by CNIs like Flannel

First set up a few variables. latest uses the GitHub API to fetch the tag of a repo's latest release:

ARCH="amd64"
latest() { curl -fsSL "https://api.github.com/repos/$1/releases/latest" | grep -oP '"tag_name":\s*"\K[^"]+'; }
# containerd: extract into /usr/local/bin
CONTAINERD_VERSION=$(latest containerd/containerd)
V=${CONTAINERD_VERSION#v}
curl -LO "https://github.com/containerd/containerd/releases/download/${CONTAINERD_VERSION}/containerd-${V}-linux-${ARCH}.tar.gz"
curl -LO "https://github.com/containerd/containerd/releases/download/${CONTAINERD_VERSION}/containerd-${V}-linux-${ARCH}.tar.gz.sha256sum"
sha256sum -c containerd-${V}-linux-${ARCH}.tar.gz.sha256sum   # verify the file was not tampered with
sudo tar Cxzvf /usr/local containerd-${V}-linux-${ARCH}.tar.gz

# containerd's systemd unit (not included in the tarball, download it separately)
sudo mkdir -p /usr/local/lib/systemd/system
sudo curl -L -o /usr/local/lib/systemd/system/containerd.service \
  https://raw.githubusercontent.com/containerd/containerd/main/containerd.service

# runc: a single statically compiled binary
RUNC_VERSION=$(latest opencontainers/runc)
curl -LO "https://github.com/opencontainers/runc/releases/download/${RUNC_VERSION}/runc.${ARCH}"
sudo install -m 755 runc.${ARCH} /usr/local/sbin/runc

# CNI plugins
CNI_VERSION=$(latest containernetworking/plugins)
sudo mkdir -p /opt/cni/bin
curl -L "https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-linux-${ARCH}-${CNI_VERSION}.tgz" \
  | sudo tar -C /opt/cni/bin -xz

This section is based on containerd's official Getting started guide (Option 1: From the official binaries).

4. Switch containerd's cgroup driver to systemd

kubelet and the container runtime must use the same cgroup driver. Ubuntu manages cgroups with systemd, and since v1.22 kubeadm also makes kubelet use systemd by default, but containerd defaults to cgroupfs.

❗Watch out

If the two do not match, the control plane Pods keep restarting. This is one of the most common pitfalls.

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
grep -n SystemdCgroup /etc/containerd/config.toml   # confirm it is now true
sudo systemctl daemon-reload                         # method 2 added a unit file, so reload first
sudo systemctl enable containerd
sudo systemctl restart containerd

containerd 2.x uses a different config format

containerd installed with apt on Ubuntu 24.04 is 1.7, while the latest release from GitHub is 2.x. Its config file uses version = 3 and the section names are different. If the grep above finds nothing, open config.toml and add SystemdCgroup = true under [plugins.'io.containerd.cri.v1.runtime'.containerd.runtimes.runc.options] by hand.

5. Install kubeadm, kubelet and kubectl

These three are:

  • kubeadm: the tool that builds the cluster
  • kubelet: the agent on every node that actually runs the Pods
  • kubectl: the CLI for working with the cluster

Method 1: apt

sudo apt-get install -y apt-transport-https ca-certificates curl gpg
sudo mkdir -p -m 755 /etc/apt/keyrings
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.37/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.37/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   # pin the versions so apt upgrade does not quietly upgrade them
sudo systemctl enable --now kubelet
  • There is one repo per minor version, and the v1.37 in the URL selects the version. The CKA also tests cluster upgrades, and that is exactly the line you change then.

Method 2: Download from dl.k8s.io

The Kubernetes binaries are not published on GitHub Releases (the kubernetes/kubernetes Releases page only has release notes). They are hosted on the official dl.k8s.io. The "Without a package manager" section of the Installing kubeadm page does it this way, but the versions hard-coded in the docs are older, so here they are fetched automatically.

The apt kubelet package pulls in conntrack and socat as dependencies. With the binaries you have to install them yourself. Without conntrack, kubeadm's preflight check fails right away:

sudo apt-get install -y conntrack socat
ARCH="amd64"
K8S_MINOR="1.37"
# stable-1.37.txt pins the latest 1.37 patch release
# the official example uses stable.txt, which gets the overall latest release, not necessarily 1.37
RELEASE=$(curl -sSL https://dl.k8s.io/release/stable-${K8S_MINOR}.txt)
DOWNLOAD_DIR=/usr/local/bin

cd /tmp
curl -L --remote-name-all https://dl.k8s.io/release/${RELEASE}/bin/linux/${ARCH}/{kubeadm,kubelet,kubectl}
sudo install -m 755 kubeadm kubelet kubectl ${DOWNLOAD_DIR}/

# crictl: kubeadm uses it to check the CRI; its version follows the Kubernetes minor
CRICTL_VERSION="v${K8S_MINOR}.0"
curl -L "https://github.com/kubernetes-sigs/cri-tools/releases/download/${CRICTL_VERSION}/crictl-${CRICTL_VERSION}-linux-${ARCH}.tar.gz" \
  | sudo tar -C ${DOWNLOAD_DIR} -xz

kubelet needs a systemd unit to be managed. The apt package ships these two files; when installing yourself, download them from the kubernetes/release repo and change the path from /usr/bin to /usr/local/bin:

RELEASE_VERSION="v0.16.2"   # version of the kubernetes/release repo, as in the official docs
curl -sSL "https://raw.githubusercontent.com/kubernetes/release/${RELEASE_VERSION}/cmd/krel/templates/latest/kubelet/kubelet.service" \
  | sed "s:/usr/bin:${DOWNLOAD_DIR}:g" | sudo tee /usr/lib/systemd/system/kubelet.service
sudo mkdir -p /usr/lib/systemd/system/kubelet.service.d
curl -sSL "https://raw.githubusercontent.com/kubernetes/release/${RELEASE_VERSION}/cmd/krel/templates/latest/kubeadm/10-kubeadm.conf" \
  | sed "s:/usr/bin:${DOWNLOAD_DIR}:g" | sudo tee /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf

sudo systemctl daemon-reload
sudo systemctl enable --now kubelet

10-kubeadm.conf tells kubelet to read /var/lib/kubelet/config.yaml and /etc/kubernetes/kubelet.conf. Those two files are only created by kubeadm init or kubeadm join.

Check the versions:

kubeadm version -o short
kubelet --version
kubectl version --client
sudo crictl --runtime-endpoint unix:///run/containerd/containerd.sock version

The first line of the crictl output is WARN[0000] Config "/etc/crictl.yaml" does not exist, trying next: "/usr/local/bin/crictl.yaml", and you can ignore it. crictl looks for /etc/crictl.yaml and then a crictl.yaml next to the binary, and carries on with defaults if neither exists. Since --runtime-endpoint already points at containerd, it is connected, as RuntimeName: containerd below shows.

crictl ps and crictl logs come up a lot when debugging later, and passing the endpoint every time is tedious, so write a config file on all three nodes:

cat <<EOF | sudo tee /etc/crictl.yaml
runtime-endpoint: unix:///run/containerd/containerd.sock
image-endpoint: unix:///run/containerd/containerd.sock
timeout: 10
EOF

sudo crictl version   # no --runtime-endpoint needed, and no WARN

Comparing the two methods

apt (pkgs.k8s.io) Direct download (GitHub / dl.k8s.io)
Dependencies Handled automatically Install conntrack and socat yourself
systemd units Included in the package Download them yourself
Upgrades Change the repo version, apt-mark unhold, then upgrade Download again and replace the binaries
Strengths Simple, and matches the CKA exam environment Distribution-independent, and you see exactly where each component lives

💡CKA exam tip

The CKA upgrade tasks are done with apt, so for exam prep stick mainly to method 1. Method 2 is better for understanding what each component does.

Whichever method you use, systemctl status kubelet will now show kubelet restarting every few seconds. That is expected: it has no config yet and is waiting for kubeadm init or kubeadm join.

6. Initialize the control plane (k8s-cp1 only)

sudo kubeadm init \
  --apiserver-advertise-address=<cp1 IP> \
  --pod-network-cidr=10.244.0.0/16

  • --pod-network-cidr: the range Pod IPs come from. It must not overlap with the network the VMs are on.

❗Watch out

In my case the VMs are on libvirt's 192.168.122.0/24, and Calico's default Pod range 192.168.0.0/16 contains it. So I use 10.244.0.0/16 here, which is safe whichever CNI you pick.

  • --apiserver-advertise-address: the IP the API server listens on. You can leave it out if the VM has only one network interface.

What init actually does:

  1. Preflight checks (swap, ports, CRI and so on)
  2. Generates the certificates under /etc/kubernetes/pki
  3. Generates kubeconfig files
  4. Writes etcd, kube-apiserver, kube-controller-manager and kube-scheduler as static Pods (in /etc/kubernetes/manifests/, started directly by kubelet)
  5. Installs CoreDNS and kube-proxy

When it finishes, set up kubectl as the output tells you:

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

Remember to copy the kubeadm join ... line at the end of the output; you will need it in step 8.

7. Install a CNI (k8s-cp1 only)

If you run kubectl get nodes now, cp1 shows NotReady and CoreDNS is stuck in Pending. kubeadm does not install Pod networking for you; this is the "pick your own building blocks" part mentioned earlier.

What a CNI actually does, and how Pods talk across Nodes, is covered in a separate post:

Kubernetes Networking: How Do Pods Communicate?A short primer on Kubernetes network plugins, how Pods talk to each other, and the common approacheslcxlab.com/post/cni-plugins-for-kubernetes

I chose Calico here because it supports NetworkPolicy, which the CKA tests. Flannel does not support it, yet applying a NetworkPolicy does not fail either; the policy just sits there and has no effect. If you get it wrong while practicing you cannot tell, so you have no way to check your answers.

Calico is now installed with the tigera-operator: install the operator first, then use an Installation resource to tell it how to set up networking.

CALICO_VERSION=v3.33.0
BASE=https://raw.githubusercontent.com/projectcalico/calico/${CALICO_VERSION}/manifests

# CRDs and operator. The files are large, so use create; apply exceeds the annotation size limit
kubectl create -f ${BASE}/v3_projectcalico_org.yaml    # use this one for Kubernetes 1.36 and later
kubectl create -f ${BASE}/tigera-operator.yaml

# The default Pod range is 192.168.0.0/16; change it to the 10.244.0.0/16 used in kubeadm init
curl -sSLO ${BASE}/custom-resources.yaml
sed -i 's#cidr: 192.168.0.0/16#cidr: 10.244.0.0/16#' custom-resources.yaml
grep cidr custom-resources.yaml    # confirm the change
kubectl create -f custom-resources.yaml

kubectl get pods -n calico-system -w    # wait for calico-node and the other components to be Running
kubectl get tigerastatus                # it is installed only when every component shows AVAILABLE True

❗Watch out

You must change the cidr in custom-resources.yaml. Otherwise Calico hands out Pod IPs from 192.168.0.0/16, which overlaps with the VMs' 192.168.122.0/24, and traffic between Pods or from Pods to nodes takes the wrong route. Older tutorials say to change CALICO_IPV4POOL_CIDR; that setting belongs to the old calico.yaml manifest install. With the operator, this is the place to change it.

Calico's Pods run in the calico-system namespace, not kube-system. When workers join later, the operator automatically runs a calico-node on each new node.

❗Watch out: the host must not rewrite the source IP of VM-to-VM traffic

Check this on the physical host (the machine running libvirt), not inside the VMs.

With Calico's default vxlanMode: CrossSubnet, traffic is only encapsulated across subnets; within the same subnet, nodes exchange routes over BGP (TCP 179). BIRD only accepts connections from known node IPs. If the host masquerades VM-to-VM packets as 192.168.122.1, BIRD rejects them as an unknown peer. calico-node then stays at 0/1 until the startup probe restarts it, and new Pods get stuck in Pending.

The problem appears when both of these are true at the same time:

  1. The host has br_netfilter loaded and net.bridge.bridge-nf-call-iptables = 1. This is common if the host has ever run Docker, k3s or kind. Bridged traffic on virbr0 then also goes through the host's iptables/nft rules.
  2. The firewalld libvirt zone has masquerade enabled. Zone masquerade does not exclude the local subnet, so VM-to-VM traffic is rewritten too. libvirt's own NAT rules already exclude the local subnet and do not need this.
# On the libvirt host: if both are true, you need to fix it
sysctl net.bridge.bridge-nf-call-iptables        # 1 means bridged traffic goes through iptables
firewall-cmd --zone=libvirt --query-masquerade   # yes means the zone masquerades

The recommended fix is to remove masquerade from the libvirt zone. You do not have to touch br_netfilter, and Docker on the host is unaffected:

sudo firewall-cmd --zone=libvirt --remove-masquerade

# Inside a VM, check that it can still reach the internet
ping -c 3 8.8.8.8
sudo apt update

# If it works, make it permanent
sudo firewall-cmd --permanent --zone=libvirt --remove-masquerade

If the host does not use firewalld, or the VMs lose internet access after removing masquerade (add it back with --add-masquerade), turn off bridge netfilter on the host instead:

sudo sysctl -w net.bridge.bridge-nf-call-iptables=0 \
 net.bridge.bridge-nf-call-ip6tables=0 \
 net.bridge.bridge-nf-call-arptables=0

This has two drawbacks: Docker's filtering between containers on the same bridge (such as --icc=false) stops working, and dockerd may set it back to 1 when it starts, bringing the problem back.

Do not confuse this with step 2: br_netfilter and bridge-nf-call-iptables = 1 inside the VMs are required by Kubernetes and must stay. This section is about the settings on the host.

Flannel (alternative)

If you just want the cluster running and do not plan to practice NetworkPolicy, Flannel installs in one line. Its default range happens to be 10.244.0.0/16, so nothing needs changing:

kubectl apply -f https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml
kubectl get pods -n kube-flannel -w    # wait for kube-flannel-ds to be Running

Pick either Calico or Flannel. Do not install both.

Calico vs. Flannel

Calico Flannel
NetworkPolicy Supported Not supported (apply does not fail, but nothing is enforced)
Installation Operator + CRDs, three steps, cidr must be changed One manifest, one line
Default Pod range 192.168.0.0/16 (must be changed in this setup) 10.244.0.0/16 (no change needed)
Packet forwarding VXLAN by default (encapsulated only across subnets); also BGP direct routing or eBPF VXLAN overlay
Resource usage More components (operator, calico-node, typha, apiserver and so on) One DaemonSet Pod per node, very light
Best for CKA prep and environments that need NetworkPolicy Practice environments that only need Pod networking to work

8. Join the workers (k8s-w1, k8s-w2)

Run the kubeadm join ... command from step 6 on w1 and w2 to add both nodes to the cluster.

sudo kubeadm join <cp1 IP>:6443 --token <token> \
  --discovery-token-ca-cert-hash sha256:<hash>

If the token has expired (it is valid for 24 hours) or you did not copy it, generate a new one on cp1:

kubeadm token create --print-join-command

Finally, verify on cp1:

kubectl get nodes -o wide   # all three are Ready

A node being Ready only means the CNI config is in place; it does not prove Calico is healthy. BGP sessions only start once the workers have joined, so check Calico again now:

kubectl get pods -n calico-system -l k8s-app=calico-node   # every node should be 1/1 Running
kubectl get tigerastatus                                    # calico should be AVAILABLE=True

# BGP must be established with the other two nodes; a three-node cluster should show = 2
kubectl logs -n calico-system -l k8s-app=calico-node -c calico-node --tail=5 | grep "BGP peering"

Then run a few Pods to confirm cross-node Pod networking works:

kubectl create deployment nginx --image=nginx:1.29 --replicas=3
kubectl get po -l app=nginx -o wide    # all Running, spread across w1 and w2

# Connect to each nginx Pod IP from another Pod; every line should print Welcome to nginx!
for ip in $(kubectl get po -l app=nginx -o jsonpath='{.items[*].status.podIP}'); do
  kubectl run tmp --rm -i --image=busybox:1.37 --restart=Never -- wget -qO- -T 3 $ip | grep -o "Welcome to nginx!" || echo "FAIL $ip"
done

kubectl delete deployment nginx    # clean up when done

If calico-node stays at 0/1 and RESTARTS keeps going up, check the logs first:

kubectl logs -n calico-system -l k8s-app=calico-node -c calico-node --tail=20

If you see BGP not established together with Unexpected connect from unknown address 192.168.122.1, it is the host masquerade problem described above. After fixing the host, delete calico-node so it gets recreated:

kubectl delete pod -n calico-system -l k8s-app=calico-node

📌 Other notes

The CKA exam environment usually has the k alias for kubectl already set up, so you can run commands like k get nodes directly. If your own Linux environment does not have it yet, add it for the shell you use.

Bash (exam environment)

echo "alias k='kubectl'" >> ~/.bashrc
source ~/.bashrc

Zsh

echo "alias k='kubectl'" >> ~/.zshrc
source ~/.zshrc

Fish

alias k kubectl
funcsave k

After that, you can use k instead of kubectl, for example:

k get nodes
k get pods -A
k describe node k8s-cp1

One more exam detail: the CKA terminal usually has kubectl completion set up too, but it is still worth getting comfortable with k, kubectl and Tab completion rather than relying too much on the alias.


Common Problems

Problem Cause
Preflight reports a swap error Step 1 was skipped, or fstab was not changed and swap came back after a reboot
Preflight reports conntrack not found conntrack was not installed when using method 2
Control plane Pods keep CrashLooping containerd was not changed to SystemdCgroup = true
Nodes stay NotReady No CNI installed yet
Pods cannot reach each other The Pod range overlaps with the VM network (192.168.122.0/24)
calico-node stays 0/1, new Pods stuck in Pending, logs show Unexpected connect from unknown address 192.168.122.1 The libvirt host's br_netfilter plus masquerade in the firewalld libvirt zone rewrite the source of VM-to-VM BGP traffic to 192.168.122.1; see the warning in step 7
Join fails or nodes break after a reboot The VMs get their IPs over DHCP and the IPs changed; give the three VMs fixed IPs in libvirt

That takes us from zero to a Kubernetes cluster built with kubeadm. It is still very basic: a single control plane, no high availability, and no storage, Ingress or monitoring yet. But having gone through it once, you at least know where each of these pieces lives:

  • containerd is the container runtime kubelet calls through the CRI, and its cgroup driver must be systemd, the same as kubelet
  • kubeadm init generates the certificates and kubeconfig files and writes the control plane components as static Pods under /etc/kubernetes/manifests/
  • The CNI is yours to install, and nodes stay NotReady until it is; Calico was chosen so NetworkPolicy can be practiced later
  • kubeadm join lets workers join the cluster with a token and the CA hash

Every cluster in the CKA exam is built with kubeadm, so where static Pods live, where the certificates are and how kubelet loads its config all come up again in the upgrade and troubleshooting tasks.

💡 Take a snapshot first

Once the cluster is built and all three nodes are Ready, take a snapshot of each VM. Practicing upgrades, etcd restores and troubleshooting will inevitably break the cluster at some point, and with snapshots you can go straight back to a clean state instead of reinstalling from scratch:

for vm in k8s-cp1 k8s-w1 k8s-w2; do sudo virsh snapshot-create-as "$vm" cluster-ready; done
sudo virsh snapshot-list k8s-cp1    # confirm the snapshot exists

To restore, revert all three together so etcd's data stays consistent with the workers:

for vm in k8s-cp1 k8s-w1 k8s-w2; do sudo virsh snapshot-revert "$vm" cluster-ready; done

A snapshot taken while the VM is running includes its memory, so after reverting the VM is running again exactly as it was, but its clock is also back at the moment the snapshot was taken. If kubectl shows certificate or lease errors right after the revert, give chrony a minute or two to correct the time.

From the next post on, this cluster is used for hands-on practice, starting with the most common topic, workloads and scheduling: rolling updates, resource limits and autoscaling.

Workloads and Scheduling: Rolling Updates, Resource Limits and AutoscalingDeployment rolling updates and rollbacks, requests/limits, taints/tolerations and affinity, plus HPA autoscaling added in the 2025 exam revisionlcxlab.com/post/cka-workloads-scheduling

References

  1. Creating a cluster with kubeadmkubernetes.io
  2. Installing kubeadmkubernetes.io
  3. Container Runtimeskubernetes.io
  4. Getting started with containerdgithub.com
  5. Calico Documentationdocs.tigera.io
  6. Flannelgithub.com

Footnotes

  1. Gentoo is a Linux distribution known for its high degree of customization: users choose, compile and configure the software and components in their system to fit their own needs. The point here is the same philosophy of control and customization: kubeadm only provides the basic flow for initializing a Kubernetes cluster, and the user picks and integrates everything else. ↩