Free lesson · CKA Prep Program · Module 1: Exam strategy and speed
kubectl Speed: Alias, Vim and Dry-Run
The CKA is won at the keyboard. This lesson installs the three speed habits (alias plus completion, vim basics, dry-run generation) that turn YAML writing from minutes into seconds.
10 min reading
Objectives
- Set up the alias, completion and editor trio that every fast candidate uses
- Generate any workload manifest with --dry-run=client -o yaml instead of typing it
- Explain any field on the spot with kubectl explain
- Keep a session note that survives the two-hour exam
Why this matters
Performance exams grade finished tasks, not knowledge. Two candidates can both understand Deployments while one finishes in four minutes and the other in fourteen; the difference is almost never Kubernetes, it is typing. The examiners allow the official docs for exactly this reason: they expect you to generate, not memorize. Speed is a skill you drill, and M00 is the drill ground before any domain content.
Concepts
alias k=kubectl plus shell completion plus export KUBE_EDITOR=vim (or nano if you truly edit faster in it) is the universal starter. Completion means k get dep plus Tab completes to k get deployment; combined with the alias, routine commands shrink to a handful of keystrokes. Set all three in the exam terminal first, before reading question one.
kubectl create ... --dry-run=client -o yaml is the manifest factory. Deployments, pods, services, jobs, cronjobs, configmaps, secrets, roles, clusterroles, rolebindings, serviceaccounts, ingresses, persistentvolumeclaims, namespaces: every one of these has a kubectl create path that emits YAML you then edit. The exam pattern is generate, redirect to a file, tweak two fields, apply. Typing a manifest from memory is the slowest legal move on the board.
kubectl explain pod.spec.containers --recursive | grep -i <field> answers field questions faster than any docs page for structure, while the docs answer semantics. Use both: explain for where a field lives, docs for what values it accepts.
Worked example
A deployment with two nginx replicas, exposed on port 80, built without typing YAML:
alias k=kubectl
source <(kubectl completion bash)
export KUBE_EDITOR=vim
k create deployment web --image=nginx --replicas=2 --dry-run=client -o yaml > web.yaml
vim web.yaml # confirm image and replicas, save
k apply -f web.yaml
k expose deployment web --port=80 --dry-run=client -o yaml | k apply -f -
k get pods -o wideTotal typing is under ten lines. The same task hand-typed is thirty-plus lines with three chances to misindent.
Exam notes
Vim survival minimum: i to insert, Esc then :wq to save and quit, / to search, u to undo. If vim panics you, set the editor to nano and move on; a slow editor you trust beats a fast one you fear. Keep one scratch file in the terminal with cluster notes (context names, IPs, passwords from questions) because re-reading a question costs a minute every time.
Quick check
A 4-question self-check. Your answers stay on your device, are never stored or sent. Only a passing score (for example 3 of 4) is saved, and only to unlock lesson progress: at least 3 correct is required before a lesson counts as complete. It never counts toward any certification assessment.
Lesson feedback
No published feedback yet.
Log in and complete the lesson to leave feedback.
Exercise
Open a fresh browser cluster and, with a timer running, create a 3-replica deployment, expose it, scale it to 5, record each command in a session note, then delete everything. Repeat until the whole loop is under three minutes with zero hand-typed YAML.
Pass criteria
Timed loop under three minutes; session note holds every command verbatim; no manifest typed by hand; alias, completion and editor set before the first create.