Containers

CKAD Practice Questions: Hands-On Tasks with Full Solutions

You can read every Kubernetes doc page and still run out of time on a CKAD task. The clock punishes hesitation more than gaps in knowledge. Good CKAD practice questions fix that by making you type the answer, watch it fail once, and check the result with kubectl before you move on. That is how this set works: ten tasks across the five curriculum domains, each with the exact manifest we applied and the output our cluster printed back.

Original content from computingforgeeks.com - post 186091

Every task here ran on a single node kubeadm cluster we built for the purpose, with Calico for NetworkPolicy and Helm 4 for the chart task. Where our first attempt broke, we kept the error and explain it, since those are the messages you will meet on your own cluster. Try each task yourself before you read our solution, and keep the kubectl cheat sheet in another tab. I ran through all ten tasks on Kubernetes 1.37 in November 2026, and every one of them works end to end.

What a CKAD task looks like

The Certified Kubernetes Application Developer (CKAD)® is a performance test, so there are no options to pick from. You get a set of task statements, a terminal with kubectl access to the task clusters, and a grader that inspects the objects you leave behind. A task usually names a namespace, a few object names and one or two behaviours, and you either produce that state or you do not. These are the facts that shape how you should practise:

  • Two hours for 15 to 20 hands-on tasks
  • A pass mark of 66 percent
  • Kubernetes documentation open in the browser during the test
  • Two killer.sh simulator sessions and one free retake included with the purchase

Open documentation changes the strategy more than anything else on that list. Memorising YAML field order is wasted effort when you can copy a working example from kubernetes.io in ten seconds. What you cannot copy is the judgement of which object a task is about, and the habit of verifying it before you leave. The domain weights in the CNCF curriculum repository put the heaviest single block, 25 percent, on environment, configuration and security, which is why three of our ten tasks sit there. ComputingForGeeks is not affiliated with The Linux Foundation or CNCF, and every task and question here is our own work. Still deciding whether the developer track is the right first credential? Our KCNA vs KCSA vs CKA comparison covers the other three Kubernetes certifications.

The practice cluster and two speed habits

We built the cluster on one Ubuntu 24.04 cloud VM with 4 vCPUs and 16 GB of RAM, which is far more than these tasks need. A single node is enough for application work, because every CKAD task lives inside a namespace and none of them asks you to touch the control plane. We removed the control plane taint so pods schedule on the only node, and chose Calico as the CNI because it enforces NetworkPolicy. The version check below is what the box reported before the first task.

kubectl version
helm version
kubectl get nodes -o wide

Client and server agree on the same patch release, Helm reports a 4.x build, and the node reports containerd as the runtime.

Client Version: v1.37.2
Kustomize Version: v5.8.1
Server Version: v1.37.2
version.BuildInfo{Version:"v4.3.1", GitCommit:"c0d08d0d6d9424d4a14febb5e8a3e51b0dd00dff", GitTreeState:"clean", GoVersion:"go1.27.2", KubeClientVersion:"v1.37"}
NAME       STATUS   ROLES           AGE   VERSION   INTERNAL-IP   EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION           CONTAINER-RUNTIME
ckad-lab   Ready    control-plane   72s   v1.37.2   10.132.0.10   <none>        Ubuntu 24.04.5 LTS   7.0.0-1017-gcp (amd64)   containerd://2.2.1

Any small cluster works for this set: kind, minikube, k3s or a kubeadm VM. The one thing to check is the CNI, since a plugin that ignores NetworkPolicy makes step 9 pass when it should not. Before the first task, set two habits that save minutes on every question. The first is a shell variable that turns any imperative command into a YAML generator.

export do="--dry-run=client -o yaml"
kubectl create deployment quick --image=nginx:1.29-alpine --replicas=2 $do

The unquoted $do relies on bash word splitting, so use it in bash, since zsh passes it as one argument. Nothing reaches the cluster. kubectl prints a complete Deployment that you redirect to a file and edit, which beats typing selectors and labels by hand.

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: quick
  name: quick
spec:
  replicas: 2
  selector:
    matchLabels:
      app: quick
  strategy: {}
  template:
    metadata:
      labels:
        app: quick
    spec:
      containers:
      - image: nginx:1.29-alpine
        name: nginx
        resources: {}
