CKA Practice Exam 1

49 questions with the correct answer and an explanation for each. Topic: Kubernetes Administration. Free, no account needed.

Take this test interactively

1. A ClusterRole `node-viewer` must give `dev-sa` in `exercise-04` permission to list nodes cluster-wide. Which command creates the correct binding?

  1. `kubectl create rolebinding dev-node-access --clusterrole=node-viewer --serviceaccount=exercise-04:dev-sa -n exercise-04`
  2. `kubectl create clusterrolebinding dev-node-access --clusterrole=node-viewer --serviceaccount=exercise-04:dev-sa`
  3. `kubectl create clusterrolebinding dev-node-access --clusterrole=nodes --serviceaccount=exercise-04:dev-sa`
  4. `kubectl create clusterrolebinding dev-node-access --role=node-viewer --serviceaccount=dev-sa`

Answer: B — `kubectl create clusterrolebinding dev-node-access --clusterrole=node-viewer --serviceaccount=exercise-04:dev-sa`

A ClusterRoleBinding grants the ClusterRole cluster-wide to the ServiceAccount.

2. A Role named `pod-manager` in `exercise-04` must allow get, list, watch, create, and delete on pods. Which command creates exactly that rule?

  1. `kubectl create role pod-manager --verb=get,list,watch --resource=pods,pods/log -n exercise-04`
  2. `kubectl create role pod-manager --verb=get,list,watch,create,delete --resource=pods -n exercise-04`
  3. `kubectl create clusterrole pod-manager --verb=get,list,watch,create,delete --resource=pods -n exercise-04`
  4. `kubectl create role pod-manager --verb=get,list,watch,create,delete --resource=deployments -n exercise-04`

Answer: B — `kubectl create role pod-manager --verb=get,list,watch,create,delete --resource=pods -n exercise-04`

The Role needs get, list, watch, create and delete on pods in the namespace.

3. An administrator must fix the `payments` Service selector to `app=payments` without changing the Deployment. Which command does that?

  1. `k label deployment payments app=payments -n exercise-32`
  2. `k expose deployment payments --name=payments --port=80 --target-port=80 -n exercise-32`
  3. `k patch service payments -n exercise-32 --type=merge -p '{"spec":{"selector":{"app":"payments"}}}'`
  4. `k edit deployment payments -n exercise-32`

Answer: C — `k patch service payments -n exercise-32 --type=merge -p '{"spec":{"selector":{"app":"payments"}}}'`

Patching the Service's selector changes only the Service, leaving the Deployment and its Pod labels untouched.

4. A container keeps restarting, but `k logs <pod>` returns nothing at all. What does that suggest?

  1. The process exits immediately, so check whether the image defines a `CMD` or `ENTRYPOINT`
  2. The container is being killed for using too much memory
  3. The kubelet service on the node has stopped
  4. The image could not be pulled

Answer: A — The process exits immediately, so check whether the image defines a `CMD` or `ENTRYPOINT`

Empty output points to a process that exits immediately, which sends the investigation to the image's `CMD` or `ENTRYPOINT`.

5. A ServiceAccount in namespace `dev` needs to get and list Pods. Which pair of commands grants exactly that access?

  1. `k create role pod-reader --verb=get,list --resource=pods -n dev` and `k create rolebinding pod-read --role=pod-reader --user=dev:<sa> -n dev`
  2. `k create role pod-reader --verb=get,list --resource=pods -n dev` and `k create clusterrolebinding pod-read --clusterrole=pod-reader --serviceaccount=dev:<sa>`
  3. `k create role pod-reader --verb=get,list --resource=pods -n dev` and `k create rolebinding pod-read --role=pod-reader --serviceaccount=dev:<sa> -n dev`
  4. `k create role pod-reader --verb=get,list --resource=deployments -n dev` and `k create rolebinding pod-read --role=pod-reader --serviceaccount=dev:<sa> -n dev`

Answer: C — `k create role pod-reader --verb=get,list --resource=pods -n dev` and `k create rolebinding pod-read --role=pod-reader --serviceaccount=dev:<sa> -n dev`

The Role grants get and list on Pods, and the RoleBinding attaches that Role to the ServiceAccount in the same namespace.

