Exam-day habits: vim, docs, time
Set up vim, budget your time, read tasks twice, search the docs fast, and avoid the traps that turn right answers into zero.
Key ideas in this lesson · tap one for a simple explanation
What you will be able to do
- Set up vim in ten seconds, so YAML indents correctly and pasted text stays in place.
- Budget time by task weight, and decide in under a minute whether to flag a task and move on.
- Name the common ways a correct-looking answer scores zero, and check for each before you leave a task.
Most people who fail the CKA know enough Kubernetes. They lose points in small ways: the wrong , a tab in a file, twenty minutes on a 4% task, or a question answered from memory. This lesson builds the habits that stop those losses. They are cheap to build in the lab. The two tasks at the end are small on purpose: the routine is the point.
vim that behaves
vim is the text editor you will use in the exam terminal. Out of the box, its Tab key types a tab character, and YAML refuses tabs. One line in vim's settings file, ~/.vimrc, fixes that.
cat > ~/.vimrc <<'EOF'
set ts=2 sw=2 et nu
EOF
# ts=2 tabstop: a tab displays as two columns
# sw=2 shiftwidth: > and < indent by two spaces
# et expandtab: the Tab key inserts spaces, never a tab character (YAML rejects tabs)
# nu line numbers, so error messages like "line 23" mean something
# Inside vim:
# :set paste before pasting from the docs (stops auto-indent from staircasing the text)
# :set nopaste after, or your Tab key and indentation stop working
# Ctrl+v j j j > select a block of lines, indent them one shiftwidth; . repeats it
# Ctrl+v j j j < outdent
# :%s/old/new/g replace everywhere; :%s/\t/ /g turns tabs into two spaces
# :set list show tabs as ^I so you can find them; :set nolist to hide again
# u / Ctrl+r undo / redo; :w save; :q! quit without savingThe exam desktop has its own keyboard rules:
- Terminal: copy with
Ctrl+Shift+Cand paste withCtrl+Shift+V, or use the right-click menu. - Firefox: the usual
Ctrl+CandCtrl+V.Ctrl+Wcloses the browser tab, so close a terminal tab withCtrl+Alt+Winstead. - No Insert key: it is blocked in the exam. In vim, press
ito start typing andEscto stop. - tmux is optional. It can show a second pane that watches
kubectl get pods -w. If you do not already use it every day, a second terminal tab does the same job.
Time: one minute per percentage point
Give each task as many minutes as its weight in percent: a 4% task gets 4 minutes. All tasks together then take about 100 of your 120 minutes. The 20 minutes left are for flagged tasks and a last check.
About 100 minutes
every task once, one minute per point
Last 20 minutes
flagged tasks, highest weight first
Final pass
check names, namespaces and files
Read twice, check once
- Read the whole task before you type. Then read it again and note the nouns: namespace, names, image tag, replica count, file path, keys. Many tasks hide one more requirement in the last sentence.
- Copy names from the question, never retype them. Select the name in the question, then paste it into the terminal. After 90 minutes,
web-apiandweb-aplboth look right. - Host and context first. Follow the infobox:
sshto the named host, and switch context or namespace if the task names one. When you finish,exitback to the base host. - Set the namespace once if the whole task is in one:
k config set-context --current --namespace=<ns>. The setting stays for the next task on the same host, so remember you changed it. - Check the result, not what you meant to do. The table below has one quick check for each kind of task.
- Grep the live object when the question lists fields:
k get pod web -o yaml | grep -E 'image:|serviceAccountName|nodeName|tier'. It takes five seconds. It catches a wrong tag, a missing label or a on the wrong node. - Leave the cluster as you found it, apart from what the task asked. Uncordon a node you cordoned to test something, delete a test Pod, undo a namespace switch. Leftovers can break the grading of a later task.
Finding things in the docs
You may open kubernetes.io during the exam, but browsing it is slow. Two habits make it fast:
- Try
kubectl explainfirst.k explain deploy.spec.strategyprints what each field means, right in the terminal. It is faster than any search. - Search by phrase. When you need a full YAML example, type a short phrase into the kubernetes.io search box and open the page with the matching title. Do not click through the menus.
The cheat sheet has the full table: one search phrase for every exam topic.
The trap list
Each of these turns a correct-looking answer into zero points. Check for them before you leave a task.
- Wrong namespace. Your object works, but the grader looks in the namespace the question named, so use
-non every command or set it in the context. - Wrong host or context. Your work is on another cluster, so read the infobox first, always.
- Skipping
rollout status. A wrong image tag means the new Pods never start, and you only see it if you wait for the rollout. - Editing a Pod field that cannot change. Most of a running Pod's spec is fixed; kubectl fluency shows the
replace --forceway around it. - A outside its range. NodePorts are 30000 to 32767 by default, so a number like 3080 is probably the Service port (Services).
- maxSurge and maxUnavailable rounding. Their percentages round in opposite directions, so write a whole number when a task needs an exact count (Deployments).
- values. If you base64-encode by hand, use
echo -n, or a hidden newline becomes part of the value (ConfigMaps and Secrets). - Tabs in YAML. YAML refuses tab characters, so set
expandtabin vim and fix a bad paste with:%s/\t/ /g. - Selector and labels that do not match. You get a Service with no endpoints or a policy that selects nothing (Service and DNS failures).
- The name in
set image. Ink set image deploy/web nginx=nginx:1.26, the part before=is the container's name, not the image's name. - A file in the wrong place. The grader does not search for your file, so write it to the exact path (
mkdir -pthe folder first) and check it withcat. - Forgetting
sudo -ion a node. Without root you cannot read the files in/etc/kubernetes/manifests, andjournalctl -u kubeletmay show nothing.
The first two minutes
On the first task host, set up your shell (the aliases from kubectl fluency) and write the vimrc above. Run k get nodes to make sure the terminal works. Then start task one, and read it twice. What to do the night before and on the morning of the exam is in the final checklist.
In the official docs· open on exam day too
- Exam Rules and Policies (handbook)search: exam rules and policies
- ExamUI: Performance Based Exams (handbook)search: examui performance based
- Candidate Identification and Authentication (handbook)search: candidate identification
- kubectl quick referencesearch: cheat sheet
Write your exam vimrc
/tmp/cka/vimrc. It must set tabstop to 2, shiftwidth to 2 and enable expandtab. Short option names are fine. You may add other settings.Cluster:kubectl config use-context kind-cka
- 1
Set up the scenario
curl -fsSL https://codewithmuh.com/labs/cka/t/fd-habits-1/setup | bash - 2
Solve it in your terminal
Use kubectl and the Kubernetes docs, like on exam day. Save any answer files under
/tmp/cka/. - 3
Check your work
curl -fsSL https://codewithmuh.com/labs/cka/t/fd-habits-1/verify | bashGot FAIL? Read which check failed, fix it, run it again. - 4
Clean up (optional)
curl -fsSL https://codewithmuh.com/labs/cka/t/fd-habits-1/cleanup | bash
Read it twice: scale exactly one Deployment
fd-habits contains several Deployments with similar names. Scale the Deployment billing-api to 3 replicas and add the label tier=backend to that Deployment. Do not modify any other Deployment in the namespace.Cluster:kubectl config use-context kind-cka
- 1
Set up the scenario
curl -fsSL https://codewithmuh.com/labs/cka/t/fd-habits-2/setup | bash - 2
Solve it in your terminal
Use kubectl and the Kubernetes docs, like on exam day. Save any answer files under
/tmp/cka/. - 3
Check your work
curl -fsSL https://codewithmuh.com/labs/cka/t/fd-habits-2/verify | bashGot FAIL? Read which check failed, fix it, run it again. - 4
Clean up (optional)
curl -fsSL https://codewithmuh.com/labs/cka/t/fd-habits-2/cleanup | bash
Finished this lesson?
0 of 2 tasks passed. Your readiness counts tasks, so run them before you move on.