status: {}

Your second habit is kubectl explain, which answers field questions without a browser. Running kubectl explain pod.spec.containers.securityContext.capabilities printed the field type and its description on our cluster, and that is often faster than searching the docs for one field name. With both habits in place, the tasks start.

Step 1: Add a native sidecar that tails a log file

Task: in namespace ckad, create a pod named web-logger that runs nginx and writes its access log to a shared volume. Add a sidecar named log-tail that streams that file, and make it a native sidecar so it starts before nginx and stays up for the life of the pod. The word native is the key. A native sidecar container is declared under initContainers with restartPolicy: Always, and that one field turns an init container into a long running helper.

kubectl create namespace ckad
vim web-logger.yaml

Our manifest mounts the same emptyDir in both containers. Mounting it at /var/log/nginx also hides the symlinks the nginx image ships there, which normally send the access log to stdout, so nginx writes a real file that the sidecar can read.

apiVersion: v1
kind: Pod
metadata:
  name: web-logger
  namespace: ckad
spec:
  initContainers:
  - name: log-tail
    image: busybox:1.37
    restartPolicy: Always
    command: ["sh", "-c", "tail -F /var/log/nginx/access.log"]
    volumeMounts:
    - name: logs
      mountPath: /var/log/nginx
  containers:
  - name: nginx
    image: nginx:1.29-alpine
    ports:
    - containerPort: 80
    volumeMounts:
    - name: logs
      mountPath: /var/log/nginx
  volumes:
  - name: logs
    emptyDir: {}

Apply it, wait for the pod, then send a request through a throwaway busybox pod so there is something in the log. We ran the request twice, which is why our log shows two lines.

kubectl apply -f web-logger.yaml
kubectl wait --for=condition=Ready pod/web-logger -n ckad --timeout=120s
kubectl get pod -n ckad web-logger
kubectl run tmp -n ckad --rm -i --restart=Never --image=busybox:1.37 -- wget -qO- $(kubectl get pod -n ckad web-logger -o jsonpath='{.status.podIP}')
kubectl logs -n ckad web-logger -c log-tail --tail=3

Read the READY column first. A native sidecar counts toward it, so 2/2 means both containers are up, and the log lines prove the sidecar is reading the file rather than the pod’s stdout.

kubectl output showing the web-logger pod at 2/2 Ready and the native sidecar log-tail container printing nginx access log lines

Notice the first line of the sidecar log: it says the file “has appeared”, because tail -F started before nginx created it. That is the native sidecar ordering doing its job. With the old pattern, a second entry under containers, you get no start order at all, and Jobs never finish because the helper never exits. Our older guide on a logging sidecar container uses that classic layout, and it still works, but the native form is the one to reach for when a task says sidecar.

Step 2: Run an indexed Job and a CronJob

Task: create a Job named pi-batch that processes four work items, two at a time, gives each pod its item number, and gives up after two retries. Then create a CronJob named cleanup that runs every minute, never overlaps itself, and keeps two successful and one failed Job in history. Four fields carry the Job half of this task, and each maps to one phrase in the statement:

  • completions: 4 for “four work items”
  • parallelism: 2 for “two at a time”
  • completionMode: Indexed for “its item number”
  • backoffLimit: 2 for “two retries”

Indexed mode sets the JOB_COMPLETION_INDEX variable in every pod, so the container can tell which slice of work it owns without any queue.

apiVersion: batch/v1
kind: Job
metadata:
  name: pi-batch
  namespace: ckad
spec:
  completions: 4
  parallelism: 2
  completionMode: Indexed
  backoffLimit: 2
  template:
    spec:
      restartPolicy: Never
      containers:
      - name: worker
        image: busybox:1.37
        command: ["sh", "-c", "echo processed item $JOB_COMPLETION_INDEX; sleep 2"]

For the CronJob, generate the skeleton instead of writing it. The kubectl create cronjob command fills in the jobTemplate nesting, which is the part people get wrong by hand.

kubectl create cronjob cleanup --image=busybox:1.37 --schedule='*/1 * * * *' -n ckad $do -- sh -c 'date; echo cleaning up' > cleanup-cronjob.yaml

We then added the three policy fields under spec. This is the file we applied:

apiVersion: batch/v1
kind: CronJob
metadata:
  name: cleanup
  namespace: ckad