6. An administrator is upgrading the control-plane node and has already installed the target kubeadm package and run `kubeadm upgrade plan`. Which command applies the upgrade?

  1. `sudo kubeadm upgrade node`
  2. `sudo kubeadm upgrade apply <target-version>`
  3. `sudo kubeadm upgrade plan --apply`
  4. `sudo kubeadm init --upgrade`

Answer: B — `sudo kubeadm upgrade apply <target-version>`

`kubeadm upgrade apply` upgrades the control plane.

7. A release has four revisions, and the administrator must return specifically to revision 2. Which command does that?

  1. `helm rollback web -n exercise-13`
  2. `helm rollback web 2 -n exercise-13`
  3. `helm history web 2 -n exercise-13`
  4. `helm upgrade web 2 -n exercise-13`

Answer: B — `helm rollback web 2 -n exercise-13`

`helm rollback web 2` returns specifically to revision 2.

8. A PVC reports `Bound`, but no Pod has used it yet. Which step actually proves the storage is usable?

  1. Confirm the claim request is below the PV capacity.
  2. Create a Pod, confirm it reaches `Running`, and write and read a file.
  3. Confirm the PV is `Available`.
  4. Confirm the StorageClass exists.

Answer: B — Create a Pod, confirm it reaches `Running`, and write and read a file.

A Bound claim only proves binding; a Running consumer Pod with a successful write and read proves the storage actually works.

9. An administrator cannot find any audit log file on the control plane. What should be checked before searching further?

  1. Whether `jq` is installed on the control-plane node
  2. Whether the control-plane node has run out of disk space
  3. Whether the kubelet service is active on the control-plane node
  4. Whether the API server was started with audit flags

Answer: D — Whether the API server was started with audit flags

Audit logging must be enabled on the API server, so its absence may simply mean the audit flags were never set.

10. A Deployment has several revisions. An administrator wants to return to revision 2 specifically. Which command does that?

  1. `kubectl rollout undo deployment/<name>`
  2. `kubectl rollout status deployment/<name> --revision=2`
  3. `kubectl rollout history deployment/<name> --revision=2`
  4. `kubectl rollout undo deployment/<name> --to-revision=2`

Answer: D — `kubectl rollout undo deployment/<name> --to-revision=2`

`--to-revision=2` selects the exact revision to restore; a plain `rollout undo` defaults to the previous revision.

11. A pod manifest sets `priorityClassName: high-priority`, but that PriorityClass was never created. What happens when the pod is applied?

  1. The pod is rejected by the API server
  2. The scheduler preempts lower-priority pods so it can run anyway
  3. The pod is created but stays Pending, with no creation error
  4. The pod runs with priority 0

Answer: C — The pod is created but stays Pending, with no creation error

A missing PriorityClass does not block pod creation; the pod is created but cannot be scheduled.

12. An administrator needs a debug container that shares the process namespace of the `broken-app` container in Pod `broken-app`, so `ps aux` shows the nginx process. Which command achieves this?

  1. `k debug node/broken-app -it --image=busybox:1.36`
  2. `k debug broken-app -it --image=busybox:1.36`
  3. `k exec broken-app -it --image=busybox:1.36 -- ps aux`
  4. `k debug broken-app -it --image=busybox:1.36 --target=broken-app`

Answer: D — `k debug broken-app -it --image=busybox:1.36 --target=broken-app`

The `--target` flag shares the process namespace with the chosen container, which is what makes the nginx processes visible.

13. A Deployment's history shows revision 2 as current. `k rollout undo deployment/webapp` completes. Which revision does the history now show as newest?

  1. 3
  2. 2
  3. 1
  4. 4

Answer: A — 3

Undo writes a new revision with the old spec, so the counter advances to 3.

14. Which `apiVersion` is used for a classic Ingress resource?

  1. `networking.k8s.io/v1`
  2. `networking.k8s.io/v1beta1`
  3. `extensions/v1beta1`
  4. `v1`

Answer: A — `networking.k8s.io/v1`

The classic Ingress examples use the `networking.k8s.io/v1` API.

15. A pod is stuck in `CreateContainerConfigError` after its manifest references a ConfigMap. What should be checked first?

  1. Whether the image pull policy is `Always`
  2. Whether the Service selector matches the pod labels
  3. Whether the referenced ConfigMap exists
  4. Whether the pod has a CPU request set

Answer: C — Whether the referenced ConfigMap exists

