Day 0: Training Ground
Goal: A kubeadm cluster with three nodes, ingress, storage, metrics and your own registry is ready for all following days. · Duration: approx. 90 min · Prerequisite: three VMs with Ubuntu 24.04
Briefing
The CKAD exam does not ask you to build a cluster – you get ready-made clusters. This chapter therefore builds the lab at full speed: commands to type along, hardly any explanation. If you already have a cluster with an ingress controller, a default StorageClass, metrics-server and a reachable registry, skip to the checkpoint.
cp1 .126 worker1 .228 worker2 .83
control-plane, kubectl, worker worker
helm, podman
4 vCPU / 12 GB 2 vCPU / 4 GB 2 vCPU / 4 GB
|_________________________|________________________|
172.16.0.0/24 · Pods 192.168.0.0/16 (Calico)
NodePorts: 30080/30443 Traefik · 30500 Registry
Replace the IPs with your own. There is no name resolution between
the VMs, which is why IPs appear everywhere. Drills 1 to 3 run on
all three VMs, the rest on cp1.
Drill 1: Prepare the kernel
printf 'overlay\nbr_netfilter\n' | sudo tee /etc/modules-load.d/k8s.conf
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 >/dev/null
sysctl net.ipv4.ip_forward net.bridge.bridge-nf-call-iptables
swapon --show | wc -lExpected:
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-iptables = 1
0
If swapon shows anything: run
sudo swapoff -a and comment out the swap line in
/etc/fstab.
Save your progress? Sign up for free
Drill 2: containerd and runc
Both straight from the project, each with a checksum:
cd /tmp
V=2.4.2
U=https://github.com/containerd/containerd/releases/download/v$V
ARCH=$(dpkg --print-architecture)
curl -sSLO $U/containerd-$V-linux-${ARCH}.tar.gz
curl -sSLO $U/containerd-$V-linux-${ARCH}.tar.gz.sha256sum
sha256sum -c containerd-$V-linux-${ARCH}.tar.gz.sha256sum
sudo tar Cxzf /usr/local containerd-$V-linux-${ARCH}.tar.gz
sudo mkdir -p /usr/local/lib/systemd/system
sudo curl -sSL -o /usr/local/lib/systemd/system/containerd.service \
https://raw.githubusercontent.com/containerd/containerd/v$V/containerd.service
R=1.5.3
U=https://github.com/opencontainers/runc/releases/download/v$R
curl -sSLO $U/runc.${ARCH}
curl -sSLO $U/runc.sha256sum
grep " runc.${ARCH}$" runc.sha256sum | sha256sum -c
sudo install -m 755 runc.${ARCH} /usr/local/sbin/runcExpected:
containerd-2.4.2-linux-amd64.tar.gz: OK
runc.amd64: OK
Generate the configuration and switch to the systemd cgroup driver (like the kubelet):
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
sudo systemctl daemon-reload
sudo systemctl enable --now containerd
containerd --versionExpected:
89: SystemdCgroup = true
containerd github.com/containerd/containerd/v2 v2.4.2 b7a25261e029...
Save your progress? Sign up for free
Drill 3: kubeadm, kubelet, kubectl
sudo apt-get update
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
K=/etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo "deb [signed-by=$K] 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=1.37.2-1.1 kubeadm=1.37.2-1.1 kubectl=1.37.2-1.1 \
cri-tools
sudo apt-mark hold kubelet kubeadm kubectl
printf 'runtime-endpoint: unix:///run/containerd/containerd.sock\n' \
| sudo tee /etc/crictl.yaml
printf 'image-endpoint: unix:///run/containerd/containerd.sock\n' \
| sudo tee -a /etc/crictl.yaml
kubeadm version -o short
sudo crictl versionExpected:
kubelet set on hold.
kubeadm set on hold.
kubectl set on hold.
...
v1.37.2
Version: 0.1.0
RuntimeName: containerd
RuntimeVersion: v2.4.2
RuntimeApiVersion: v1
Save your progress? Sign up for free
Drill 4: Initialize the cluster and join the nodes
On cp1:
sudo kubeadm init --kubernetes-version=v1.37.2 \
--apiserver-advertise-address=172.16.0.126 --pod-network-cidr=192.168.0.0/16
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/configExpected (shortened):
Your Kubernetes control-plane has initialized successfully!
The Calico network plugin via its operator:
C=https://raw.githubusercontent.com/projectcalico/calico/v3.33.1/manifests
kubectl create -f $C/operator-crds.yaml
kubectl create -f $C/tigera-operator.yaml
kubectl create -f $C/custom-resources.yaml
kubeadm token create --print-join-commandExpected (shortened):
installation.operator.tigera.io/default created
kubeadm join 172.16.0.126:6443 --token ... --discovery-token-ca-cert-hash sha256:...
Run the printed kubeadm join line with sudo
on worker1 and worker2. Then back on
cp1:
kubectl get nodes
kubectl get tigerastatus calicoExpected:
NAME STATUS ROLES AGE VERSION
cp1 Ready control-plane 11m v1.37.2
worker1 Ready <none> 10m v1.37.2
worker2 Ready <none> 10m v1.37.2
NAME AVAILABLE PROGRESSING DEGRADED SINCE MESSAGE
calico True False False 9m9s All objects available
Save your progress? Sign up for free
Drill 5: Helm, metrics-server, local-path
cd /tmp
ARCH=$(dpkg --print-architecture)
curl -sSLO https://get.helm.sh/helm-v4.3.2-linux-${ARCH}.tar.gz
curl -sSLO https://get.helm.sh/helm-v4.3.2-linux-${ARCH}.tar.gz.sha256sum
sha256sum -c helm-v4.3.2-linux-${ARCH}.tar.gz.sha256sum
tar xzf helm-v4.3.2-linux-${ARCH}.tar.gz
sudo install -m 755 linux-${ARCH}/helm /usr/local/bin/helm
helm version --shortExpected:
helm-v4.3.2-linux-amd64.tar.gz: OK
v4.3.2+g8346aaa
In the lab, metrics-server needs --kubelet-insecure-tls
because the kubelet certificates are self-signed:
M=https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.9.1
kubectl apply -f $M/components.yaml
kubectl -n kube-system patch deployment metrics-server --type=json -p \
'[{"op":"add","path":"/spec/template/spec/containers/0/args/-",
"value":"--kubelet-insecure-tls"}]'
L=https://raw.githubusercontent.com/rancher/local-path-provisioner/v0.0.37
kubectl apply -f $L/deploy/local-path-storage.yaml
kubectl patch storageclass local-path -p \
'{"metadata":{"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
kubectl get storageclassExpected (shortened):
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE
local-path (default) rancher.io/local-path Delete WaitForFirstConsumer
WaitForFirstConsumer means: the volume is only created
when a pod uses the PVC – on that pod’s node.
Save your progress? Sign up for free
Drill 6: Traefik ingress controller
helm repo add traefik https://traefik.github.io/charts
helm install traefik traefik/traefik --version 42.4.1 -n traefik --create-namespace \
--set service.spec.type=NodePort \
--set ports.web.nodePort=30080 --set ports.websecure.nodePort=30443
kubectl get svc -n traefik
kubectl get ingressclassExpected:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
traefik NodePort 10.109.178.12 <none> 80:30080/TCP,443:30443/TCP 7m
NAME CONTROLLER PARAMETERS AGE
traefik (default) traefik.io/ingress-controller <none> 7m
Warning:
--set service.type=NodePortfails against the chart’s schema with “additional properties ‘type’ not allowed”. The type lives underservice.spec.
Save your progress? Sign up for free
Drill 7: A registry in the cluster
Your own images from Day 2 need a destination. A simple registry as a Deployment with NodePort 30500:
kubectl create namespace registry
kubectl create deployment registry -n registry \
--image=docker.io/library/registry:3.1.2 --port=5000
kubectl expose deployment registry -n registry --type=NodePort --port=5000 \
--dry-run=client -o yaml > registry-svc.yamlIn registry-svc.yaml, add the line
nodePort: 30500 under ports::
ports:
- nodePort: 30500
port: 5000
protocol: TCP
targetPort: 5000kubectl apply -f registry-svc.yaml
curl -s http://172.16.0.126:30500/v2/_catalogExpected:
{"repositories":[]}
The registry only speaks HTTP. So that containerd can pull from it, on all three VMs:
sudo sed -i "s|config_path = ''|config_path = '/etc/containerd/certs.d'|" \
/etc/containerd/config.toml
sudo mkdir -p /etc/containerd/certs.d/172.16.0.126:30500
cat <<'EOF' | sudo tee /etc/containerd/certs.d/172.16.0.126:30500/hosts.toml
server = "http://172.16.0.126:30500"
[host."http://172.16.0.126:30500"]
capabilities = ["pull", "resolve"]
EOF
sudo systemctl restart containerd
grep -n "config_path" /etc/containerd/config.tomlExpected:
31: config_path = '/etc/containerd/certs.d'
149: plugin_config_path = '/etc/nri/conf.d'
255: config_path = '/etc/containerd/certs.d'
Warning: The registry stores its data in an emptyDir. If its pod restarts, all images are gone – then simply push them again (Day 2).
Save your progress? Sign up for free
Drill 8: podman on cp1
To build images you use podman – it needs no daemon, and the exam also works with podman or docker.
sudo apt-get install -y podman
podman version | head -3Expected:
Client: Podman Engine
Version: 4.9.3
API Version: 4.9.3
Save your progress? Sign up for free
Exercise: Speed Drills
- Show which node the registry runs on. Target time: 20 s
- Check via the CRI whether containerd uses the systemd cgroup driver. Target time: 20 s
- Show the CPU load of all nodes. Target time: 10 s
Solution
kubectl get pods -n registry -o wide
sudo crictl info | grep -i systemdcgroup
kubectl top nodesExpected (shortened):
NAME READY STATUS RESTARTS AGE IP NODE
registry-75bc98b96b-gcgdq 1/1 Running 0 6m 192.168.189.70 worker2
"SystemdCgroup": true
NAME CPU(cores) CPU(%) MEMORY(bytes) MEMORY(%)
cp1 567m 14% 1292Mi 10%
worker1 374m 18% 653Mi 17%
worker2 226m 11% 484Mi 12%
Save your progress? Sign up for free
Checkpoint
kubectl get nodes -o wideExpected: three nodes Ready,
v1.37.2, containerd://2.4.2.
kubectl get pods -n kube-system --field-selector=status.phase!=RunningExpected:
No resources found in kube-system namespace.
helm list -n traefikExpected: traefik with chart
traefik-42.4.1, status deployed.
curl -s http://172.16.0.126:30500/v2/_catalogExpected: {"repositories":[]} (after
Day 2: {"repositories":["notes-api"]})
Challenge
Find out which pause image (sandbox image) containerd starts for every pod.
Hint: It is in the containerd configuration.
Solution
grep -n "sandbox = " /etc/containerd/config.tomlExpected:
28: sandbox = 'registry.k8s.io/pause:3.10.2'
Save your progress? Sign up for free
Exam Tip
- In the CKAD you do not build a cluster. But you do need
kubectl get nodes,kubectl topand a look at the IngressClass and StorageClass – these come back on Days 5, 7 and 16. - In the exam you build images with podman or docker on a prepared host, not in the cluster.
Enterprise Note
- Production clusters come from managed offerings (EKS, AKS, GKE) or distributions (OpenShift, RKE2, Talos), not from manual work.
- Registries run with TLS, authentication and persistent storage (Harbor, GitLab, Artifactory) – never as an emptyDir over HTTP.
- Ingress, storage and metrics are platform tasks; as a developer you
use them via IngressClass, StorageClass and
kubectl top.