spec:
  schedule: "*/1 * * * *"
  concurrencyPolicy: Forbid
  successfulJobsHistoryLimit: 2
  failedJobsHistoryLimit: 1
  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: OnFailure
          containers:
          - name: cleanup
            image: busybox:1.37
            command: ["sh", "-c", "date; echo cleaning up"]

Apply both, wait for the Job to complete, and check its status and the indexed logs.

kubectl apply -f pi-batch.yaml -f cleanup-cronjob.yaml
kubectl wait --for=condition=complete job/pi-batch -n ckad --timeout=120s
kubectl get job -n ckad pi-batch
kubectl logs -n ckad -l job-name=pi-batch --prefix

Our Job finished 4/4 in 12 seconds, which matches two waves of two pods at roughly two seconds each plus scheduling. Each pod printed a different index from 0 to 3. Then give the CronJob about three minutes to fire a few times before you list it with its Jobs.

kubectl get cronjob,jobs -n ckad

Both checks are in the capture below, the Job at the top and the CronJob history underneath.

Indexed Kubernetes Job completing 4 of 4 items and a CronJob keeping two finished jobs in history

By then the CronJob had been alive for 3 minutes and 20 seconds, so it had run three times, yet only two cleanup Jobs remain. That is the successfulJobsHistoryLimit pruning the oldest one, and it is the line a grader would check. When a task asks you to trigger a scheduled job right now, kubectl create job manual-run --from=cronjob/cleanup -n ckad does it without waiting for the next minute, and it worked first time on our cluster.

Step 3: Roll out a bad image and roll it back

Task: the Deployment shop runs four nginx replicas. Upgrade it to nginx:1.29-alpine without ever dropping below four ready pods and record the reason. Then a teammate pushes a tag that does not exist, and you must restore the last working version. The “never below four” phrase maps to maxUnavailable: 0, and maxSurge: 1 lets the rollout add one new pod at a time.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: shop
  namespace: ckad
  labels:
    app: shop
spec:
  replicas: 4
  selector:
    matchLabels:
      app: shop
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
  template:
    metadata:
      labels:
        app: shop
    spec:
      containers:
      - name: nginx
        image: nginx:1.28-alpine
        ports:
        - containerPort: 80

After applying it, change the image and annotate the change cause, because --record is deprecated and the annotation is what fills the CHANGE-CAUSE column.

kubectl apply -f shop.yaml
kubectl rollout status deployment/shop -n ckad
kubectl set image deployment/shop nginx=nginx:1.29-alpine -n ckad
kubectl annotate deployment/shop -n ckad kubernetes.io/change-cause="upgrade nginx to 1.29-alpine"
kubectl rollout status deployment/shop -n ckad

Our first rollout finished cleanly. Next we simulated the bad push with a tag that does not exist, and put a 60 second limit on the status check so it could not block the terminal.

kubectl set image deployment/shop nginx=nginx:1.99-doesnotexist -n ckad
kubectl annotate deployment/shop -n ckad kubernetes.io/change-cause="try nginx 1.99-doesnotexist" --overwrite
kubectl rollout status deployment/shop -n ckad --timeout=60s
kubectl get pods -n ckad -l app=shop
kubectl rollout undo -n ckad deployment/shop
kubectl rollout status deployment/shop -n ckad
kubectl rollout history deployment/shop -n ckad

Look at the pod list before the undo. One new pod sits in ErrImagePull while all four old pods stay 1/1 Running, so users never saw an outage.

kubectl rollout status timing out on a bad nginx image, ErrImagePull pod beside four running pods, then rollout undo and history

You are looking at maxUnavailable: 0 paying for itself. The history after the undo surprises people: revision 2 is gone and revision 4 carries its change cause, because an undo re-creates the old ReplicaSet template as a new revision. If a task asks you to roll back to a specific revision, read the history first and use --to-revision, since the numbers shift every time you undo. Our guide to CrashLoopBackOff and ImagePullBackOff errors covers the image pull side in more depth.

Step 4: Install, upgrade and roll back a Helm release

Task: install the chart in ./webapp as release webapp in a new namespace web with two replicas, upgrade it to three, then return the release to its first revision. Helm tasks are short, but they mix up two numbering systems, release revisions and chart versions, so the history command is the one to trust. We generated a sample chart with helm create webapp and ran the whole cycle against it.