A missing or misspelled ConfigMap name produces `CreateContainerConfigError`, and the pod events name the missing object.

16. A Service must send traffic to the container port named `web` in the `catalog` Pods. Which Service field should be set to `web`?

  1. `nodePort`
  2. `targetPort`
  3. `port`
  4. `name`

Answer: B — `targetPort`

`targetPort` can reference the named container port, so `targetPort: web` resolves to that port.

17. After correcting the API server manifest, the static Pod does not restart within 10 seconds. What should be tried next?

  1. Run `kubectl delete pod kube-apiserver-<node> -n kube-system`
  2. Restart etcd on every worker node
  3. Delete and recreate the PersistentVolumeClaim
  4. Run `sudo systemctl restart kubelet` on the control plane node

Answer: D — Run `sudo systemctl restart kubelet` on the control plane node

A kubelet file-watching race can delay the restart, and restarting kubelet on the control plane forces it to reload the manifest.

18. An egress NetworkPolicy is blocking DNS lookups from selected pods. Which egress rule restores DNS while allowing it to any destination?

  1. `to: []` with `ports: [{protocol: TCP, port: 53}]`
  2. `to: []` with `ports: [{protocol: UDP, port: 53}]`
  3. `to: []` with `ports: [{protocol: UDP, port: 5353}]`
  4. `from: []` with `ports: [{protocol: UDP, port: 53}]`

Answer: B — `to: []` with `ports: [{protocol: UDP, port: 53}]`

DNS egress is allowed with `to: []` and UDP port 53.

19. A PVC is not binding to the intended PV. Which two fields must match between them?

  1. `namespace` and `nodeName`
  2. `capacity` and `mountPath`
  3. `storageClassName` and `accessModes`
  4. `volumeName` and `reclaimPolicy`

Answer: C — `storageClassName` and `accessModes`

A PVC must match the PV's `storageClassName` and `accessModes`.

20. From the `netcheck` Pod, which command tests name resolution for the Service's fully qualified name?

  1. `k get svc payments -n exercise-32`
  2. `k logs netcheck -n exercise-32`
  3. `k exec netcheck -n exercise-32 -- nslookup payments.exercise-32.svc.cluster.local`
  4. `k exec netcheck -n exercise-32 -- wget -qO- -T 3 http://payments.exercise-32.svc.cluster.local`

Answer: C — `k exec netcheck -n exercise-32 -- nslookup payments.exercise-32.svc.cluster.local`

`nslookup` inside the test Pod resolves the fully qualified Service name through cluster DNS.

21. A Deployment's containers listen on port 8080. Users must reach it through a Service on port 80, and the Service must be reachable on each node's IP. Which command creates it?

  1. `kubectl expose deployment app --port=80 --target-port=8080 --type=LoadBalancer`
  2. `kubectl expose deployment app --port=8080 --target-port=80 --type=NodePort`
  3. `kubectl expose deployment app --port=80 --target-port=8080 --type=NodePort`
  4. `kubectl expose deployment app --port=80 --target-port=8080 --type=ClusterIP`

Answer: C — `kubectl expose deployment app --port=80 --target-port=8080 --type=NodePort`

`--port` is the Service port and `--target-port` is the container port; `--type=NodePort` exposes it on each node's IP.

22. On a node, an administrator wants to confirm that kube-proxy has programmed iptables rules. Which command does that?

  1. `sudo iptables-save | grep -c KUBE`
  2. `sudo systemctl status kubelet`
  3. `k get configmap kube-proxy -n kube-system -o yaml`
  4. `k logs -n kube-system -l k8s-app=kube-proxy`

Answer: A — `sudo iptables-save | grep -c KUBE`

Counting `KUBE` entries in the saved iptables rules shows whether kube-proxy has written its rules on that node.

23. A worker node's packages are updated and the node is drained. Which kubeadm command upgrades that worker's node configuration?

  1. `sudo kubeadm upgrade apply <target-version>`
  2. `sudo kubeadm join --upgrade`
  3. `sudo kubeadm upgrade node`
  4. `sudo kubeadm upgrade plan`

Answer: C — `sudo kubeadm upgrade node`

Workers use `kubeadm upgrade node`, not `kubeadm upgrade apply`.

