|
| 1 | +# Exam Notes |
| 2 | + |
| 3 | +Things I keep forgetting or that cost me time in practice runs. |
| 4 | + |
| 5 | +## Time Management |
| 6 | + |
| 7 | +- 2 hours, 17 questions — roughly 7 min per question |
| 8 | +- Flag hard ones and come back, don't get stuck on a single task |
| 9 | +- Some questions are worth 4%, others 7-8% — prioritize high-value ones |
| 10 | + |
| 11 | +## Shortcuts That Save Time |
| 12 | + |
| 13 | +```bash |
| 14 | +# Set these up FIRST, before touching any question |
| 15 | +alias k='kubectl' |
| 16 | +alias kgp='kubectl get pods -A' |
| 17 | +alias kgn='kubectl get nodes' |
| 18 | +alias kd='kubectl describe' |
| 19 | +export do='--dry-run=client -o yaml' |
| 20 | +export now='--grace-period=0 --force' |
| 21 | + |
| 22 | +# vim settings (add to ~/.vimrc) |
| 23 | +set tabstop=2 |
| 24 | +set shiftwidth=2 |
| 25 | +set expandtab |
| 26 | +``` |
| 27 | + |
| 28 | +## jsonpath |
| 29 | + |
| 30 | +Comes up all the time. I always forget the syntax. |
| 31 | + |
| 32 | +```bash |
| 33 | +# Get internal IPs of all nodes |
| 34 | +kubectl get nodes -o jsonpath='{.items[*].status.addresses[?(@.type=="InternalIP")].address}' |
| 35 | + |
| 36 | +# List all container images running in a namespace |
| 37 | +kubectl get pods -n kube-system -o jsonpath='{range .items[*]}{.spec.containers[*].image}{"\n"}{end}' |
| 38 | + |
| 39 | +# Get PV sorted by capacity |
| 40 | +kubectl get pv --sort-by=.spec.capacity.storage |
| 41 | + |
| 42 | +# Custom columns |
| 43 | +kubectl get pods -o custom-columns=NAME:.metadata.name,STATUS:.status.phase,NODE:.spec.nodeName |
| 44 | +``` |
| 45 | + |
| 46 | +## etcd |
| 47 | + |
| 48 | +Always need the certs. Check the etcd pod manifest if unsure: |
| 49 | + |
| 50 | +```bash |
| 51 | +cat /etc/kubernetes/manifests/etcd.yaml | grep -E 'cert|key|cacert' |
| 52 | +``` |
| 53 | + |
| 54 | +## Common Mistakes |
| 55 | + |
| 56 | +- Forgetting `--namespace` — always double-check which namespace the question asks for |
| 57 | +- NetworkPolicy: once you create ANY policy selecting a pod, all other traffic is denied by default |
| 58 | +- PV/PVC: accessModes and capacity must match, otherwise the PVC stays Pending |
| 59 | +- `kubeadm upgrade apply` only on control plane, `kubeadm upgrade node` on workers |
| 60 | +- Static pod manifests go in `/etc/kubernetes/manifests/`, not applied via kubectl |
| 61 | +- After editing a static pod manifest, kubelet picks it up automatically — no restart needed |
| 62 | + |
| 63 | +## kubectl Tricks |
| 64 | + |
| 65 | +```bash |
| 66 | +# Generate YAML without applying |
| 67 | +kubectl run tmp --image=nginx $do > pod.yml |
| 68 | + |
| 69 | +# Quick debug pod |
| 70 | +kubectl run debug --image=busybox:1.36 --rm -it -- sh |
| 71 | + |
| 72 | +# Check if RBAC allows something |
| 73 | +kubectl auth can-i create deployments --as=dev -n staging |
| 74 | + |
| 75 | +# See why a pod isn't scheduled |
| 76 | +kubectl describe pod <name> | grep -A5 Events |
| 77 | + |
| 78 | +# Diff before applying |
| 79 | +kubectl diff -f manifest.yml |
| 80 | +``` |
0 commit comments