helm create webapp
helm install webapp ./webapp -n web --create-namespace --set replicaCount=2
helm upgrade webapp ./webapp -n web --set replicaCount=3
helm rollback webapp 1 -n web
helm history webapp -n web
helm get values webapp -n web

Helm did not rewind to revision 1. It created revision 3 with the description “Rollback to 1”, and the values it restored are the two replicas from the install.

helm rollback webapp 1 followed by helm history showing revision 3 Rollback to 1 and the user-supplied values

Helm behaves like kubectl rollout undo here: history only moves forward. helm get values is the quickest proof that the rollback restored the right settings, because it prints only what you supplied, not the whole values file. One more command earns its place in practice. helm template webapp ./webapp --set replicaCount=5 | grep replicas renders the chart locally and printed replicas: 5 on our cluster without touching it, which is how you check an override before you install. Our Helm install and usage guide covers repositories and chart layout, and the commands above work the same on Helm 4.

Step 5: Take a pod out of a Service with a readiness probe

Task: the Deployment api serves traffic through a Service named api. Add a readiness probe that passes only while /tmp/ready exists, and a liveness probe on HTTP port 80, then prove that a pod failing readiness stops receiving traffic but is not restarted. The two probes answer different questions, and mixing them up is the most common probe mistake:

  • Readiness decides whether the Service sends traffic
  • Liveness decides whether the kubelet restarts the container
  • Startup holds both off until a slow app has booted

This task needs the first two. Our manifest checks a file for readiness so you can flip it by hand, and an HTTP GET for liveness.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: api
  namespace: ckad
spec:
  replicas: 1
  selector:
    matchLabels:
      app: api
  template:
    metadata:
      labels:
        app: api
    spec:
      containers:
      - name: nginx
        image: nginx:1.29-alpine
        command: ["sh", "-c", "touch /tmp/ready && exec nginx -g 'daemon off;'"]
        ports:
        - containerPort: 80
        readinessProbe:
          exec:
            command: ["cat", "/tmp/ready"]
          periodSeconds: 5
        livenessProbe:
          httpGet:
            path: /
            port: 80
          periodSeconds: 10
---
apiVersion: v1
kind: Service
metadata:
  name: api
  namespace: ckad
spec:
  selector:
    app: api
  ports:
  - port: 80
    targetPort: 80

Once the pod is Ready, delete the file to make readiness fail, wait three probe periods, and read the endpoint conditions rather than the summary table.

kubectl apply -f api.yaml
kubectl rollout status deployment/api -n ckad
kubectl exec -n ckad deploy/api -- rm /tmp/ready
sleep 15
kubectl get pods -n ckad -l app=api
kubectl get endpointslice -n ckad -l kubernetes.io/service-name=api -o jsonpath='{.items[0].endpoints[0].conditions}{"\n"}'
kubectl describe pod -n ckad -l app=api | grep -E 'Readiness probe failed|Unhealthy'

Your pod should drop to 0/1 with RESTARTS still at 0, while the endpoint reports ready false. Putting the file back with kubectl exec -n ckad deploy/api -- touch /tmp/ready brought our pod back to 1/1 within a few seconds.

Readiness probe failing after /tmp/ready is removed, pod at 0/1 and the EndpointSlice endpoint marked ready false

Here is the detail that cost us a minute. The plain kubectl get endpointslices table kept listing the pod IP 10.244.39.222 in its ENDPOINTS column while the pod was not ready, because EndpointSlices keep not-ready addresses and flag them with conditions. kube-proxy only routes to endpoints whose ready condition is true, so the jsonpath query is the honest check. Liveness never fired, since nginx kept answering on port 80, which is exactly the separation the task wanted you to show.

Step 6: Feed a pod from a ConfigMap and a Secret

Task: create a ConfigMap app-config with APP_MODE=production and LOG_LEVEL=info, and a Secret db-creds with a username and password. Run a pod named config-demo that loads every ConfigMap key as an environment variable and mounts the Secret read only at /etc/db. Both objects come straight from imperative commands, which is faster than writing YAML and base64 encoding values by hand.

