CKAD

Free CKAD practice questions

10 questions from our CKAD practice tests, each with the correct answer and a written explanation. Read them with the answers shown, or switch to quiz mode and answer first.

Back to the CKAD practice exams

Question 1 of 10, Application Design and Build

A log-shipping agent must run as a container alongside the main application container in the same Pod, start before the app, and keep running for the whole life of the Pod. On a current Kubernetes version, how should the agent be declared?

  1. AIn containers with a startupProbe that waits for it
  2. BAs an ephemeral container added via kubectl debug
  3. CIn initContainers with no restartPolicy field set
  4. DIn initContainers with restartPolicy: Always Correct answer

Answer and explanation: Native sidecar containers are declared as init containers with restartPolicy: Always; they start before regular containers in order and keep running for the Pod's lifetime. A normal init container must exit successfully before the next one starts, so a long-running agent would block the app. Listing it in containers gives no start ordering guarantee, and a startupProbe only delays traffic, not start order. Ephemeral containers are for interactive debugging and cannot be declared in the Pod spec at creation.

Question 2 of 10, Application Design and Build

A Job must process 12 work items. Each Pod must know which item it owns (0-11) without an external queue, and at most 3 Pods should run at the same time. Which Job settings achieve this?

  1. Acompletions: 12, parallelism: 3, completionMode: Indexed Correct answer
  2. Bcompletions: 3, parallelism: 12, completionMode: NonIndexed
  3. Ccompletions: 12, parallelism: 12, and restartPolicy: Always
  4. Dparallelism: 3, backoffLimit: 12, no completions set

Answer and explanation: An Indexed Job gives every Pod a completion index (exposed through the JOB_COMPLETION_INDEX environment variable), completions sets 12 total successful Pods and parallelism caps concurrency at 3. Swapping the values runs 12 at once and only needs 3 completions, with no index. Leaving completions unset makes the Job a work-queue style Job without indexes, and backoffLimit only counts retries. restartPolicy: Always is not allowed for Job Pods, and parallelism 12 breaks the concurrency limit.

Question 3 of 10, Application Deployment

After switching the shop Service from blue to green, error rates spike. Blue's Deployment is still running. What is the fastest rollback?

  1. ASwitch the Service selector back to version=blue Correct answer
  2. Bhelm rollback shop 1 for the green release
  3. Ckubectl rollout undo deployment/app-green
  4. DScale app-green to zero and wait for blue to take over

Answer and explanation: In blue/green, the old environment is kept running so traffic can be returned instantly by restoring the Service selector. Undoing the green Deployment's rollout changes green's Pods, but the Service still points at green. A helm rollback only applies if the switch was made through Helm, which the scenario does not state. Scaling green to zero leaves the Service with no endpoints because it still selects green.

Question 4 of 10, Application Deployment

A team wants kubectl rollout history to show a human-readable reason for each revision of Deployment web. What should they do after each change?

  1. AAdd a label revision-reason to the Pod template
  2. BSet the kubernetes.io/change-cause annotation on the Deployment Correct answer
  3. CRun kubectl rollout history with the --record=true flag afterwards
  4. DWrite the reason into the Deployment's spec.revisionHistoryLimit

Answer and explanation: The CHANGE-CAUSE column is filled from the kubernetes.io/change-cause annotation, for example with kubectl annotate deployment/web kubernetes.io/change-cause="...". A label on the Pod template is not read by rollout history and would itself trigger a rollout. --record is deprecated and was a flag of mutating commands, not rollout history. revisionHistoryLimit is a number of retained ReplicaSets.

Question 5 of 10, Application Observability and Maintenance

After a cluster upgrade, applying an old manifest fails with: no matches for kind "CronJob" in version "batch/v1beta1". What is the correct fix?

  1. AConvert the CronJob into a Job with a schedule field set
  2. BChange apiVersion to batch/v1, the served version for CronJob Correct answer
  3. CEnable the batch/v1beta1 API with a feature gate on kubectl
  4. DAdd the --validate=false flag so the apply is not checked

Answer and explanation: batch/v1beta1 CronJob was removed in Kubernetes 1.25; the stable batch/v1 version is served, so the manifest must be updated (the kubectl convert plugin can help). Removed API versions cannot be re-enabled from kubectl, which is only a client. --validate=false skips client-side schema checks, but the API server still has no such resource version. A Job has no schedule field.

Question 6 of 10, Application Observability and Maintenance

