CKA Practice Exam 2
48 questions with the correct answer and an explanation for each.
Topic: Kubernetes Administration. Free, no account needed.
Take this test interactively
1. A cluster uses flannel. NetworkPolicies are created, but disallowed traffic still flows. What explains this?
- Flannel does not enforce NetworkPolicy.
- The policies need `policyTypes: [Ingress, Egress]`.
- CoreDNS must be labeled `name=coredns`.
- Flannel requires `endPort`.
Answer: A — Flannel does not enforce NetworkPolicy.
Flannel is listed among the non-enforcing CNIs, so the policy objects exist but traffic is not blocked.
2. Before answering a task, an administrator notices the terminal is pointed at the wrong cluster. Which command switches to the correct context?
- `kubectl config set-context --current --namespace=<ns>`
- `kubectl config use-context <name>`
- `kubectl cluster-info`
- `kubectl config current-context`
Answer: B — `kubectl config use-context <name>`
`kubectl config use-context <name>` switches the active context and should be done before reading the task.
3. An administrator deletes a PVC. The bound PV uses `persistentVolumeReclaimPolicy: Retain`. What status does the PV enter?
- `Released`
- `Available`
- `Bound`
- `Failed`
Answer: A — `Released`
Retain releases the PV when the claim is deleted but leaves the data; the PV status becomes Released.
4. Which command tests HTTP access to the `payments` Service from the existing `netcheck` Pod in namespace `service-lab`?
- `kubectl exec netcheck -n service-lab -- wget -qO- -T 3 http://payments.service-lab.svc.cluster.local`
- `kubectl exec payments -n service-lab -- wget -qO- -T 3 http://netcheck`
- `kubectl port-forward svc/payments -n service-lab 80:80`
- `kubectl run netcheck -n service-lab --image=busybox:1.36 -- nslookup payments`
Answer: A — `kubectl exec netcheck -n service-lab -- wget -qO- -T 3 http://payments.service-lab.svc.cluster.local`
The command executes `wget` inside `netcheck` against the Service's cluster DNS name.
5. Which command creates an Ingress named `app-ingress` in namespace `ingress-lab` that routes the `/` prefix to `web-service:80` and the `/api` prefix to `api-service:8080` using the `nginx` class?
- `kubectl create ingress app-ingress -n ingress-lab --rule='/*=web-service:80' --rule='/api/*=api-service:8080' --class=traefik`
- `kubectl create ingress app-ingress -n ingress-lab --rule='/=web-service:80' --rule='/api=api-service:8080' --class=nginx`
- `kubectl create ingress app-ingress -n ingress-lab --rule='/*=web-service:80' --rule='/api/*=api-service:8080'`
- `kubectl create ingress app-ingress -n ingress-lab --rule='/*=web-service:80' --rule='/api/*=api-service:8080' --class=nginx`
Answer: D — `kubectl create ingress app-ingress -n ingress-lab --rule='/*=web-service:80' --rule='/api/*=api-service:8080' --class=nginx`
The two `--rule` values map the root and `/api` paths to their Services, and `--class=nginx` selects the IngressClass.
6. A candidate wants to generate a Deployment manifest for editing without creating the object. Which exported value produces client-side YAML?
- `export do='--dry-run=client -o yaml'`
- `export do='--dry-run=server -o yaml'`
- `export do='--force --grace-period=0'`
- `export do='--validate=false -o json'`
Answer: A — `export do='--dry-run=client -o yaml'`
`$do` expands to `--dry-run=client -o yaml`, which generates the manifest locally instead of creating the object.
7. A pod in namespace `dev` needs the fully qualified name of Service `api` in namespace `prod`. Which name is correct?
- `api.prod.cluster.local`
- `prod.api.svc.cluster.local`
- `api.prod.svc.cluster.local`
- `api.dev.svc.cluster.local`
Answer: C — `api.prod.svc.cluster.local`
The DNS name format is `<service>.<namespace>.svc.cluster.local`.
8. A user can get and list Deployments but `kubectl scale deployment` is denied. Which rule grants only the missing permission?
- `verbs: ["patch"]` with `resources: ["deployments"]`
- `verbs: ["get", "list"]` with `resources: ["deployments/scale"]`
- `verbs: ["patch"]` with `resources: ["deployments/scale"]`
- `verbs: ["update"]` with `resources: ["deployments"]`
Answer: C — `verbs: ["patch"]` with `resources: ["deployments/scale"]`
Scaling a Deployment requires `patch` on the `deployments/scale` subresource.
9. An administrator needs to find which file the API server writes audit events to. Where is that configured?
- In `/etc/kubernetes/manifests/etcd.yaml`, on the `--listen-client-urls` flag
- In `/etc/kubernetes/kubelet.conf`, under an audit section
- In the kubelet's systemd unit, on an `--audit-log-path` flag
- In `/etc/kubernetes/manifests/kube-apiserver.yaml`, on the `--audit-log-path` flag
Answer: D — In `/etc/kubernetes/manifests/kube-apiserver.yaml`, on the `--audit-log-path` flag
The API server manifest carries the audit flags, including `--audit-log-path`, which sets where events are written.
10. A Deployment named `payments` already exists, and an administrator needs a ClusterIP Service that forwards port 80 to container port 80. Which command creates it?
- `k expose deployment payments --name=payments --port=80 --target-port=80`
- `k expose pod payments --name=payments --port=80`
- `k patch service payments --type=merge -p '{"spec":{"ports":[{"port":80}]}}'`
- `k create service clusterip payments --tcp=80:8080`
Answer: A — `k expose deployment payments --name=payments --port=80 --target-port=80`
Exposing the Deployment creates a Service whose port 80 forwards to the container's target port 80.
11. An administrator must change only the container image in a running Deployment and avoid touching the rest of the container list. Which command is the safer choice?
- `kubectl edit deployment <name>`
- `kubectl set image deployment/<name> <container>=<image>`
- `kubectl replace -f deployment.yaml`
- `kubectl patch deployment <name> --patch '{"spec":{"template":{"spec":{"containers":[{"image":"<image>"}]}}}}'`
Answer: B — `kubectl set image deployment/<name> <container>=<image>`
For image-only updates, `k set image` is usually safer than patching the entire `containers` list.
12. A Role and RoleBinding look correct, but `kubectl auth can-i` returns `no` for the ServiceAccount. The administrator never created that ServiceAccount. What is the cause?
- The RoleBinding is cluster-scoped.
- The ServiceAccount does not exist.
- The `--as` flag cannot test ServiceAccounts.
- The Role verbs are wrong.
Answer: B — The ServiceAccount does not exist.
The ServiceAccount did not exist, so the binding had nothing to grant permissions to.
13. A worker node is `NotReady`. Which sequence best finds the root cause?
- SSH to the node, run `systemctl status kubelet` and `journalctl -u kubelet --no-pager -l | tail -30`
- Run `k get pods -n kube-system`, then restart CoreDNS
- Run `k describe node` on the control plane, then `k top nodes`
- Run `k get events -A`, then delete the node
Answer: A — SSH to the node, run `systemctl status kubelet` and `journalctl -u kubelet --no-pager -l | tail -30`
Checking the kubelet service and its logs on the affected node exposes the failure that put the node in `NotReady`.
14. Where is the `kubernetes.io/change-cause` annotation stored when tracking Deployment revisions?
- On the namespace
- On each Pod
- On the Deployment object itself
- On each ReplicaSet
Answer: C — On the Deployment object itself
The annotation is placed on the Deployment itself, not on individual revisions.
15. `kubectl top` reports that metrics are unavailable immediately after a new Pod starts, although metrics-server is Running. What should the administrator do?
- Reinstall metrics-server
- Wait about 90 seconds and retry
- Add `resources.requests.cpu` to the Pod's Deployment
- Restart the metrics-server Deployment in `kube-system`
Answer: B — Wait about 90 seconds and retry
Metrics need time to accumulate, so a new Pod will not appear in `kubectl top` until after the initial wait.
16. A container exits with code `0` even though it is meant to keep running. What should be changed?
- Fix file permissions in the image
- Increase the memory limit
- Fix the command's arguments in the YAML
- Fix the entrypoint or add an infinite loop
Answer: D — Fix the entrypoint or add an infinite loop
Exit code 0 means the process completed when it was not supposed to, so the entrypoint must be corrected or made to keep running.
17. A namespace must deny all ingress traffic to every pod by default. Which policy achieves that?
- `namespaceSelector: {}` with `policyTypes: [Ingress]`
- `podSelector: {}` with `policyTypes: [Egress]`
- `podSelector: {matchLabels: {app: none}}` with `policyTypes: [Ingress]`
- `podSelector: {}` with `policyTypes: [Ingress]`
Answer: D — `podSelector: {}` with `policyTypes: [Ingress]`
An empty `podSelector` selects all pods, and `policyTypes: [Ingress]` denies ingress.
18. A Pod named `netcheck` in namespace `service-lab` must resolve the `payments` Service by its fully qualified cluster DNS name. Which name is correct?
- `payments.svc.service-lab.cluster.local`
- `payments.service-lab.cluster.local.svc`
- `payments.default.svc.cluster.local`
- `payments.service-lab.svc.cluster.local`
Answer: D — `payments.service-lab.svc.cluster.local`
The Service DNS name is the Service name, namespace, `svc`, and `cluster.local` in that order.
19. A StatefulSet named `mysql` with three replicas is scaled to two. Which pod is removed?
- `mysql-2`
- `mysql-1`
- A randomly selected pod
- `mysql-0`
Answer: A — `mysql-2`
StatefulSet scale-down terminates pods in reverse ordinal order, starting with the highest ordinal.
20. A static pod manifest was placed in `/etc/kubernetes/manifests/`, but no static pod appears. What should be checked first?
- Whether the kubelet needs several minutes to scan for new manifests
- The `staticPodPath` in the kubelet configuration
- Whether `kubectl delete pod` was run against the static pod
- The commented-out flags at the top of the kubelet config file
Answer: B — The `staticPodPath` in the kubelet configuration
The kubelet only scans its configured `staticPodPath`, so a manifest in the wrong directory is ignored.
21. A Pod has two containers, `app` and `sidecar`, and the failure is in `sidecar`. A debug container was started with `--target=app`. Why can't the broken process be seen?
- The node is under disk pressure
- `--target` selects only one container, and it points at the wrong one
- The debug image lacks `ps`
- The debug container needs `chroot /host` before other containers' processes become visible
Answer: B — `--target` selects only one container, and it points at the wrong one
`--target` chooses a single container to share with, so targeting `app` hides the processes of `sidecar`.
22. A pod must reserve 100m CPU when the scheduler places it but may use up to 250m while running. Which manifest settings express this?
- `requests.cpu: 250m` and `limits.cpu: 250m`
- `requests.cpu: 100m` and `limits.cpu: 100m`
- `limits.cpu: 250m` with no CPU request
- `requests.cpu: 100m` and `limits.cpu: 250m`
Answer: D — `requests.cpu: 100m` and `limits.cpu: 250m`
Requests reserve 100m CPU for scheduling, while limits allow the container to use up to 250m.
23. An administrator runs `kubectl cordon worker-1` to move workloads off the node, but existing pods stay put. Why?
- Cordon only marks the node unschedulable; it does not evict existing pods.
- Cordon only works after the node is drained.
- Cordon requires `--delete-emptydir-data` to evict pods.
- Cordon evicts only DaemonSet pods.
Answer: A — Cordon only marks the node unschedulable; it does not evict existing pods.
Cordon marks the node unschedulable but does not evict existing pods; drain does.
24. A PersistentVolume supports `ReadWriteOnce` and the PersistentVolumeClaim requests `ReadWriteMany`. The storage class and capacity match, yet the claim remains `Pending`. What is the cause?
- No StorageClass exists in the cluster
- The PersistentVolume capacity is smaller than requested
- The PersistentVolume is already bound to another claim
- The access modes do not match, so the two will not bind
Answer: D — The access modes do not match, so the two will not bind
A claim and volume with different access modes will not bind, even when class and capacity agree.
25. Frontend Pods have a default-deny egress policy. A policy in the `backend` namespace allows ingress from the `frontend` namespace on TCP 8080, yet frontend requests still fail. What must also be allowed?
- egress from frontend to backend on TCP 8080
- ingress on frontend from backend on TCP 8080
- ingress on backend from kube-dns on UDP 53
- egress from backend to frontend on TCP 8080
Answer: A — egress from frontend to backend on TCP 8080
NetworkPolicy enforces both sides: the destination allows ingress, but the source also needs egress permission to the backend.
26. An administrator runs `k delete pod static-web-node01` and the pod returns within seconds. What recreates it?
- The kubelet, from the manifest file on the node
- The Deployment controller
- The API server, from etcd
- A ReplicaSet with one replica
Answer: A — The kubelet, from the manifest file on the node
The kubelet watches the static pod manifest directory and recreates any pod whose manifest is still present.
27. A staging overlay is complete in `kustomize-lab/overlays/staging/`. Which command applies it?
- `kubectl apply -f kustomize-lab/overlays/staging/`
- `kubectl apply -k kustomize-lab/overlays/staging/`
- `kubectl create -k kustomize-lab/base/`
- `kubectl kustomize kustomize-lab/overlays/staging/`
Answer: B — `kubectl apply -k kustomize-lab/overlays/staging/`
`kubectl apply -k` applies a kustomization directory.
28. A worker hosts DaemonSet pods and pods with emptyDir data. Which command drains it successfully?
- `kubectl drain worker-1 --force --grace-period=0`
- `kubectl drain worker-1 --ignore-daemonsets --delete-emptydir-data`
- `kubectl cordon worker-1 --ignore-daemonsets --delete-emptydir-data`
- `kubectl drain worker-1`
Answer: B — `kubectl drain worker-1 --ignore-daemonsets --delete-emptydir-data`
Drain needs `--ignore-daemonsets` and `--delete-emptydir-data` to handle DaemonSet pods and local emptyDir data.
29. You are creating a StorageClass for local volumes and there is no dynamic provisioner. Which provisioner value should the StorageClass use?
- `manual`
- `kubernetes.io/host-path`
- `kubernetes.io/local-volume`
- `kubernetes.io/no-provisioner`
Answer: D — `kubernetes.io/no-provisioner`
A StorageClass for local volumes with no dynamic provisioner uses `kubernetes.io/no-provisioner`.
30. An Ingress is created successfully, but `kubectl get ingress` shows `<pending>` for ADDRESS. What is the most likely cause?
- The IngressClass is named `nginx`.
- `pathType` is set to `Prefix`.
- The Service has no endpoints.
- The Ingress controller is not running.
Answer: D — The Ingress controller is not running.
Without an Ingress controller, the Ingress object is created but no address is assigned.
31. An ingress rule has a single `from` item containing only `podSelector: {}`. What does it allow?
- all Pods in all namespaces
- no Pods
- all Pods in the policy's namespace
- only Pods on the same node
Answer: C — all Pods in the policy's namespace
An empty pod selector in an ingress `from` block is a blanket allow for all Pods in that namespace.
32. A PV uses `hostPath: /data/pv`, but that directory was never created on the node. A Pod mounting the bound PVC is created. What is the likely result?
- The Pod runs but the mount is read-only.
- The Pod runs and the directory is created automatically.
- The PVC drops back to `Pending` until the directory is created.
- The Pod stays Pending.
Answer: D — The Pod stays Pending.
The node must have the backing hostPath directory; without it the Pod cannot mount the volume and stays Pending.
33. An administrator needs to verify that kube-proxy is running on all nodes. Which command checks the DaemonSet?
- `k get deployment kube-proxy -n kube-system`
- `k get pods -n kube-system -l k8s-app=kube-dns`
- `k get ds kube-proxy -n kube-system`
- `k get svc kube-proxy -n kube-system`
Answer: C — `k get ds kube-proxy -n kube-system`
kube-proxy runs as a DaemonSet, so inspecting that object shows whether it is deployed across the nodes.
34. After applying a PV and PVC, you want to confirm the binding succeeded before creating the consumer Pod. Which command and result confirm it?
- `kubectl get pvc my-pvc -n app` reports `Bound`
- `kubectl get pods -n app` reports `Running`
- `kubectl get events -n app` reports no errors
- `kubectl get pv -n app` reports `Available`
Answer: A — `kubectl get pvc my-pvc -n app` reports `Bound`
The PVC's status is the direct evidence of binding; `kubectl get pvc` showing Bound confirms it before the Pod is created.
35. An egress rule must select the CoreDNS Pods in `kube-system`. Which `matchLabels` entry is commonly used for that selection?
- `app: kube-dns`
- `name: coredns`
- `k8s-app: kube-dns`
- `k8s-app: coredns`
Answer: C — `k8s-app: kube-dns`
CoreDNS commonly carries `k8s-app=kube-dns`; the actual labels should still be checked before relying on the selector.
36. A node shows `NotReady`. `k describe node` from the control plane shows only conditions, not the cause. Where should the administrator look for the root cause?
- In the `Conditions` section of `k describe node` on the control plane
- In `k top nodes` output on the control plane
- In `ps aux | grep kubelet` output on the affected node
- In `journalctl -u kubelet` on the affected node
Answer: D — In `journalctl -u kubelet` on the affected node
The kubelet logs on the broken node hold the error that explains why the node is not ready.
37. `kubectl get gatewayclass` returns no resources. What must be done before a Gateway can become functional?
- Create a LoadBalancer Service for the HTTPRoute.
- Change the Gateway listener protocol to `TCP`.
- Create an IngressClass named `nginx`.
- Install a Gateway API controller such as Envoy Gateway or Cilium.
Answer: D — Install a Gateway API controller such as Envoy Gateway or Cilium.
A GatewayClass controller must be installed; without one, the Gateway API objects cannot function.
38. An Ingress controller must be reachable from outside the cluster, and the cluster has no external load-balancer provider. Which Service type should be used to expose the controller on a port of every node?
- `NodePort`
- `ClusterIP`
- `ExternalName`
- `LoadBalancer`
Answer: A — `NodePort`
The controller needs a LoadBalancer or NodePort Service to be externally reachable; without a load balancer, NodePort exposes it on the nodes.
39. A Deployment's three pods each request 512Mi memory, but the nodes have less free memory. The pods remain Pending even though actual usage would be low. Why?
- The scheduler reserves requested memory, so the pods cannot fit
- The scheduler waits for actual usage data from metrics-server before placing pods
- The pods must wait for lower-priority pods to be preempted to free memory
- Resource requests are advisory; the memory limits are what block scheduling
Answer: A — The scheduler reserves requested memory, so the pods cannot fit
The scheduler reserves requested resources, so a request larger than free capacity keeps the pod Pending.
40. A CRD with group `platform.example` has been installed. An administrator wants to confirm the custom resource is visible in discovery. Which command lists resources in that API group?
- `kubectl get crd --api-group=platform.example`
- `kubectl api-resources --api-group=platform.example`
- `kubectl get all --api-group=platform.example`
- `kubectl explain platform.example`
Answer: B — `kubectl api-resources --api-group=platform.example`
`kubectl api-resources --api-group=platform.example` lists resources in that API group.
41. A debug container is attached, but `ps aux` shows only the busybox shell and no nginx processes. What is the likely explanation?
- The debug image is not cached on the node
- The debug container has its own process namespace because `--target` was omitted
- The node is under memory pressure
- The nginx container has already exited
Answer: B — The debug container has its own process namespace because `--target` was omitted
Without `--target`, the debug container does not share the target container's process namespace, so the application processes are invisible.
42. A local PV is tied by node affinity to `node-1`. A Pod using its PVC is constrained by a node selector to `node-2`. What happens?
- The PVC becomes `Bound`, but the Pod stays Pending.
- The Pod runs on `node-2` and mounts the volume over the network.
- The Pod schedules on `node-1`, because PV node affinity overrides the node selector.
- The Pod will not schedule.
Answer: D — The Pod will not schedule.
The local PV can only be used on its affinity node, so a Pod constrained to another node cannot schedule.
43. Before applying an overlay, an administrator wants to see the rendered resources without creating anything. Which command does that?
- `kubectl get -k kustomize-lab/overlays/staging/`
- `kubectl apply -k kustomize-lab/overlays/staging/ --dry-run=server`
- `kubectl kustomize kustomize-lab/overlays/staging/`
- `kubectl diff -f kustomize-lab/overlays/staging/`
Answer: C — `kubectl kustomize kustomize-lab/overlays/staging/`
`kubectl kustomize` renders the overlay without applying it.
44. The API server manifest uses `--etcd-servers=https://127.0.0.1:2384`, and the API server cannot connect. Which endpoint should be used instead?
- `https://127.0.0.1:6443`
- `https://127.0.0.1:8080`
- `https://127.0.0.1:2379`
- `https://127.0.0.1:2384`
Answer: C — `https://127.0.0.1:2379`
Port 2379 is etcd's client port, while 2384 is the peer port and will not accept the API server's client connection.
45. `kubectl get pods` reports connection refused, and `k get pods -n kube-system | grep apiserver` shows the API server pod in `CrashLoopBackOff`. Which cause should be investigated?
- A missing metrics-server Deployment
- A PersistentVolumeClaim with the wrong access mode
- A Service selector that does not match its Pods
- An incorrect etcd endpoint used by the API server
Answer: D — An incorrect etcd endpoint used by the API server
An API server that cannot reach etcd will crash, so the etcd endpoint is the cause to investigate.
46. Before running `kubectl debug` against a node, an administrator wants to check whether pressure conditions might prevent the debug Pod from being created. Which command shows those conditions?
- `k get events -A`
- `k get nodes -o wide`
- `k describe node`
- `k top pods`
Answer: C — `k describe node`
Node pressure conditions are reported in the node's description, which shows whether a debug Pod can be created.
47. A Pod is `Pending` and its Events report `PersistentVolumeClaim is not Bound`. Where should the administrator look next?
- At storage: whether a matching PersistentVolume exists and can bind
- At the Pod's tolerations and affinity rules
- At the metrics-server Deployment
- At node memory and CPU capacity
Answer: A — At storage: whether a matching PersistentVolume exists and can bind
An unbound claim is a storage problem, so the next step is to check the PersistentVolume side rather than node resources or scheduling rules.
48. Each replica of a StatefulSet must get its own PersistentVolumeClaim created automatically. Which field provides this?
- `spec.serviceName`
- `spec.volumes` with an `emptyDir`
- `spec.template.spec.volumes` with a `persistentVolumeClaim`
- `spec.volumeClaimTemplates`
Answer: D — `spec.volumeClaimTemplates`
`volumeClaimTemplates` creates a PVC for each StatefulSet replica automatically.
Take this test interactively
More Certified Kubernetes Administrator (CKA) practice tests