CKA — Exam Setup & Speed Tips

6 minute read

CKA Exam Domain

All Domains — Speed tips apply to every question on the exam.

First 2 Minutes Setup

The moment your exam starts, before touching any question, run these commands in your terminal. This investment of 2 minutes will save you 10+ minutes over the exam.

# Alias kubectl to k
alias k=kubectl

# Dry-run shortcut — generates YAML without creating the resource
export do="--dry-run=client -o yaml"

# Force delete shortcut — instantly deletes resources without waiting
export now="--force --grace-period=0"

# Set vi as default editor (usually pre-set, but be safe)
export EDITOR=vi

# Enable kubectl autocompletion for bash
source <(kubectl completion bash)

# Make autocompletion work with the alias 'k' as well
complete -o default -F __start_kubectl k

Test it immediately:

k get nodes

If k works and tab-completion works, you’re ready.

Why These Aliases Matter

Without aliases:

kubectl create deployment web --image=nginx --dry-run=client -o yaml > deploy.yaml

With aliases:

k create deployment web --image=nginx $do > deploy.yaml

That’s 15 fewer characters per command. Over 15–20 questions, this adds up to minutes saved.

vi Editor Shortcuts

You will use vi (or vim) extensively during the exam to edit YAML files. Master these shortcuts:

Essential Shortcuts

Shortcut Action
i Enter insert mode (start typing)
Esc Return to normal mode
dd Delete current line
5dd Delete 5 lines from current position
yy Copy (yank) current line
5yy Copy 5 lines
p Paste below current line
P Paste above current line
u Undo last change
Ctrl+r Redo
:wq Save and quit
:q! Quit without saving
:w Save without quitting

Search & Replace

Shortcut Action
/search Search forward for “search”
n Go to next match
N Go to previous match
:%s/old/new/g Find and replace all occurrences
:s/old/new/ Replace first occurrence on current line
Shortcut Action
gg Go to beginning of file
Shift+G Go to end of file
:42 Go to line 42
0 Go to beginning of line
$ Go to end of line
w Jump forward one word
b Jump backward one word

Indentation & Display

Shortcut Action
:set number Show line numbers
:set nonumber Hide line numbers
:set paste Enable paste mode (preserves indentation)
:set nopaste Disable paste mode
>> Indent current line
<< Un-indent current line
5>> Indent 5 lines

Pro tip: Before pasting YAML from the kubernetes.io docs, always run :set paste first. Without it, vi may auto-indent the pasted text and break your YAML structure.

YAML Generation Tricks

Never write YAML from scratch. Use imperative commands with --dry-run=client -o yaml to generate base YAML, then edit it.

Pods

k run nginx --image=nginx $do > pod.yaml
k run busybox --image=busybox --command -- sleep 3600 $do > debug-pod.yaml
k run nginx --image=nginx --port=80 --labels="app=web,tier=frontend" $do > pod-labels.yaml

Deployments

k create deployment web --image=nginx --replicas=3 $do > deploy.yaml
k create deployment api --image=node:18 --port=3000 $do > api-deploy.yaml

Services

k create service clusterip my-svc --tcp=80:8080 $do > svc.yaml
k create service nodeport my-np --tcp=80:8080 $do > np-svc.yaml
k expose deployment web --port=80 --target-port=8080 --type=ClusterIP $do > expose-svc.yaml

ConfigMaps & Secrets

k create configmap app-config --from-literal=key=value --from-literal=env=prod $do > cm.yaml
k create secret generic my-secret --from-literal=pass=secret --from-literal=user=admin $do > secret.yaml

RBAC

k create role pod-reader --verb=get,list,watch --resource=pods $do > role.yaml
k create rolebinding read-pods --role=pod-reader --user=jane $do > rb.yaml
k create clusterrole node-reader --verb=get,list --resource=nodes $do > cr.yaml
k create clusterrolebinding read-nodes --clusterrole=node-reader --user=jane $do > crb.yaml

ServiceAccounts

k create serviceaccount my-sa $do > sa.yaml

Namespaces

k create namespace team-blue

Jobs & CronJobs

k create job my-job --image=busybox -- echo "Hello" $do > job.yaml
k create cronjob my-cron --image=busybox --schedule="*/5 * * * *" -- echo "tick" $do > cron.yaml

Copy-Paste in the Exam

The exam uses a PSI Secure Browser. Standard copy-paste shortcuts may differ:

Action Shortcut
Copy Ctrl+Insert or Ctrl+Shift+C
Paste Shift+Insert or Ctrl+Shift+V
Select All Ctrl+A (in text fields)

Important notes:

  • Right-click paste does NOT work in the terminal
  • Practice with these shortcuts before exam day
  • You can copy from the kubernetes.io docs and paste into the terminal

Kubernetes Documentation Navigation

During the exam, you’re allowed to browse:

  • kubernetes.io/docs
  • kubernetes.io/blog
  • github.com/kubernetes

How to Find Things Fast

  1. Use the search bar on kubernetes.io/docs — it’s faster than browsing the sidebar
  2. Bookmark nothing — you can’t use bookmarks in the exam browser, but the search is fast enough

Frequently Needed Docs Pages

Topic What to Search
NetworkPolicy YAML “network policy”
PV/PVC examples “persistent volume”
etcd backup “operating etcd”
kubeadm upgrade “kubeadm upgrade”
RBAC example “RBAC” or “role-based”
Ingress TLS “ingress tls”
Resource limits “resource management”
Taints & tolerations “taint and toleration”
Node affinity “assign pods nodes affinity”
Init containers “init containers”

Pro tip: When you find the right page, use Ctrl+F (browser find) to jump to the YAML example you need. Copy it, paste into your terminal with :set paste, and modify.

Useful One-Liners

These commands come up repeatedly. Commit them to memory:

# Get all resources in a namespace
k get all -n <namespace>

# Get Pods sorted by creation time
k get pods --sort-by=.metadata.creationTimestamp

# Get Pods with their node placements
k get pods -o wide

# Get Pod YAML (useful for debugging)
k get pod <name> -o yaml

# Check which node a Pod is running on
k get pod <name> -o jsonpath='{.spec.nodeName}'

# Get events sorted by time
k get events --sort-by=.metadata.creationTimestamp

# Quick pod logs
k logs <pod> --tail=50

# Check resource usage
k top nodes
k top pods -A

# Quickly test DNS
k run dns-test --image=busybox:1.36 --rm -it --restart=Never -- nslookup kubernetes

Practice Questions

Question 1: Setup Speed

Write the exact commands you’d run in the first 2 minutes of the exam. Time yourself — can you do it in under 90 seconds?

Show Answer
alias k=kubectl
export do="--dry-run=client -o yaml"
export now="--force --grace-period=0"
source <(kubectl completion bash)
complete -o default -F __start_kubectl k

Verify with:

k get nodes

Target time: Under 30 seconds (you should type this from muscle memory).

Question 2: Generate a Pod YAML

Using your aliases, generate a YAML file for a Pod named web with image nginx:1.27 and port 80, saved to /tmp/web.yaml. Don’t create it yet.

Show Answer
k run web --image=nginx:1.27 --port=80 $do > /tmp/web.yaml

This generates the YAML without creating the Pod. You can then edit the file to add any additional specifications before applying.

Question 3: Fast Deployment + Service

Create a Deployment called app with 3 replicas of httpd:2.4 and expose it as a ClusterIP Service on port 80. Do it in 2 commands or fewer.

Show Answer
k create deployment app --image=httpd:2.4 --replicas=3
k expose deployment app --port=80 --target-port=80

Two commands, done in under 15 seconds. No YAML files needed.

Question 4: vi Paste Fix

You pasted YAML into vi but the indentation is completely wrong. All the nested fields are shifted to the right. How do you fix this before it happens next time?

Show Answer

Prevention: Before pasting, type :set paste in vi normal mode. This disables auto-indentation.

Fix current mess:

  1. Press u repeatedly to undo all the paste
  2. Type :set paste
  3. Press i to enter insert mode
  4. Paste again — indentation will be preserved
  5. Press Esc, then :set nopaste to re-enable normal editing

Question 5: Quick Resource Lookup

You need to create a NetworkPolicy but don’t remember the YAML structure. Walk through exactly how you’d find a working example in under 60 seconds during the exam.

Show Answer
  1. Open the kubernetes.io/docs tab in the exam browser
  2. Type “network policy” in the search bar
  3. Click on “Network Policies” under Concepts → Services, Load Balancing, and Networking
  4. Scroll down or use Ctrl+F to search for “apiVersion” to find YAML examples
  5. Copy the example YAML
  6. In terminal: vi netpol.yaml, then :set paste, then i, then paste
  7. Modify the YAML to match your question requirements
  8. k apply -f netpol.yaml

Practice this workflow until it’s second nature.


Next: Common Mistakes →

Updated: