Skip to content
Français
Account: not signed in, sync available My learning
Select theme
Français

CKA exercises: timed practice for the exam

By updated

Improve this page

Logo Kubernetes

Each exercise reproduces the CKA format: a short statement, an observable goal and a target time. Aim for 80% success. A capstone, then a 120-minute mock exam with no hints, close the page.

What you will learn

This page trains you on the CKA tasks, domain by domain, then puts you through two tests with no hints. By the end, you will be able to:

  • run each exercise within the target time, using the kubectl reflexes of the exam;
  • handle the tasks of the five domains of the curriculum: cluster architecture and RBAC, workloads, networking, storage and troubleshooting;
  • diagnose and repair a broken cluster in under 10 minutes;
  • find three independent faults on your own in the capstone, with no ticket to guide you;
  • measure your level on the 120-minute mock exam, with a pass mark of 66 out of 100.

CKA reflexes

On the exam hosts, kubectl, the k alias and bash completion are already configured: the "One designated host per task" box of the page CKA certification gives the source. On your own practice cluster, set up your environment before you start:

Terminal window
# Essential aliases
alias k=kubectl
alias kn='kubectl config set-context --current --namespace'
alias kgp='kubectl get pods'
alias kgn='kubectl get nodes'
export do="--dry-run=client -o yaml"
export now="--force --grace-period=0"
# Autocompletion
source <(kubectl completion bash)
complete -F __start_kubectl k
# Working namespace
kubectl create ns cka-exercises
kn cka-exercises

Cluster Architecture (25%)