24. Load against an HPA-managed Deployment stops, but the replica count stays high for several minutes. Why?

  1. The HPA target uses `type: AverageValue`, which cannot be computed for CPU
  2. The HPA deliberately delays scale-down about five minutes to avoid flapping
  3. The Deployment lacks `resources.requests.cpu`, so the HPA cannot compute utilization
  4. The metrics-server is missing, so the HPA cannot observe that load dropped

Answer: B — The HPA deliberately delays scale-down about five minutes to avoid flapping

HPA scale-down is intentionally delayed about five minutes after load drops to prevent flapping.

25. A Role grants `resources: ["*"]` and `verbs: ["*"]`, yet a user still cannot read pod logs or exec into pods. What explains this?

  1. Wildcards do not cover subresources; `pods/log` and `pods/exec` must be granted explicitly.
  2. The wildcard only covers core API resources, so pods are excluded.
  3. The RoleBinding must be a ClusterRoleBinding before subresources work.
  4. `verbs: ["*"]` covers reads but never writes such as exec.

Answer: A — Wildcards do not cover subresources; `pods/log` and `pods/exec` must be granted explicitly.

Wildcards do not cover subresources; `pods/log` and `pods/exec` need explicit grants.

26. A consumer Pod has been Pending for several minutes, yet `kubectl get pvc` shows its claim is Bound. Which is a likely cause?

  1. The StorageClass binding mode is `WaitForFirstConsumer`.
  2. The PV capacity is greater than the PVC request.
  3. The hostPath directory is missing on the node, or the Pod landed on a node without it.
  4. The PV reclaim policy is `Retain`.

Answer: C — The hostPath directory is missing on the node, or the Pod landed on a node without it.

With the claim already Bound, the remaining common cause is the node-side directory or placement; the Pod needs a node that has the backing path.

27. Which command runs a temporary BusyBox Pod in namespace `catalog-lab` to request `catalog-svc` on port 80?

  1. `kubectl exec catalog -n catalog-lab -- wget -qO- -T 3 http://catalog-svc:80`
  2. `kubectl port-forward svc/catalog-svc -n catalog-lab 30080:80`
  3. `kubectl run catalog-check -n catalog-lab --rm -i --restart=Never --image=busybox:1.36 -- wget -qO- -T 3 http://catalog-svc:80`
  4. `kubectl run catalog-check -n catalog-lab --rm -i --restart=Never --image=busybox:1.36 -- nslookup catalog-svc`

Answer: C — `kubectl run catalog-check -n catalog-lab --rm -i --restart=Never --image=busybox:1.36 -- wget -qO- -T 3 http://catalog-svc:80`

The temporary Pod runs `wget` against the Service on port 80 and is removed after the command.

28. A Deployment named `critical-app` was created without a priority class. Which patch adds `high-priority` to the Deployment's pod template?

  1. `{"spec":{"template":{"metadata":{"priorityClassName":"high-priority"}}}}`
  2. `{"metadata":{"priorityClassName":"high-priority"}}`
  3. `{"spec":{"priorityClassName":"high-priority"}}`
  4. `{"spec":{"template":{"spec":{"priorityClassName":"high-priority"}}}}`

Answer: D — `{"spec":{"template":{"spec":{"priorityClassName":"high-priority"}}}}`

`priorityClassName` belongs in the pod template at `spec.template.spec`, not at the Deployment's `spec`.

29. Audit events are stored as JSON, and the administrator wants to isolate delete operations. Which approach fits?

  1. Run `grep "error"` on the audit file
  2. Pipe the audit file through `jq` with `select(.stage=="ResponseComplete")`
  3. Pipe the audit file through `jq` with `select(.user.username=="delete")`
  4. Pipe the audit file through `jq` with `select(.verb=="delete")`

Answer: D — Pipe the audit file through `jq` with `select(.verb=="delete")`

The audit log is JSON, so filtering on the `verb` field with `jq` isolates delete operations.

30. The `payments` Service selects `app=payment`, but its Pods are labeled `app=payments`. The Deployment must not be changed. What fix restores endpoints?

  1. Change the Service `targetPort` to 8080.
  2. Patch the Service selector to `app=payments`.
  3. Delete the EndpointSlices.
  4. Patch the Deployment Pod template to `app=payment`.

Answer: B — Patch the Service selector to `app=payments`.

Changing the Service selector to match the existing Pod labels restores the endpoint set without touching the Deployment.

