Home / Certified Kubernetes Application Developer (CKAD) / Mock exam
Certified Kubernetes Application Developer (CKAD) Exam-style mock test

CKAD Certified Kubernetes Application Developer Practice Exams|Practice test

Full explanations Exam format Pass line 66%
33 USD One-time · lifetime access
Enroll →

Sample questions

Example1 · Application Design and Build
A retail e-commerce team ships a Go pricing service. Their Dockerfile uses golang:1.22 as the base and the final image is 940MB, which slows every rollout. Which single Dockerfile change shrinks the runtime image the most while keeping the compiled binary runnable?
・Append RUN apt-get clean after each install step
Incorrect. Cleaning apt caches trims a few MB but the full Go toolchain and OS still remain in the final image.
・Switch the base to ubuntu:22.04 and install only the Go toolchain packages that are needed
Incorrect. Ubuntu plus the Go toolchain is still a large runtime image because the compiler stays in the shipped layers.
・Reorder the COPY and RUN steps so dependency layers are cached across rebuilds of the image
Incorrect. Layer reordering speeds up rebuild caching but does not remove the toolchain bytes from the final image.
✓Add a second FROM gcr.io/distroless/static stage and COPY only the built binary into it
Correct. A multi-stage build compiles in the golang stage, then COPYs just the static binary into a tiny distroless final stage, so the toolchain never ships.
Explanation
Multi-stage builds separate the build environment from the runtime, letting you COPY only the artifact into a minimal final stage. Distroless or scratch bases are the standard way to cut Go images from hundreds of MB to tens of MB.
Example2 · Application Deployment
A retail e-commerce team runs a blue/green rollout. The live Service 'checkout' selects pods with 'version: blue'. The green Deployment is healthy with label 'version: green'. To cut all production traffic to green in a single atomic step, what do you change?
・Scale the blue Deployment to zero replicas so its pods terminate and clients fail over
Incorrect. Scaling blue to zero drops its endpoints but leaves the Service selecting blue labels, so green pods are never added to the endpoint list.
・Add 'version: green' as a second selector key alongside the existing blue key
Incorrect. A Service selector is ANDed, so requiring both 'blue' and 'green' matches no pod because no pod carries both labels at once.
・Delete the blue Deployment entirely and wait for endpoints to refresh across nodes
Incorrect. Deleting the blue Deployment removes blue pods but the selector still targets blue labels, leaving the Service with no matching endpoints.
✓Edit the live Service's selector so it matches 'version: green' instead of the current 'version: blue' value
Correct. A Service routes to pods matching its selector, so repointing the live selector to 'version: green' atomically shifts all traffic to the green pods.
Explanation
In a blue/green switch, the Service selector is the traffic switch. Editing the selector to the green label set is the single atomic cutover; scaling or deleting blue does not add green to the endpoints.
Example3 · Application Observability and Maintenance
A payments API in a retail e-commerce cluster takes up to 40 seconds to warm its JVM cache before it can serve any traffic. During that window the kubelet keeps restarting the container because the liveness probe fires first. Which probe should you add so the slow boot is tolerated without disabling the liveness check?
・Set the liveness probe terminationGracePeriodSeconds to 40 so the restart waits for the cache to finish warming up first
Incorrect. terminationGracePeriodSeconds governs how long a container may take to shut down, not how long the kubelet waits before probing a starting container.
・Replace the liveness probe with a readiness probe that has a 40-second initialDelaySeconds applied
Incorrect. Dropping the liveness probe removes restart-on-hang protection entirely, and readiness only affects Service endpoints, not kubelet restarts.
✓Add a startupProbe with a high failureThreshold so the liveness probe is held off until the app finishes booting
Correct. A startupProbe gates the liveness and readiness probes; until it succeeds the liveness probe does not run, so a high failureThreshold * periodSeconds covers the 40-second warm-up.
・Set restartPolicy to OnFailure on the Pod so the kubelet does not restart the container during the cache warm-up window
Incorrect. restartPolicy OnFailure still restarts a container the liveness probe reports as failed, so the premature restarts continue.
Explanation
The startupProbe exists specifically for slow-starting containers: it suspends liveness and readiness checks until it passes once, after which normal probing resumes. This protects legitimately slow boots without weakening liveness protection.
Example4 · Application Environment, Configuration and Security
A genomics platform installs an operator that bundles a CustomResourceDefinition named SequencingJob. A developer runs kubectl get sequencingjob and gets 'the server doesn't have a resource type'. kubectl get crd shows the CRD exists with scope Namespaced. What is the most likely cause of the lookup failure?
・The command omits the target namespace, so the API server rejected the given plural resource name outright on this call
Incorrect. A missing namespace defaults to 'default' and never produces a 'doesn't have a resource type' error from the discovery layer.
・The developer queried a namespace where no SequencingJob object has been created yet
Incorrect. An empty namespace returns 'No resources found', not a resource-type-unknown error, because the type is still known.
✓The listed CRD is not yet Established, so its API endpoint is not being served
Correct. Until the CRD reaches the Established condition the API server has not wired up its REST endpoint, so discovery reports the resource type as unknown.
・The CRD must be re-registered with the aggregation layer before any shortName resolves
Incorrect. CRDs are served directly by the API server and do not use the aggregation layer, which is only for extension API servers.
Explanation
A registered CRD only becomes queryable once its Established condition is true and names are accepted. Checking kubectl get crd <name> -o yaml for status.conditions distinguishes a not-yet-served type from an empty namespace.
Example5 · Services and Networking
A patient-records API in namespace clinical currently accepts traffic from every pod in the cluster. Security asks you to block all inbound connections to its pods by default while leaving egress untouched. Which NetworkPolicy spec applied in clinical achieves this?
✓podSelector: {} selecting every pod in the namespace, with policyTypes: [Ingress] and no ingress rules listed so all inbound is denied
Correct. An empty podSelector selects all pods in the namespace, and declaring policyTypes Ingress with zero ingress rules isolates ingress completely while egress stays unaffected.
・podSelector: {} with policyTypes: [Ingress] and an ingress rule whose from array is empty
Incorrect. An ingress rule with an empty from array actually allows all sources, so this permits inbound traffic rather than denying it.
・podSelector matching the API label with policyTypes: [Egress] and no egress rules so nothing leaves
Incorrect. Selecting Egress only governs outbound traffic, so inbound connections to the API remain fully open.
・podSelector: {} with policyTypes: [Ingress, Egress] blocking both directions across the entire namespace at once
Incorrect. Including Egress with no egress rules also cuts off outbound traffic, violating the requirement to leave egress untouched.
Explanation
A default-deny ingress policy uses an empty podSelector to target every pod and lists Ingress in policyTypes with no actual ingress rules. Adding Egress to policyTypes would unintentionally block outbound traffic.
Example6 · Application Design and Build
A genomics pipeline image for an analytics service ships at 1.4 GB because it bundles the Go toolchain used to compile the binary. You want the shipped image to contain only the compiled binary and its runtime files. Which Dockerfile approach meets this with the least ongoing maintenance?
✓Use a multi-stage build: compile in a builder stage, then COPY --from=builder the binary into a small base
Correct. Multi-stage builds discard the builder stage entirely, so the final image carries only the artifacts you COPY --from, giving a small image with no manual cleanup.
・Add a RUN rm -rf /usr/local/go at the Dockerfile's end so the SDK directory is cleared after the build finishes
Incorrect. Deleting files in a later layer does not reclaim space; the toolchain still exists in earlier layers and remains in the image.
・Flatten the final image with docker export and import to drop layers
Incorrect. Flattening removes history but is a manual, lossy post-process that must be redone each build.
・Switch the base image to a smaller distro tag and rely on the layer cache
Incorrect. A smaller base helps marginally, but the Go toolchain is still installed on top, so the heavy layers remain.
Explanation
Space consumed by files in an earlier layer is not freed by deleting them later, since each layer is additive. Multi-stage builds solve this cleanly by copying only the needed artifact out of a throwaway builder stage.
Example7 · Application Design and Build
A telemetry collector for a factory's IoT gateways is built from a Dockerfile that compiles a Go binary and then copies it into a runtime stage. The final image is still 900 MB because the toolchain layers remain. Which Dockerfile change makes the final image small while keeping the build reproducible?
・Add a RUN command at the end of the single build stage that deletes the Go toolchain directory and all cached module files it downloaded
Incorrect. Deleting files in a later RUN in the same stage leaves the earlier layers intact, so the toolchain bytes still inflate the image.
・Append a .dockerignore file listing the vendor directory so the toolchain source is never sent to the daemon during the build context upload
Incorrect. .dockerignore only trims the build context upload; it does not remove toolchain layers baked into the image by compilation steps.
・Rebuild using docker build --squash so all intermediate layers from the compiler are merged into one compressed final layer
Incorrect. --squash merges layers but keeps all toolchain content present in the single stage, so the size is not meaningfully reduced.
✓Set the base of the final runtime stage to a minimal image such as gcr.io/distroless/static and use COPY --from=build to pull only the compiled binary into it
Correct. A multi-stage build whose final stage starts FROM a minimal base and uses COPY --from=build to pull only the compiled binary discards every toolchain layer, yielding a tiny reproducible image.
Explanation
Reducing image size for compiled apps relies on multi-stage builds where the runtime stage starts from a minimal base and copies only the artifact. Deleting files afterward, ignoring context, or squashing do not discard content produced earlier in the same stage.
Example8 · Application Design and Build
A logistics team builds an image on a CI runner that has no Docker daemon and runs as a non-root user inside a rootless container. They need a daemonless OCI build directly from a Dockerfile. Which command satisfies this?
・docker build -t registry.example.com/router:1.4 .
Incorrect. docker build requires the Docker daemon, which this rootless runner does not provide.
・kubectl create deployment --image registry.example.com/router:1.4
Incorrect. kubectl create deployment schedules an existing image; it never builds one from a Dockerfile.
・podman pull registry.example.com/router:1.4 locally
Incorrect. podman pull downloads an already-built image from a registry rather than building one from a Dockerfile.
✓buildah bud registry.example.com/router:1.4
Correct. buildah bud (build-using-dockerfile) performs a daemonless, rootless-capable OCI build from a Dockerfile, which matches a CI runner with no Docker daemon.
Explanation
buildah is a daemonless image builder that reads a Dockerfile and can run rootless, fitting daemon-free CI environments. docker build needs a daemon, while pull and create deployment consume existing images rather than building them.
Example9 · Application Design and Build
A sensor-firmware updater image is pushed as registry.example.com/updater:latest, and the Deployment references the latest tag with imagePullPolicy omitted. After a rebuild, some nodes still run the old code. What is the most reliable fix for application developers?
✓Push each build under an immutable version tag like updater:2.7.3 and reference that exact tag in the Deployment
Correct. Pushing immutable version tags and referencing the exact tag guarantees every node pulls the intended, identical image, eliminating drift from a reused latest tag.
・Keep the latest tag but add imagePullPolicy: Never so every node is forced to reuse a consistent cached copy of the image
Incorrect. imagePullPolicy: Never forbids pulling entirely, so nodes keep whatever stale image they cached and the drift worsens.
・Set imagePullPolicy: IfNotPresent on the container so Kubernetes checks the registry before every single pod start
Incorrect. IfNotPresent skips the pull when any image for that tag is already cached, which is exactly how stale latest copies persist.
・Add a nodeSelector to the Deployment so that pods only schedule onto nodes that already pulled the newest image layers
Incorrect. nodeSelector constrains scheduling but does nothing to ensure the correct image version is pulled onto a node.
Explanation
The latest tag is mutable, so cached copies cause version drift across nodes. Using immutable, explicit version tags is the dependable practice; pull-policy tweaks or scheduling constraints do not solve the mutable-tag problem.
Example10 · Application Design and Build
A B2B SaaS billing service ships as a Go binary. Your current Dockerfile uses golang:1.22 as the single base image, yielding a 900MB image. You want to compile in one stage and copy only the binary into a tiny runtime stage. Which Dockerfile construct achieves this?
・Set the build stage FROM golang:1.22 with a RUN rm -rf /usr/local/go after compiling
Incorrect. Deleting the Go install in the same stage still leaves it in prior layers, so image size is not reduced.
・Add ONBUILD COPY --from directives so children inherit the slimmed layers at build
Incorrect. ONBUILD defers instructions to downstream builds and does not slim the current final image.
✓Add a second FROM gcr.io/distroless/static stage and COPY --from=build /app/svc /svc
Correct. A multi-stage build adds a second FROM and copies the compiled artifact with COPY --from=build, discarding the toolchain from the final image.
・Append a .dockerignore entry for the compiler toolchain so it is excluded from the final layer
Incorrect. .dockerignore only filters the build context sent to the daemon; it cannot remove toolchain layers already baked by FROM golang.
Explanation
Multi-stage builds use one stage to compile and a minimal second stage that copies only the resulting binary via COPY --from. Deleting files in a later RUN or using .dockerignore does not shrink earlier layers.
Example11 · Application Design and Build
On a CI node for an online gaming platform, Docker is unavailable and the pipeline runs as a non-root user with no daemon socket. You must build and push the matchmaking image from the existing Dockerfile. Which command set fits a rootless, daemonless workflow?
・dockerd --rootless then docker build -t reg/mm:1 . followed by docker push reg/mm:1
Incorrect. dockerd still needs a daemon and typically privileges, which contradicts the daemonless non-root constraint.
・nerdctl --address /run/docker.sock build . after starting the Docker daemon as root
Incorrect. nerdctl talking to /run/docker.sock requires a running daemon, violating the daemonless requirement.
・kubectl create job build --image=docker:dind so the privileged daemon runs inside the gaming cluster
Incorrect. docker:dind launches a privileged Docker daemon in a container, the opposite of a rootless daemonless build.
✓buildah bud -t reg/mm:1 . then buildah push reg/mm:1 using the Dockerfile directly
Correct. buildah bud builds from a Dockerfile without a daemon and runs rootless, then buildah push uploads the image.
Explanation
buildah can build directly from a Dockerfile with no daemon and in rootless mode, and buildah push uploads to a registry. Approaches that start dockerd or dind reintroduce the daemon and privilege the setup avoids.
Example12 · Application Design and Build
A state energy-grid dashboard ships as a 1.2 GB image because the Go build toolchain is baked in. You want a tiny runtime image that holds only the compiled binary. Which Dockerfile approach meets this best?
・Add a RUN rm -rf /usr/local/go step at the very end of the single build stage so the toolchain is deleted before the image is finally committed and pushed
Incorrect. A later RUN that deletes files cannot shrink earlier layers; the toolchain still occupies the layers it was added in, so the image stays large.
・Set the image tag to :slim so the registry automatically strips unused build layers from the final pushed artifact
Incorrect. A :slim tag is just a name you assign; registries do not analyze or strip layers based on the tag string.
✓Use a multi-stage build that compiles in a golang stage, then COPY --from the binary into a minimal base image
Correct. A multi-stage build discards the builder stage and the final image contains only the copied binary on a minimal base, giving the smallest footprint.
・Mount the build cache as an emptyDir volume so the compiler files live outside the committed image layers at runtime
Incorrect. emptyDir is a runtime Pod volume and has no effect on how the image is built or its committed layer size.
Explanation
Multi-stage builds separate compile-time dependencies from the runtime image so only artifacts are copied forward. Deleting files in a later layer never reclaims space from earlier layers, and tags or runtime volumes do not reduce image size.
Example13 · Application Design and Build
On an air-gapped campus build server with no Docker daemon, a university DevOps team must build an OCI image from a Dockerfile in a rootless, daemonless way. Which command fits?
・docker build -t campus/api:1.0 . then docker push to the internal registry once the daemon socket becomes reachable again
Incorrect. docker build requires a running Docker daemon, which is exactly what this daemonless, air-gapped environment lacks.
・kubectl create deployment campus-api --image=Dockerfile so the kubelet compiles the image directly on the node
Incorrect. kubectl create deployment only schedules an existing image; it cannot compile a Dockerfile and does not accept one as an image reference.
✓buildah bud -t campus/api:1.0 . which reads the Dockerfile and produces an OCI image without any long-running daemon
Correct. buildah bud builds an OCI image straight from a Dockerfile without a daemon and supports rootless operation, matching the constraints.
・crictl build --file Dockerfile campus/api:1.0 using the node container runtime interface endpoint to assemble layers
Incorrect. crictl is a CRI debugging client for inspecting and running containers; it has no image-build subcommand.
Explanation
buildah builds OCI images from Dockerfiles without a daemon and can run rootless, which suits restricted build hosts. Docker requires its daemon, while kubectl and crictl manage or inspect workloads rather than build images.
Example14 · Application Design and Build
A claims-processing service is built from a Go source tree, but the shipped image is 940 MB because it carries the full Go toolchain. You want the final image to contain only the compiled binary and a minimal base. Which Dockerfile approach meets this with a single build command?
・Add a trailing RUN rm -rf /usr/local/go step so that the compiler directory is removed from the resulting final image layer
Incorrect. Deleting files in a later layer does not shrink earlier layers; the toolchain still occupies the image history and size.
✓Use a multi-stage build that compiles in a golang stage, then COPY --from=build the binary into a small base
Correct. A multi-stage build compiles in one stage and copies only the artifact into a lean final stage, discarding the toolchain.
・Set ENV GOFLAGS to strip symbols and rely on docker to prune the leftover toolchain layers during the registry push
Incorrect. GOFLAGS can strip debug symbols but does not remove the Go toolchain, and docker does not prune build layers on push.
・Switch the single FROM line to alpine and run go build in that one stage
Incorrect. Running go build in the sole alpine stage still bakes the compiler into the shipped image.
Explanation
Multi-stage builds are the canonical way to reduce image size: one stage holds the heavy build tooling, and only the resulting binary is copied forward. Deleting files in later layers or changing flags cannot reclaim space already recorded in earlier layers.
Example15 · Application Design and Build
A hotel-booking API image is tagged resort-api:latest and pushed to a registry. After a hotfix you rebuild and push again under the same tag, but some nodes keep serving the old code even after pods restart. What is the most reliable fix?
✓Push and reference an immutable, uniquely versioned tag such as resort-api:1.4.2 for every build instead of repeatedly reusing the mutable latest tag
Correct. Unique immutable version tags give each build a distinct identity, so nodes cannot silently keep serving a stale cached layer.
・Set imagePullPolicy to IfNotPresent so each node always fetches the newest copy before it starts
Incorrect. IfNotPresent tells the kubelet to skip pulling when a cached image exists, which worsens staleness with a reused tag.
・Add a restartPolicy of Always to the pod so the kubelet re-downloads the image each cycle
Incorrect. restartPolicy governs container restart behavior, not whether the image is re-pulled from the registry.
・Scale the Deployment to zero and back so every replica is forced to re-pull the mutable tag
Incorrect. Scaling may re-pull on some nodes, but a cached latest tag can still be reused and the staleness returns.
Explanation
Reusing a mutable tag like latest lets nodes serve whatever digest they cached. Immutable version tags make each build uniquely addressable so rollouts are deterministic. Pull policy and restart settings do not solve identity ambiguity.
▶ Try 10 free questions (graded)
Measure your readiness with a full mock exam
All questions · full explanations · lifetime access
Enroll(33 USD)