kubectl create configmap app-config -n ckad --from-literal=APP_MODE=production --from-literal=LOG_LEVEL=info
kubectl create secret generic db-creds -n ckad --from-literal=username=app --from-literal=password=S3cretPass

Our pod uses envFrom so every key arrives without listing them one by one, and a secret volume for the credentials.

apiVersion: v1
kind: Pod
metadata:
  name: config-demo
  namespace: ckad
spec:
  containers:
  - name: app
    image: busybox:1.37
    command: ["sleep", "3600"]
    envFrom:
    - configMapRef:
        name: app-config
    volumeMounts:
    - name: db
      mountPath: /etc/db
      readOnly: true
  volumes:
  - name: db
    secret:
      secretName: db-creds

We then changed LOG_LEVEL to debug in the ConfigMap and checked the running pod before and after recreating it. The update itself is the create, dry run and apply pipe, which edits an existing object without opening an editor.

kubectl apply -f config-demo.yaml
kubectl wait --for=condition=Ready pod/config-demo -n ckad --timeout=90s
kubectl exec config-demo -n ckad -- env | grep -E 'APP_MODE|LOG_LEVEL'
kubectl exec config-demo -n ckad -- ls /etc/db
kubectl create configmap app-config -n ckad --from-literal=APP_MODE=production --from-literal=LOG_LEVEL=debug $do | kubectl apply -f -
kubectl exec config-demo -n ckad -- env | grep -E 'APP_MODE|LOG_LEVEL'
kubectl delete pod config-demo -n ckad
kubectl apply -f config-demo.yaml
kubectl wait --for=condition=Ready pod/config-demo -n ckad --timeout=90s
kubectl exec config-demo -n ckad -- env | grep -E 'APP_MODE|LOG_LEVEL'

Our ConfigMap reported debug straight away, but the running pod kept printing info until we recreated it.

ConfigMap updated to LOG_LEVEL=debug while the running pod still shows info until it is recreated

Environment variables are copied into the container when it starts, and nothing updates them afterwards. A ConfigMap mounted as a volume does refresh in place after the kubelet sync period, which is the reason to pick a volume when an application can reload its config file. For a Deployment, kubectl rollout restart is the clean way to pick up new environment values, and our post on how to restart a pod with kubectl compares it with deleting pods by hand. The apply in this step also printed a warning about a missing last-applied-configuration annotation, which is harmless here and is covered in the traps section.

Step 7: Lock a pod down with securityContext

Task: create a ServiceAccount reporter that does not mount an API token, and a pod secure-app that uses it. The pod must run as user 1000 and group 3000 with fsGroup 2000, refuse to run as root, block privilege escalation, use a read only root filesystem and drop every Linux capability. The trick is knowing which fields live at pod level and which only exist on the container:

  • Pod level: runAsUser, runAsGroup, fsGroup, runAsNonRoot
  • Container only: allowPrivilegeEscalation, readOnlyRootFilesystem, capabilities

Pod-level PodSecurityContext has no allowPrivilegeEscalation, readOnlyRootFilesystem or capabilities fields at all, which kubectl explain pod.spec.securityContext confirms in seconds. Those three only work on the container, so this split is worth knowing cold.

apiVersion: v1
kind: ServiceAccount
metadata:
  name: reporter
  namespace: ckad
automountServiceAccountToken: false
---
apiVersion: v1
kind: Pod
metadata:
  name: secure-app
  namespace: ckad
spec:
  serviceAccountName: reporter
  securityContext:
    runAsUser: 1000
    runAsGroup: 3000
    fsGroup: 2000
    runAsNonRoot: true
  containers:
  - name: app
    image: busybox:1.37
    command: ["sleep", "3600"]
    securityContext:
      allowPrivilegeEscalation: false
      readOnlyRootFilesystem: true
      capabilities:
        drop: ["ALL"]

Give each requirement its own check, because a grader tests behaviour and so should you. If you skip one, you will not know which field failed.

kubectl apply -f secure-app.yaml
kubectl wait --for=condition=Ready pod/secure-app -n ckad --timeout=90s
kubectl exec secure-app -n ckad -- id
kubectl exec secure-app -n ckad -- touch /tmp/x
kubectl exec secure-app -n ckad -- ls /var/run/secrets/kubernetes.io/serviceaccount