31. A Service of type NodePort must use an externally reachable port. Which port range is valid?

  1. `1-32767`
  2. `30000-32767`
  3. `1024-65535`
  4. `8000-9000`

Answer: B — `30000-32767`

NodePort services use ports in the 30000-32767 range.

32. An HPA for CPU shows `<unknown>` metrics because its resource metric uses `target.type: AverageValue`. Which target type should it use instead?

  1. `type: ContainerResource`
  2. `type: AverageValue`
  3. `type: Value`
  4. `type: Utilization`

Answer: D — `type: Utilization`

CPU utilization targets use `type: Utilization` with `averageUtilization`.

33. Which command checks whether `web-gateway` in namespace `gateway-lab` reports `Programmed: True`?

  1. `kubectl get gatewayclass -o yaml`
  2. `kubectl get gateway web-gateway -n gateway-lab -o yaml`
  3. `kubectl get httproute web-route -n gateway-lab`
  4. `kubectl describe svc web-svc -n gateway-lab`

Answer: B — `kubectl get gateway web-gateway -n gateway-lab -o yaml`

The Gateway's status conditions, including `Programmed`, are inspected from the Gateway object itself.

34. Which storage resource is cluster-scoped and therefore must be created without a namespace?

  1. Pod
  2. Deployment
  3. PersistentVolume
  4. PersistentVolumeClaim

Answer: C — PersistentVolume

PVs are cluster-scoped and have no namespace, while PVCs are namespace-scoped.

35. Pods are Pending with an `Insufficient memory` event. Which command shows a node's allocatable memory and what is already allocated?

  1. `k describe node <node-name>`
  2. `k get events --sort-by=.lastTimestamp`
  3. `k describe pod <pod-name>`
  4. `k top pods -n exercise-23`

Answer: A — `k describe node <node-name>`

`k describe node` reports both Allocatable and the resources already allocated to pods.

36. A cluster has no kube-proxy Pods, yet Services work correctly. What is the best conclusion?

  1. kube-proxy must be reinstalled before any Service can work
  2. CoreDNS is masking the missing kube-proxy
  3. The API server has the wrong etcd endpoint
  4. The cluster may use an eBPF-based data plane that replaces kube-proxy, so its absence is not necessarily a failure

Answer: D — The cluster may use an eBPF-based data plane that replaces kube-proxy, so its absence is not necessarily a failure

Some data planes replace kube-proxy entirely, so its absence is only a fault if the cluster is actually expected to run it.

37. A PV uses the `Delete` reclaim policy. What happens to that PV and its data when its PVC is removed?

  1. The PV becomes `Available` and its data remains.
  2. The PV and its data are automatically deleted.
  3. The PV remains `Bound` until manually cleared.
  4. The PV becomes `Released` and its data remains.

Answer: B — The PV and its data are automatically deleted.

The Delete policy removes the PV and destroys its data when the PVC is deleted.

38. A NodePort Service for `catalog-svc` sets `port: 80`, `targetPort: web`, and `nodePort: 30080`. Which port is exposed on each node?

  1. 8080
  2. 80
  3. the container port number only
  4. 30080

Answer: D — 30080

`nodePort` is the node-facing port; `port` is the cluster Service port.

39. Pods cannot communicate at all, even after all NetworkPolicies in the namespace are deleted. Where should troubleshooting start?

  1. Rewrite the ingress selectors.
  2. Change the Service type to NodePort.
  3. Add a DNS egress rule.
  4. Check the CNI plugin and node routing.

Answer: D — Check the CNI plugin and node routing.

Once policies are removed, a total connectivity failure points to the CNI or routing layer rather than NetworkPolicy.

40. An administrator needs the etcd certificate paths for a snapshot command but has not memorized them. Where are the paths found on the control-plane node?

  1. In the etcd static Pod manifest.
  2. In the kubelet configuration file.
  3. In the kube-proxy ConfigMap.
  4. In the CoreDNS Deployment.

Answer: A — In the etcd static Pod manifest.

The certificate paths are in the etcd static Pod manifest, so grep them there rather than memorizing them.

