The CKAD exam has no multiple choice. You get 2 hours, a terminal and 15 to 20 tasks to complete on live clusters, and an automatic grader checks the result. Speed matters as much as knowledge, so try each task on a cluster before you open the solution.
These come from the CKPrep CKAD pack's topic drills. In the pack, each one is set up on a real local cluster, timed and graded check by check. You can also try them on any practice cluster, such as kind or minikube, by first creating the objects each task starts from.
On exam day you'd have roughly 6 to 8 minutes per task.
Question 1 · Application Design and Build 20% Create a CronJob with concurrency, history and time limits
In namespace reports, create a CronJob named ledger-rollup:
- image
busybox:1.37, commandsh -c 'echo rollup done' - runs every day at 02:30
- a new run must not start while the previous one is still running
- keeps 3 successful and 1 failed Job in its history
- each Job is terminated if it runs longer than 40 seconds
Then, without waiting for the schedule, start a Job named ledger-rollup-now from this CronJob and let it complete.
Show the solution
kubectl config use-context main
kubectl -n reports create cronjob ledger-rollup --image=busybox:1.37 --schedule='30 2 * * *' \
--dry-run=client -o yaml -- sh -c 'echo rollup done' > cj.yaml
Add to cj.yaml:
spec:
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 1
jobTemplate:
spec:
activeDeadlineSeconds: 40 # Job spec, not CronJob spec
kubectl apply -f cj.yaml
kubectl -n reports create job ledger-rollup-now --from=cronjob/ledger-rollup
kubectl -n reports wait job/ledger-rollup-now --for=condition=Complete
Pitfall: activeDeadlineSeconds belongs to the Job template. startingDeadlineSeconds on the CronJob is a different setting: how late a missed run may still start.
Question 2 · Application Deployment 20% Cut a Service over from blue to green
In namespace atlas-prod, Service atlas sends traffic to Deployment atlas-blue (Pod labels app=atlas,version=blue).
Perform a blue/green release:
- Create Deployment
atlas-greenwith 2 replicas, Pod labelsapp=atlas,version=green, and the same container spec as blue, but mounting ConfigMapatlas-green-page. - When all green Pods are Ready, switch Service
atlasto the green Pods only. - Keep
atlas-bluerunning with 2 replicas so the release can be reverted instantly.
Show the solution
kubectl config use-context main
kubectl -n atlas-prod get deploy atlas-blue -o yaml > green.yaml
# rename to atlas-green, set version: green in selector and template, use configMap atlas-green-page
kubectl apply -f green.yaml
kubectl -n atlas-prod rollout status deploy/atlas-green
kubectl -n atlas-prod patch svc atlas -p '{"spec":{"selector":{"app":"atlas","version":"green"}}}'
To revert, patch the selector back to version: blue. Nothing has to restart, which is the whole point of blue/green.
Question 3 · Application Deployment 20% Find a broken rollout and roll it back
The latest rollout of Deployment notes-api in namespace notes never became healthy.
- Find the revision number of the broken rollout and write it to
~/ckprep-answers/notes-bad-revision.txt. - Return the Deployment to the most recent healthy revision. All 3 replicas must be Ready.
Show the solution
kubectl config use-context main
kubectl -n notes rollout status deploy/notes-api --timeout=10s # stuck
kubectl -n notes rollout history deploy/notes-api # revision 3: "add readiness check"
kubectl -n notes describe pod -l app=notes-api | grep -A3 Readiness
echo 3 > ~/ckprep-answers/notes-bad-revision.txt
kubectl -n notes rollout undo deploy/notes-api # back to revision 2's template
kubectl -n notes rollout status deploy/notes-api
The probe checks port 8081, where nothing listens. Because the rolling update stops at the first unready Pod, the old Pods kept serving.
After the undo, the template of revision 2 becomes revision 4.
Question 4 · Application Observability and Maintenance 15% Add probes to a slow-starting app
Deployment slowboot in namespace orders takes about 20 seconds to start listening on port 8080, and its current liveness probe keeps killing it before it's up.
Replace its health checks with:
- a startup probe: HTTP GET
/healthzon port 8080, allowing the app at least 60 seconds to start - a liveness probe: HTTP GET
/healthzon port 8080, every 10 seconds - a readiness probe: HTTP GET
/healthzon port 8080, every 5 seconds
Both replicas must become Ready and stop restarting.
Show the solution
kubectl config use-context main
kubectl -n orders edit deploy slowboot
startupProbe:
httpGet: {path: /healthz, port: 8080}
periodSeconds: 5
failureThreshold: 12 # 12 x 5s = 60s to start
livenessProbe:
httpGet: {path: /healthz, port: 8080}
periodSeconds: 10
readinessProbe:
httpGet: {path: /healthz, port: 8080}
periodSeconds: 5
- Liveness and readiness don't run until the startup probe has succeeded once. That protects a slow starter without weakening the liveness check.
- A failing liveness probe restarts the container. A failing readiness probe only removes the Pod from Service endpoints.
Question 5 · Application Environment, Configuration and Security 25% Give a ServiceAccount least-privilege RBAC
In namespace ci-tools:
- Create a ServiceAccount
build-bot. - Using a Role and a RoleBinding, allow it to
get,listandwatchPods, read Pod logs, andcreateJobs, in this namespace only. Grant nothing else. - Make the existing Deployment
builderrun with this ServiceAccount.
Show the solution
kubectl config use-context main
kubectl -n ci-tools create sa build-bot
kubectl -n ci-tools create role build-bot --verb=get,list,watch --resource=pods,pods/log
kubectl -n ci-tools patch role build-bot --type=json \
-p='[{"op":"add","path":"/rules/-","value":{"apiGroups":["batch"],"resources":["jobs"],"verbs":["create"]}}]'
kubectl -n ci-tools create rolebinding build-bot --role=build-bot --serviceaccount=ci-tools:build-bot
kubectl -n ci-tools set serviceaccount deploy/builder build-bot
kubectl auth can-i create jobs -n ci-tools --as=system:serviceaccount:ci-tools:build-bot
- Logs are the subresource
pods/log. Access topodsdoesn't include it. - Jobs are in API group
batch, Pods in the core group"".
Question 6 · Application Environment, Configuration and Security 25% Lock down a Pod with a securityContext
In namespace hardening, create a Pod api-locked, image busybox:1.37, command sleep 86400, with an emptyDir volume mounted at /data, such that:
- all processes run as UID
1000and GID3000 - files created in
/databelong to group2000 - the container's root filesystem is read-only
- privilege escalation is disabled
- all Linux capabilities are dropped, and only
NET_BIND_SERVICEis added back
Show the solution
apiVersion: v1
kind: Pod
metadata: {name: api-locked, namespace: hardening}
spec:
securityContext: # Pod level
runAsUser: 1000
runAsGroup: 3000
fsGroup: 2000
containers:
- name: api
image: busybox:1.37
command: ["sleep", "86400"]
securityContext: # container level only
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities:
drop: [ALL]
add: [NET_BIND_SERVICE]
volumeMounts: [{name: data, mountPath: /data}]
volumes:
- name: data
emptyDir: {}
Pitfall: capabilities, readOnlyRootFilesystem and allowPrivilegeEscalation don't exist in the Pod-level securityContext. fsGroup exists only there.
Question 7 · Services and Networking 20% Write NetworkPolicies for a three-tier app
Namespace bank runs two Deployments, each with a Service on port 80: api (Pods labelled tier=api) and ledger-db (Pods labelled tier=db).
Using NetworkPolicies in bank:
- Create
default-denythat blocks all incoming traffic to every Pod in the namespace. - Allow Pods labelled
tier=frontendto reach theapiPods on TCP 80. - Allow Pods labelled
tier=apito reach theledger-dbPods on TCP 80.
No other incoming traffic may be allowed. Don't change any existing object.
Show the solution
Docs: search "Network Policies" and copy the example.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: {name: default-deny, namespace: bank}
spec:
podSelector: {}
policyTypes: [Ingress]
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: {name: frontend-to-api, namespace: bank}
spec:
podSelector: {matchLabels: {tier: api}}
policyTypes: [Ingress]
ingress:
- from:
- podSelector: {matchLabels: {tier: frontend}}
ports:
- {protocol: TCP, port: 80}
The third policy has the same shape, with tier: db as the target and tier: api as the source.
Policies are additive: the allow rules punch holes in the default deny, regardless of order.
Question 8 · Services and Networking 20% Fix a Service with no endpoints
Clients in namespace bookings get errors from http://bookings-api:8000. Deployment bookings-api (2 replicas) is healthy.
Fix Service bookings-api so that requests to port 8000 reach the application. Don't change the Deployment, and keep the Service port at 8000.
Show the solution
kubectl config use-context main
kubectl -n bookings get svc bookings-api -o wide # selector app=booking-api
kubectl -n bookings get pods --show-labels # app=bookings-api
kubectl -n bookings get endpointslices -l kubernetes.io/service-name=bookings-api # no endpoints
kubectl -n bookings get deploy bookings-api -o jsonpath='{.spec.template.spec.containers[0].ports}' # 8080
kubectl -n bookings edit svc bookings-api # selector app: bookings-api, targetPort: 8080
There are two faults: a typo in the selector (no endpoints) and a wrong targetPort (endpoints, but connection refused). Fixing only the first still fails.
Want the full exam?
The CKAD pack has 60 tasks like these across every domain, including 2 full two-hour mock exams scored against the real 66% pass mark and 5 topic drills, all running on a real cluster on your own machine.
New to the exam? Read the CKAD exam guide first: format, domains, allowed docs and a study plan.