# Free CKAD practice questions

> 10 free CKAD practice questions with the correct answer and an explanation.

Page: https://devopscodelab.com/exams/ckad/free-practice-questions/
Practice exams: https://devopscodelab.com/exams/ckad/

### Question 1 of 10

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?

- A. In containers with a startupProbe that waits for it
- B. As an ephemeral container added via kubectl debug
- C. In initContainers with no restartPolicy field set
- D. In initContainers with restartPolicy: Always

**Answer:** D

**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

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?

- A. completions: 12, parallelism: 3, completionMode: Indexed
- B. completions: 3, parallelism: 12, completionMode: NonIndexed
- C. completions: 12, parallelism: 12, and restartPolicy: Always
- D. parallelism: 3, backoffLimit: 12, no completions set

**Answer:** A

**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

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

- A. Switch the Service selector back to version=blue
- B. helm rollback shop 1 for the green release
- C. kubectl rollout undo deployment/app-green
- D. Scale app-green to zero and wait for blue to take over

**Answer:** A

**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

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?

- A. Add a label revision-reason to the Pod template
- B. Set the kubernetes.io/change-cause annotation on the Deployment
- C. Run kubectl rollout history with the --record=true flag afterwards
- D. Write the reason into the Deployment's spec.revisionHistoryLimit

**Answer:** B

**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

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

- A. Convert the CronJob into a Job with a schedule field set
- B. Change apiVersion to batch/v1, the served version for CronJob
- C. Enable the batch/v1beta1 API with a feature gate on kubectl
- D. Add the --validate=false flag so the apply is not checked

**Answer:** B

**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

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?

- A. Run helm upgrade with --force so Helm skips comparing against the previous release manifest
- B. Delete the Deployment objects by hand so the release has nothing left to compare against
- C. Downgrade kubectl to a version that still knows the removed API, then run the upgrade again
- D. Rewrite the removed APIs in the stored release record (helm mapkubeapis), then upgrade

**Answer:** D

**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

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

- A. Authentication, mutating admission, authorization, validating admission, then persistence
- B. Authorization, authentication, validating admission, mutating admission, then persistence
- C. Authentication, authorization, validating admission, persistence, and then mutating admission
- D. Authentication, authorization, mutating admission, validating admission, then persistence

**Answer:** D

**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

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?

- A. fsGroup set to a non-zero group and an explicit runAsGroup value
- B. seccompProfile type RuntimeDefault and allowPrivilegeEscalation: false
- C. hostNetwork: true with automountServiceAccountToken disabled
- D. readOnlyRootFilesystem: true and a memory limit for the container

**Answer:** B

**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

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?

- A. An ingress rule allowing UDP port 53 from all Pods in namespace kube-system
- B. An egress rule allowing all ports to the namespace payments with a podSelector {}
- C. An egress rule allowing UDP and TCP port 53 to the kube-dns Pods in kube-system
- D. Removing Egress from policyTypes so that only ingress traffic is filtered

**Answer:** C

**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

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

- A. An Opaque Secret mounted into the backend Pods at /etc/tls on port 443
- B. A kubernetes.io/tls Secret in the Ingress namespace, referenced under spec.tls
- C. A kubernetes.io/tls Secret in kube-system, referenced by its annotation
- D. A ConfigMap with tls.crt and tls.key, referenced under spec.rules.http

**Answer:** B

**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.

Ready for a timed run? Take the free 15-question CKAD mini exam: https://devopscodelab.com/app/exams/ckad/mini/

DevOpsCode Lab is not affiliated with CNCF. CKAD and related names are trademarks of their owners. We write every question ourselves; these are not real exam questions.