41. An administrator edits the API server's static Pod manifest with `kubectl apply`, but nothing changes. What is the correct approach?

  1. Recreate the cluster with kubeadm
  2. Delete the API server Pod and wait for the Deployment to recreate it
  3. Edit the manifest in place under `/etc/kubernetes/manifests/`; the kubelet watches the directory and restarts the Pod
  4. Run `kubectl rollout restart pod kube-apiserver-<node>`

Answer: C — Edit the manifest in place under `/etc/kubernetes/manifests/`; the kubelet watches the directory and restarts the Pod

Static Pods are controlled by the kubelet watching the manifest directory, not by `kubectl apply`.

42. Which command starts an interactive debug container on node `node-1` with the host filesystem available?

  1. `k debug pod/node-1 -it --image=busybox:1.36`
  2. `k debug node/node-1 -it --image=busybox:1.36`
  3. `k exec node/node-1 -it --image=busybox:1.36`
  4. `k debug node-1 -it --image=busybox:1.36 --target=node-1`

Answer: B — `k debug node/node-1 -it --image=busybox:1.36`

Node debugging uses the `node/<node-name>` target and mounts the host filesystem at `/host`.

43. Why use a named container port as a Service's `targetPort`?

  1. The name stays stable when the container's numeric port changes.
  2. It enables DNS resolution for the Service.
  3. It assigns a fixed NodePort automatically.
  4. It lets the Service select Pods by port name instead of labels.

Answer: A — The name stays stable when the container's numeric port changes.

A named target port remains valid when the container port number changes, as long as the name stays the same.

44. A request from a frontend Pod to a backend Service worked before a policy was applied but now hangs until timeout. The only change was applying the policy, and the backend container is listening on the expected port. What does the timeout most likely indicate?

  1. DNS is returning the wrong IP.
  2. The backend is refusing connections with RST.
  3. The NetworkPolicy is dropping packets.
  4. The Service selector is wrong.

Answer: C — The NetworkPolicy is dropping packets.

A hang with no response is the signature of packets being dropped by policy; a refusal would return RST instead.

45. A PVC has been Pending for ten minutes. Capacity and access modes match, but the PV specifies `storageClassName: manual` while the PVC specifies `standard`. What happens?

  1. The PVC's events report an error naming the mismatched class.
  2. The PVC stays Pending with no error message.
  3. The PVC binds after the controller reconciles.
  4. The PVC binds, because capacity and access modes already match.

Answer: B — The PVC stays Pending with no error message.

A mismatch in `storageClassName` prevents binding entirely and produces no helpful error, leaving the PVC Pending indefinitely.

46. After patching a Deployment to use `high-priority`, which `jsonpath` confirms the value on the pod template?

  1. `{.spec.template.spec.priorityClassName}`
  2. `{.metadata.priorityClassName}`
  3. `{.status.priorityClassName}`
  4. `{.spec.priorityClassName}`

Answer: A — `{.spec.template.spec.priorityClassName}`

The pod template path is `spec.template.spec.priorityClassName`.

47. A `targetPort` experiment left the `payments` Service forwarding to port 8080, where nothing listens. What restores HTTP access?

  1. Set the Service `port` to `8080`
  2. Change the selector to `app=payment`
  3. Delete the EndpointSlice
  4. Set `targetPort` back to `80`

Answer: D — Set `targetPort` back to `80`

The container listens on port 80, so restoring the Service's target port to 80 makes HTTP requests reach the application again.

48. An Ingress rule uses path `/api`. Requests to `/api/v1/users` must match. Which `pathType` should the rule use?

  1. `ImplementationSpecific`
  2. `Prefix`
  3. `Exact`
  4. `Regex`

Answer: B — `Prefix`

`Prefix` matches any request path that starts with the rule path, so `/api` also matches `/api/v1/users`.

49. An HPA reports `<unknown>/XX%` for its target. What is the likely cause and fix?

  1. The Pod has no `resources.requests`; add `resources.requests.cpu` to the Deployment
  2. The metrics-server Pod is Pending; fix its scheduling first
  3. metrics-server is missing; reinstall it with `init-cluster.sh`
  4. The metrics are still accumulating; wait 90 seconds and check the HPA again

Answer: A — The Pod has no `resources.requests`; add `resources.requests.cpu` to the Deployment

The HPA cannot compute a utilization percentage without a resource request, so adding the CPU request fixes the unknown metric.

Take this test interactively

More Certified Kubernetes Administrator (CKA) practice tests