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
kubectlreflexes 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:
# Essential aliasesalias k=kubectlalias 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"
# Autocompletionsource <(kubectl completion bash)complete -F __start_kubectl k
# Working namespacekubectl create ns cka-exerciseskn cka-exercisesCluster 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
| Context | kubeadm cluster running version 1.36.x |
|---|---|
| Task | Upgrade the control plane and one worker to the latest patch version of 1.37 |
| Constraint | Use the versions available in the apt repo |
| Validation | kubectl get nodes shows all nodes in v1.37.x |
Solution
# 0. On every node: switch the apt repository to the 1.37 branchsudo sed -i 's#/v1.36/#/v1.37/#' /etc/apt/sources.list.d/kubernetes.list
# 1. Identify the latest patch version availablesudo apt updateapt-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 againsudo apt-mark unhold kubeadmsudo apt-get install -y kubeadm=1.37.2-1.1sudo apt-mark hold kubeadmsudo kubeadm upgrade plansudo kubeadm upgrade apply v1.37.2 --yes
# Drain the control plane before upgrading its kubeletkubectl drain controlplane --ignore-daemonsets
sudo apt-mark unhold kubelet kubectlsudo apt-get install -y kubelet=1.37.2-1.1 kubectl=1.37.2-1.1sudo apt-mark hold kubelet kubectlsudo systemctl daemon-reload && sudo systemctl restart kubelet
# Put the control plane back in servicekubectl uncordon controlplane
# 3. Drain the worker from the control planekubectl drain worker1 --ignore-daemonsets --delete-emptydir-data
# 4. On the worker (over SSH)sudo apt-mark unhold kubeadmsudo apt-get install -y kubeadm=1.37.2-1.1sudo apt-mark hold kubeadmsudo kubeadm upgrade nodesudo apt-mark unhold kubeletsudo apt-get install -y kubelet=1.37.2-1.1sudo apt-mark hold kubeletsudo systemctl daemon-reload && sudo systemctl restart kubelet
# 5. Uncordon from the control planekubectl uncordon worker1kubectl get nodesKey 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
| Context | Standard kubeadm cluster |
|---|---|
| Task | Create an etcd snapshot in /opt/backup/etcd-snapshot.db |
| Constraint | Certificates are in /etc/kubernetes/pki/etcd/ |
| Validation | etcdutl 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.
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 anythingetcdutl snapshot status /opt/backup/etcd-snapshot.db --write-out=tableExercise 3: etcd restore [kubeadm]
Target time: 10 minutes
| Context | An etcd snapshot is available in /opt/backup/etcd-snapshot.db |
|---|---|
| Task | Restore etcd to /var/lib/etcd-restore and reconfigure the cluster |
| Constraint | Use etcdutl (the etcdctl snapshot restore subcommand no longer exists) |
| Validation | kubectl 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.
# 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 kubeletmkdir -p /root/manifestes-arretesmv /etc/kubernetes/manifests/*.yaml /root/manifestes-arretes/
# 2. Wait until the containers are gone (rerun until the list is empty)crictl ps --name etcdcrictl ps --name kube-apiserver
# 3. Restore with etcdutl (not etcdctl!) into a new directoryetcdutl 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-dirsed -i 's#path: /var/lib/etcd$#path: /var/lib/etcd-restore#' /root/manifestes-arretes/etcd.yaml
# 5. Put the manifests back and restart the kubeletmv /root/manifestes-arretes/*.yaml /etc/kubernetes/manifests/systemctl restart kubelet
# 6. Check (the API may take a few seconds to answer)kubectl get nodeskubectl get pods -n kube-systemThe 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
| Context | Namespace cka-exercises |
|---|---|
| Task | Create a Role pod-reader (get, list, watch pods) and a RoleBinding read-pods for the user jane |
| Validation | kubectl auth can-i list pods -n cka-exercises --as=jane returns yes |
Solution
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
# Validationkubectl auth can-i list pods -n cka-exercises --as=jane # yeskubectl auth can-i delete pods -n cka-exercises --as=jane # noExercise 5: ClusterRole for nodes
Target time: 4 minutes
| Context | Cluster-wide resource: nodes |
|---|---|
| Task | Create a ClusterRole node-viewer (get, list, watch nodes) and a ClusterRoleBinding node-view-binding for the user bob |
| Validation | kubectl auth can-i list nodes --as=bob returns yes |
Solution
kubectl create clusterrole node-viewer \ --verb=get,list,watch \ --resource=nodes
kubectl create clusterrolebinding node-view-binding \ --clusterrole=node-viewer \ --user=bob
# Validationkubectl auth can-i list nodes --as=bob # yeskubectl auth can-i delete nodes --as=bob # noExercise 6: ServiceAccount with permissions
Target time: 5 minutes
| Context | Namespace cka-exercises |
|---|---|
| Task | Create a ServiceAccount app-sa and a Role secret-reader (get, list secrets), bind them, and create a Pod app-pod that uses this SA |
| Constraint | The Pod must use serviceAccountName in the YAML (the --serviceaccount flag has no longer existed in kubectl run since 1.24) |
| Validation | kubectl auth can-i list secrets --as=system:serviceaccount:cka-exercises:app-sa -n cka-exercises returns yes |
Solution
# ServiceAccountkubectl create sa app-sa -n cka-exercises
# Rolekubectl create role secret-reader \ --verb=get,list \ --resource=secrets \ -n cka-exercises
# RoleBindingkubectl 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: v1kind: Podmetadata: name: app-pod namespace: cka-exercisesspec: serviceAccountName: app-sa containers: - name: nginx image: nginx:1.30.5@sha256:9bf97bd7714f5e24c1ccd545ecb9eb5435cb6d109c97cebb15e7e455e0239edbEOF
# Validationkubectl auth can-i list secrets \ --as=system:serviceaccount:cka-exercises:app-sa \ -n cka-exercisesKey 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
| Context | Node worker1 available |
|---|---|
| Task | Add a taint env=prod:NoSchedule on worker1, then create a Pod prod-app that tolerates this taint and is guaranteed to land on worker1 |
| Constraint | A toleration alone does not guarantee placement, you also need a nodeSelector |
| Validation | kubectl get pod prod-app -o wide shows worker1 in the NODE column |
Solution
# Taintkubectl taint node worker1 env=prod:NoSchedule
# Pod with a toleration AND a nodeSelectorkubectl apply -f - <<'EOF'apiVersion: v1kind: Podmetadata: name: prod-app namespace: cka-exercisesspec: nodeSelector: kubernetes.io/hostname: worker1 tolerations: - key: env operator: Equal value: prod effect: NoSchedule containers: - name: nginx image: nginx:1.30.5@sha256:9bf97bd7714f5e24c1ccd545ecb9eb5435cb6d109c97cebb15e7e455e0239edbEOF
# Validationkubectl get pod prod-app -n cka-exercises -o wide | grep worker1
# Cleanupkubectl 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
| Context | Node worker1 available |
|---|---|
| Task | Label worker1 with disktype=ssd, then create a Deployment storage-app (3 replicas, nginx) that prefers nodes with this label |
| Validation | kubectl get pods -o wide shows the pods on worker1 (if available) |
Solution
# Labelkubectl label node worker1 disktype=ssd
# Deploymentkubectl apply -f - <<'EOF'apiVersion: apps/v1kind: Deploymentmetadata: name: storage-app namespace: cka-exercisesspec: 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:9bf97bd7714f5e24c1ccd545ecb9eb5435cb6d109c97cebb15e7e455e0239edbEOF
# Validationkubectl get pods -n cka-exercises -o wideExercise 9: Drain and cordon
Target time: 3 minutes
| Context | Node worker1 running pods |
|---|---|
| Task | Cordon, drain, then uncordon worker1 |
| Validation | kubectl get nodes shows worker1 Ready without SchedulingDisabled |
Solution
kubectl cordon worker1kubectl drain worker1 --ignore-daemonsets --delete-emptydir-datakubectl uncordon worker1kubectl get nodesServices & Networking (20%)
Exercise 10: ClusterIP Service
Target time: 3 minutes
| Context | Namespace cka-exercises |
|---|---|
| Task | Create a Deployment web (2 replicas, nginx) and expose it as ClusterIP on port 80 |
| Validation | kubectl run test --rm -it --image=busybox:1.37@sha256:bdf57e528e45e4433820e045b29b4597825a1c9e38353532d90a01445013f82e -- wget -qO- web returns HTML |
Solution
kubectl create deploy web --image=nginx:1.30.5@sha256:9bf97bd7714f5e24c1ccd545ecb9eb5435cb6d109c97cebb15e7e455e0239edb --replicas=2 -n cka-exerciseskubectl expose deploy web --port=80 -n cka-exercises
# Validationkubectl run test --rm -it --image=busybox:1.37@sha256:bdf57e528e45e4433820e045b29b4597825a1c9e38353532d90a01445013f82e -n cka-exercises -- wget -qO- webExercise 11: NetworkPolicy deny all
Target time: 4 minutes
| Context | Namespace cka-exercises with the Deployment web |
|---|---|
| Task | Create a NetworkPolicy deny-all that blocks all ingress and egress traffic in the namespace |
| Validation | kubectl describe netpol deny-all shows Allowing ingress traffic: <none> |
Solution
kubectl apply -f - <<'EOF'apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata: name: deny-all namespace: cka-exercisesspec: podSelector: {} policyTypes: - Ingress - EgressEOF
# Validationkubectl describe netpol deny-all -n cka-exercisesExercise 12: NetworkPolicy allow specific traffic
Target time: 6 minutes
| Context | Deployment web with label app=web in cka-exercises |
|---|---|
| Task | Create a NetworkPolicy allow-frontend that allows ingress traffic on port 80 only from pods with label role=frontend |
| Constraint | The policy's podSelector must target app=web |
| Validation | A pod with role=frontend can reach web, a pod without this label cannot |
Solution
# If you did exercise 11, remove deny-all first: it would also block the test podskubectl delete netpol deny-all -n cka-exercises --ignore-not-found
kubectl apply -f - <<'EOF'apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata: name: allow-frontend namespace: cka-exercisesspec: podSelector: matchLabels: app: web policyTypes: - Ingress ingress: - from: - podSelector: matchLabels: role: frontend ports: - protocol: TCP port: 80EOF
# Positive testkubectl 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 webKey point: check that the labels of the podSelector match the real labels of the targeted pods.
Exercise 13: Ingress
Target time: 5 minutes
| Context | Service web exposed on port 80 |
|---|---|
| Task | Create an Ingress web-ingress that routes web.demo.test/ to the service web on port 80 |
| Constraint | Use ingressClassName: traefik |
| Validation | kubectl get ingress web-ingress shows the Ingress you created |
Solution
kubectl apply -f - <<'EOF'apiVersion: networking.k8s.io/v1kind: Ingressmetadata: name: web-ingress namespace: cka-exercisesspec: ingressClassName: traefik rules: - host: web.demo.test http: paths: - path: / pathType: Prefix backend: service: name: web port: number: 80EOF
# Validationkubectl get ingress web-ingress -n cka-exercisesStorage (10%)
Exercise 14: PersistentVolume and PVC
Target time: 7 minutes
| Context | StorageClass manual for hostPath |
|---|---|
| Task | Create a PV pv-data (1Gi, RWO, hostPath /data/pv-data), a PVC pvc-data (500Mi), and a Pod storage-pod that mounts the PVC |
| Validation | kubectl get pv shows BOUND, kubectl get pvc -n cka-exercises shows BOUND |
Solution
# PV (cluster-scoped, no namespace)kubectl apply -f - <<'EOF'apiVersion: v1kind: PersistentVolumemetadata: name: pv-dataspec: capacity: storage: 1Gi accessModes: - ReadWriteOnce persistentVolumeReclaimPolicy: Retain storageClassName: manual hostPath: path: /data/pv-dataEOF
# PVC (namespaced)kubectl apply -f - <<'EOF'apiVersion: v1kind: PersistentVolumeClaimmetadata: name: pvc-data namespace: cka-exercisesspec: accessModes: - ReadWriteOnce resources: requests: storage: 500Mi storageClassName: manualEOF
# Podkubectl apply -f - <<'EOF'apiVersion: v1kind: Podmetadata: name: storage-pod namespace: cka-exercisesspec: containers: - name: app image: nginx:1.30.5@sha256:9bf97bd7714f5e24c1ccd545ecb9eb5435cb6d109c97cebb15e7e455e0239edb volumeMounts: - name: data mountPath: /data volumes: - name: data persistentVolumeClaim: claimName: pvc-dataEOF
# Validationkubectl get pv # cluster-scopedkubectl get pvc -n cka-exercises # namespacedKey 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
| Context | Pod broken-pod with image nginx:nonexistent-tag |
|---|---|
| Task | Diagnose and fix the Pod |
| Validation | kubectl get pod broken-pod shows Running |
Solution
# Create the problem# ❌ deliberately nonexistent tag: this is the fault to diagnosekubectl run broken-pod --image=nginx:nonexistent-tag -n cka-exercises
# Diagnosiskubectl get pod broken-pod -n cka-exerciseskubectl describe pod broken-pod -n cka-exercises | tail -10
# Fixkubectl set image pod/broken-pod broken-pod=nginx:1.30.5@sha256:9bf97bd7714f5e24c1ccd545ecb9eb5435cb6d109c97cebb15e7e455e0239edb -n cka-exercises
# Validationkubectl get pod broken-pod -n cka-exercisesExercise 16: Node NotReady [kubeadm]
Target time: 8 minutes
| Context | Node worker1 in NotReady status |
|---|---|
| Task | Identify the cause and repair the node |
| Simulation | On worker1: systemctl stop kubelet |
| Validation | kubectl get nodes shows worker1 Ready |
Solution
# Diagnosis from the control planekubectl get nodeskubectl describe node worker1 | grep -A5 Conditions
# SSH to the workerssh worker1
# Check the kubeletsystemctl status kubeletjournalctl -u kubelet --since "5 minutes ago" | tail -20
# Repairsystemctl start kubeletsystemctl status kubelet
# Back on the control planeexitkubectl get nodesExercise 17: Service without endpoints
Target time: 4 minutes
| Context | Service broken-svc with selector app=myapp, Pod with label application=myapp |
|---|---|
| Task | Diagnose why the Service has no endpoints and fix it |
| Validation | kubectl get endpointslice -l kubernetes.io/service-name=broken-svc shows an IP |
Solution
# Create the problemkubectl apply -f - <<'EOF'apiVersion: v1kind: Servicemetadata: name: broken-svc namespace: cka-exercisesspec: selector: app: myapp ports: - port: 80---apiVersion: v1kind: Podmetadata: name: myapp-pod namespace: cka-exercises labels: application: myappspec: containers: - name: nginx image: nginx:1.30.5@sha256:9bf97bd7714f5e24c1ccd545ecb9eb5435cb6d109c97cebb15e7e455e0239edbEOF
# Diagnosiskubectl get endpointslice -n cka-exercises -l kubernetes.io/service-name=broken-svckubectl describe svc broken-svc -n cka-exercises | grep Selectorkubectl 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
# Validationkubectl get endpointslice -n cka-exercises -l kubernetes.io/service-name=broken-svcExercise 18: kubelet does not start [kubeadm]
Target time: 8 minutes
| Context | A worker node does not join the cluster |
|---|---|
| Task | The kubelet does not start. Identify the cause and repair it |
| Hints | Check the kubelet logs with journalctl -u kubelet |
| Validation | kubectl get nodes shows the node Ready |
Solution
# On the worker - check the statussystemctl status kubelet
# Read the logsjournalctl -u kubelet --no-pager | tail -50
# Common causes and fixes:# 1. Missing configuration filels -la /var/lib/kubelet/config.yamlls -la /etc/kubernetes/kubelet.conf
# 2. Container runtime not startedsystemctl status containerdsystemctl start containerd
# 3. Swap enabled (forbidden by default)swapoff -a
# 4. Configuration errorcat /var/lib/kubelet/config.yaml
# Restart the kubelet after the fixsystemctl restart kubeletsystemctl status kubeletExercise 19: API Server unreachable [kubeadm]
Target time: 10 minutes
| Context | kubectl returns connection refused |
|---|---|
| Task | The API Server does not answer. Diagnose and repair it |
| Simulation | Edit /etc/kubernetes/manifests/kube-apiserver.yaml to introduce an error |
| Validation | kubectl get nodes works |
Solution
# 1. Check whether the container is runningcrictl ps | grep kube-apiserver# If empty → the static pod did not start
# 2. Check the logs of the dead containercrictl ps -a | grep kube-apiservercrictl logs <container-id>
# Or through the static pod logsls /var/log/pods/kube-system_kube-apiserver-*/cat /var/log/pods/kube-system_kube-apiserver-*/kube-apiserver/*.log | tail -50
# 3. Check the manifestcat /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 manifestvim /etc/kubernetes/manifests/kube-apiserver.yaml
# 5. The kubelet restarts the static pod automatically# Wait 30-60 secondssleep 30
# 6. Validationkubectl get nodesKey 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
| Context | DNS resolution does not work |
|---|---|
| Task | The CoreDNS pods are in CrashLoopBackOff. Diagnose and repair them |
| Validation | kubectl run test --rm -it --image=busybox:1.37@sha256:bdf57e528e45e4433820e045b29b4597825a1c9e38353532d90a01445013f82e -- nslookup kubernetes.default.svc.cluster.local returns an IP |
Solution
# Diagnosiskubectl get pods -n kube-system -l k8s-app=kube-dnskubectl logs -n kube-system -l k8s-app=kube-dns --tail=20
# If it is a crash loop, restart the deploymentkubectl rollout restart deploy coredns -n kube-system
# Wait for the pods to be Readykubectl get pods -n kube-system -l k8s-app=kube-dns -w
# Validationkubectl run test --rm -it --image=busybox:1.37@sha256:bdf57e528e45e4433820e045b29b4597825a1c9e38353532d90a01445013f82e -- nslookup kubernetes.default.svc.cluster.localExercise 21: CoreDNS, corrupted ConfigMap
Target time: 6 minutes
| Context | CoreDNS pods Running but DNS resolution fails |
|---|---|
| Task | The coredns ConfigMap contains an error. Identify and fix it |
| Validation | kubectl run test --rm -it --image=busybox:1.37@sha256:bdf57e528e45e4433820e045b29b4597825a1c9e38353532d90a01445013f82e -- nslookup kubernetes.default.svc.cluster.local returns an IP |
Solution
# Check the ConfigMapkubectl 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 fixkubectl get cm coredns -n kube-system -o yaml > coredns-backup.yamlkubectl edit cm coredns -n kube-system
# Restart CoreDNS to apply the changekubectl rollout restart deploy coredns -n kube-system
# Validationkubectl run test --rm -it --image=busybox:1.37@sha256:bdf57e528e45e4433820e045b29b4597825a1c9e38353532d90a01445013f82e -- nslookup kubernetes.default.svc.cluster.localExercise 22: CoreDNS, missing kube-dns Service
Target time: 5 minutes
| Context | CoreDNS pods Running but the kube-dns service does not exist |
|---|---|
| Task | Recreate the kube-dns service so that resolution works |
| Constraint | The service must target the CoreDNS pods and expose ports 53 TCP/UDP |
| Validation | kubectl get endpointslice -n kube-system -l kubernetes.io/service-name=kube-dns shows IPs |
Solution
# Check that the service does not existkubectl get svc kube-dns -n kube-system
# Recreate the servicekubectl apply -f - <<'EOF'apiVersion: v1kind: Servicemetadata: name: kube-dns namespace: kube-system labels: k8s-app: kube-dnsspec: selector: k8s-app: kube-dns clusterIP: 10.96.0.10 ports: - name: dns port: 53 protocol: UDP - name: dns-tcp port: 53 protocol: TCPEOF
# Validationkubectl get svc kube-dns -n kube-systemkubectl get endpointslice -n kube-system -l kubernetes.io/service-name=kube-dnskubectl run test --rm -it --image=busybox:1.37@sha256:bdf57e528e45e4433820e045b29b4597825a1c9e38353532d90a01445013f82e -- nslookup kubernetes.default.svc.cluster.localKey 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
| # | Exercise | Domain | Time | Type |
|---|---|---|---|---|
| 1 | Cluster upgrade | Architecture | 15 min | kubeadm |
| 2 | etcd backup | Architecture | 6 min | kubeadm |
| 3 | etcd restore | Architecture | 10 min | kubeadm |
| 4 | Role and RoleBinding | RBAC | 4 min | generic |
| 5 | ClusterRole nodes | RBAC | 4 min | generic |
| 6 | ServiceAccount | RBAC | 5 min | generic |
| 7 | Taints + placement | Scheduling | 6 min | generic |
| 8 | Node affinity | Scheduling | 5 min | generic |
| 9 | Drain and cordon | Scheduling | 3 min | generic |
| 10 | ClusterIP Service | Networking | 3 min | generic |
| 11 | NetworkPolicy deny | Networking | 4 min | generic |
| 12 | NetworkPolicy allow | Networking | 6 min | generic |
| 13 | Ingress | Networking | 5 min | generic |
| 14 | PV and PVC | Storage | 7 min | generic |
| 15 | ImagePullBackOff | Troubleshooting | 3 min | generic |
| 16 | Node NotReady | Troubleshooting | 8 min | kubeadm |
| 17 | Service endpoints | Troubleshooting | 4 min | generic |
| 18 | kubelet crash | Troubleshooting | 8 min | kubeadm |
| 19 | API Server down | Troubleshooting | 10 min | kubeadm |
| 20 | CoreDNS crash | Troubleshooting | 5 min | generic |
| 21 | CoreDNS config | Troubleshooting | 6 min | generic |
| 22 | CoreDNS service | Troubleshooting | 5 min | generic |
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.
kubectl delete ns cka-exerciseskubectl taint node worker1 env- 2>/dev/nullkubectl label node worker1 disktype- 2>/dev/nullKey takeaways
- To restore etcd, use
etcdutlinto a new directory, with the manifests moved out before and put back after:etcdctl snapshot restorehas been removed. - 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. - In a Pod's YAML, write
serviceAccountName: the--serviceaccountflag ofkubectl runwas removed in 1.24. - A toleration does not guarantee placement: add a
nodeSelector. - A PV is cluster-scoped, a PVC is namespaced.
- A static Pod restarts by itself when you edit its manifest.
- CoreDNS has three points of failure: the pods, the configuration and the service.
- The CKA aliases are
k,kn,$doand$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
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
Review
(0/0)Score by domain
A domain groups several guides and gets several questions, so its score is more reliable than a per-topic score, which often rests on a single question.
Summary
Strengths
No topic passed at 80% on at least two questions yet.
Weak areas
No topic below the pass mark.
Recommended next
Hints before you try again?
Continue the course: Prepare for the CKS: format, domains and study plan
A new full quiz with random questions
Work again only on the questions you missed