You can see uid 1000, gid 3000 and the supplementary group 2000 from fsGroup in the id output. The write fails on the read only filesystem, and the token directory does not exist.

securityContext checks: id shows uid 1000, touch fails on a read-only root filesystem, no service account token, nginx pod in CreateContainerConfigError

Look at the last line in that capture. It is a second pod we ran on purpose, and you can skip it: stock nginx with runAsNonRoot set and no runAsUser, from this manifest.

apiVersion: v1
kind: Pod
metadata:
  name: nginx-secure
  namespace: ckad
spec:
  containers:
  - name: nginx
    image: nginx:1.29-alpine
    securityContext:
      runAsNonRoot: true
      readOnlyRootFilesystem: true

After kubectl apply -f nginx-root.yaml the pod sat in CreateContainerConfigError, because the image runs as root and the kubelet refuses to start it rather than silently running it as some other user. On a real application, the fix is an image built to run unprivileged, or an explicit runAsUser the image can work with. Our post on restricting a service account to one namespace with RBAC picks up where the ServiceAccount half of this task stops.

Step 8: Make a namespace quota usable with a LimitRange

Task: namespace team-a may use at most 1 CPU and 1 GiB in requests, 2 CPUs and 2 GiB in limits, and 5 pods. Developers keep running pods without resource settings, so make those pods start with sensible defaults instead of failing. The quota alone answers the first sentence and breaks the second one, which is why the task pairs it with a LimitRange.

apiVersion: v1
kind: ResourceQuota
metadata:
  name: team-a-quota
  namespace: team-a
spec:
  hard:
    requests.cpu: "1"
    requests.memory: 1Gi
    limits.cpu: "2"
    limits.memory: 2Gi
    pods: "5"

A LimitRange fills in a request and a limit for any container that arrives without them.

apiVersion: v1
kind: LimitRange
metadata:
  name: team-a-defaults
  namespace: team-a
spec:
  limits:
  - type: Container
    default:
      cpu: 500m
      memory: 256Mi
    defaultRequest:
      cpu: 250m
      memory: 128Mi

We applied the quota first and tried a bare pod, then added the LimitRange and tried again, which is the order you should test it in too.

kubectl create namespace team-a
kubectl apply -f team-a-quota.yaml
kubectl run nolimits --image=nginx:1.29-alpine -n team-a
kubectl apply -f team-a-defaults.yaml
kubectl run nolimits --image=nginx:1.29-alpine -n team-a
kubectl describe quota -n team-a

Your first run is refused with “must specify limits.cpu”, and the second succeeds with the defaults counted against the quota.

kubectl run refused by a ResourceQuota until a LimitRange adds default requests and limits, then describe quota shows usage

A quota on requests.cpu or limits.cpu makes those fields mandatory for every new pod in the namespace, and the error lists each missing one. After the LimitRange, the pod spec showed limits of 500m and 256Mi and requests of 250m and 128Mi, injected at admission. We also tried a pod asking for 2 CPUs, and the quota refused it with “exceeded quota: team-a-quota, requested: limits.cpu=2,requests.cpu=2”. Read that message from the right: “limited” is the hard cap and “used” is what is already spent, so the request did not fit in the 750m of request CPU that was left.

Step 9: Allow only frontend pods to reach the backend

Task: Deployment backend and its Service accept traffic from anywhere. Restrict them so that only pods labelled role=frontend in the same namespace can connect, and only on TCP port 80. Do you need a default deny policy first? Not here. Once any policy selects a pod for Ingress, that pod rejects every connection the policy does not allow, so one policy covers the whole task.

Start with the backend itself: two nginx replicas and a ClusterIP Service in front of them. This is the file we applied.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: backend
  namespace: ckad
spec:
  replicas: 2
  selector:
    matchLabels:
      app: backend
  template:
    metadata:
      labels:
        app: backend
    spec:
      containers:
      - name: nginx
        image: nginx:1.29-alpine
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: backend
  namespace: ckad
spec:
  selector:
    app: backend
  ports:
  - port: 80
    targetPort: 80

Apply it, wait for both replicas, then start the two test clients. Only one of them carries the role=frontend label.