After a cluster upgrade removed an old API version, helm upgrade for release legacy fails with: unable to build kubernetes objects from current release manifest. The chart itself was already updated to the new API version. What resolves this?

  1. ARun helm upgrade with --force so Helm skips comparing against the previous release manifest
  2. BDelete the Deployment objects by hand so the release has nothing left to compare against
  3. CDowngrade kubectl to a version that still knows the removed API, then run the upgrade again
  4. DRewrite the removed APIs in the stored release record (helm mapkubeapis), then upgrade Correct answer

Answer and explanation: Helm compares the new manifests with the manifest stored for the last release; if that stored manifest uses an API version the server no longer serves, the upgrade fails until the release record is rewritten, which the mapkubeapis plugin does. Forcing the upgrade does not avoid parsing the stored manifest. API removal happens on the server, so an older kubectl cannot help. Deleting live objects causes an outage and leaves the stored manifest unchanged.

Question 7 of 10, Application Environment, Configuration and Security

In what order does the API server process a request to create a Pod?

  1. AAuthentication, mutating admission, authorization, validating admission, then persistence
  2. BAuthorization, authentication, validating admission, mutating admission, then persistence
  3. CAuthentication, authorization, validating admission, persistence, and then mutating admission
  4. DAuthentication, authorization, mutating admission, validating admission, then persistence Correct answer

Answer and explanation: The API server first authenticates the caller, then authorizes the request (for example with RBAC), then runs mutating admission (such as LimitRanger defaults) followed by validating admission (such as ResourceQuota or ValidatingAdmissionPolicy), and finally stores the object in etcd. Authorization cannot precede knowing who the caller is. Admission happens only after authorization. Mutation must happen before validation so that validators see the final object.

Question 8 of 10, Application Environment, Configuration and Security

A namespace enforces the restricted Pod Security Standard. A Pod already sets runAsNonRoot: true and drops ALL capabilities, but is still rejected. Which additional container setting is MOST likely missing?

  1. AfsGroup set to a non-zero group and an explicit runAsGroup value
  2. BseccompProfile type RuntimeDefault and allowPrivilegeEscalation: false Correct answer
  3. ChostNetwork: true with automountServiceAccountToken disabled
  4. DreadOnlyRootFilesystem: true and a memory limit for the container

Answer and explanation: The restricted profile requires, besides running as non-root and dropping ALL capabilities, that allowPrivilegeEscalation is false and that a seccomp profile of RuntimeDefault or Localhost is set. fsGroup and runAsGroup are allowed but not required. readOnlyRootFilesystem and resource limits are good practice but not part of the restricted checks. hostNetwork: true is forbidden even by the baseline profile.

Question 9 of 10, Services and Networking

Namespace payments contains a NetworkPolicy with podSelector: {} and policyTypes: [Ingress, Egress] and no rules. Pods there can no longer resolve Service names. Which additional policy restores name resolution without opening other traffic?

  1. AAn ingress rule allowing UDP port 53 from all Pods in namespace kube-system
  2. BAn egress rule allowing all ports to the namespace payments with a podSelector {}
  3. CAn egress rule allowing UDP and TCP port 53 to the kube-dns Pods in kube-system Correct answer
  4. DRemoving Egress from policyTypes so that only ingress traffic is filtered

Answer and explanation: The policy denies all ingress and egress, so DNS queries to CoreDNS are blocked; an egress rule to the kube-dns Pods on port 53 (UDP and TCP) restores resolution only. DNS replies are allowed automatically because NetworkPolicies are stateful, so an ingress rule from kube-system does not help the outbound query. Allowing egress inside payments does not reach kube-system. Dropping Egress from policyTypes reopens all outbound traffic, which violates the requirement.

Question 10 of 10, Services and Networking

An Ingress for secure.example.com must terminate HTTPS using an existing certificate and key. What must be in place?

  1. AAn Opaque Secret mounted into the backend Pods at /etc/tls on port 443
  2. BA kubernetes.io/tls Secret in the Ingress namespace, referenced under spec.tls Correct answer
  3. CA kubernetes.io/tls Secret in kube-system, referenced by its annotation
  4. DA ConfigMap with tls.crt and tls.key, referenced under spec.rules.http

Answer and explanation: Ingress TLS uses spec.tls with the host list and a secretName pointing to a TLS Secret holding tls.crt and tls.key in the same namespace as the Ingress. ConfigMaps are not used for certificates and the rules section does not reference them. A Secret in another namespace cannot be referenced by spec.tls. Mounting a certificate into backend Pods terminates TLS in the app, not at the Ingress.