Free lesson · CKAD Prep Program · Module 1: Strategy and speed
YAML Speed for Developers: vim and Generate
CKAD tasks are YAML assembly at speed. This lesson makes generation (not typing) the default and vim a tool instead of a hazard, so manifests stop being the bottleneck.
10 min reading
Objectives
- Edit YAML in vim without the editor costing points
- Generate Pod, Deployment and Service manifests from dry-run only
- Patch a live object with kubectl edit, patch and set commands
- Keep a per-task scratch pattern for names, ports and image tags
Why this matters
A CKAD task is typically: read the requirement, produce or modify two or three manifests, apply, verify. Developers who hand-write YAML spend half the task on indentation and the other half debugging it, while the grading checks the cluster state, not the file. Generation plus surgical edits is the whole game, and it is mechanical enough to drill to reflex.
Concepts
The factory line stays the same as the admin one: kubectl create ... --dry-run=client -o yaml for pods, deployments, services, jobs, cronjobs, configmaps and secrets. For developers the highest-frequency variant is the pod generator with env, labels and resource requests inline:
k run api --image=myapp:v2 --restart=Never --dry-run=client -o yaml \
--labels=app=api --env=LOG_LEVEL=debug > pod.yamlVim minimum for YAML work: i insert, Esc back to normal, :wq save-quit, o open a line below, dd delete a line, / search, u undo, :set number for line numbers, >>` indent. YAML errors are always indentation or colons; line numbers plus search find them in seconds. If vim still scares you, export the editor to nano today and never look back.
Live-object surgery avoids the file round-trip: kubectl set image, kubectl scale, kubectl label, kubectl annotate, kubectl patch and kubectl edit change running objects directly. Prefer the narrowest command that fits: set and scale for one field, edit for structural changes, patch when you must script it.
Worked example
Multi-container pod with a shared volume, generated then edited:
k run worker --image=busybox --restart=Never --dry-run=client -o yaml \
--command -- sh -c "while true; do date >> /shared/log; sleep 5; done" > worker.yaml
# vim worker.yaml: add second container (log-reader) + emptyDir volume "shared"
k apply -f worker.yaml
k logs worker -c log-readerThe generator writes the skeleton and the restart policy; vim adds the ten lines that make it multi-container. Hand-typing the full forty lines invites two indentation bugs on average.
Exam notes
kubectl run defaults to a Deployment unless --restart=Never (pod) or --restart=OnFailure (job): the single most common CKAD generator mistake. Resource requests and limits go inline with --requests and --limits flags where supported, otherwise one vim pass. And verify with reads, not faith: get, describe and logs after every apply.
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
With a timer: generate a pod with two env vars and a label, add resource limits in vim, apply, then change the image with kubectl set image and verify. Repeat until generate-to-verified is under four minutes.
Pass criteria
Generate-to-verified under four minutes; zero hand-typed manifests; vim pass limited to the delta; verification reads after every apply.