cka-sim/CKA_EXAM_GUIDE.md
vumast3r 55ab18f814 fix: repair the CKA bank and harness after a live audit; add Simulator Set D
Every changed task was seeded, graded untouched, solved and re-graded on a
separate kind cluster. The four sim sets were rehearsed as full sittings (real
baseline, seed everything, solve in order, grade at the end): A 150/150,
B 176/176, C 163/163, D 122/122. Every random-pool task was either passed in a
real session or cycled the same way.

Graders that could never pass, or passed for free:
  Q306 (local-path cannot resize; now graded as an in-place resize), Q314 (GNU
  grep prefixed file names), Q305 (plain `get events` has no SOURCE column and
  events expire; now managedFields), Q410 (kindnet DOES enforce NetworkPolicy;
  the expected answer is now derived from the CNI), Q35, Q212 (missing `]`),
  Q101 (`can-i create pods/exec` asks about a pod NAMED exec; multi-type get),
  Q109 (an emptyDir over nginx's /var/log crash-loops it), Q40 (TTL was
  measured at grading time), Q121, Q106, Q104, Q41, Q26, Q403, Q409, Q417,
  Q113, Q22, Q24/Q108 (flaky right after a rollout), and free points on
  untouched Q24/Q102/Q108/Q119/Q122.