kubectl apply -f backend.yaml
kubectl rollout status deployment/backend -n ckad
kubectl run frontend --image=busybox:1.37 -l role=frontend -n ckad -- sleep 3600
kubectl run other --image=busybox:1.37 -n ckad -- sleep 3600
kubectl wait --for=condition=Ready pod/frontend pod/other -n ckad --timeout=90s

Our policy selects the backend pods and allows one source on one port.

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: backend-allow-frontend
  namespace: ckad
spec:
  podSelector:
    matchLabels:
      app: backend
  policyTypes:
  - Ingress
  ingress:
  - from:
    - podSelector:
        matchLabels:
          role: frontend
    ports:
    - protocol: TCP
      port: 80

Test before and after, with one labelled client and one without a label. Testing before the policy matters: it proves the backend works, so a later failure means the policy and not a broken Service. You are looking for this pattern:

  • Before the policy: frontend and other both get the page
  • After the policy: frontend gets the page
  • After the policy: other times out

Anything else means either the labels or the CNI are wrong. The first two wget lines run before the policy exists, and the last two run after it.

kubectl exec -n ckad frontend -- wget -qO- --timeout=3 backend | grep '<title>'
kubectl exec -n ckad other -- wget -qO- --timeout=3 backend | grep '<title>'
kubectl apply -f backend-allow-frontend.yaml
kubectl exec -n ckad frontend -- wget -qO- --timeout=3 backend | grep '<title>'
kubectl exec -n ckad other -- wget -qO- --timeout=3 backend | grep '<title>'

Before the policy both clients fetched the nginx welcome page. After it, only the frontend pod did.

NetworkPolicy test where the frontend pod fetches the nginx page and the unlabelled pod times out

A timeout, not a refusal, is the normal result of a NetworkPolicy block, because the packets are dropped. Always pass --timeout to wget or curl in these tests, otherwise a blocked request hangs for minutes of your two hours. The policy also kept working through the Service name, since Calico enforces it on the backend pods themselves. Notice that DNS still resolved for the blocked pod: the policy restricts ingress to backend, and DNS traffic goes to CoreDNS, which no policy here selects.

Step 10: Debug a pod that keeps crashing

Task: pod broken in namespace ckad keeps restarting. Find out why without changing the original pod. We built the failure with a busybox container that reads a config file nobody mounted, then worked through it in this order:

  1. kubectl get pod for status and restart count
  2. kubectl logs for what the process printed
  3. kubectl describe for the last state and exit code
  4. kubectl get events when the first three say nothing
  5. kubectl debug with a copy only after that

Most crashes are solved by step 2 or 3, which is why the copy comes last. To reproduce the failure, apply this pod first.

apiVersion: v1
kind: Pod
metadata:
  name: broken
  namespace: ckad
spec:
  containers:
  - name: app
    image: busybox:1.37
    command: ["sh", "-c", "cat /config/app.conf"]

Apply it and give it 45 seconds to fail a few times before the first three checks, which is what the sleep is for.

kubectl apply -f broken.yaml
sleep 45

Our pod had restarted three times by then.

kubectl get pod broken -n ckad
kubectl logs broken -n ckad
kubectl describe pod broken -n ckad | grep -A3 'Last State'

Three restarts in 45 seconds, an exit code of 1 and a log line that names the missing file. That is the whole diagnosis. The block below joins two of our checks taken about half a minute apart, so the log line comes from the later one.

NAME     READY   STATUS   RESTARTS      AGE
broken   0/1     Error    3 (30s ago)   45s
cat: can't open '/config/app.conf': No such file or directory
    Last State:     Terminated
      Reason:       Error
      Exit Code:    1
      Started:      Mon, 09 Nov 2026 03:52:43 +0000

When logs are not enough, kubectl debug with --copy-to clones the pod with an extra container you can work in, leaving the original untouched. Our copy came up 1/2: the debugger container ran, while the copied app container kept crashing exactly like the original. From inside the debugger, ls /config confirmed the directory does not exist, so the fix is a ConfigMap volume mounted at /config. That pattern, clone and inspect rather than edit the broken pod, is what a task means when it says do not change the original.

kubectl debug pod/broken -n ckad --image=busybox:1.37 --copy-to=broken-debug --container=debugger -- sleep 600
sleep 10
kubectl exec -n ckad broken-debug -c debugger -- ls /config

Our exec returned “ls: /config: No such file or directory” with exit code 1, which closes the case. Delete the broken-debug copy when you finish, since it counts against any quota in the namespace.

Try the CKAD practice question bank

The ten tasks train your hands. Our question bank trains the reasoning behind them: why a field lives where it does, which object answers a requirement, what a status or error message means. Every question was written from the public curriculum and checked against the Kubernetes docs or our own cluster, with an explanation for each answer. The set below draws 15 questions at random from all 24 of our CKAD banks, 187 questions in total, so each attempt is different.

Loading quiz...

Our banks follow the curriculum domain weights, so a mixed draw spreads across all five areas. This is how the 187 questions break down today:

DomainWeightBanksQuestions
Application Design and Build20%436
Application Deployment20%439
Application Observability and Maintenance15%528
Application Environment, Configuration and Security25%848
Services and Networking20%336

When a question catches you out, go back to the matching step above and run it again on your cluster. If you are also working toward the administrator credential, the sibling set of CKA practice questions covers etcd backups, cluster upgrades and broken nodes on a two node kubeadm cluster.

Why a CKAD dump will not help you

Sites selling “real CKAD questions” exist, but a performance test leaves them little to sell. The grader checks the objects in your clusters, so the most a leaked file could hold is a list of task statements, and knowing a statement in advance does not type the manifest for you. Speed comes from having typed these objects many times, and no answer file gives you that.

Buying one also puts the credential at risk, since the Linux Foundation’s certification rules forbid using leaked test content and can revoke a certificate for it. The two killer.sh simulator sessions that come with the registration use the same type of hands-on tasks, and they are the closest legitimate rehearsal you will get. For reading alongside the labs, our list of the best Kubernetes books includes study guides written for this credential.

What broke during our run

None of these stopped a task for long, but each one would cost minutes if you met it for the first time under a clock. The exact messages are below so you can search this page when your own terminal prints them.

“Error: container has runAsNonRoot and image will run as root”

You see this in the pod events as CreateContainerConfigError when runAsNonRoot is true and the image’s default user is root, with no runAsUser to override it. The kubelet checks the image metadata before starting the container and refuses rather than guessing. Set a non-root runAsUser the image supports, or switch to an image built to run unprivileged. Removing runAsNonRoot makes the error go away but fails any task that asked for it.

“unable to retrieve container logs for containerd://…” with –previous

Our kubectl logs broken --previous returned this instead of the crash output. We did not chase the root cause, since a container that restarts every few seconds is a moving target for the previous instance’s log. Plain kubectl logs without the flag printed the error line, because each new instance fails the same way within a second. Try both before you reach for kubectl debug.

“warning: couldn’t attach to pod/tmp, falling back to streaming logs”

A kubectl run --rm -i pod whose command finishes in under a second is gone before kubectl can attach, so kubectl falls back to the logs and still shows the output. The warning is harmless. If a run is interrupted before kubectl cleans up, the tmp pod stays behind and the next run with the same name fails, so delete it or pick a new name.

“Warning: resource … is missing the kubectl.kubernetes.io/last-applied-configuration annotation”

We saw this when piping a dry run into kubectl apply for a ConfigMap first made with kubectl create. kubectl patches the annotation in and carries on, so the object is fine. kubectl rollout undo printed a related warning: the rollback does not update that annotation, so a later kubectl apply of the old file can bring the bad image back. In a timed task, ignore both and keep going, then fix the manifest file if you keep one around.

Keep reading

Best UI Applications for Managing Docker Containers Containers Best UI Applications for Managing Docker Containers Install Docker and Run Containers on Ubuntu 24.04|22.04 Containers Install Docker and Run Containers on Ubuntu 24.04|22.04 Install UniFi OS Server on Ubuntu 24.04 LTS Containers Install UniFi OS Server on Ubuntu 24.04 LTS OpenCloud vs ownCloud vs Nextcloud: Tested on Identical VMs Cloud OpenCloud vs ownCloud vs Nextcloud: Tested on Identical VMs Kiri Container Runtime on Linux: Install and Benchmark vs Docker Containers Kiri Container Runtime on Linux: Install and Benchmark vs Docker Install Harbor Registry on Ubuntu/Debian/Rocky/Alma Containers Install Harbor Registry on Ubuntu/Debian/Rocky/Alma

Leave a Comment

Press ESC to close