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.

30 min 2 hands-on tasks

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.

First thing on each exam host, right after the kubectl aliases
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 saving

The exam desktop has its own keyboard rules:

  • Terminal: copy with Ctrl+Shift+C and paste with Ctrl+Shift+V, or use the right-click menu.
  • Firefox: the usual Ctrl+C and Ctrl+V. Ctrl+W closes the browser tab, so close a terminal tab with Ctrl+Alt+W instead.
  • No Insert key: it is blocked in the exam. In vim, press i to start typing and Esc to 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.

How to spend the two hours

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

Task weightBudgetWhen the budget runs out
2%2 minutesNot done? Leave what you have, flag it, move on.
4%4 minutesThe same rule. Most 4% tasks are two commands and a check.
6 to 8%6 to 8 minutesUsually several steps, such as an chain, an plus a , or a broken . Do the parts you are sure of first.
Any task, after 12 minutesStopFlag it and move on. No single task is worth more of your time than that.
Last 20 minutesReserveGo back to flagged tasks, highest weight first. Then do one final check pass.
OrderAs givenWork the tasks in order, unless one is clearly long. Jumping around means reading tasks twice. Flag tasks in the exam screen, not in your head.

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-api and web-apl both look right.
  • Host and context first. Follow the infobox: ssh to the named host, and switch context or namespace if the task names one. When you finish, exit back 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.
To checkRun
Replicas and image of a k get deploy web -n ns -o wide
The Pods are Runningk get pods -n ns -l app=web
A has finishedk rollout status deploy/web -n ns
An answer filecat the file
RBACk auth can-i <verb> <resource> --as=<user> -n ns
A Service or an Ingresscurl its address

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 explain first. k explain deploy.spec.strategy prints 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.
TopicType into the search boxOpen the page titled
Roles, bindings, verbsrbacUsing RBAC Authorization
snapshot save and restoreetcd backupOperating etcd clusters for Kubernetes
YAML, default denynetwork policiesNetwork Policies
commands(search helm.sh/docs instead, for example helm upgrade)Helm Upgrade

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 -n on 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 --force way 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 expandtab in 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. In k 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 -p the folder first) and check it with cat.
  • Forgetting sudo -i on a node. Without root you cannot read the files in /etc/kubernetes/manifests, and journalctl -u kubelet may 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

Hands-on task 1 of 2fd-habits-1
~2 min2% weightArchitecture

Write your exam vimrc

Write the vim configuration you will use on the exam to /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. 1

    Set up the scenario

    curl -fsSL https://codewithmuh.com/labs/cka/t/fd-habits-1/setup | bash
  2. 2

    Solve it in your terminal

    Use kubectl and the Kubernetes docs, like on exam day. Save any answer files under /tmp/cka/.

  3. 3

    Check your work

    curl -fsSL https://codewithmuh.com/labs/cka/t/fd-habits-1/verify | bash
    Got FAIL? Read which check failed, fix it, run it again.
  4. 4

    Clean up (optional)

    curl -fsSL https://codewithmuh.com/labs/cka/t/fd-habits-1/cleanup | bash
Hands-on task 2 of 2fd-habits-2
~4 min3% weightWorkloads

Read it twice: scale exactly one Deployment

Namespace 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. 1

    Set up the scenario

    curl -fsSL https://codewithmuh.com/labs/cka/t/fd-habits-2/setup | bash
  2. 2

    Solve it in your terminal

    Use kubectl and the Kubernetes docs, like on exam day. Save any answer files under /tmp/cka/.

  3. 3

    Check your work

    curl -fsSL https://codewithmuh.com/labs/cka/t/fd-habits-2/verify | bash
    Got FAIL? Read which check failed, fix it, run it again.
  4. 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.