Reference solutions: S[43], S[107], S[121], S[106] rewritten; S[116] (a
Completed Job pod still pins its PVC), S[119] (a pods quota equal to replicas
deadlocks the rollout); DNS checks use FQDNs; the explainer and exam guide
are corrected (etcd restore is etcdutl's job on 3.6+).

Cross-session leaks: the pre-session baseline now also repairs Q114 (the
kube-system NetworkPolicy and CoreDNS replicas), Q117/Q39 kubelet CA paths,
Q317, kubelet drop-in binary paths, a moved scheduler manifest, leftover
static pods and the default StorageClass. Q115 releases its fixed PVs from
claims left by earlier sessions.

Conflicts: `breaks` may be a list and `solo` keeps Q102's etcd restore out of
mixed sessions. Q118, Q5/Q103, Q26 vs the W1 taints, set A 203/204/208/212 and
set B 305/309 no longer sabotage each other. Q317 now disables only CSR
signing (the old break killed the whole controller-manager). Q110/Q311 no
longer compare against the whole cluster at submit time. Two delete/recreate
races in setups are fixed.

Harness: the weak list clears after two clean passes in a row, weak entries
show the latest attempt's failures, domain scores use the exam's own tasks,
history entries can be marked synthetic (entry 11 is), the web UI lists
every sim set, `./exam grade` refuses mid-exam (--force), preflight checks W1.

Set D (`./exam sim d`): 17 original killer.sh-style tasks, ids 501-517,
122 points - control-plane inventory, event forensics with crictl, a broken
kubelet unit, kubelet certificates, manual scheduling with the scheduler
stopped, Helm housekeeping with a stuck release, an enforced AND-vs-OR
NetworkPolicy, dnsPolicy and access-mode troubleshooting, and more.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-22 21:59:35 -06:00

6.0 KiB

CKA Exam Preparation & Scenario Decision Guide

This guide is designed for fast mental retrieval during exam scenarios. It outlines which command to choose based on the situation, the exact syntax to run, and the official documentation shortcuts permitted during the exam.


1. Quick Environment Setup & Muscle Memory

Run these first on every terminal/node session in the exam:

# Core aliases & shell variables
alias k=kubectl
export do="--dry-run=client -o yaml"
export now="--force --grace-period=0"

# Shell auto-completion with alias support
source <(kubectl completion bash)
complete -o default -F __start_kubectl k

# Vim configuration (~/.vimrc)
cat << 'EOF' > ~/.vimrc
set tabstop=2
set shiftwidth=2
set expandtab
set number
syntax on
EOF

2. Situation-to-Command Decision Matrix

Situation / Task First-Choice Command / Action Key Flags / Syntax
Create a single pod k run <name> --image=<img...> $do > pod.yaml
Expose a pod/deployment as Service k expose <pod/deploy> <name> --port=80 --target-port=8080 --type=NodePort/ClusterIP
Create Deployment k create deploy <name> --image=<img> --replicas=3 $do > deploy.yaml
Create Job / CronJob k create job <name> --image=<img>
k create cj <name> --image=<img>
--schedule="*/5 * * * *"
Create Secret / ConfigMap k create secret generic <name>
k create cm <name>
--from-literal=key=val
--from-file=config.txt
Create ServiceAccount & Token k create sa <name>
k create token <name>
(Kubernetes 1.24+ standard)
Create RBAC Role & RoleBinding k create role <name>
k create rolebinding <name>
--verb=get,list,watch --resource=pods,deployments
--role=<role> --serviceaccount=<ns>:<sa>
Create ClusterRole & ClusterRoleBinding k create clusterrole <name>
k create clusterrolebinding <name>
--verb=get,list --resource=nodes,pv
--clusterrole=<cr> --user=<user>
Create Ingress k create ingress <name> --rule="host/path*=svc:port"
--class=nginx --annotation=...
Check API permissions k auth can-i <verb> <res> --as=system:serviceaccount:<ns>:<sa> -n <ns>
Find YAML syntax / field paths k explain <resource>.<field> k explain pod.spec.containers.securityContext --recursive
Inspect Node / Pod metrics k top node / k top pod -A --sort-by=cpu or --sort-by=memory
Drain node for maintenance k drain <node> --ignore-daemonsets --delete-emptydir-data --force
Reactivate / Uncordon node k uncordon <node>
Troubleshoot Node (Kubelet) systemctl status kubelet
journalctl -u kubelet -e --no-pager
Check /etc/kubernetes/kubelet.conf & /var/lib/kubelet/config.yaml
Control Plane Troubleshooting Inspect /etc/kubernetes/manifests/ Check kube-apiserver.yaml, kube-scheduler.yaml, kube-controller-manager.yaml
Etcd Backup etcdctl snapshot save <file> --endpoints=https://127.0.0.1:2379 --cacert=... --cert=... --key=...
Etcd Restore etcdutl snapshot restore <file> --data-dir=/var/lib/etcd-backup (update etcd.yaml volume hostPath). etcdctl snapshot restore is gone from etcd 3.6+
Upgrade Node (Control Plane / Worker) apt-get update && apt-get install -y --allow-change-held-packages kubeadm=1.31.x-1.1 kubeadm upgrade plan -> kubeadm upgrade apply -> upgrade kubelet/kubectl -> systemctl restart kubelet

3. Top Troubleshooting Patterns

A. Pod in CrashLoopBackOff or Pending

  1. Check events: k describe pod <pod-name> -n <ns>
  2. Check logs: k logs <pod-name> -n <ns> --previous
  3. If Pending: Check node taints, node selectors, affinity, or resource quotas/limits.
    k get nodes -o custom-columns=NAME:.metadata.name,TAINTS:.spec.taints
    

B. Node in NotReady

  1. SSH into the node: ssh <node>
  2. Check kubelet service: systemctl status kubelet
  3. View logs: journalctl -u kubelet -n 100 --no-pager
  4. Common issues:
    • Container runtime (containerd/crio) is down (systemctl restart containerd).
    • Swap is enabled (swapoff -a).
    • Invalid configuration or wrong certificate path in /var/lib/kubelet/config.yaml or /etc/kubernetes/kubelet.conf.

C. Static Pods

  • Manifest location: /etc/kubernetes/manifests/ (or check staticPodPath in /var/lib/kubelet/config.yaml).
  • To create a static pod on a worker node:
    k run my-static --image=nginx $do > /etc/kubernetes/manifests/my-static.yaml
    

4. Etcd Backup & Restore Reference

Snapshot:

ETCDCTL_API=3 etcdctl \
  --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 \
  snapshot save /opt/snapshot-pre-boot.db

Restore:

etcdutl snapshot restore /opt/snapshot-pre-boot.db \
  --data-dir=/var/lib/etcd-from-backup

Then edit /etc/kubernetes/manifests/etcd.yaml to update the hostPath volume for etcd-data to /var/lib/etcd-from-backup.

Restore is an offline file operation, so it needs no endpoints or certificates - and it lives in etcdutl, not etcdctl: etcdctl snapshot restore was deprecated in etcd 3.5 and is gone from 3.6+ (this cluster runs 3.7, where it fails with unknown flag: --data-dir). Check first with etcdctl version; on a 3.5 node the old ETCDCTL_API=3 etcdctl snapshot restore still works.


5. Official Kubernetes Documentation URLs Allowed in CKA

  • Kubernetes Documentation: https://kubernetes.io/docs/
  • Kubernetes Blog: https://kubernetes.io/blog/
  • GitHub Kubernetes Organization: https://github.com/kubernetes/
  • Cheatsheet: https://kubernetes.io/docs/reference/kubectl/cheatsheet/

Pro Tip for Search in Docs:

Use the documentation search bar for exact resource types, e.g., NetworkPolicy, PersistentVolume, Ingress, or kubeadm upgrade. Copy YAML snippets directly from the docs and edit with $do.