CKAD — Exam Setup & Speed Tips

1 minute read

Essential Exam Environment Setup

Do this immediately when the exam starts (first 2 minutes):

# Set up aliases (saves hundreds of keystrokes)
alias k=kubectl
alias kn='kubectl config set-context --current --namespace'
alias kaf='kubectl apply -f'

# Enable autocomplete
source <(kubectl completion bash)
complete -o default -F __start_kubectl k

# Set your preferred editor (vi is default)
export KUBE_EDITOR=vi
# Or if you prefer nano:
# export KUBE_EDITOR=nano

# Verify cluster access
kubectl cluster-info
kubectl get nodes

Exam tip: These aliases are usually pre-configured in the exam environment, but verify them. The k alias alone saves massive time.

kubectl Speed Tips

Generate YAML Instead of Writing From Scratch

# Pod
k run nginx --image=nginx:1.27 --dry-run=client -o yaml > pod.yaml

# Deployment
k create deployment web --image=nginx:1.27 --replicas=3 --dry-run=client -o yaml > deploy.yaml

# Service
k expose deployment web --port=80 --target-port=8080 --dry-run=client -o yaml > svc.yaml

# Job
k create job backup --image=busybox -- /bin/sh -c "echo done" --dry-run=client -o yaml > job.yaml

# CronJob
k create cronjob backup --image=busybox --schedule="0 2 * * *" -- /bin/sh -c "echo done" --dry-run=client -o yaml > cron.yaml

# ConfigMap
k create configmap app-config --from-literal=key=value --dry-run=client -o yaml > cm.yaml

# Secret
k create secret generic db-creds --from-literal=password=secret --dry-run=client -o yaml > secret.yaml

# Ingress
k create ingress web --class=nginx --rule="app.example.com/*=web-svc:80" --dry-run=client -o yaml > ingress.yaml

# ServiceAccount
k create serviceaccount app-sa --dry-run=client -o yaml > sa.yaml

# Role & RoleBinding
k create role pod-reader --verb=get,list --resource=pods --dry-run=client -o yaml > role.yaml
k create rolebinding read-pods --role=pod-reader --serviceaccount=default:app-sa --dry-run=client -o yaml > rb.yaml

Quick Lookups

# Find the field path you need
k explain pod.spec.containers.securityContext
k explain deployment.spec.strategy

# List all resource types
k api-resources | grep -i network

# Check permissions
k auth can-i create deployments --as=system:serviceaccount:default:app-sa

Fast Editing

# Edit in place
k edit deployment web

# Patch a single field
k patch deployment web -p '{"spec":{"replicas":5}}'

# Scale quickly
k scale deployment web --replicas=5

# Set image
k set image deployment/web nginx=nginx:1.28

# Set resources
k set resources deployment web --requests=cpu=100m,memory=128Mi --limits=cpu=250m,memory=256Mi

Namespace Management

# Switch namespace (so you don't need -n on every command)
k config set-context --current --namespace=production

# Or with the alias
kn production

# Always verify which namespace you are in
k config get-contexts

Next: Common Mistakes →

Updated: