CKAD Practice: 20 Developer Tasks on a Real Cluster
What you build: 20 timed CKAD-style developer tasks on a real GKE cluster with tested answers: rollouts, config, probes, sidecars, jobs, quotas, security, PVCs, a CrashLoopBackOff fix, HPA and blue/gr

✍️ Translate this blog into Hindi, Tamil or Telugu
The CKAD (Certified Kubernetes Application Developer) exam is a hands-on, timed exam: about 2 hours of real tasks in a terminal, no multiple choice. You pass by being **fast and correct with kubectl, and the only way to get there is practice on a real cluster. This post gives you 20 CKAD-style developer tasks** with tested answers, run on a GKE cluster: pods, deployments and rollbacks, services, ConfigMaps and Secrets, probes and resources, sidecars and init containers, Jobs and CronJobs, quotas, service accounts, security contexts, persistent volumes, a CrashLoopBackOff you debug and fix, autoscaling and blue/green. Every answer shows the real output.
Who it is for: anyone preparing for CKAD (or CKA) who knows basic Kubernetes objects. Time: about 1.5 hours the first time; aim for under 60 minutes by your third run. Cost: a small GKE cluster for the session (a small compute cost); delete it right after.
Every command below was run for real by the CareerByteCode Team on a GKE cluster in a fresh Google Cloud project, and every output is the real one we got. Pod names and IPs will differ on your cluster.
🎓⭐ Recommended by CareerByteCode · Live trainingAWS Cloud Architecture and AIOps Bootcampโน10,620See the training →Part A: how to practise for a hands-on exam

Three habits matter more than any single command:
- Imperative first, YAML second.
kubectl run,kubectl create deployment,kubectl expose,kubectl create configmap/secret/job/cronjobare much faster than writing YAML. When you need YAML, generate it:--dry-run=client -o yaml > file.yaml, then edit. - Set the namespace once.
kubectl config set-context --current --namespace=<ns>saves typing-n50 times. - Verify every task.
kubectl get,describe,logsand a test pod withwgetorcurl. A task you did not verify is a task you might have lost.
Real-life example: a driving test. The examiner does not care that you know the rules; they watch you drive, on time, and check you stopped at every sign.
Before you start
- A Google Cloud account with billing and a project. This lab uses a small GKE cluster (not free).
- Open Cloud Shell (the
>_icon at the top right of the console) and create the cluster (about 5 minutes):
export PROJECT_ID="your-project-id"
gcloud config set project $PROJECT_ID
gcloud services enable container.googleapis.com
gcloud container clusters create lab-cluster --zone=us-east1-b --num-nodes=2 \
--machine-type=e2-standard-4 --disk-type=pd-standard --disk-size=50Try each task yourself first, with a timer. Then compare with the tested answer.
Part B: the 20 tasks
Setup: a namespace and exam habits
# Connect to the cluster and make a practice namespace. Exam habits: an alias and a dry-run shortcut
gcloud container clusters get-credentials lab-cluster --zone=us-east1-b > /dev/null 2>&1
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y -qq python3-yaml > /dev/null 2>&1
kubectl create namespace ckad > /dev/null && kubectl config set-context --current --namespace=ckad > /dev/null && kubectl config view --minify -o jsonpath='{..namespace}'; echo
echo 'alias k=kubectl; export do="--dry-run=client -o yaml"' && kubectl version 2>/dev/null | grep Serverckad
alias k=kubectl; export do="--dry-run=client -o yaml"
Server Version: v1.36.4-gke.2377000Tasks 1 and 2: a labelled pod, and YAML without creating anything
# Task 1: a pod "web" (nginx:1.27) with label tier=frontend. Task 2: get its YAML without creating anything (dry run)
kubectl run web --image=nginx:1.27 --labels=tier=frontend > /dev/null && kubectl wait pod/web --for=condition=Ready --timeout=90s
kubectl get pod web --show-labels --no-headers | awk '{print $1, $2, $3, $NF}'
kubectl run api --image=nginx:1.27 --port=8080 --dry-run=client -o yaml | grep -vE "creationTimestamp|resources: \{\}|^status|dnsPolicy|restartPolicy"pod/web condition met
web 1/1 Running tier=frontend,topology.kubernetes.io/region=us-east1,topology.kubernetes.io/zone=us-east1-b
apiVersion: v1
kind: Pod
metadata:
labels:
run: api
name: api
spec:
containers:
- image: nginx:1.27
name: api
ports:
- containerPort: 8080--dry-run=client -o yaml printed a ready-to-edit pod manifest without creating anything. (GKE adds topology labels to pods; your own label tier=frontend is there.)
Tasks 3 and 4: a deployment, an image change, a rollback, and a Service
# Task 3: a deployment "shop" with 3 replicas, then a new image and a rollback. Task 4: expose it inside the cluster
kubectl create deployment shop --image=nginx:1.26 --replicas=3 > /dev/null && kubectl rollout status deploy/shop --timeout=120s
kubectl set image deploy/shop nginx=nginx:1.27 > /dev/null && kubectl rollout status deploy/shop --timeout=120s > /dev/null && kubectl rollout history deploy/shop | tail -3
kubectl rollout undo deploy/shop > /dev/null && kubectl rollout status deploy/shop --timeout=120s > /dev/null && kubectl get deploy shop -o jsonpath='{.spec.template.spec.containers[0].image}'; echo
kubectl expose deploy/shop --port=80 > /dev/null && kubectl get endpoints shop --no-headers | awk '{print "endpoints:", $2}'
kubectl run client --image=busybox:1.36 -- sleep 3600 > /dev/null && kubectl wait pod/client --for=condition=Ready --timeout=90s > /dev/null
for i in 1 2 3 4 5 6; do kubectl exec client -- wget -qO- -T 3 http://shop 2>/dev/null | grep -o "<title>.*</title>" && break; sleep 5; doneWaiting for deployment "shop" rollout to finish: 0 out of 3 new replicas have been updated...
Waiting for deployment "shop" rollout to finish: 0 of 3 updated replicas are available...
Waiting for deployment "shop" rollout to finish: 1 of 3 updated replicas are available...
Waiting for deployment "shop" rollout to finish: 2 of 3 updated replicas are available...
deployment "shop" successfully rolled out
1 <none>
2 <none>
nginx:1.26
Warning: v1 Endpoints is deprecated in v1.33+; use discovery.k8s.io/v1 EndpointSlice
endpoints: 10.0.0.89:80,10.0.1.118:80,10.0.1.119:80
<title>Welcome to nginx!</title>
rollout history shows two revisions; rollout undo brought back nginx:1.26. kubectl expose created a Service with three endpoints (one per pod), and a small busybox client pod (kept running for the later tasks) reached it by name with kubectl exec client -- wget. A brand-new Service can refuse connections for a few seconds while it is being wired up, so the check retries; in the exam, just run it again.
Tasks 5 and 6: a ConfigMap as environment variables, a Secret as a file
# Task 5: a ConfigMap as environment variables. Task 6: a Secret mounted as a file
kubectl create configmap app-config --from-literal=MODE=production --from-literal=LOG_LEVEL=info > /dev/null
kubectl create secret generic db-cred --from-literal=password=lab-only-pass > /dev/null
cat <<YAML | kubectl apply -f - > /dev/null
apiVersion: v1
kind: Pod
metadata: {name: config-demo}
spec:
restartPolicy: Never
containers:
- name: app
image: busybox:1.36
command: ["sh", "-c", "echo MODE=\$MODE LOG_LEVEL=\$LOG_LEVEL; echo secret file: \$(ls /etc/db); echo length: \$(wc -c < /etc/db/password)"]
envFrom: [{configMapRef: {name: app-config}}]
volumeMounts: [{name: db, mountPath: /etc/db, readOnly: true}]
volumes: [{name: db, secret: {secretName: db-cred}}]
YAML
kubectl wait pod/config-demo --for=jsonpath='{.status.phase}'=Succeeded --timeout=90s > /dev/null; kubectl logs config-demoMODE=production LOG_LEVEL=info
secret file: password
length: 13envFrom turned every ConfigMap key into an environment variable; the Secret appeared as a read-only file whose content the pod could use without printing it.
Tasks 7 and 8: requests, limits, and readiness and liveness probes
# Task 7: requests and limits. Task 8: a readiness and a liveness probe
kubectl create deployment probed --image=nginx:1.27 --dry-run=client -o yaml > probed.yaml
python3 - <<'PY'
import yaml
d = yaml.safe_load(open("probed.yaml")); c = d["spec"]["template"]["spec"]["containers"][0]
c["resources"] = {"requests": {"cpu": "50m", "memory": "64Mi"}, "limits": {"memory": "128Mi"}}
c["readinessProbe"] = {"httpGet": {"path": "/", "port": 80}, "periodSeconds": 5}
c["livenessProbe"] = {"httpGet": {"path": "/", "port": 80}, "initialDelaySeconds": 5, "periodSeconds": 10}
yaml.safe_dump(d, open("probed.yaml", "w"))
PY
kubectl apply -f probed.yaml > /dev/null && kubectl rollout status deploy/probed --timeout=120s
kubectl get pod -l app=probed -o jsonpath='{.items[0].spec.containers[0].resources}{"\n"}{.items[0].spec.containers[0].readinessProbe.httpGet}{"\n"}'Waiting for deployment "probed" rollout to finish: 0 out of 1 new replicas have been updated...
Waiting for deployment "probed" rollout to finish: 0 of 1 updated replicas are available...
deployment "probed" successfully rolled out
{"limits":{"memory":"128Mi"},"requests":{"cpu":"50m","memory":"64Mi"}}
{"path":"/","port":80,"scheme":"HTTP"}Generate with --dry-run, edit the YAML (here with a small Python helper; in the exam, with vim), apply. The output confirms the requests, the memory limit and the readiness probe on / port 80.
Tasks 9 and 10: a sidecar and an init container
# Task 9: a sidecar container that reads the main container's log file (shared emptyDir). Task 10: an init container
cat <<YAML | kubectl apply -f - > /dev/null
apiVersion: v1
kind: Pod
metadata: {name: sidecar-demo}
spec:
initContainers:
- {name: init, image: busybox:1.36, command: ["sh", "-c", "echo init done at \$(date +%T) > /work/ready"], volumeMounts: [{name: work, mountPath: /work}]}
containers:
- {name: app, image: busybox:1.36, command: ["sh", "-c", "cat /work/ready > /work/app.log; i=0; while true; do i=\$((i+1)); echo request \$i >> /work/app.log; sleep 2; done"], volumeMounts: [{name: work, mountPath: /work}]}
- {name: shipper, image: busybox:1.36, command: ["sh", "-c", "tail -f /work/app.log"], volumeMounts: [{name: work, mountPath: /work}]}
volumes: [{name: work, emptyDir: {}}]
YAML
kubectl wait pod/sidecar-demo --for=condition=Ready --timeout=90s > /dev/null; sleep 6
kubectl get pod sidecar-demo --no-headers | awk '{print $1, "READY", $2, $3}'
kubectl logs sidecar-demo -c shipper | head -3sidecar-demo READY 2/2 Running
init done at 01:10:46
request 1
request 2
The init container wrote a file and finished first; then both containers started (READY 2/2). The shipper sidecar reads the app's log through a shared emptyDir volume, the classic logging-sidecar pattern.
Tasks 11 and 12: a Job with 3 completions, and a CronJob
# Task 11: a Job that must succeed 3 times. Task 12: a CronJob every minute
kubectl create job count --image=busybox:1.36 --dry-run=client -o yaml -- sh -c 'echo job ran on $(hostname)' | sed 's/^spec:/spec:\n completions: 3\n parallelism: 1/' | kubectl apply -f - > /dev/null
kubectl wait job/count --for=condition=complete --timeout=120s && kubectl get job count --no-headers | awk '{print $1, "completions", $2}'
kubectl create cronjob tick --image=busybox:1.36 --schedule="*/1 * * * *" -- sh -c 'date +%T' > /dev/null && kubectl get cronjob tick --no-headers | awk '{print $1, $2, $3, $4, $5, $6}'job.batch/count condition met
count completions Complete
tick */1 * * * *Tasks 13 and 14: a ResourceQuota, and a ServiceAccount
# Task 13: a ResourceQuota (max 4 pods). Task 14: a ServiceAccount used by a pod
kubectl create namespace limited > /dev/null && kubectl create quota pods-max --hard=pods=4 -n limited > /dev/null
kubectl create deployment many --image=nginx:1.27 --replicas=6 -n limited > /dev/null; sleep 15
kubectl get deploy many -n limited --no-headers | awk '{print "many: ready", $2}'; kubectl get quota pods-max -n limited --no-headers | awk '{print "quota:", $2, $3}'
kubectl get events -n limited --field-selector reason=FailedCreate -o jsonpath='{.items[0].message}' | cut -c1-150; echo
kubectl create serviceaccount reporter > /dev/null && kubectl run sa-demo --image=busybox:1.36 --restart=Never --overrides='{"spec":{"serviceAccountName":"reporter"}}' -- sleep 3600 > /dev/null && kubectl wait pod/sa-demo --for=condition=Ready --timeout=90s > /dev/null
kubectl get pod sa-demo -o jsonpath='{.spec.serviceAccountName}'; echo " is the pod's service account"many: ready 4/6
quota: pods: 4/4
Error creating: pods "many-68955c4d55-9bqf4" is forbidden: exceeded quota: pods-max, requested: pods=1, used: pods=4, limited: pods=4
reporter is the pod's service accountOnly 4 of 6 replicas run: the quota allows 4 pods, and the event says exactly why the 5th was refused (exceeded quota: pods-max). The second pod runs as the reporter service account.
Tasks 15 and 16: run as non-root, and keep data in a PersistentVolumeClaim
# Task 15: run as a non-root user (securityContext). Task 16: a PersistentVolumeClaim that keeps data across pod restarts
cat <<YAML | kubectl apply -f - > /dev/null
apiVersion: v1
kind: Pod
metadata: {name: nonroot}
spec:
securityContext: {runAsUser: 1000, runAsGroup: 3000}
containers:
- {name: app, image: busybox:1.36, command: ["sh", "-c", "id; touch /root/x 2>&1 | head -1; sleep 3600"], securityContext: {allowPrivilegeEscalation: false}}
YAML
kubectl wait pod/nonroot --for=condition=Ready --timeout=90s > /dev/null; sleep 2; kubectl logs nonroot
kubectl apply -f - > /dev/null <<YAML
apiVersion: v1
kind: PersistentVolumeClaim
metadata: {name: data}
spec: {accessModes: [ReadWriteOnce], resources: {requests: {storage: 1Gi}}}
YAML
for n in 1 2; do kubectl run writer$n --image=busybox:1.36 --restart=Never --overrides='{"spec":{"volumes":[{"name":"d","persistentVolumeClaim":{"claimName":"data"}}],"containers":[{"name":"w","image":"busybox:1.36","command":["sh","-c","echo pod '$n' was here >> /data/visits; cat /data/visits"],"volumeMounts":[{"name":"d","mountPath":"/data"}]}]}}' > /dev/null; kubectl wait pod/writer$n --for=jsonpath='{.status.phase}'=Succeeded --timeout=180s > /dev/null; done
kubectl logs writer2; kubectl get pvc data --no-headers | awk '{print "pvc", $1, $2, $4, $6}'uid=1000 gid=3000 groups=3000
touch: /root/x: Permission denied
pod 1 was here
pod 2 was here
pvc data Bound 1Gi standard-rwo
The pod runs as uid=1000 and cannot write to /root. Two different pods wrote to the same data claim, and the second one sees the first one's line: the data lives in the volume, not the pod.
Task 17 (break it): a pod in CrashLoopBackOff
Why: the most common debugging task. Find the reason fast: status, logs, and the last state.
🎓⭐ Recommended by CareerByteCode · Live trainingAzure Cloud Architecture and AIOps Bootcampโน10,620See the training →# Task 17 (break it): a pod in CrashLoopBackOff. Find the reason as fast as possible
kubectl run crashy --image=busybox:1.36 --restart=Always -- sh -c 'echo "config file /etc/app.conf not found"; exit 1' > /dev/null; sleep 40
kubectl get pod crashy --no-headers | awk '{print $1, $3, "restarts:", $4}'
echo "logs: $(kubectl logs crashy 2>/dev/null | tail -1)"
kubectl describe pod crashy | grep -A3 "Last State" | sed 's/^ *//' | head -3crashy Error restarts: 2
logs: config file /etc/app.conf not found
Last State: Terminated
Reason: Error
Exit Code: 1The pod restarts again and again. Its log says the reason (config file /etc/app.conf not found), and describe shows the last state Terminated with Exit Code: 1. Rule: logs first (add --previous for the crashed attempt), then describe.
Task 18 (fix it): give the pod the file it needs
# Task 18 (fix it): give the pod the file it needs from a ConfigMap, and it runs
kubectl delete pod crashy --wait=true > /dev/null; kubectl create configmap app-conf --from-literal=app.conf="port=8080" > /dev/null
kubectl run crashy --image=busybox:1.36 --restart=Always --overrides='{"spec":{"volumes":[{"name":"c","configMap":{"name":"app-conf"}}],"containers":[{"name":"crashy","image":"busybox:1.36","command":["sh","-c","echo loaded $(cat /etc/app/app.conf); sleep 3600"],"volumeMounts":[{"name":"c","mountPath":"/etc/app"}]}]}}' > /dev/null
sleep 20; kubectl get pod crashy --no-headers | awk '{print $1, $3, "restarts:", $4}'; kubectl logs crashycrashy Running restarts: 0
loaded port=8080Tasks 19 and 20: autoscaling, and blue/green by switching a Service selector
# Task 19: scale with an HPA (CPU 50 percent, 1 to 4 pods). Task 20: blue/green by switching a Service selector
kubectl autoscale deploy probed --cpu=50% --min=1 --max=4 > /dev/null && sleep 20 && kubectl get hpa probed -o custom-columns=NAME:.metadata.name,MIN:.spec.minReplicas,MAX:.spec.maxReplicas,TARGET_CPU:.spec.metrics[0].resource.target.averageUtilization
kubectl create deployment blue --image=hashicorp/http-echo:1.0 -- /http-echo -text=blue > /dev/null; kubectl create deployment green --image=hashicorp/http-echo:1.0 -- /http-echo -text=green > /dev/null
kubectl rollout status deploy/blue --timeout=120s > /dev/null; kubectl rollout status deploy/green --timeout=120s > /dev/null
kubectl create service clusterip live --tcp=80:5678 > /dev/null && kubectl patch service live -p '{"spec":{"selector":{"app":"blue"}}}' > /dev/null
for i in $(seq 1 12); do R=$(kubectl exec client -- wget -qO- -T 3 http://live 2>/dev/null); [ "$R" = blue ] && break; sleep 5; done; echo "live -> $R (after $i checks)"
kubectl patch service live -p '{"spec":{"selector":{"app":"green"}}}' > /dev/null
for i in $(seq 1 12); do R=$(kubectl exec client -- wget -qO- -T 3 http://live 2>/dev/null); [ "$R" = green ] && break; sleep 5; done; echo "live -> $R (after $i checks)"NAME MIN MAX TARGET_CPU
probed 1 4 50
live -> blue (after 3 checks)
live -> green (after 3 checks)
kubectl autoscale created the HPA. The live Service sent traffic to blue, then one kubectl patch of its selector switched everyone to green: blue/green with only Kubernetes basics. The switch is not instant: the check repeats until the answer changes (the output shows after how many checks).
POC: prove it works
- 20 tasks done and verified on a real cluster, each with real output.
- A rollback, a quota refusal, a non-root refusal and a CrashLoopBackOff, all diagnosed from Kubernetes' own messages.
- Data kept across pods in a PVC; a blue/green switch done with one selector patch.
Quiz task: timed drills
Do these against a clock (target in brackets):
- Create deployment
apiwith imagenginx:1.27and 2 replicas, expose it on port 80, prove it answers. (3 minutes) - Add a readiness probe on
/port 80 toapi. (3 minutes) - Create a CronJob that prints the date every 5 minutes. (2 minutes)
- A pod is
CrashLoopBackOff: find the reason. *(1 minute:kubectl logs <pod> --previous,kubectl describe pod <pod>.)* - Limit namespace
teamto 10 pods. *(1 minute:kubectl create quota q --hard=pods=10 -n team.)*
Clean up (delete everything)
# Clean up: delete the practice namespaces (everything inside goes with them)
kubectl config set-context --current --namespace=default > /dev/null
kubectl delete namespace ckad limited --wait=true 2>&1 | tail -2
echo "namespaces left: $(kubectl get ns --no-headers | grep -cE '^(ckad|limited) ')"namespace "ckad" deleted
namespace "limited" deleted
namespaces left: 0
Then delete the cluster:
gcloud container clusters delete lab-cluster --zone=us-east1-b --quietFAQ
Is GKE like the exam cluster? The exam uses plain Kubernetes clusters; everything in this lab is standard Kubernetes and works the same. GKE only adds a few labels and a default storage class (standard-rwo).
How fast should I be? About 6 to 8 minutes per task on average in the exam. If a task takes over 10 minutes, flag it and move on.
Should I memorise YAML? No. Memorise the imperative commands and --dry-run=client -o yaml, and know where fields go (kubectl explain pod.spec.containers.readinessProbe).
Can I use the docs in the exam? Yes, kubernetes.io is allowed. Practise finding things there quickly (for example "PersistentVolumeClaim" or "liveness probe" examples).
What about network policies? They are on the exam. Note that a cluster needs network policy enforcement turned on (on GKE: Dataplane V2 or network policy enforcement) for them to work; practise them on such a cluster.
How many times should I repeat these tasks? Until you can do all 20 in under 60 minutes without looking. Three or four runs is typical.
Troubleshooting
| You see | Why | Fix |
|---|---|---|
wget: can't connect ... Connection refused right after expose | The Service is still being wired up | Wait a few seconds and retry; check kubectl get endpoints |
pods "x" already exists | A pod with that name is still terminating | kubectl delete pod x --wait=true, then create again |
exceeded quota events | The namespace quota is full | Raise the quota or lower replicas |
Pod Pending with a PVC | The volume is still being created | Wait; check kubectl get pvc and events |
unable to retrieve container logs | The container just restarted | Use kubectl logs <pod> --previous |
What next
- See the whole learning path: our Kubernetes roadmap, from pods to platform engineering.
- Deploy the GitOps way: Argo CD on Kubernetes: GitOps from Zero.
- Observe your apps: Prometheus and Grafana on Kubernetes from Scratch.
- More hands-on posts: ByteBlog. Practice in ByteLabs and see the courses.
Prepared by the CareerByteCode Team from our tested lab, with AI help for the write-up.
⭐ Keep learning with CareerByteCode
Hand-picked to go deeper on this topicGet CareerByteCode Team's next blog by email
One email a week when they publish. Add the weekly Best of ByteBlog too. No spam, unsubscribe with one click.
We email you once to confirm. By subscribing you agree to the privacy policy.
Related blogs
CareerByteCode TeamKubernetes Roadmap: From Pods to Platform Engineering
What you build: an 8-level Kubernetes roadmap from pods to platform engineering, with a real script that checks every level on GKE (pod, service, config, probes, HPA, RBAC, Helm, as code).
#beginners
CareerByteCode TeamDevOps Engineer Roadmap 2027 with Hands-On Labs
What you build: a 2027 DevOps roadmap in 7 stages where every stage links to a tested lab, plus a real 15-minute lab that runs the whole loop: code, build, deploy, observe and roll back.
#beginners
CareerByteCode TeamHow to Talk About Your Cloud Projects in Interviews
What you build: a STAR answer for cloud interviews from a real lab: a Cloud Run load test (0 failed, p95 64 ms), a broken release caught on its tag URL, and a script that uses only measured numbers.
#ai
CareerByteCode TeamAI Engineer Roadmap: From Python to Production LLM Apps
What you build: a 7-stage AI engineer roadmap from Python to production LLM apps, with a real lab: a Gemini call, schema-checked JSON, a golden-set evaluation (6/6) and a temperature test.
💬 Comments (0)
Top · NewestSign in to comment