The CKA exam has no multiple choice. Every question is a task you complete in a terminal on a live cluster, and an automatic grader checks the result. So the best way to use these questions is to do them, not just read them.
Run them on a real cluster, free. The free CKPrep runner sets these 8 tasks up on a local kind cluster, times you and grades every check. Then ./ckprep solution 1 shows the same solutions as below.
./ckprep doctor
./ckprep start drill-5-storage
./ckprep q 1
./ckprep grade
Try each one before you open the solution. On exam day you'd have roughly 6 to 8 minutes per task.
Question 1 · Storage 10% Create a new default StorageClass
- Create a StorageClass named
local-fastwith:- provisioner
rancher.io/local-path - reclaim policy
Retain - volume binding mode
WaitForFirstConsumer - volume expansion allowed
- provisioner
- Make
local-fastthe cluster's default StorageClass.standardmust no longer be a default. - In namespace
sc-default, create a PVC namedscratchrequesting100Mi, access modeReadWriteOnce, without setting a storage class in it. It should end up usinglocal-fast. (It may stay Pending — no pod uses it yet.)
Show the solution
There's no kubectl create storageclass; copy the YAML from the docs (search "Storage Classes"):
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: local-fast
annotations:
storageclass.kubernetes.io/is-default-class: "true"
provisioner: rancher.io/local-path
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
kubectl apply -f sc.yaml
kubectl annotate sc standard storageclass.kubernetes.io/is-default-class=false --overwrite
kubectl get sc # exactly one "(default)"
# PVC: no storageClassName line at all → the default class is filled in at creation time
kubectl -n sc-default get pvc scratch -o jsonpath='{.spec.storageClassName}' # local-fast
Pitfalls: order matters — a PVC created before you switch the default gets standard and storageClassName can't be changed afterwards (delete and recreate it). storageClassName: "" is not the same as leaving it out: "" means "no class, bind only to a PV without class". provisioner, parameters, reclaimPolicy and volumeBindingMode are immutable — to change them, delete and recreate the class.
Question 2 · Storage 10% Expand a PersistentVolumeClaim in place
In namespace reports, PVC report-data (1Gi) is used by pod report-writer and is running out of space.
Increase the PVC's requested size to 2Gi. Change whatever is needed on the storage side to allow it, but don't delete or recreate the PVC or the pod.
(The local-path provisioner in this practice cluster can't actually grow volumes, so the PVC's status capacity will stay at 1Gi. Graded is the request.)
Show the solution
kubectl -n reports patch pvc report-data -p '{"spec":{"resources":{"requests":{"storage":"2Gi"}}}}'
# error: … only dynamically provisioned pvc can be resized and the storageclass that provisions the pvc must support resize
kubectl get pvc -n reports report-data -o jsonpath='{.spec.storageClassName}' # resizable
kubectl patch sc resizable -p '{"allowVolumeExpansion": true}' # this field IS mutable
kubectl -n reports patch pvc report-data -p '{"spec":{"resources":{"requests":{"storage":"2Gi"}}}}' # or: kubectl edit pvc
kubectl -n reports get pvc report-data
With a real CSI driver the PVC shows a Resizing / FileSystemResizePending condition and then CAPACITY 2Gi; most drivers grow the filesystem online. Pitfalls: PVCs can only grow, never shrink; only bound PVCs can be resized; the PVC's own capacity in kubectl get pvc updates only after the resize finished.
Question 3 · Storage 10% Share a memory-backed emptyDir volume
In namespace scratch, create a Pod named ram-share with:
- a volume named
cache: anemptyDirbacked by memory (tmpfs), limited to 64Mi - container
writer, imagebusybox:1.37, commandsh -c 'echo ready > /cache/status; sleep 3600', mountingcacheat/cache - container
reader, imagebusybox:1.37, commandsleep 3600, mountingcacheread-only at/data
Show the solution
kubectl -n scratch run ram-share --image=busybox:1.37 --dry-run=client -o yaml --command -- sh -c 'echo ready > /cache/status; sleep 3600' > p.yaml
# edit: name the container writer, add the reader container and the volume (docs: search "emptyDir")
spec:
volumes:
- name: cache
emptyDir:
medium: Memory
sizeLimit: 64Mi
containers:
- name: writer
image: busybox:1.37
command: ["sh", "-c", "echo ready > /cache/status; sleep 3600"]
volumeMounts: [{name: cache, mountPath: /cache}]
- name: reader
image: busybox:1.37
command: ["sleep", "3600"]
volumeMounts: [{name: cache, mountPath: /data, readOnly: true}]
kubectl -n scratch exec ram-share -c reader -- cat /data/status
kubectl -n scratch exec ram-share -c reader -- grep /data /proc/mounts # tmpfs … ro
Notes: medium: Memory uses RAM and the data counts against the containers' memory limit. Without sizeLimit a tmpfs emptyDir can grow up to the pod's memory limit (or node RAM). Going over sizeLimit gets the pod evicted. An emptyDir lives exactly as long as the pod — container restarts keep it, pod deletion wipes it.
Question 4 · Storage 10% Combine a ConfigMap and a Secret in one projected volume
In namespace webcfg, create a Pod named portal (image nginx:1.27-alpine) with one volume named bundle, mounted read-only at /etc/portal, that combines:
- key
site.confof ConfigMapsite-config→ file/etc/portal/site.conf - key
tokenof Secretapi-token→ file/etc/portal/auth/token
No other files from the ConfigMap should appear in /etc/portal.
Show the solution
kubectl -n webcfg run portal --image=nginx:1.27-alpine --dry-run=client -o yaml > portal.yaml
# add the volume (docs: search "Projected Volumes")
spec:
containers:
- name: portal
image: nginx:1.27-alpine
volumeMounts:
- {name: bundle, mountPath: /etc/portal, readOnly: true}
volumes:
- name: bundle
projected:
sources:
- configMap:
name: site-config
items: [{key: site.conf, path: site.conf}]
- secret:
name: api-token
items: [{key: token, path: auth/token}]
kubectl -n webcfg exec portal -- ls -R /etc/portal
Notes: items both selects keys (others are left out) and sets the file path, which may include sub-directories. Without items every key becomes a file. Two separate volumes can't be mounted on the same path — that's what projected is for (it can also add downwardAPI and serviceAccountToken sources).
Question 5 · Storage 10% Reuse a Released PersistentVolume without losing data
PersistentVolume archive-pv still holds important data (report.txt), but its old claim was deleted and the PV is now Released.
- Make the PV usable again without deleting it and without losing the data. Its reclaim policy must stay
Retain. - In namespace
archive, create a PVC namedarchive-claim(1Gi,ReadWriteOnce) that binds toarchive-pv. - Create a Pod
archive-readerin namespacearchive(imagebusybox:1.37, commandsleep 3600) that mounts the claim at/archive.
Show the solution
A Released PV still has a claimRef pointing at the deleted claim (by UID), so no new claim can bind to it. Removing the claimRef makes it Available again; the data on disk is untouched (that's what Retain is for).
kubectl get pv archive-pv # STATUS Released, CLAIM archive/old-claim
kubectl patch pv archive-pv --type=json -p='[{"op":"remove","path":"/spec/claimRef"}]'
# (or: kubectl edit pv archive-pv → delete the claimRef block)
kubectl get pv archive-pv # Available
apiVersion: v1
kind: PersistentVolumeClaim
metadata: {name: archive-claim, namespace: archive}
spec:
storageClassName: "" # the PV has no class; leaving this out would assign the default class → no match
volumeName: archive-pv # optional here, but pins it to this PV
accessModes: [ReadWriteOnce]
resources: {requests: {storage: 1Gi}}
Then kubectl -n archive run archive-reader --image=busybox:1.37 --dry-run=client -o yaml --command -- sleep 3600, add the persistentVolumeClaim volume and mount, apply, and kubectl exec … -- cat /archive/report.txt.
Reclaim policies: Delete removes the PV and the backing storage when the claim goes; Retain keeps both and leaves the PV Released for an admin to clean up or reuse. Change it on a live PV with kubectl patch pv <pv> -p '{"spec":{"persistentVolumeReclaimPolicy":"Retain"}}'.
Question 6 · Storage 10% Bind a PVC to a PersistentVolume with a label selector
Three PersistentVolumes pv-red, pv-blue and pv-green (StorageClass manual, 1Gi, ReadWriteOnce) only differ by their team label.
- In namespace
teams, create a PVC namedblue-claim(classmanual, 1Gi,ReadWriteOnce) that binds to the PV labelledteam=blue. Use a label selector — don't name the PV in the claim. - Create a Pod
blue-appin namespaceteams(imagebusybox:1.37, commandsh -c 'echo hello > /work/hello.txt; sleep 3600') that mountsblue-claimat/workwith subPathblue-app, so its files land in ablue-appsub-directory of the volume.
Show the solution
apiVersion: v1
kind: PersistentVolumeClaim
metadata: {name: blue-claim, namespace: teams}
spec:
storageClassName: manual
selector:
matchLabels: {team: blue}
accessModes: [ReadWriteOnce]
resources: {requests: {storage: 1Gi}}
---
apiVersion: v1
kind: Pod
metadata: {name: blue-app, namespace: teams}
spec:
containers:
- name: app
image: busybox:1.37
command: ["sh", "-c", "echo hello > /work/hello.txt; sleep 3600"]
volumeMounts:
- {name: data, mountPath: /work, subPath: blue-app}
volumes:
- name: data
persistentVolumeClaim: {claimName: blue-claim}
kubectl get pv -L team # pv-blue → Bound teams/blue-claim
ssh cka-main-worker ls -R /srv/teams/blue # blue-app/hello.txt
Binding rules: a claim binds to a PV only if class, access modes and size (PV ≥ request) match, plus the selector if one is given. Pinning with spec.volumeName is the other way. subPath mounts a sub-directory of the volume (kubelet creates it); handy to share one volume between apps — but subPath mounts don't receive ConfigMap/Secret updates.
Question 7 · Storage 10% Fix a Pod stuck in Pending because of its PVC
In namespace shop-db, the pod of Deployment db is stuck in Pending.
Find out why and fix it so the pod runs with its data on a PVC named db-data (500Mi, StorageClass standard). Don't change the Deployment's pod template.
Show the solution
kubectl -n shop-db describe pod -l app=db # … unbound immediate PersistentVolumeClaims / waiting for volume
kubectl -n shop-db describe pvc db-data # Events: ProvisioningFailed … the access mode ReadWriteMany is not supported (local-path is node-local)
kubectl -n shop-db get pvc db-data -o yaml > pvc.yaml # edit: accessModes [ReadWriteOnce]; strip status/uid/annotations
kubectl -n shop-db scale deploy db --replicas=0 # the pod holds the claim (pvc-protection finalizer)
kubectl -n shop-db delete pvc db-data
kubectl apply -f pvc.yaml
kubectl -n shop-db scale deploy db --replicas=1
Diagnosis path: pod Pending → describe pod points at the PVC → describe pvc shows the provisioner's event. A PVC's spec (except the requested size) is immutable, so a wrong access mode or class means delete and recreate. Access modes: RWO (one node), ROX (many nodes read-only), RWX (many nodes read-write — needs NFS/CephFS-like storage), RWOP (exactly one pod). Node-local storage such as local-path or hostPath can't do RWX.
Question 8 · Storage 10% Give a StatefulSet per-pod storage
In namespace kvstore:
- Create a headless Service named
kvfor pods labelledapp=kv, port6379. - Create a StatefulSet named
kvusing that Service, with 2 replicas, pod labelapp=kv, imageredis:7-alpine. Each replica must get its own PersistentVolumeClaim from a claim template nameddata: 256Mi,ReadWriteOnce, StorageClassstandard, mounted at/data.
Show the solution
kubectl -n kvstore create service clusterip kv --clusterip=None --tcp=6379:6379 --dry-run=client -o yaml > svc.yaml
# then set the selector to app: kv (create service sets app: kv already — check it)
StatefulSet YAML from the docs (search "StatefulSets", the web example), adapted:
apiVersion: apps/v1
kind: StatefulSet
metadata: {name: kv, namespace: kvstore}
spec:
serviceName: kv
replicas: 2
selector: {matchLabels: {app: kv}}
template:
metadata: {labels: {app: kv}}
spec:
containers:
- name: redis
image: redis:7-alpine
volumeMounts: [{name: data, mountPath: /data}]
volumeClaimTemplates:
- metadata: {name: data}
spec:
storageClassName: standard
accessModes: [ReadWriteOnce]
resources: {requests: {storage: 256Mi}}
kubectl -n kvstore get pvc # data-kv-0, data-kv-1 → <template>-<sts>-<ordinal>
Notes: the claims outlive the StatefulSet — deleting or scaling it down keeps them (unless persistentVolumeClaimRetentionPolicy says otherwise), and kv-0 always gets data-kv-0 back. Pods start one after the other (OrderedReady), so a stuck kv-0 blocks kv-1.
Want the full exam?
Storage is only 10% of the CKA. Troubleshooting is 30%, and that's where most people lose points. The CKA pack has 157 tasks like these across every domain, including 6 full two-hour mock exams scored against the real 66% pass mark, and kubeadm labs on real VMs.
New to the exam? Read the CKA exam guide first: format, domains, allowed docs and a study plan.