The solutions in this section (kubeadm, etcd, kubelet) run as root on the node concerned: first open a root shell with sudo -i, otherwise prefix every command with sudo. A pitfall comes with this second route: with sudo mv /root/folder/*.yaml …, the * wildcard is expanded by your user, who cannot read /root, and the command fails. For a command with a wildcard, write sudo sh -c 'mv /root/folder/*.yaml /destination/'.

Exercise 1: Cluster upgrade [kubeadm]

Target time: 15 minutes

Contextkubeadm cluster running version 1.36.x
TaskUpgrade the control plane and one worker to the latest patch version of 1.37
ConstraintUse the versions available in the apt repo
Validationkubectl get nodes shows all nodes in v1.37.x
Solution
Terminal window
# 0. On every node: switch the apt repository to the 1.37 branch
sudo sed -i 's#/v1.36/#/v1.37/#' /etc/apt/sources.list.d/kubernetes.list
# 1. Identify the latest patch version available
sudo apt update
apt-cache madison kubeadm | grep 1.37
# Example: 1.37.2-1.1 (the first line is the most recent)
# 2. On the control plane: unhold kubeadm, install it, hold it again
sudo apt-mark unhold kubeadm
sudo apt-get install -y kubeadm=1.37.2-1.1
sudo apt-mark hold kubeadm
sudo kubeadm upgrade plan
sudo kubeadm upgrade apply v1.37.2 --yes
# Drain the control plane before upgrading its kubelet
kubectl drain controlplane --ignore-daemonsets
sudo apt-mark unhold kubelet kubectl
sudo apt-get install -y kubelet=1.37.2-1.1 kubectl=1.37.2-1.1
sudo apt-mark hold kubelet kubectl
sudo systemctl daemon-reload && sudo systemctl restart kubelet
# Put the control plane back in service
kubectl uncordon controlplane
# 3. Drain the worker from the control plane
kubectl drain worker1 --ignore-daemonsets --delete-emptydir-data
# 4. On the worker (over SSH)
sudo apt-mark unhold kubeadm
sudo apt-get install -y kubeadm=1.37.2-1.1
sudo apt-mark hold kubeadm
sudo kubeadm upgrade node
sudo apt-mark unhold kubelet
sudo apt-get install -y kubelet=1.37.2-1.1
sudo apt-mark hold kubelet
sudo systemctl daemon-reload && sudo systemctl restart kubelet
# 5. Uncordon from the control plane
kubectl uncordon worker1
kubectl get nodes

Key point: never skip a minor version: 1.36 goes up to 1.37, never to 1.38. And aim for the latest patch available in the repository, read from apt-cache madison, rather than a number you copied. The 1.37.2 numbers in the solution are the ones the repository returned when this page was written: replace them with the ones you read. The pkgs.k8s.io repository has one branch per minor version: as long as a node points to /v1.36/, apt-cache madison only shows it 1.36.x packages, hence step 0, to run on the worker too (see Upgrade a Kubernetes cluster).

On a cluster installed as the official documentation describes, kubeadm, kubelet and kubectl are pinned with apt-mark hold, so that an apt upgrade does not change them by accident. Without apt-mark unhold, apt-get install -y stops with E: Held packages were changed and -y was used without --allow-change-held-packages. and the package keeps its old version. So you unhold them just before the install, and hold them again right after. kubeadm upgrade apply also asks [upgrade] Are you sure you want to proceed? [y/N]:: the --yes option answers for you.

The control plane is handled like a worker: you empty it with kubectl drain before upgrading its kubelet, then put it back in service with kubectl uncordon. The Pods it carried are moved in the meantime, except those of DaemonSets and the static Pods of the control plane. --delete-emptydir-data allows the eviction of Pods that use an emptyDir volume, whose data is lost. A bare Pod, created without a controller, would never be recreated elsewhere: the drain would refuse it, and you would have to add --force.


Exercise 2: etcd backup [kubeadm]

Target time: 6 minutes

ContextStandard kubeadm cluster
TaskCreate an etcd snapshot in /opt/backup/etcd-snapshot.db
ConstraintCertificates are in /etc/kubernetes/pki/etcd/
Validationetcdutl snapshot status /opt/backup/etcd-snapshot.db --write-out=table prints the snapshot info
Solution

Both commands run on the node, with etcdctl and etcdutl installed: on your practice cluster, take them from the official etcd archive, digest verified, as shown in the backup and restore lesson.

Terminal window
mkdir -p /opt/backup
etcdctl snapshot save /opt/backup/etcd-snapshot.db \
--endpoints=https://127.0.0.1:2379 \
--cacert=/etc/kubernetes/pki/etcd/ca.crt \
--cert=/etc/kubernetes/pki/etcd/server.crt \
--key=/etc/kubernetes/pki/etcd/server.key
# Validation: etcdutl, because etcdctl snapshot status returns 0 without checking anything
etcdutl snapshot status /opt/backup/etcd-snapshot.db --write-out=table

Exercise 3: etcd restore [kubeadm]

Target time: 10 minutes

ContextAn etcd snapshot is available in /opt/backup/etcd-snapshot.db
TaskRestore etcd to /var/lib/etcd-restore and reconfigure the cluster
ConstraintUse etcdutl (the etcdctl snapshot restore subcommand no longer exists)
Validationkubectl get pods -n kube-system works after the restore
Solution

The six steps are those of the lesson Back up and restore Kubernetes. They apply to a single control plane, and the lesson recommends taking a backup of the current state first. The values between angle brackets are read from the etcd manifest, /etc/kubernetes/manifests/etcd.yaml.

Terminal window
# This whole block is played in a root shell: sudo -i
# (root expands the * wildcard itself, and reads /root)
# 1. Move the four manifests out of the directory watched by the kubelet
mkdir -p /root/manifestes-arretes
mv /etc/kubernetes/manifests/*.yaml /root/manifestes-arretes/
# 2. Wait until the containers are gone (rerun until the list is empty)
crictl ps --name etcd
crictl ps --name kube-apiserver
# 3. Restore with etcdutl (not etcdctl!) into a new directory
etcdutl snapshot restore /opt/backup/etcd-snapshot.db \
--name <member-name> \
--initial-cluster <member-name>=https://<node-ip>:2380 \
--initial-advertise-peer-urls https://<node-ip>:2380 \
--data-dir /var/lib/etcd-restore
# 4. Repoint only the data hostPath, without touching --data-dir
sed -i 's#path: /var/lib/etcd$#path: /var/lib/etcd-restore#' /root/manifestes-arretes/etcd.yaml
# 5. Put the manifests back and restart the kubelet
mv /root/manifestes-arretes/*.yaml /etc/kubernetes/manifests/
systemctl restart kubelet
# 6. Check (the API may take a few seconds to answer)
kubectl get nodes
kubectl get pods -n kube-system

The restore succeeds if kubectl get nodes answers and the objects created before the snapshot are back. Do not change --data-dir in the manifest: the container still sees /var/lib/etcd, it is the node that mounts the new directory. Once the restore is validated, also update etcd.local.dataDir with kubectl -n kube-system edit configmap kubeadm-config, otherwise a regeneration of the manifest by kubeadm would bring etcd back onto the old directory. Reread the value with kubectl -n kube-system get configmap kubeadm-config -o yaml | grep dataDir.

Key point: etcdctl snapshot restore has been removed, not just deprecated. In etcd 3.7, etcdctl snapshot only offers save, and the call answers Error: unknown flag: --data-dir (exit code 1, recorded with etcd 3.7.0 on 13 November 2026). Both the restore and the check go through etcdutl.


RBAC (part of Cluster Architecture)

Exercise 4: Role and RoleBinding

Target time: 4 minutes

ContextNamespace cka-exercises
TaskCreate a Role pod-reader (get, list, watch pods) and a RoleBinding read-pods for the user jane
Validationkubectl auth can-i list pods -n cka-exercises --as=jane returns yes
Solution
Terminal window
kubectl create role pod-reader \
--verb=get,list,watch \
--resource=pods \
-n cka-exercises
kubectl create rolebinding read-pods \
--role=pod-reader \
--user=jane \
-n cka-exercises
# Validation
kubectl auth can-i list pods -n cka-exercises --as=jane # yes
kubectl auth can-i delete pods -n cka-exercises --as=jane # no

Exercise 5: ClusterRole for nodes

Target time: 4 minutes

ContextCluster-wide resource: nodes
TaskCreate a ClusterRole node-viewer (get, list, watch nodes) and a ClusterRoleBinding node-view-binding for the user bob
Validationkubectl auth can-i list nodes --as=bob returns yes
Solution
Terminal window
kubectl create clusterrole node-viewer \
--verb=get,list,watch \
--resource=nodes
kubectl create clusterrolebinding node-view-binding \
--clusterrole=node-viewer \
--user=bob
# Validation
kubectl auth can-i list nodes --as=bob # yes
kubectl auth can-i delete nodes --as=bob # no

Exercise 6: ServiceAccount with permissions

Target time: 5 minutes

ContextNamespace cka-exercises
TaskCreate a ServiceAccount app-sa and a Role secret-reader (get, list secrets), bind them, and create a Pod app-pod that uses this SA
ConstraintThe Pod must use serviceAccountName in the YAML (the --serviceaccount flag has no longer existed in kubectl run since 1.24)
Validationkubectl auth can-i list secrets --as=system:serviceaccount:cka-exercises:app-sa -n cka-exercises returns yes
Solution
Terminal window
# ServiceAccount
kubectl create sa app-sa -n cka-exercises
# Role
kubectl create role secret-reader \
--verb=get,list \
--resource=secrets \
-n cka-exercises
# RoleBinding
kubectl create rolebinding app-secret-binding \
--role=secret-reader \
--serviceaccount=cka-exercises:app-sa \
-n cka-exercises
# Pod with serviceAccountName (--serviceaccount no longer exists in kubectl run)
kubectl apply -f - <<'EOF'
apiVersion: v1
kind: Pod
metadata:
name: app-pod
namespace: cka-exercises
spec:
serviceAccountName: app-sa
containers:
- name: nginx
image: nginx:1.30.5@sha256:9bf97bd7714f5e24c1ccd545ecb9eb5435cb6d109c97cebb15e7e455e0239edb
EOF
# Validation
kubectl auth can-i list secrets \
--as=system:serviceaccount:cka-exercises:app-sa \
-n cka-exercises

Key point: the --serviceaccount flag of kubectl run was removed in 1.24. Use a YAML manifest with serviceAccountName.


Workloads & Scheduling (15%)

Exercise 7: Taints, tolerations and guaranteed placement

Target time: 6 minutes

ContextNode worker1 available
TaskAdd a taint env=prod:NoSchedule on worker1, then create a Pod prod-app that tolerates this taint and is guaranteed to land on worker1
ConstraintA toleration alone does not guarantee placement, you also need a nodeSelector
Validationkubectl get pod prod-app -o wide shows worker1 in the NODE column
Solution
Terminal window
# Taint
kubectl taint node worker1 env=prod:NoSchedule
# Pod with a toleration AND a nodeSelector
kubectl apply -f - <<'EOF'
apiVersion: v1
kind: Pod
metadata:
name: prod-app
namespace: cka-exercises
spec:
nodeSelector:
kubernetes.io/hostname: worker1
tolerations:
- key: env
operator: Equal
value: prod
effect: NoSchedule
containers:
- name: nginx
image: nginx:1.30.5@sha256:9bf97bd7714f5e24c1ccd545ecb9eb5435cb6d109c97cebb15e7e455e0239edb
EOF
# Validation
kubectl get pod prod-app -n cka-exercises -o wide | grep worker1
# Cleanup
kubectl taint node worker1 env-

Key point: a toleration allows scheduling on a tainted node, but does not guarantee placement. To guarantee it, add a nodeSelector or a nodeAffinity.


Exercise 8: Node affinity

Target time: 5 minutes

ContextNode worker1 available
TaskLabel worker1 with disktype=ssd, then create a Deployment storage-app (3 replicas, nginx) that prefers nodes with this label
Validationkubectl get pods -o wide shows the pods on worker1 (if available)
Solution
Terminal window
# Label
kubectl label node worker1 disktype=ssd
# Deployment
kubectl apply -f - <<'EOF'
apiVersion: apps/v1
kind: Deployment
metadata:
name: storage-app
namespace: cka-exercises
spec:
replicas: 3
selector:
matchLabels:
app: storage-app
template:
metadata:
labels:
app: storage-app
spec:
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
preference:
matchExpressions:
- key: disktype
operator: In
values:
- ssd
containers:
- name: nginx
image: nginx:1.30.5@sha256:9bf97bd7714f5e24c1ccd545ecb9eb5435cb6d109c97cebb15e7e455e0239edb
EOF
# Validation
kubectl get pods -n cka-exercises -o wide

Exercise 9: Drain and cordon

Target time: 3 minutes

ContextNode worker1 running pods
TaskCordon, drain, then uncordon worker1
Validationkubectl get nodes shows worker1 Ready without SchedulingDisabled
Solution
Terminal window
kubectl cordon worker1
kubectl drain worker1 --ignore-daemonsets --delete-emptydir-data
kubectl uncordon worker1
kubectl get nodes

Services & Networking (20%)

Exercise 10: ClusterIP Service

Target time: 3 minutes

ContextNamespace cka-exercises
TaskCreate a Deployment web (2 replicas, nginx) and expose it as ClusterIP on port 80
Validationkubectl run test --rm -it --image=busybox:1.37@sha256:bdf57e528e45e4433820e045b29b4597825a1c9e38353532d90a01445013f82e -- wget -qO- web returns HTML
Solution
Terminal window
kubectl create deploy web --image=nginx:1.30.5@sha256:9bf97bd7714f5e24c1ccd545ecb9eb5435cb6d109c97cebb15e7e455e0239edb --replicas=2 -n cka-exercises
kubectl expose deploy web --port=80 -n cka-exercises
# Validation
kubectl run test --rm -it --image=busybox:1.37@sha256:bdf57e528e45e4433820e045b29b4597825a1c9e38353532d90a01445013f82e -n cka-exercises -- wget -qO- web

Exercise 11: NetworkPolicy deny all

Target time: 4 minutes

ContextNamespace cka-exercises with the Deployment web
TaskCreate a NetworkPolicy deny-all that blocks all ingress and egress traffic in the namespace
Validationkubectl describe netpol deny-all shows Allowing ingress traffic: <none>
Solution
Terminal window
kubectl apply -f - <<'EOF'
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-all
namespace: cka-exercises
spec:
podSelector: {}
policyTypes:
- Ingress
- Egress
EOF
# Validation
kubectl describe netpol deny-all -n cka-exercises

Exercise 12: NetworkPolicy allow specific traffic

Target time: 6 minutes

ContextDeployment web with label app=web in cka-exercises
TaskCreate a NetworkPolicy allow-frontend that allows ingress traffic on port 80 only from pods with label role=frontend
ConstraintThe policy's podSelector must target app=web
ValidationA pod with role=frontend can reach web, a pod without this label cannot
Solution
Terminal window
# If you did exercise 11, remove deny-all first: it would also block the test pods
kubectl delete netpol deny-all -n cka-exercises --ignore-not-found
kubectl apply -f - <<'EOF'
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-frontend
namespace: cka-exercises
spec:
podSelector:
matchLabels:
app: web
policyTypes:
- Ingress
ingress:
- from:
- podSelector:
matchLabels:
role: frontend
ports:
- protocol: TCP
port: 80
EOF
# Positive test
kubectl run frontend --image=busybox:1.37@sha256:bdf57e528e45e4433820e045b29b4597825a1c9e38353532d90a01445013f82e -n cka-exercises \
--labels="role=frontend" --rm -it -- wget -qO- --timeout=2 web
# Negative test (must time out)
kubectl run other --image=busybox:1.37@sha256:bdf57e528e45e4433820e045b29b4597825a1c9e38353532d90a01445013f82e -n cka-exercises \
--rm -it -- wget -qO- --timeout=2 web

Key point: check that the labels of the podSelector match the real labels of the targeted pods.


Exercise 13: Ingress

Target time: 5 minutes

ContextService web exposed on port 80
TaskCreate an Ingress web-ingress that routes web.demo.test/ to the service web on port 80
ConstraintUse ingressClassName: traefik
Validationkubectl get ingress web-ingress shows the Ingress you created
Solution
Terminal window
kubectl apply -f - <<'EOF'
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: web-ingress
namespace: cka-exercises
spec:
ingressClassName: traefik
rules:
- host: web.demo.test
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: web
port:
number: 80
EOF
# Validation
kubectl get ingress web-ingress -n cka-exercises

Storage (10%)

Exercise 14: PersistentVolume and PVC

Target time: 7 minutes

ContextStorageClass manual for hostPath
TaskCreate a PV pv-data (1Gi, RWO, hostPath /data/pv-data), a PVC pvc-data (500Mi), and a Pod storage-pod that mounts the PVC
Validationkubectl get pv shows BOUND, kubectl get pvc -n cka-exercises shows BOUND
Solution
Terminal window
# PV (cluster-scoped, no namespace)
kubectl apply -f - <<'EOF'
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-data
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: manual
hostPath:
path: /data/pv-data
EOF
# PVC (namespaced)
kubectl apply -f - <<'EOF'
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-data
namespace: cka-exercises
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 500Mi
storageClassName: manual
EOF
# Pod
kubectl apply -f - <<'EOF'
apiVersion: v1
kind: Pod
metadata:
name: storage-pod
namespace: cka-exercises
spec:
containers:
- name: app
image: nginx:1.30.5@sha256:9bf97bd7714f5e24c1ccd545ecb9eb5435cb6d109c97cebb15e7e455e0239edb
volumeMounts:
- name: data
mountPath: /data
volumes:
- name: data
persistentVolumeClaim:
claimName: pvc-data
EOF
# Validation
kubectl get pv # cluster-scoped
kubectl get pvc -n cka-exercises # namespaced

Key point: PVs are cluster-scoped (kubectl get pv without -n). PVCs are namespaced (kubectl get pvc -n <ns>).


Troubleshooting (30%)

This domain weighs 30% of the points, the biggest share of the exam according to the official CKA curriculum.

Exercise 15: Pod in ImagePullBackOff

Target time: 3 minutes

ContextPod broken-pod with image nginx:nonexistent-tag
TaskDiagnose and fix the Pod
Validationkubectl get pod broken-pod shows Running
Solution
Terminal window
# Create the problem
# ❌ deliberately nonexistent tag: this is the fault to diagnose
kubectl run broken-pod --image=nginx:nonexistent-tag -n cka-exercises
# Diagnosis
kubectl get pod broken-pod -n cka-exercises
kubectl describe pod broken-pod -n cka-exercises | tail -10
# Fix
kubectl set image pod/broken-pod broken-pod=nginx:1.30.5@sha256:9bf97bd7714f5e24c1ccd545ecb9eb5435cb6d109c97cebb15e7e455e0239edb -n cka-exercises
# Validation
kubectl get pod broken-pod -n cka-exercises

Exercise 16: Node NotReady [kubeadm]

Target time: 8 minutes

ContextNode worker1 in NotReady status
TaskIdentify the cause and repair the node
SimulationOn worker1: systemctl stop kubelet
Validationkubectl get nodes shows worker1 Ready
Solution
Terminal window
# Diagnosis from the control plane
kubectl get nodes
kubectl describe node worker1 | grep -A5 Conditions
# SSH to the worker
ssh worker1
# Check the kubelet
systemctl status kubelet
journalctl -u kubelet --since "5 minutes ago" | tail -20
# Repair
systemctl start kubelet
systemctl status kubelet
# Back on the control plane
exit
kubectl get nodes

Exercise 17: Service without endpoints

Target time: 4 minutes

ContextService broken-svc with selector app=myapp, Pod with label application=myapp
TaskDiagnose why the Service has no endpoints and fix it
Validationkubectl get endpointslice -l kubernetes.io/service-name=broken-svc shows an IP
Solution
Terminal window
# Create the problem
kubectl apply -f - <<'EOF'
apiVersion: v1
kind: Service
metadata:
name: broken-svc
namespace: cka-exercises
spec:
selector:
app: myapp
ports:
- port: 80
---
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
namespace: cka-exercises
labels:
application: myapp
spec:
containers:
- name: nginx
image: nginx:1.30.5@sha256:9bf97bd7714f5e24c1ccd545ecb9eb5435cb6d109c97cebb15e7e455e0239edb
EOF
# Diagnosis
kubectl get endpointslice -n cka-exercises -l kubernetes.io/service-name=broken-svc
kubectl describe svc broken-svc -n cka-exercises | grep Selector
kubectl get pod myapp-pod -n cka-exercises --show-labels
# Fix (the labels do not match)
kubectl label pod myapp-pod -n cka-exercises app=myapp
# Validation
kubectl get endpointslice -n cka-exercises -l kubernetes.io/service-name=broken-svc

Exercise 18: kubelet does not start [kubeadm]

Target time: 8 minutes

ContextA worker node does not join the cluster
TaskThe kubelet does not start. Identify the cause and repair it
HintsCheck the kubelet logs with journalctl -u kubelet
Validationkubectl get nodes shows the node Ready
Solution
Terminal window
# On the worker - check the status
systemctl status kubelet
# Read the logs
journalctl -u kubelet --no-pager | tail -50
# Common causes and fixes:
# 1. Missing configuration file
ls -la /var/lib/kubelet/config.yaml
ls -la /etc/kubernetes/kubelet.conf
# 2. Container runtime not started
systemctl status containerd
systemctl start containerd
# 3. Swap enabled (forbidden by default)
swapoff -a
# 4. Configuration error
cat /var/lib/kubelet/config.yaml
# Restart the kubelet after the fix
systemctl restart kubelet
systemctl status kubelet

Exercise 19: API Server unreachable [kubeadm]

Target time: 10 minutes

Contextkubectl returns connection refused
TaskThe API Server does not answer. Diagnose and repair it
SimulationEdit /etc/kubernetes/manifests/kube-apiserver.yaml to introduce an error
Validationkubectl get nodes works
Solution
Terminal window
# 1. Check whether the container is running
crictl ps | grep kube-apiserver
# If empty → the static pod did not start
# 2. Check the logs of the dead container
crictl ps -a | grep kube-apiserver
crictl logs <container-id>
# Or through the static pod logs
ls /var/log/pods/kube-system_kube-apiserver-*/
cat /var/log/pods/kube-system_kube-apiserver-*/kube-apiserver/*.log | tail -50
# 3. Check the manifest
cat /etc/kubernetes/manifests/kube-apiserver.yaml
# Common errors:
# - Wrong port (--secure-port)
# - Wrong certificate path (--tls-cert-file)
# - Typo in an option
# 4. Fix the manifest
vim /etc/kubernetes/manifests/kube-apiserver.yaml
# 5. The kubelet restarts the static pod automatically
# Wait 30-60 seconds
sleep 30
# 6. Validation
kubectl get nodes

Key point: the control plane components are static pods. Editing the manifest in /etc/kubernetes/manifests/ makes the kubelet restart them automatically.


Exercise 20: CoreDNS, crashing Pods

Target time: 5 minutes

ContextDNS resolution does not work
TaskThe CoreDNS pods are in CrashLoopBackOff. Diagnose and repair them
Validationkubectl run test --rm -it --image=busybox:1.37@sha256:bdf57e528e45e4433820e045b29b4597825a1c9e38353532d90a01445013f82e -- nslookup kubernetes.default.svc.cluster.local returns an IP
Solution
Terminal window
# Diagnosis
kubectl get pods -n kube-system -l k8s-app=kube-dns
kubectl logs -n kube-system -l k8s-app=kube-dns --tail=20
# If it is a crash loop, restart the deployment
kubectl rollout restart deploy coredns -n kube-system
# Wait for the pods to be Ready
kubectl get pods -n kube-system -l k8s-app=kube-dns -w
# Validation
kubectl run test --rm -it --image=busybox:1.37@sha256:bdf57e528e45e4433820e045b29b4597825a1c9e38353532d90a01445013f82e -- nslookup kubernetes.default.svc.cluster.local

Exercise 21: CoreDNS, corrupted ConfigMap

Target time: 6 minutes

ContextCoreDNS pods Running but DNS resolution fails
TaskThe coredns ConfigMap contains an error. Identify and fix it
Validationkubectl run test --rm -it --image=busybox:1.37@sha256:bdf57e528e45e4433820e045b29b4597825a1c9e38353532d90a01445013f82e -- nslookup kubernetes.default.svc.cluster.local returns an IP
Solution
Terminal window
# Check the ConfigMap
kubectl get cm coredns -n kube-system -o yaml
# Look for syntax errors in the Corefile
# Common errors:
# - Block not closed
# - Unknown directive
# - Wrong upstream format
# Back up, then fix
kubectl get cm coredns -n kube-system -o yaml > coredns-backup.yaml
kubectl edit cm coredns -n kube-system
# Restart CoreDNS to apply the change
kubectl rollout restart deploy coredns -n kube-system
# Validation
kubectl run test --rm -it --image=busybox:1.37@sha256:bdf57e528e45e4433820e045b29b4597825a1c9e38353532d90a01445013f82e -- nslookup kubernetes.default.svc.cluster.local

Exercise 22: CoreDNS, missing kube-dns Service

Target time: 5 minutes

ContextCoreDNS pods Running but the kube-dns service does not exist
TaskRecreate the kube-dns service so that resolution works
ConstraintThe service must target the CoreDNS pods and expose ports 53 TCP/UDP
Validationkubectl get endpointslice -n kube-system -l kubernetes.io/service-name=kube-dns shows IPs
Solution
Terminal window
# Check that the service does not exist
kubectl get svc kube-dns -n kube-system
# Recreate the service
kubectl apply -f - <<'EOF'
apiVersion: v1
kind: Service
metadata:
name: kube-dns
namespace: kube-system
labels:
k8s-app: kube-dns
spec:
selector:
k8s-app: kube-dns
clusterIP: 10.96.0.10
ports:
- name: dns
port: 53
protocol: UDP
- name: dns-tcp
port: 53
protocol: TCP
EOF
# Validation
kubectl get svc kube-dns -n kube-system
kubectl get endpointslice -n kube-system -l kubernetes.io/service-name=kube-dns
kubectl run test --rm -it --image=busybox:1.37@sha256:bdf57e528e45e4433820e045b29b4597825a1c9e38353532d90a01445013f82e -- nslookup kubernetes.default.svc.cluster.local

Key point: the IP of the kube-dns service (often 10.96.0.10) is configured in the kubelet. Recreate the service with the same cluster IP.


Capstone: the full scenario, with no statement to help you

The exercises above each isolate one fault and name the domain concerned. The capstone does the opposite, and that is what brings it closer to the exam: a namespace left behind by a team that has gone, a portal that answers nothing, and no ticket to say why. There are three independent faults to find, two requirements that were never met, and a single measure of success: the portal answers on every node of the cluster.

Plan for 45 minutes, and keep it for the end of the exercises. It assumes you can already diagnose a node, a kubelet and an API server, which you practice separately in Cluster Troubleshooting, Worker Nodes and Control Plane.

Are you ready for the CKA? The timed mock exam

Once the capstone is done, the mock exam puts you in conditions close to the real exam: all the tasks run back to back, with no hints, and you manage the time yourself. It has 17 tasks, spread like the five domains of the official curriculum (troubleshooting weighs 30%, storage 10%). It runs on a kubeadm cluster and reproduces the mechanics of the real exam. Each task opens with a box that asks you to connect over ssh to a designated host. You do the task there, then return to the base host with exit before the next one. Nested ssh is forbidden: never connect to a second host from the first. The statement of each task gives the host to use: read it before you type the first command. In this lab, the base host is also a task host, and the hosts all point to the same cluster: the score is read from the cluster state and does not check that you went through ssh. Respecting the mechanics is up to you, and it is what trains you for exam day. They are described in the "One designated host per task" box of the page CKA certification.

The score is read from the final state of the cluster, never from the commands you typed. Each check, for example "the node is Ready" or "the route is accepted", is a state worth 5 points. There are 20 of them, because a task worth 10% carries two. The passing score is 66 out of 100, that is 14 states out of 20, as in the real exam (see the Linux Foundation CKA, CKAD and CKS FAQ). The lab gives no hints, only the verdict, like on exam day.

The lab tool, dsoxlab, does not time the exam. Plan for 120 minutes in one go and start your own timer before the first task. The tasks are independent, except task 9, which assumes the node from task 3 has been repaired.

This mock exam does not reproduce everything. The real exam chains one cluster per task, which this lab does not reproduce: the tasks are done on the lab hosts. You have neither the remote desktop nor the browser limited to the official documentation, and there is no partial credit inside a state: it is passed or it is not.

Time summary

#ExerciseDomainTimeType
1Cluster upgradeArchitecture15 minkubeadm
2etcd backupArchitecture6 minkubeadm
3etcd restoreArchitecture10 minkubeadm
4Role and RoleBindingRBAC4 mingeneric
5ClusterRole nodesRBAC4 mingeneric
6ServiceAccountRBAC5 mingeneric
7Taints + placementScheduling6 mingeneric
8Node affinityScheduling5 mingeneric
9Drain and cordonScheduling3 mingeneric
10ClusterIP ServiceNetworking3 mingeneric
11NetworkPolicy denyNetworking4 mingeneric
12NetworkPolicy allowNetworking6 mingeneric
13IngressNetworking5 mingeneric
14PV and PVCStorage7 mingeneric
15ImagePullBackOffTroubleshooting3 mingeneric
16Node NotReadyTroubleshooting8 minkubeadm
17Service endpointsTroubleshooting4 mingeneric
18kubelet crashTroubleshooting8 minkubeadm
19API Server downTroubleshooting10 minkubeadm
20CoreDNS crashTroubleshooting5 mingeneric
21CoreDNS configTroubleshooting6 mingeneric
22CoreDNS serviceTroubleshooting5 mingeneric

Total time: ~132 minutes (the 22 exercises, without the capstone or the mock exam)

The CKA exam lasts 2 hours (120 min). If you hit the target time of each exercise with 80% success, you are ready to try the mock exam above.


Cleanup

Deleting the cka-exercises namespace removes every object created during the exercises, and the last two commands remove the taint and the label set on worker1. Do it at the end of each session to start the next one from a clean cluster.

Terminal window
kubectl delete ns cka-exercises
kubectl taint node worker1 env- 2>/dev/null
kubectl label node worker1 disktype- 2>/dev/null

Key takeaways

  1. To restore etcd, use etcdutl into a new directory, with the manifests moved out before and put back after: etcdctl snapshot restore has been removed.
  2. For an upgrade, never go more than one minor version at a time, aim for the latest patch, unhold the packages (apt-mark unhold) before installing them then hold them again, and drain the node (drain) before its kubelet, control plane included.
  3. In a Pod's YAML, write serviceAccountName: the --serviceaccount flag of kubectl run was removed in 1.24.
  4. A toleration does not guarantee placement: add a nodeSelector.
  5. A PV is cluster-scoped, a PVC is namespaced.
  6. A static Pod restarts by itself when you edit its manifest.
  7. CoreDNS has three points of failure: the pods, the configuration and the service.
  8. The CKA aliases are k, kn, $do and $now.

Test your knowledge

Check that you have understood the essentials of this guide. The questions only cover what has just been explained here.

Knowledge check

Check what you have learned with this interactive quiz

6 questions
6 min
70% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer