Courseiva

CCNA Application Observability and Maintenance Questions

75 of 146 questions · Page 1/2 · Application Observability and Maintenance · Answers revealed

1
MCQeasy

Refer to the exhibit. A pod named 'app-backend-6b4c9d8f7-2x4z5' is in CrashLoopBackOff state. What is the MOST likely cause of this issue?

A.The container is crashing due to a misconfiguration or application error.
B.The container has exceeded its memory limit and is being OOMKilled.
C.The node running the pod is down, preventing the container from starting.
D.A network policy is blocking the container from accessing required services.
AnswerA

CrashLoopBackOff means the container has started and exited repeatedly with a non-zero exit code, and the kubelet is applying an exponential backoff between restarts. This is typically caused by a misconfiguration—such as a missing ConfigMap value, incorrect environment variable, bad command-line argument, or a malformed config file—or an application-level error like an unhandled panic. Check kubectl logs with --previous to see the actual error message and exit code.

Why this answer

A CrashLoopBackOff state indicates that the container in the pod is repeatedly crashing and being restarted by the kubelet. The most common cause is a misconfiguration (e.g., incorrect environment variables, missing dependencies, or a faulty entrypoint script) or an application error (e.g., a runtime exception or panic). The kubelet detects the crash via the container runtime (e.g., containerd) and applies an exponential backoff delay before restarting, leading to the CrashLoopBackOff status.

Exam trap

CNCF often tests the distinction between CrashLoopBackOff and other pod failure states like OOMKilled or ImagePullBackOff, and the trap here is that candidates may assume any crash is due to resource limits or network issues without checking the specific exit code or pod events.

How to eliminate wrong answers

Option B is wrong because an OOMKilled container would show a status of 'OOMKilled' in the pod's last state, not CrashLoopBackOff; CrashLoopBackOff is a generic restart loop, not a specific resource limit violation. Option C is wrong because if the node were down, the pod would be in 'NodeLost' or 'Unknown' state, and the kubelet would not be able to restart the container; CrashLoopBackOff requires the kubelet to be actively managing the pod. Option D is wrong because a network policy blocking access would cause the application to fail to connect to services, but the container itself would still start and run (possibly with errors), not crash immediately; CrashLoopBackOff implies the container process exits with a non-zero code at startup.

2
MCQmedium

A pod is stuck in 'Pending' state. You run 'kubectl describe pod my-pod' and see the event: '0/3 nodes are available: 3 Insufficient cpu.' Which action should you take?

A.Increase the CPU limits on the pod to give it more resources.
B.Reduce the CPU request of the pod and reapply the manifest.
C.Add another node to the cluster to increase overall CPU capacity.
D.Add a nodeSelector to the pod to target a specific node.
AnswerB

The scheduler places pods on nodes using the CPU request as the reservation; a pending pod with 'Insufficient cpu' events has a request larger than any node's free capacity. Reducing the CPU request in the pod spec to fit within an existing node's available allocatable CPU allows the scheduler to find a suitable node, and reapply the manifest (via kubectl replace -f or delete/recreate) so the pod is re-created with the lowered request. This directly addresses the root cause and is faster than infrastructure changes.

Why this answer

The pod is stuck in 'Pending' because the scheduler cannot find a node with enough allocatable CPU to satisfy the pod's CPU request. Reducing the CPU request (the amount guaranteed to the container) makes the pod schedulable on existing nodes. Increasing limits would only worsen the problem, as limits are a cap on usage, not a scheduling constraint.

Exam trap

The trap here is that candidates confuse CPU requests with CPU limits, assuming that increasing limits gives the pod more resources, when in fact the scheduler only checks requests for admission, and limits are a runtime constraint.

How to eliminate wrong answers

Option A is wrong because increasing CPU limits does not affect scheduling; the scheduler only considers requests, not limits. Option C is wrong because adding a node is an operational overhead and not the immediate fix; the issue is that the pod's request is too high for the current cluster capacity. Option D is wrong because a nodeSelector targets a specific node but does not resolve the underlying resource insufficiency; if no node has enough CPU, the pod will still remain Pending.

3
MCQeasy

A pod is running but not responding to traffic. You suspect the application inside the container is unhealthy but the pod is still marked as 'Running'. Which probe should be configured to remove the pod from the service's endpoints automatically?

A.Readiness probe
B.Resource limits
C.Startup probe
D.Liveness probe
AnswerA

The readiness probe is the only probe that directly controls whether the Pod is added to or retained in the Endpoints object backing a Service. When it fails, the kubelet marks the Pod's Ready condition as False, and the endpoints controller removes its IP from all matching Service backends, so it stops receiving new traffic while it is still running. This precisely matches the symptom of a running Pod that is unresponsive: it should be taken out of rotation, not restarted.

Why this answer

A Readiness probe determines whether a container is ready to accept traffic. If the probe fails, Kubernetes removes the pod's IP address from the endpoints of all Services that match the pod's labels, effectively stopping traffic from reaching the pod while it remains in the Running state. This is the correct probe for removing an unhealthy pod from Service endpoints without terminating it.

Exam trap

The CKAD exam often tests the distinction between Liveness and Readiness probes, and the trap here is that candidates mistakenly choose Liveness probe because they think 'unhealthy' always means 'restart', but the question specifically asks about removing the pod from Service endpoints, which is the Readiness probe's job.

How to eliminate wrong answers

Option B is wrong because resource limits (CPU/memory constraints) control how much resources a container can use but do not affect Service endpoint membership or health checking. Option C is wrong because a Startup probe is used to determine when a container has started successfully; it runs only during initialization and does not manage ongoing traffic routing after the pod is Running. Option D is wrong because a Liveness probe indicates whether the container is alive; if it fails, the kubelet restarts the container, but it does not remove the pod from Service endpoints—the pod remains in the endpoint list until it is terminated or its Readiness probe fails.

4
MCQeasy

A DevOps engineer needs to set up resource monitoring for pods in a namespace. Which built-in Kubernetes resource provides CPU and memory metrics out-of-the-box?

A.Metrics Server
B.Prometheus
C.CoreDNS
D.Kubernetes Dashboard
AnswerA

Metrics Server is the correct choice because it is a built-in cluster addon that aggregates resource usage metrics (CPU and memory) per node and pod from kubelet's Summary API via the Metrics API. It provides these lightweight, in-memory metrics to `kubectl top` and the Horizontal Pod Autoscaler (HPA) without needing external storage. Being cluster-native and automatically available on most managed Kubernetes distributions, it is the standard zero-configuration tool for basic resource monitoring.

Why this answer

The Metrics Server is the built-in Kubernetes resource that collects resource metrics (CPU and memory) from the kubelet on each node via the Summary API and exposes them through the metrics.k8s.io API. It provides these metrics out-of-the-box without requiring any additional configuration or external storage, making it the standard solution for horizontal pod autoscaling and kubectl top commands.

Exam trap

CNCF often tests the distinction between built-in Kubernetes components and third-party add-ons, so candidates may mistakenly choose Prometheus because it is a popular monitoring tool, but the question specifically asks for a built-in resource that provides metrics out-of-the-box.

How to eliminate wrong answers

Option B is wrong because Prometheus is a third-party monitoring system that is not built into Kubernetes; it requires separate installation and configuration, and while it can scrape metrics, it is not the built-in resource for CPU and memory metrics. Option C is wrong because CoreDNS is a DNS server for service discovery within the cluster, not a metrics provider; it has no capability to expose CPU or memory metrics. Option D is wrong because Kubernetes Dashboard is a web UI for managing the cluster, not a metrics source; it relies on the Metrics Server or another backend to display resource usage data.

5
Multi-Selecthard

Which THREE of the following are true about the 'kubectl describe pod' output? (Select 3)

Select 3 answers
A.It shows the exact resource requests and limits of each container
B.It shows the last few lines of the container logs
C.It shows recent events related to the pod
D.It shows the current CPU and memory usage of the pod
E.It shows the node name where the pod is scheduled
AnswersA, C, E

In the 'Containers' section of 'kubectl describe pod', you'll find a 'Limits' and 'Requests' line for each container, mirroring the resource requirements defined in the pod's YAML. These show the CPU and memory requests and limits that affect scheduling decisions and QoS class. Hence, this is a true capability of describe.

Why this answer

kubectl describe pod provides static configuration details and recent events. It shows resource requests and limits per container (A), recent pod events (C), and the node name where the pod is scheduled (E). It does not show container logs (B) or current CPU/memory usage (D).

Exam trap

The CKAD exam often tests the distinction between static configuration (requests/limits) shown in `describe` and dynamic metrics (CPU/memory usage) shown in `top` or `metrics-server`, causing candidates to confuse the two.

6
MCQeasy

What is the purpose of a readiness probe?

A.To restart the container if it becomes unresponsive
B.To indicate whether the container is ready to serve traffic
C.To indicate that the container has started successfully
D.To measure the resource usage of the container
AnswerB

A readiness probe tells the kubelet whether the application inside the container is ready to accept incoming requests. When the probe succeeds, the pod is added to the endpoints of Services that select it; when it fails, the pod is removed from those endpoints without being terminated. This prevents clients from sending traffic to pods that are still starting up or are temporarily overloaded.

Why this answer

A readiness probe determines whether a container is ready to accept traffic. If the probe fails, the Pod's IP address is removed from the Endpoints of the associated Service, preventing traffic from being routed to an unready container. This is distinct from liveness probes, which restart containers, and startup probes, which indicate successful initialization.

Exam trap

The trap here is confusing readiness probes with liveness probes, as both are health checks, but readiness probes control traffic routing while liveness probes trigger container restarts.

How to eliminate wrong answers

Option A is wrong because restarting an unresponsive container is the purpose of a liveness probe, not a readiness probe. Option C is wrong because indicating that the container has started successfully is the purpose of a startup probe, which is used for slow-starting containers to delay liveness checks. Option D is wrong because measuring resource usage is done by metrics servers or resource monitoring tools (e.g., cAdvisor, Prometheus), not by probes.

7
MCQhard

You want to debug a pod that is failing to start. The pod does not have a shell installed. Which command can you use to attach an ephemeral debug container to the running (or failed) pod?

A.kubectl attach <pod>
B.kubectl exec -it <pod> -- /bin/sh
C.kubectl run debug --image=busybox -it --restart=Never
D.kubectl debug -it <pod> --image=busybox --target=<container>
AnswerD

kubectl debug -it <pod> --image=busybox --target=<container> creates an ephemeral container inside the existing pod, sharing its network, volumes, and (if enabled) process namespace. The --target flag names the container whose namespaces the debug container will share, letting you inspect the failing container's filesystem and processes even while it is crashing. Because ephemeral containers do not restart or affect the original container's lifecycle, this is the correct way to inject a debugging tool into the pod without modifying the pod spec.

Why this answer

`kubectl debug` allows you to attach an ephemeral debug container to a running or failed pod, even if the pod lacks a shell. The `--target` parameter specifies the container in the pod to which the debug container attaches, enabling network namespace sharing and process inspection without modifying the original container.

Exam trap

The trap here is that candidates often choose `kubectl exec` or `kubectl attach` out of habit, not realizing those commands require a running container with a shell, whereas `kubectl debug` is the only option that can inject a new container into a pod that lacks debugging tools or is in a failed state.

How to eliminate wrong answers

Option A is wrong because `kubectl attach` attaches to a running container's stdin/stdout/stderr, but it requires the container to have a shell or process running; it cannot add a new container or work if the pod is in a CrashLoopBackOff state. Option B is wrong because `kubectl exec` requires the target container to have a shell (e.g., /bin/sh) and a running process; if the pod has no shell or is failing to start, exec will fail. Option C is wrong because `kubectl run` creates a new standalone pod, not an ephemeral container attached to an existing pod; it cannot debug the original pod's namespace or processes.

8
Multi-Selecteasy

Which TWO are valid ways to debug a pod using ephemeral containers?

Select 2 answers
A.kubectl debug -it <pod> --image=busybox -- sh
B.kubectl run debug --image=busybox -- sh
C.Adding an ephemeral container to the pod's spec under ephemeralContainers
D.kubectl exec -it <pod> -- sh
E.kubectl attach to the pod
AnswersA, C

kubectl debug -it <pod> --image=busybox -- sh is the standard command to create an ephemeral debug container in the target pod. It injects a busybox container into the pod's namespace and attaches your terminal to it, allowing you to inspect the pod's shared network, storage, and process state. This is the sanctioned workflow for adding a temporary troubleshooting container.

Why this answer

`kubectl debug -it <pod> --image=busybox -- sh` creates an ephemeral container in the target pod and attaches an interactive terminal to it. This is the standard Kubernetes mechanism for debugging a running pod without modifying its original container spec, using the ephemeral container feature (alpha in v1.16, stable in v1.23).

Exam trap

The trap here is that candidates confuse `kubectl exec` (which runs a command in an existing container) with `kubectl debug` (which creates a new ephemeral container), and also mistakenly think `kubectl run` or `kubectl attach` can inject a debug container into a running pod.

9
Multi-Selectmedium

Which THREE of the following are correct statements about the terminationGracePeriodSeconds field? (Select 3)

Select 3 answers
A.The default value is 30 seconds
B.It gives the container time to shut down gracefully after receiving SIGTERM
C.After the grace period expires, the container is forcefully killed with SIGKILL
D.The default value is 0 seconds
E.It is used to configure the readiness probe timeout
AnswersA, B, C

The `terminationGracePeriodSeconds` field in a Pod spec defaults to 30 seconds when omitted. This value sets how long Kubernetes waits after sending SIGTERM to a container's main process before sending SIGKILL. It is a deliberate default to allow most workloads enough time to shut down cleanly without forcing an immediate hard kill.

Why this answer

The Kubernetes documentation specifies that the default value for terminationGracePeriodSeconds is 30 seconds. This field is part of the PodSpec and controls the duration between sending SIGTERM to the container and forcefully killing it with SIGKILL. If not set, Kubernetes applies this default to ensure a reasonable window for graceful shutdown.

Exam trap

CNCF often tests the exact default value (30 seconds) and the distinction between SIGTERM (graceful) and SIGKILL (forceful), so candidates must not confuse terminationGracePeriodSeconds with probe settings like readiness or liveness probe timeouts.

10
MCQhard

You deploy a pod with the following specification: apiVersion: v1 kind: Pod metadata: name: probe-pod spec: containers: - name: app image: nginx livenessProbe: httpGet: path: /healthz port: 8080 initialDelaySeconds: 5 periodSeconds: 10 failureThreshold: 3 The application listens on port 80, not 8080. What will happen to the pod?

A.The pod will be terminated and not restarted
B.The pod will start and run normally
C.The container will be restarted repeatedly due to liveness probe failure
D.The pod will be stuck in 'Pending' state
AnswerC

Correct. The liveness probe checks a health endpoint or TCP port on the container; when that probe fails continuously, the kubelet kills the container and restarts it according to restartPolicy (Always by default). Each subsequent restart is followed by another failing probe, so the container enters a restart loop with exponential backoff, visible as CrashLoopBackOff in container status. This matches the expected behavior for a misconfigured or broken liveness probe on port 8080.

Why this answer

The liveness probe is configured to perform an HTTP GET request on port 8080, but the application (nginx) listens on port 80. Since the probe will never receive a successful HTTP response (it will get a connection refused or timeout), it will fail. With a failureThreshold of 3, after three consecutive failures the kubelet will consider the container unhealthy and restart it.

This cycle repeats indefinitely, causing the container to be restarted repeatedly.

Exam trap

The trap here is that candidates assume the pod will be terminated or stuck, but they forget that liveness probes cause container restarts (not pod deletion) and that the pod will still reach 'Running' state initially, only to be repeatedly restarted.

How to eliminate wrong answers

Option A is wrong because the liveness probe failure triggers a container restart, not pod termination; the pod is not deleted, and the restart policy (default Always) ensures the container is restarted. Option B is wrong because the probe will fail due to the port mismatch, so the container will not run normally; it will be restarted repeatedly. Option D is wrong because the pod will transition to 'Running' state (the container starts successfully), but the liveness probe failures cause restarts; 'Pending' indicates the pod cannot be scheduled or images cannot be pulled, which is not the case here.

11
MCQeasy

You have a pod 'app-pod' that keeps restarting. You want to see the logs from the previous (crashed) container instance. Which command should you use?

A.kubectl logs app-pod --previous
B.kubectl logs app-pod -prev
C.kubectl logs app-pod -f
D.kubectl describe pod app-pod
AnswerA

The `--previous` flag is the long form of `-p` and retrieves the logs from the last terminated instance of the container. In a crash loop, the currently running container may be brand new with little/no output, while the previous instance's logs contain the stack trace or error that caused the exit. This is the standard way to inspect logs from a crashed container that has since restarted. The command returns logs to stdout, making them easy to review or pipe to tools.

Why this answer

The `--previous` flag in `kubectl logs` retrieves logs from the previous instance of a container in a pod. Option B uses `-prev` which is not a valid shorthand (the correct shorthand is `-p`, which is not listed). Options C and D are incorrect: `-f` is for following logs in real-time, and `describe` shows events and configuration, not logs.

Exam trap

The trap here is that candidates might confuse `-prev` with `-p`, which is the actual correct shorthand for `--previous`. However, `-prev` is invalid. Additionally, `-f` is for following logs and `describe` shows events, not logs, which could lead candidates to pick wrong options when the pod is restarting.

How to eliminate wrong answers

Option B is wrong because `-p` is the shorthand for `--previous`, so it is functionally identical to option A and not incorrect; however, the question asks for the command to use, and both A and B are valid, but A is listed as correct. Option C is wrong because `-f` (or `--follow`) streams logs from the current container instance, not the previous crashed one, so it would show no output if the current container has no logs or is restarting. Option D is wrong because `kubectl describe pod` shows pod metadata, events, and status, but not the container logs from a previous instance; it can show restart counts and reasons but not the actual log output.

12
MCQmedium

A pod named 'web-app' is experiencing high CPU usage. You want to investigate which process inside the container is consuming the most CPU. Which command should you run?

A.kubectl logs -f web-app
B.kubectl exec web-app -- top
C.kubectl describe node
D.kubectl top pod web-app
AnswerB

kubectl exec web-app -- top is correct because it runs the top utility inside the container, which reads /proc to display a live view of processes with their PID, CPU usage, memory usage, and command name. This directly identifies the process consuming the most CPU from the perspective of the container's PID namespace. Note that top must exist in the container image, or you may need an alternative like kubectl exec web-app -- ps aux or /bin/sh -c 'top -b -n 1'.

Why this answer

`kubectl exec web-app -- top` runs the `top` command inside the container of the pod 'web-app', which displays real-time process-level CPU usage. This allows you to identify the specific process consuming the most CPU, directly addressing the question's requirement to investigate inside the container.

Exam trap

The trap here is that candidates confuse `kubectl top pod` (which shows pod-level resource usage) with the ability to inspect processes inside the container, leading them to choose Option D instead of using `kubectl exec` to run a process inspection command like `top`.

How to eliminate wrong answers

Option A is wrong because `kubectl logs -f web-app` streams the container's stdout/stderr logs, which do not show process-level CPU usage or running processes. Option C is wrong because `kubectl describe node` provides node-level resource allocation and conditions, not process-level details inside a specific pod's container. Option D is wrong because `kubectl top pod web-app` shows aggregate CPU and memory usage of the pod's containers, but does not reveal individual processes inside the container.

13
Multi-Selecthard

Which TWO of the following are valid approaches to debug a pod that is in a CrashLoopBackOff state? (Select 2)

Select 2 answers
A.Exec into the pod with 'kubectl exec -it' to inspect the environment
B.Check resource usage with 'kubectl top pod'
C.Use 'kubectl debug' to start an ephemeral container for troubleshooting
D.View logs from the previous container instance with 'kubectl logs --previous'
E.Create a new pod with 'kubectl run' using the same image
AnswersC, D

kubectl debug attaches an ephemeral container to the target pod without restarting or modifying the original container, so you can inspect the shared filesystem, environment variables, and network namespace even while the main container is crash-looping. Ephemeral containers are managed by the kubelet and are not subject to the pod's restart policy, allowing them to remain available for interactive troubleshooting when the main container keeps failing. This is the direct, supported way to debug a crashing pod when exec is impossible.

Why this answer

'kubectl debug' can start an ephemeral container in the same pod as the crashing container, allowing you to inspect the environment (e.g., filesystem, network, processes) without the main container running. This is especially useful when the main container crashes immediately and you cannot exec into it. Ephemeral containers share the pod's namespaces (e.g., network, PID) and can mount the same volumes, giving you a live debugging environment.

Exam trap

CNCF often tests the distinction between 'kubectl exec' (requires a running container) and 'kubectl debug' (works even when the container is crashing), and candidates mistakenly think exec can be used on a CrashLoopBackOff pod.

14
MCQeasy

A deployment 'web-app' is running with 3 replicas. Users report that the application is slow. The team suspects a memory leak. Which command provides the most immediate insight into the memory usage of the pods?

A.kubectl describe deployment web-app
B.kubectl get events
C.kubectl logs <pod>
D.kubectl top pod
AnswerD

kubectl top pod is the correct choice because it directly queries the metrics-server (via the metrics.k8s.io API) for live CPU and memory usage data per pod and per container. It returns a compact table of instantaneous resource usage, such as MEMORY and MEMORY% columns, which is exactly what a user needs to inspect memory consumption across the three replicas. This command requires the metrics-server to be deployed and properly configured in the cluster to function.

Why this answer

`kubectl top pod` directly queries the metrics server to display real-time CPU and memory usage for each pod, providing the most immediate insight into whether a pod is consuming excessive memory due to a suspected leak. Unlike logs or events, it gives quantitative resource utilization data without requiring additional configuration or parsing.

Exam trap

The trap here is that candidates may choose `kubectl logs` thinking application logs will reveal memory leak details, but logs only show application output, not raw memory metrics, and `kubectl top pod` is the standard tool for immediate resource usage insight.

How to eliminate wrong answers

Option A is wrong because `kubectl describe deployment web-app` shows the deployment's configuration and status, not the actual runtime memory usage of individual pods. Option B is wrong because `kubectl get events` lists cluster events (e.g., scheduling failures, restarts) but does not provide memory usage metrics. Option C is wrong because `kubectl logs <pod>` outputs application logs, which may contain memory-related error messages but do not give direct, real-time memory consumption numbers.

15
Multi-Selectmedium

Which THREE of the following are valid parameters for configuring probes? (Select 3)

Select 3 answers
A.retryIntervalSeconds
B.timeoutSeconds
C.cooldownSeconds
D.initialDelaySeconds
E.periodSeconds
AnswersB, D, E

timeoutSeconds is a valid Kubernetes probe parameter. It defines the maximum time in seconds that the kubelet waits for a probe to complete after starting it. If the probe exceeds this duration, it is considered failed, and the failure is counted toward failureThreshold. To be effective, timeoutSeconds should be less than periodSeconds to avoid overlapping probe executions.

Why this answer

In Kubernetes, probe configuration parameters are defined in the container spec within a Pod. `timeoutSeconds` is a valid parameter that specifies the number of seconds after which the probe times out, defaulting to 1 second if not set. It is used in liveness, readiness, and startup probes to control how long kubelet waits for a probe response before considering it failed.

Exam trap

The CKAD exam often tests the distinction between valid probe parameters and common-sounding but non-existent fields like `retryIntervalSeconds` or `cooldownSeconds`, tricking candidates into selecting them because they seem logical for retry or cooldown behavior.

16
Multi-Selecthard

Which THREE of the following are best practices for configuring readiness probes?

Select 3 answers
A.Use the same endpoint as the liveness probe
B.Configure the probe to restart the container if it fails
C.Set initialDelaySeconds to avoid startup race conditions
D.Use a separate endpoint from the liveness probe
E.Use an HTTP GET request to a lightweight endpoint
AnswersC, D, E

Setting initialDelaySeconds gives the application a grace period to finish startup tasks such as loading configuration, connecting to databases, or opening listen sockets before the kubelet begins sending probe requests. Without this delay, a still-initializing container may fail its first probes and be repeatedly restarted, creating a crash loop instead of a healthy pod.

Why this answer

Setting `initialDelaySeconds` in a readiness probe prevents the probe from starting before the container's application has had time to initialize. Without this delay, the probe might fail immediately during startup, causing the container to be prematurely marked as not ready and removed from service, even though the application would have become ready given a few more seconds. This avoids race conditions between container startup and probe evaluation.

Exam trap

The trap here is that candidates confuse readiness probes with liveness probes, mistakenly thinking readiness probes can restart containers or that sharing the same endpoint is acceptable, when in fact readiness probes only control traffic routing and should use a separate, dependency-aware endpoint.

17
MCQeasy

Which probe type is used to indicate that a container is ready to serve traffic and should be added to Service endpoints?

A.Readiness probe
B.Liveness probe
C.Startup probe
D.Both liveness and readiness probes
AnswerA

Readiness probes are the mechanism Kubernetes uses to decide if a container is ready to serve traffic. When a readiness probe fails, the pod is removed from all backing Service endpoints, so no requests are forwarded to it, but the container is not killed or restarted. This makes readiness probes the direct indicator of whether a container is prepared to handle incoming traffic, including dependencies like database connectivity or loaded configuration.

Why this answer

A Readiness probe determines whether a container is ready to accept traffic. If the probe fails, the container is removed from all Service endpoints, ensuring only healthy pods receive requests. This is the correct probe for indicating readiness to serve traffic.

Exam trap

The CKAD exam often tests the distinction between readiness and liveness probes, trapping candidates who confuse 'is the container alive?' with 'is the container ready to serve?'.

How to eliminate wrong answers

Option B is wrong because a Liveness probe indicates whether a container is running, not whether it is ready to serve traffic; a failed liveness probe restarts the container. Option C is wrong because a Startup probe checks if the container's application has started successfully, used for slow-starting containers, and does not control Service endpoint membership. Option D is wrong because both probes together serve different purposes: liveness for restarting dead containers, readiness for traffic routing; only the readiness probe controls Service endpoints.

18
MCQeasy

A developer needs to view the logs of a pod named 'web-app-84b7f6f5b6-abcde' that crashed and has been restarted. Which kubectl command should they use to see the logs from the previous (crashed) instance?

A.kubectl logs web-app-84b7f6f5b6-abcde
B.kubectl logs --all-containers web-app-84b7f6f5b6-abcde
C.kubectl logs --previous web-app-84b7f6f5b6-abcde
D.kubectl logs -f web-app-84b7f6f5b6-abcde
AnswerC

The --previous flag instructs kubectl to retrieve logs from the previous, terminated instance of the container rather than the current one. In a typical crash-loop scenario, the kubelet retains the log file of the last terminated container on the node, and kubectl accesses it through the API's 'previous' option. This gives the developer visibility into the exact output that caused the prior container to exit, making it the correct command when the pod is named with an instance suffix and the developer suspects a restart has occurred.

Why this answer

The `--previous` flag in `kubectl logs` retrieves logs from the previous instance of a container that has been restarted. This is essential for debugging a crashed pod, as the current container's logs only reflect the new instance after the restart.

Exam trap

The trap here is that candidates often confuse `--previous` with `--all-containers` or `-f`, not realizing that only `--previous` specifically targets logs from the terminated container instance.

How to eliminate wrong answers

Option A is wrong because `kubectl logs` without flags only shows logs from the current (running) container, not the crashed instance. Option B is wrong because `--all-containers` targets all containers in the pod but still fetches logs from the current instance, not the previous one. Option D is wrong because `-f` (follow) streams logs in real-time from the current container, which does not provide access to logs from the previous crashed instance.

19
MCQmedium

Which command outputs the pod's full YAML specification including status?

A.kubectl describe pod <pod-name>
B.kubectl get pod <pod-name> --export
C.kubectl get pod <pod-name> -o json
D.kubectl get pod <pod-name> -o yaml
AnswerD

kubectl get pod <pod-name> -o yaml returns the live pod object from the API server serialized as YAML, including metadata (annotations/labels), spec, and status. This is the canonical way to dump the complete pod specification as stored by Kubernetes, though it includes defaulted fields and status that aren't part of the original input manifest.

Why this answer

`kubectl get pod <pod-name> -o yaml` outputs the full YAML specification of the pod, including its status (e.g., conditions, container statuses, phase). The `-o yaml` flag retrieves the complete Kubernetes resource object from the API server, which includes both the desired spec and the current status, as stored in etcd.

Exam trap

The trap here is that candidates often confuse `kubectl describe` (which shows status in a readable format) with `kubectl get -o yaml` (which outputs the full YAML specification including status), or mistakenly think `--export` preserves status when it actually strips it.

How to eliminate wrong answers

Option A is wrong because `kubectl describe pod` outputs a human-readable summary, not the full YAML specification; it omits many fields and is not structured for programmatic use. Option B is wrong because `--export` is a deprecated flag that strips cluster-specific information (like status, nodeName, and uid) to produce a minimal spec for re-creation, so it does not include status. Option C is wrong because `-o json` outputs the full specification in JSON format, not YAML, so it does not match the question's requirement for YAML output.

20
MCQhard

You are asked to ensure that a pod with a slow-starting container (requires 60 seconds to initialize) is not prematurely restarted by the liveness probe. The liveness probe should start only after the container is fully initialized. Which probe type should you add to the pod spec?

A.startupProbe
B.readinessProbe
C.livenessProbe with initialDelaySeconds=60
D.lifecycle preStop hook
AnswerA

A startupProbe is the only probe type designed for slow-starting containers; it runs repeatedly until the process signals it has initialized successfully. Kubelet disables liveness and readiness probes until this probe succeeds, so the container gets unlimited (or configured) attempts to start without being killed. You can set a large failureThreshold with short periodSeconds to allow a long but controlled startup window.

Why this answer

A startupProbe is specifically designed for slow-starting containers. It runs at pod startup and only after it succeeds does the liveness probe begin. This prevents the liveness probe from restarting the container during its 60-second initialization period, as the startupProbe will keep failing until the container is fully ready.

Exam trap

CNCF often tests the misconception that initialDelaySeconds on a liveness probe is sufficient for slow-starting containers, but the trap is that initialDelaySeconds is a fixed delay that does not account for variable startup times, whereas a startupProbe dynamically waits until the container is actually ready.

How to eliminate wrong answers

Option B is wrong because a readinessProbe controls whether the pod receives traffic, not whether the container is restarted; it does not prevent the liveness probe from killing the container during initialization. Option C is wrong because initialDelaySeconds only delays the first liveness probe check by 60 seconds, but if the container takes exactly 60 seconds to initialize and the probe fires immediately after, a single slow response could still trigger a restart; moreover, initialDelaySeconds is a static delay and does not adapt to variable startup times. Option D is wrong because a lifecycle preStop hook runs before a container is terminated, not at startup, and has no effect on preventing premature restarts during initialization.

21
MCQmedium

You want to ensure your containerized application handles SIGTERM gracefully and shuts down within 30 seconds. Which field should you set in the Pod spec?

A.terminationPeriodSeconds
B.terminationGracePeriodSeconds
C.shutdownTimeoutSeconds
D.gracefulShutdownPeriod
AnswerB

terminationGracePeriodSeconds is the correct PodSpec field that sets the time allotted for a container to shut down gracefully. After the kubelet sends SIGTERM to the primary process, it waits this many seconds before sending SIGKILL to force termination. The default value is 30 seconds, and you can override it per deletion request with kubectl delete --grace-period.

Why this answer

`terminationGracePeriodSeconds` is the Pod spec field that controls the duration Kubernetes waits between sending a SIGTERM signal to the container and forcibly killing it with SIGKILL. Setting this to 30 seconds ensures the application has up to 30 seconds to perform cleanup and shut down gracefully after receiving SIGTERM.

Exam trap

The trap here is that candidates confuse the generic concept of a 'grace period' with the exact Kubernetes field name, often picking a plausible-sounding but non-existent field like `shutdownTimeoutSeconds` or `gracefulShutdownPeriod` instead of the precise `terminationGracePeriodSeconds`.

How to eliminate wrong answers

Option A is wrong because `terminationPeriodSeconds` is not a valid Kubernetes field; the correct field name is `terminationGracePeriodSeconds`. Option C is wrong because `shutdownTimeoutSeconds` is not a Kubernetes Pod spec field; it does not exist in the API. Option D is wrong because `gracefulShutdownPeriod` is not a Kubernetes Pod spec field; it is a generic term that might be used in other orchestrators or application configurations, but not in Kubernetes.

22
MCQmedium

You have a Deployment running a web application that takes 60 seconds to start up. You need to configure probes so that Kubernetes waits for the application to fully start before checking its health and directing traffic to it. Which combination of probes should you use?

A.Liveness probe with initialDelaySeconds=10 and readiness probe without delay
B.Readiness probe with initialDelaySeconds=60 only
C.Liveness probe with initialDelaySeconds=60 and readiness probe with initialDelaySeconds=60
D.Startup probe with failureThreshold=30 and periodSeconds=2, plus liveness and readiness probes
AnswerD

A startup probe with failureThreshold=30 and periodSeconds=2 gives the container up to 60 seconds to become ready (30 failures × 2 seconds). The kubelet runs the startup probe first, and only after it succeeds do the liveness and readiness probes begin executing. This cleanly separates the startup phase from steady-state health checking, preventing premature liveness restarts without limiting the app's startup time to a hard-coded initialDelay. Once the startup probe passes, the liveness probe takes over to restart the container if it later becomes unhealthy, while the readiness probe controls traffic admission.

Why this answer

A startup probe with a low failureThreshold and periodSeconds allows Kubernetes to wait up to 60 seconds (30 failures × 2 seconds) for the application to start, after which the liveness and readiness probes begin. This ensures the liveness probe does not kill the container prematurely during the slow startup, and the readiness probe only directs traffic once the app is fully ready.

Exam trap

The trap here is that candidates often rely solely on initialDelaySeconds for liveness probes, not realizing that a startup probe provides a more robust mechanism for slow-starting containers by decoupling the startup grace period from the regular health-check cycle.

How to eliminate wrong answers

Option A is wrong because a liveness probe with initialDelaySeconds=10 would start checking health after only 10 seconds, likely killing the container before the 60-second startup completes. Option B is wrong because a readiness probe with initialDelaySeconds=60 alone does not protect against the liveness probe killing the container during startup; the liveness probe would still start immediately and fail. Option C is wrong because setting both liveness and readiness probes with initialDelaySeconds=60 still allows the liveness probe to start after 60 seconds, but if the app takes exactly 60 seconds, the first liveness check might fail and restart the container; a startup probe provides a more flexible grace period.

23
Multi-Selectmedium

Which THREE of the following are valid parameters for a probe?

Select 3 answers
A.maxRetries
B.initialDelaySeconds
C.timeoutSeconds
D.backoffSeconds
E.periodSeconds
AnswersB, C, E

This is a valid parameter in the Kubernetes probe specification. It sets the number of seconds the kubelet waits after the container starts before performing the first probe, giving the application time to initialize. Properly setting this value is critical for liveness probes to avoid restarting containers that are still starting up.

Why this answer

`initialDelaySeconds` is a valid field in a Kubernetes probe specification that defines the number of seconds to wait before initiating the first probe after the container starts. This allows the application time to initialize before health checks begin, preventing premature failures.

Exam trap

The trap here is that candidates confuse Kubernetes probe parameters with similar concepts from other systems (e.g., retry logic or backoff strategies) and assume `maxRetries` or `backoffSeconds` are valid, when in fact Kubernetes uses `failureThreshold` and fixed-interval polling instead.

24
Multi-Selectmedium

Which TWO of the following are valid types of probes in Kubernetes? (Select 2)

Select 2 answers
A.Readiness probe
B.HTTP probe
C.Liveness probe
D.Exec probe
E.TCP probe
AnswersA, C

Readiness probes are a first-class probe type that tells the kubelet when a container is ready to begin accepting traffic. If the probe fails, the Pod's IP is removed from the endpoints of all Services, but the container is not terminated or restarted. This allows the container to remain running while it load-balances nothing, making it distinct from liveness probes which restart containers. The assignment of readiness is crucial for rolling updates to avoid sending requests to Pods still starting up.

Why this answer

A is correct because a Readiness probe determines whether a Pod is ready to serve traffic. If the probe fails, the Pod is removed from the Service's endpoints, preventing traffic from being routed to an unready container. This is essential for rolling updates and graceful shutdowns.

Exam trap

The trap here is that candidates confuse the probe types (liveness, readiness, startup) with the handler mechanisms (HTTP, TCP, exec), leading them to select handler names as if they were probe types.

25
Multi-Selectmedium

Which TWO statements about readiness probes are correct? (Choose two.)

Select 2 answers
A.Readiness probes are only used during initial startup
B.Readiness probes run continuously after the container starts
C.Readiness probes can only be of type httpGet
D.Readiness probes restart the container if they fail
E.If a readiness probe fails, the pod is removed from all Service endpoints
AnswersB, E

This statement is correct because a readiness probe is a recurring health check, not a one-time gate. The kubelet executes it every periodSeconds once the container is running, even after the pod has already become Ready. If the probe later fails, the pod is marked NotReady and traffic is withdrawn; if it passes again, the pod is marked Ready and endpoints are restored.

Why this answer

Readiness probes are designed to run continuously throughout the lifecycle of a container, not just during startup. They are periodically executed by the kubelet to determine whether the container is ready to accept traffic, and their success or failure directly controls the pod's inclusion in Service endpoints.

Exam trap

The trap here is confusing readiness probes with liveness probes, leading candidates to incorrectly think readiness probes restart containers or are only used at startup, when in fact readiness probes manage traffic routing without restarting the pod.

26
MCQmedium

Which field in the container spec controls the time Kubernetes waits after sending SIGTERM before sending SIGKILL during pod shutdown?

A.timeoutSeconds
B.periodSeconds
C.terminationGracePeriodSeconds
D.activeDeadlineSeconds
AnswerC

terminationGracePeriodSeconds is actually a Pod-level field in the pod spec, not a container-level field, and it controls the duration Kubernetes waits after sending SIGTERM to containers before forcefully sending SIGKILL. This grace period gives processes time to save state, close connections, and complete cleanup handlers. After the period elapses, the kubelet forcibly terminates any containers that have not exited, and overriding it on a per-container basis is impossible.

Why this answer

`terminationGracePeriodSeconds` is the field in the Pod spec that defines the duration Kubernetes waits after sending SIGTERM to the main process in each container before forcefully sending SIGKILL. This grace period allows the application to perform clean shutdown tasks, such as closing connections or flushing data. The default value is 30 seconds if not specified.

Exam trap

The trap here is that candidates confuse `terminationGracePeriodSeconds` with probe-related fields like `timeoutSeconds` or `periodSeconds`, or with Job-level fields like `activeDeadlineSeconds`, because all involve time-based configuration but serve entirely different purposes in the lifecycle of a Pod.

How to eliminate wrong answers

Option A is wrong because `timeoutSeconds` is not a valid field in the container spec; it is used in probes (e.g., livenessProbe, readinessProbe) to specify the timeout for probe execution, not for pod termination. Option B is wrong because `periodSeconds` is also a probe-related field that defines how often a probe is performed, not related to shutdown behavior. Option D is wrong because `activeDeadlineSeconds` is a field in the Job spec (not container spec) that limits the duration a Job can run before being terminated, and it applies to the Job's overall runtime, not the pod shutdown sequence.

27
MCQmedium

A CKAD candidate must make a container's exit code observable after a crash so that a monitoring agent reading pod status can distinguish an application error from an out-of-memory kill. The container has terminated and restarted several times. Which command shows the exit code and termination reason of the most recent terminated instance of the container?

A.kubectl get pod <pod> -o jsonpath='{.status.containerStatuses[*].lastState.terminated}'
B.kubectl describe node <node> | grep -i exit
C.kubectl logs <pod> --previous
D.kubectl get pod <pod> -o jsonpath='{.status.containerStatuses[*].state.running}'
AnswerA

The lastState.terminated object records the previous container instance, including its exitCode, reason, and signal. Querying it with jsonpath returns exactly the diagnostic data the monitoring agent needs, allowing a reason of OOMKilled to be separated from a generic Error exit code without inspecting node-level logs or restarting anything.

Why this answer

Container termination facts are persisted on the pod's status under containerStatuses, where lastState.terminated holds the exitCode, reason, and timing of the previous instance. Extracting that subtree with jsonpath or a custom-columns output gives the monitoring agent the precise reason value, such as OOMKilled, that distinguishes a memory kill from an ordinary application failure. Logs and node descriptions do not carry this structured field.

Exam trap

The trap here is reaching for kubectl logs --previous when the requested datum is a structured exit code that only exists in pod status.

28
MCQhard

A pod has a readiness probe using tcpSocket on port 3306. The application listens on port 3306 but returns errors on database queries. What is the effect of the readiness probe?

A.The pod will be evicted from the node
B.The pod will be considered ready as long as the TCP port is open, even if the application is not fully functional
C.The pod will be marked not ready because the application returns errors
D.The container will be restarted due to readiness probe failure
AnswerB

A tcpSocket readiness probe is considered successful if the kubelet can establish a TCP connection to the specified port, typically via a three-way handshake. It does not send any application-level data, nor does it read or inspect the application's response. Consequently, as long as the listening socket is open, the pod is marked Ready and receives traffic, even if the application inside is misconfigured, returning errors, or not fully initialized.

Why this answer

A readiness probe with tcpSocket only checks whether the TCP port is open and accepting connections. It does not verify application-level health, such as whether the application can process queries or return valid responses. Since port 3306 is open, the probe succeeds, and the pod is considered ready, even though the application returns errors on database queries.

Exam trap

The trap here is that candidates often assume readiness probes check application health or error responses, but a tcpSocket probe only verifies that the port is open, not that the application is working correctly.

How to eliminate wrong answers

Option A is wrong because readiness probe failures do not cause pod eviction; eviction is related to node resource pressure or taints, not probe results. Option C is wrong because a tcpSocket readiness probe does not evaluate application-level errors; it only checks if the TCP handshake succeeds on the specified port. Option D is wrong because readiness probe failures do not restart the container; only liveness probe failures trigger container restarts.

29
Multi-Selecthard

Which TWO of the following are valid reasons for using a startup probe?

Select 2 answers
A.To monitor the health of a container after it has started
B.To prevent unnecessary restarts during initial startup
C.To provide additional logging for the container
D.To replace the need for a readiness probe
E.To delay the start of liveness and readiness probes for slow-starting containers
AnswersB, E

During the startup phase, the liveness probe is suppressed until the startup probe succeeds, so a slow-initializing container will not be prematurely killed. By configuring a generous failureThreshold and periodSeconds, the startup probe gives the container a controlled window to become ready. This prevents a crash-looping cycle that would otherwise occur when a liveness check fires before the application is fully operational.

Why this answer

A startup probe is specifically designed to address containers that require a longer initialization time before they are ready to handle traffic or respond to health checks. By delaying the start of liveness and readiness probes until the startup probe succeeds, it prevents the kubelet from prematurely restarting the container due to failed liveness checks during its slow startup phase. This is the primary reason for using a startup probe: to avoid unnecessary restarts during initial startup.

Exam trap

The trap here is that candidates confuse the startup probe with a readiness probe, thinking it controls traffic routing, when in fact it only controls the activation timing of liveness and readiness probes.

30
MCQeasy

A pod is in CrashLoopBackOff state. You need to view the last few lines of its logs to understand why it is crashing. Which command is most appropriate?

A.kubectl logs -f my-pod
B.kubectl logs my-pod
C.kubectl logs my-pod --tail=20
D.kubectl get events --field-selector involvedObject.name=my-pod
AnswerC

The --tail=20 flag instructs kubectl to print only the last 20 lines of the container's log output. For a pod in CrashLoopBackOff, these final lines almost always contain the exact exception, panic, or error that triggered the latest restart. This targeted snapshot cuts through the noise of earlier failed attempts and gives you the actionable diagnostic information you need immediately.

Why this answer

The `--tail=20` flag limits the output to the last 20 lines of the pod's logs, which is the most efficient way to see the recent crash-related errors without scrolling through the entire log history. In a CrashLoopBackOff state, the pod is repeatedly restarting, so viewing the tail of the logs directly shows the most recent failure messages, which is the standard diagnostic approach.

Exam trap

CNCF often tests the distinction between `kubectl logs` and `kubectl logs -f`, where candidates mistakenly choose the `-f` option thinking it shows 'the last few lines' because of the 'follow' concept, but `-f` actually streams new logs and does not limit output to a specific number of lines.

How to eliminate wrong answers

Option A is wrong because `kubectl logs -f` follows (tails) the log stream continuously, which is useful for real-time monitoring but not for viewing the last few lines of a crashed pod's logs; it will hang waiting for new output that may never come if the pod is not actively logging. Option B is wrong because `kubectl logs my-pod` without `--tail` will output the entire log history, which can be excessively long and inefficient for quickly identifying the crash cause, especially in pods with many restarts. Option D is wrong because `kubectl get events` shows cluster events (e.g., scheduling, pulling images) but does not display the application's stdout/stderr logs; it provides operational context but not the specific error messages from the crashing container.

31
MCQhard

You are a platform engineer managing a production Kubernetes cluster. A team deploys a stateful application called 'inventory-service' with 3 replicas using a StatefulSet. Each pod writes logs to a persistent volume via a PersistentVolumeClaim. Recently, the team reports that the application becomes unresponsive after running for a few hours. You notice that the pods are still running (READY 1/1) but the application does not respond to HTTP requests. You exec into one pod and find that the disk is 100% full. The PVC is backed by a cloud disk (e.g., AWS EBS). You check the pod's resource limits and see that memory and CPU are not exhausted. The container logs are not rotated. Which course of action should you take to resolve the immediate issue and prevent recurrence?

A.Increase the size of the PVC to provide more disk space, and configure log rotation inside the container to limit log file size
B.Add a sidecar container that compresses and archives logs to a remote storage every hour
C.Change the application to log to stdout and configure Docker log rotation on the host
D.Configure a log rotation sidecar that writes logs to an emptyDir volume with size limit
AnswerA

Resizing the PersistentVolumeClaim provides immediate temporary relief by giving the container more disk headroom, which is often the fastest way to mitigate an acute disk-full incident. However, without log rotation inside the container, the new space will eventually be consumed again, so configuring rotation (e.g., logrotate to cap total log size) prevents recurrence by keeping per-file and aggregate growth bounded. This combination addresses the immediate symptom and the root cause, making it the right answer.

Why this answer

The immediate issue is a full disk caused by unrotated logs. Increasing the PVC size provides temporary relief, while configuring log rotation inside the container (e.g., using logrotate or the application's own rotation) prevents the disk from filling up again. This directly addresses the root cause without changing the application's logging behavior or introducing unnecessary sidecars.

Exam trap

CNCF often tests the distinction between logs written to stdout (handled by container runtime) versus logs written to a file inside the container (which require explicit rotation or external management).

How to eliminate wrong answers

Option B is wrong because compressing and archiving logs to remote storage does not free disk space on the local PVC; the logs remain on disk until deleted, so the disk will still fill up. Option C is wrong because changing the application to log to stdout and configuring Docker log rotation on the host does not affect logs written to a persistent volume; the application is writing logs to a file inside the container, not to stdout. Option D is wrong because using an emptyDir volume with a size limit would only cap the sidecar's own log storage, not the application's logs written to the PVC; the application's logs would still fill the PVC.

32
MCQhard

A pod is running but the application inside is not serving traffic. The team runs 'kubectl exec -it <pod> -- curl localhost:8080' and gets 'Connection refused'. What is the most likely cause?

A.Container logs are full and writing to disk is slow
B.NetworkPolicy is blocking traffic
C.Application is not listening on port 8080
D.Liveness probe is failing and restarting the container
AnswerC

Connection refused means the client sent a SYN to port 8080 on the loopback address, and the kernel responded with RST because nothing is bound to that listen socket. The application either never started, crashed before binding, or is configured to listen on a different port or interface such as 127.0.0.1:9090 instead of 0.0.0.0:8080. Troubleshooting should include checking the process in the container (ss -tlnp), reading application logs, and confirming the command/config passed to the container.

Why this answer

The 'Connection refused' error from curl indicates that the TCP connection to port 8080 was actively rejected by the kernel, meaning no process is listening on that port inside the container. This is most commonly caused by the application not starting, crashing before binding, or being configured to listen on a different port (e.g., 3000, 8443). The error is immediate and does not suggest a timeout or network-level block.

Exam trap

CNCF often tests the distinction between 'Connection refused' (no listener) and 'Connection timed out' (network block) — candidates mistakenly attribute the error to NetworkPolicy or resource issues, but the immediate RST is a definitive sign of a missing socket, not a network filter.

How to eliminate wrong answers

Option A is wrong because full container logs or slow disk writes would cause performance degradation or write errors, not a TCP 'Connection refused' — the kernel would still accept the connection if a socket is listening. Option B is wrong because NetworkPolicy operates at the network layer (iptables/eBPF) to allow or deny traffic between pods, but 'kubectl exec' runs inside the pod's network namespace, bypassing NetworkPolicy entirely; a NetworkPolicy cannot block localhost traffic. Option D is wrong because a failing liveness probe would cause the container to be restarted, but during the restart window the application might briefly be unavailable; however, 'Connection refused' is a persistent socket-level rejection, not a transient restart behavior, and a failing probe would also show events or crash loop status, not just a curl error.

33
MCQmedium

You run 'kubectl get pods -o wide' and see that a pod's NODE column shows 'node-1'. You want to see more details about that node's resource usage. Which command should you use?

A.kubectl top pods --all-namespaces
B.kubectl describe node node-1
C.kubectl top pod node-1
D.kubectl top node node-1
AnswerD

kubectl top node node-1 is correct because it directly queries the metrics-server for that specific node and displays real-time CPU and memory utilization at the node level. This command provides a snapshot of current usage, typically expressed as a percentage and absolute values, fulfilling the requirement to see what resources the node is actually using.

Why this answer

`kubectl top node node-1` directly displays real-time resource usage (CPU and memory) for the specified node, which is exactly what you need when you want to see more details about a node's resource consumption after identifying the node from `kubectl get pods -o wide`.

Exam trap

The trap here is that candidates confuse `kubectl top node` with `kubectl top pod` or `kubectl describe node`, mistakenly thinking that `describe` provides real-time resource usage or that `top pod` can target a node by name.

How to eliminate wrong answers

Option A is wrong because `kubectl top pods --all-namespaces` shows resource usage for pods across all namespaces, not for a specific node. Option B is wrong because `kubectl describe node node-1` shows detailed metadata, conditions, and capacity of the node, but not real-time resource usage metrics like CPU and memory consumption. Option C is wrong because `kubectl top pod node-1` attempts to get resource usage for a pod named 'node-1', not for a node; the command syntax is invalid for node-level metrics.

34
Multi-Selecthard

Which THREE of the following are valid fields for configuring a probe in Kubernetes? (Select 3)

Select 3 answers
A.initialDelaySeconds
B.retrySeconds
C.intervalSeconds
D.periodSeconds
E.timeoutSeconds
AnswersA, D, E

The field specifies the waiting period after the container starts before the kubelet begins running the probe. It is crucial for applications that need time to initialize, such as loading configuration or establishing connections. Without it, probes might fail prematurely, causing unnecessary restarts. The field is part of the probe specification along with periodSeconds, timeoutSeconds, successThreshold, and failureThreshold.

Why this answer

`initialDelaySeconds` is a valid field in a Kubernetes probe configuration (e.g., livenessProbe, readinessProbe, startupProbe). It defines the number of seconds after the container has started before the probe is initiated, allowing the application time to initialize before health checks begin.

Exam trap

The trap here is that candidates confuse `intervalSeconds` with `periodSeconds` and `retrySeconds` with `failureThreshold`, as the incorrect options sound plausible but do not exist in the Kubernetes API specification.

35
MCQmedium

A pod with a startup probe configured is taking longer than usual to start. The startup probe has 'failureThreshold: 10' and 'periodSeconds: 5'. What is the maximum time the pod has to start before it is restarted?

A.50 seconds
B.10 seconds
C.30 seconds
D.60 seconds
AnswerA

The correct calculation multiplies failureThreshold (10) by periodSeconds (5), yielding 50 seconds. With no initialDelaySeconds specified, the kubelet begins probing immediately and gives exactly this window for the container to become ready. If the probe fails 10 consecutive times at 5-second intervals, the kubelet restarts the container, making 50 seconds the definitive startup deadline.

Why this answer

The maximum time a pod has to start before being restarted is calculated by multiplying the startup probe's `failureThreshold` (10) by its `periodSeconds` (5), which equals 50 seconds. This is because the startup probe runs every 5 seconds, and after 10 consecutive failures (i.e., the probe never succeeds within that window), the kubelet restarts the container. The startup probe is specifically designed to give slow-starting applications a grace period before the liveness probe takes over.

Exam trap

The trap here is that candidates often forget to multiply `failureThreshold` by `periodSeconds` and instead pick a single value (like 10 or 5) or add them, missing the core formula for probe timeout calculation.

How to eliminate wrong answers

Option B (10 seconds) is wrong because it incorrectly assumes the `failureThreshold` alone (10) is the time limit, ignoring the `periodSeconds` multiplier. Option C (30 seconds) is wrong because it might result from multiplying `failureThreshold` (10) by a mistaken `periodSeconds` of 3, or from adding the two values (10+5=15) and doubling, but it does not match the correct product of 10*5=50. Option D (60 seconds) is wrong because it likely comes from misreading `periodSeconds` as 6 or adding an extra 10 seconds; the correct calculation is strictly `failureThreshold * periodSeconds`.

36
Multi-Selecthard

Which THREE of the following are valid reasons to use a startup probe? (Select THREE.)

Select 3 answers
A.To handle containers that have a variable startup time
B.To check if the container is healthy after startup
C.To delay readiness and liveness probes until the application is fully initialized
D.To remove the pod from service endpoints if it fails
E.To allow a container a long time to start up without being killed by liveness probe
AnswersA, C, E

Containers that take a variable amount of time to become ready—for example, because they must load large datasets or wait for external dependencies—can trip the default liveness probe settings and be restarted before they finish initializing. A startup probe lets you set a generous periodSeconds and failureThreshold so the kubelet waits an adequate, configurable window that can encompass all startup variability. Once the startup probe succeeds, normal liveness/readiness probing begins, but the startup probe itself ensures the variable initialization doesn't cause premature termination.

Why this answer

A startup probe is specifically designed for containers that have a variable or long initialization time. It allows the kubelet to delay the start of liveness and readiness probes until the application has finished starting up, preventing premature failures.

Exam trap

CNCF often tests the distinction between probe types, and the trap here is confusing the startup probe's role of delaying other probes with the readiness probe's role of controlling service traffic, or the liveness probe's role of restarting unhealthy containers.

37
MCQmedium

You run 'kubectl get events' and see an event 'FailedScheduling' for a pod. What is the most common cause?

A.Insufficient node resources to meet the pod's requests
B.The pod's container image pull failed
C.The liveness probe failed
D.The pod was deleted by a Deployment update
AnswerA

The FailedScheduling event is emitted by the kube-scheduler when no node passes all scheduling predicates for the pod. For a plain resource shortage, the scheduler cannot find a node with enough allocatable CPU/memory to meet the sum of container requests (not limits). This can also be triggered by node selectors, taints/tolerations, or affinity rules excluding every node, but the most common cause is insufficient resources. The event message typically names the specific constraint, such as 'Insufficient memory', for the node(s) attempted.

Why this answer

The 'FailedScheduling' event indicates that the Kubernetes scheduler could not find a suitable node to place the pod. The most common cause is insufficient node resources (CPU, memory, or ephemeral storage) to meet the pod's resource requests defined in the pod spec. The scheduler uses the `kube-scheduler` component to evaluate node fit based on predicates like `PodFitsResources`, and if no node satisfies the requested resources, the pod remains in a Pending state with this event.

Exam trap

The trap here is that candidates confuse 'FailedScheduling' with pod runtime failures (like image pull or probe failures), but scheduling events occur before the pod is bound to a node, so only resource-related or node affinity issues apply.

How to eliminate wrong answers

Option B is wrong because a container image pull failure generates a 'Failed' or 'ErrImagePull' event, not 'FailedScheduling', and is handled by the kubelet on an already scheduled node. Option C is wrong because a liveness probe failure causes the kubelet to restart the container, not a scheduling failure; it would produce a 'Unhealthy' or 'BackOff' event. Option D is wrong because a Deployment update that deletes a pod triggers a 'Killing' event and the pod is terminated, not left unscheduled; 'FailedScheduling' occurs before the pod is placed on any node.

38
Multi-Selecthard

Which THREE commands can be used to get detailed information about a pod named 'my-pod'? (Choose three.)

Select 3 answers
A.kubectl logs my-pod
B.kubectl get pod my-pod -o json
C.kubectl describe pod my-pod
D.kubectl exec my-pod -- env
E.kubectl get pod my-pod -o yaml
AnswersB, C, E

Running `kubectl get pod my-pod -o json` requests the full Pod resource from the Kubernetes API and formats it as a JSON document. This output contains the complete object, including metadata (labels, annotations, ownerReferences), the desired spec, and the live status (pod IP, phase, container states, conditions). It is the canonical machine-readable representation, which can be piped to tools like `jq` for automation.

Why this answer

`kubectl get pod my-pod -o json` retrieves the full object representation of the pod in JSON format, which includes all fields such as metadata, spec, status, and annotations. This provides detailed, machine-readable information about the pod's current state and configuration.

Exam trap

CNCF often tests the distinction between commands that retrieve object metadata/status (get/describe) versus commands that interact with the pod's runtime (logs/exec), leading candidates to mistakenly select runtime commands for 'detailed information' about the pod itself.

39
MCQmedium

You need to collect metrics from an application running in a pod. The application exposes metrics on port 8080 at /metrics in Prometheus format. Which resource should you configure to allow Prometheus to scrape these metrics?

A.Create an Ingress resource that exposes the /metrics endpoint externally.
B.Create a ConfigMap with the Prometheus scrape configuration and mount it into the Prometheus pod.
C.Create a Service with annotation 'prometheus.io/scrape: "true"' and 'prometheus.io/port: "8080"'.
D.Add a PrometheusRule resource that defines the scrape target.
AnswerC

This is the standard approach for Prometheus operator's annotation-based discovery: the service's annotations `prometheus.io/scrape: "true"` and `prometheus.io/port: "8080"` allow the auto-discovery component to generate a scrape_config targeting the service's endpoints on port 8080. The Service provides a stable DNS name and selects the pods, so even if pod IPs change, Prometheus can dynamically look up the current endpoints. This is distinct from the static ConfigMap method because it enables automatic, label-based target discovery across the cluster.

Why this answer

Prometheus uses a pull-based model to scrape metrics from targets. By adding the `prometheus.io/scrape: "true"` and `prometheus.io/port: "8080"` annotations to a Service that selects the pod, you enable Prometheus's built-in service discovery to automatically detect and scrape the `/metrics` endpoint on port 8080 without manual configuration.

Exam trap

The trap here is that candidates confuse Prometheus's pull-based scraping with push-based or external access patterns, leading them to choose Ingress (external exposure) or PrometheusRule (alerting) instead of the service annotation that enables automatic internal discovery.

How to eliminate wrong answers

Option A is wrong because an Ingress resource exposes HTTP/HTTPS routes externally for client access, not for Prometheus scraping; Prometheus scrapes internally and does not use Ingress for target discovery. Option B is wrong because while a ConfigMap can hold Prometheus scrape configuration, mounting it into the Prometheus pod is a manual configuration step, not the resource that enables automatic scraping of an application pod; the question asks which resource to configure on the application side to allow scraping. Option D is wrong because a PrometheusRule resource defines alerting and recording rules, not scrape targets; scrape targets are defined via ServiceMonitor, PodMonitor, or service annotations.

40
MCQhard

You have a Deployment that uses an httpGet liveness probe on port 8080 with path /healthz. The probe fails after the container starts, but you can successfully curl http://localhost:8080/healthz from within the container. What is the most likely cause?

A.The liveness probe port is incorrect
B.The container is not running
C.The liveness probe path is incorrect
D.The container is listening on localhost (127.0.0.1) instead of 0.0.0.0
AnswerD

The liveness probe is executed by the kubelet on the node, which dials the pod's IP address on the specified port, not the container's loopback interface. If the application binds only to 127.0.0.1 (or ::1), it is reachable solely from within its own network namespace, making the pod IP's port appear closed or refused from the node. This exactly matches the symptom: curl localhost:8080 succeeds inside the container, but the kubelet's external connection fails. The fix is to configure the application server to listen on 0.0.0.0 (or the container's specific eth0 IP) so it accepts connections on all interfaces.

Why this answer

The liveness probe is executed by the kubelet from the node's network namespace, not from within the container. If the application binds only to 127.0.0.1 (localhost), it will only accept connections from within the container itself. The kubelet's HTTP GET request to the pod's IP on port 8080 will be refused because the socket is not listening on 0.0.0.0, causing the probe to fail even though a local curl succeeds.

Exam trap

The trap here is that candidates see a successful curl from inside the container and assume the probe should work, failing to realize that the kubelet probes from outside the container's network namespace and cannot reach a service bound only to 127.0.0.1.

How to eliminate wrong answers

Option A is wrong because the probe is configured to use port 8080, and the curl test confirms the application is indeed listening on port 8080 inside the container, so the port is correct. Option B is wrong because the container is clearly running — the user can successfully execute curl inside it, which requires a running container. Option C is wrong because the curl test uses the exact same path /healthz and succeeds, proving the path is correct and the endpoint is reachable from within the container.

41
MCQmedium

A pod named 'app' is stuck in 'Pending' state. You run 'kubectl describe pod app' and see the event: '0/3 nodes are available: 3 Insufficient cpu'. What is the most likely cause?

A.The pod's CPU request is higher than the available CPU on any node
B.The container image is not found
C.The pod is in CrashLoopBackOff
D.The pod has been evicted due to memory pressure
AnswerA

A pod with a CPU request exceeding the allocatable CPU on every node cannot be scheduled. The Kubernetes scheduler filters out nodes lacking sufficient unallocated capacity to satisfy the request, leaving the pod in the Pending phase and emitting events such as 'Insufficient cpu'. Requests, not limits, drive these placement decisions, so the pod can wait indefinitely until node capacity is freed or the request is lowered.

Why this answer

The event '0/3 nodes are available: 3 Insufficient cpu' indicates that the pod's CPU resource request exceeds the allocatable CPU capacity on every node in the cluster. Kubernetes schedules pods based on resource requests, not limits, so if the sum of CPU requests across all pods on a node would exceed the node's capacity, the pod remains Pending. This is the most likely cause because the error message directly points to insufficient CPU resources.

Exam trap

The trap here is that candidates confuse resource requests with resource limits, or assume that the pod is failing at runtime (like CrashLoopBackOff) when the error is purely a scheduling issue indicated by the Pending state and the specific 'Insufficient cpu' event.

How to eliminate wrong answers

Option B is wrong because a missing container image would produce an 'ImagePullBackOff' or 'ErrImagePull' event, not an 'Insufficient cpu' scheduling error. Option C is wrong because CrashLoopBackOff is a pod status that occurs after the pod has been scheduled and started, not while it is still Pending. Option D is wrong because eviction due to memory pressure results in a 'Evicted' status, not a Pending state, and the event would mention memory, not CPU.

42
MCQmedium

You want to see the IP address and the node on which each pod in the 'default' namespace is running. Which command provides this information?

A.kubectl describe pods
B.kubectl get pods -o wide
C.kubectl get pods --show-labels
D.kubectl get pods -o yaml
AnswerB

kubectl get pods -o wide is correct because the -o wide flag extends the default pod listing with the IP and NODE columns, displaying each pod's cluster-assigned IP address and the name of the node hosting it. These fields come directly from the pod's status.podIP and spec.nodeName, and the output remains a single-row-per-pod table, making it ideal for quickly answering exactly what the question asks.

Why this answer

`kubectl get pods -o wide` outputs additional columns including the pod's IP address and the node it is scheduled on, which directly answers the question. The `-o wide` flag extends the default output format to show these fields without requiring a full resource description or YAML output.

Exam trap

The trap here is that candidates may choose `kubectl describe pods` (Option A) because it shows IP and node information, but they overlook that `-o wide` provides a cleaner, tabular view for multiple pods, which is the intended use case in the question.

How to eliminate wrong answers

Option A is wrong because `kubectl describe pods` shows detailed information about pods, including IP and node, but it is not a concise command to 'see' this data for all pods at once; it requires scrolling through verbose output per pod. Option C is wrong because `--show-labels` only adds label columns to the default pod list, not IP or node information. Option D is wrong because `-o yaml` outputs the full YAML representation of pod objects, which includes IP and node fields but is overly verbose and not the standard way to quickly view this tabular data.

43
Multi-Selecthard

A pod is running but not serving traffic. You suspect the readiness probe is failing. Which THREE commands or actions would help you diagnose the readiness probe issue?

Select 3 answers
A.Examine the container logs for errors during readiness probe checks.
B.Run 'kubectl top pod <pod-name>' to check CPU/memory usage.
C.Run 'kubectl get nodes' to see node conditions.
D.Run 'kubectl describe pod <pod-name>' to check the events section for probe failures.
E.Exec into the container and manually curl the readiness endpoint to test it.
AnswersA, D, E

Container logs are one of the first places to look when a readiness probe fails. The kubelet sends probe requests (e.g., HTTP GET to the probe path), and if the application logs each request, you may see the probe arriving with a non-2xx status, stack traces, or slow response times indicating why the endpoint is not healthy. While probe requests are not always logged, if they are, they can directly reveal the underlying cause such as a crash loop, a missing dependency, or a connection timeout.

Why this answer

Container logs often contain detailed error messages from the readiness probe itself, such as HTTP 4xx/5xx responses or connection timeouts. By examining the logs, you can directly see why the probe is failing, e.g., the application's health endpoint returning a non-2xx status or the probe timing out.

Exam trap

CNCF often tests the distinction between resource monitoring commands and probe-specific diagnostics, so candidates may mistakenly choose 'kubectl top pod' or 'kubectl get nodes' thinking they reveal probe failures, when in fact only describe, logs, and direct endpoint testing are relevant.

44
MCQmedium

A team ships a container that writes structured JSON diagnostics to stdout and nothing to a file. A support engineer needs to filter those lines for entries with level 'error' across all containers of a deployment named 'checkout', without installing additional tooling on the nodes. Which approach accomplishes this using only kubectl?

A.kubectl logs deployment/checkout --since=1h --tail=-1
B.kubectl exec -it deployment/checkout -- cat /var/log/app.log | grep error
C.kubectl describe deployment checkout | grep error
D.kubectl logs deployment/checkout --all-containers=true | grep '"level":"error"'
AnswerD

kubectl logs accepts a deployment as a resource argument and, with --all-containers=true, streams logs from every container in the pods the deployment owns. Piping that combined stream through grep filters the JSON lines locally in the engineer's shell, satisfying the requirement with no extra software on the cluster nodes.

Why this answer

Container logs are fetched from the kubelet's log files through the API server by kubectl logs, which can target a workload such as a deployment and aggregate every container with --all-containers=true. Filtering that aggregated stream in the local shell with grep isolates the structured error entries. Options that adjust time windows, describe the deployment, or read a nonexistent file inside one pod do not deliver the filtered, deployment-wide view that was requested.

Exam trap

The trap here is assuming kubectl logs can filter by content or that a deployment's diagnostics live anywhere other than the containers' stdout streams.

45
MCQmedium

You need to configure a container to shut down gracefully when it receives a SIGTERM signal, with a timeout of 30 seconds before force kill. Which field in the Pod spec should you set?

A.activeDeadlineSeconds
B.livenessProbe.periodSeconds
C.restartPolicy
D.terminationGracePeriodSeconds
AnswerD

terminationGracePeriodSeconds is the correct Pod-level setting that determines how long Kubernetes waits between sending SIGTERM and the forced SIGKILL when a Pod is being terminated. This gives the main container process time to flush state, close connections, and complete cleanup. It is configurable per Pod in the Pod spec and defaults to 30 seconds; setting it appropriately is essential for graceful shutdown.

Why this answer

The `terminationGracePeriodSeconds` field in a Pod spec defines the duration (in seconds) that Kubernetes waits after sending a SIGTERM signal to the container's main process before forcefully killing it with SIGKILL. Setting this to 30 seconds allows the container to perform graceful shutdown tasks (e.g., closing connections, flushing data) within that window, meeting the requirement.

Exam trap

The trap here is confusing `terminationGracePeriodSeconds` with `activeDeadlineSeconds` (which limits Pod runtime) or assuming `restartPolicy` affects shutdown behavior, when in fact only `terminationGracePeriodSeconds` controls the SIGTERM-to-SIGKILL timeout.

How to eliminate wrong answers

Option A is wrong because `activeDeadlineSeconds` sets a hard time limit for the Pod's overall runtime (e.g., for Jobs), not the grace period for shutdown after SIGTERM. Option B is wrong because `livenessProbe.periodSeconds` controls how often the kubelet checks if the container is alive, not the termination behavior. Option C is wrong because `restartPolicy` determines whether containers are restarted after exit (Always, OnFailure, Never), and has no effect on the SIGTERM-to-SIGKILL timeout.

46
MCQeasy

Which command shows resource usage (CPU/memory) of pods in the default namespace?

A.kubectl get pods -o wide
B.kubectl logs pod
C.kubectl top pod
D.kubectl describe pod
AnswerC

kubectl top pod is the correct command because it queries the metrics API (typically backed by metrics-server) to retrieve and display live CPU and memory usage for each pod. It shows current resource consumption at the container and pod level, and optionally displays per-container details with the --containers flag. This makes it the standard command for quick, immediate resource observation.

Why this answer

`kubectl top pod` is the Kubernetes command that displays real-time CPU and memory usage metrics for pods, leveraging the metrics server to collect resource utilization data. This command is essential for monitoring pod performance and is part of the Application Observability and Maintenance domain.

Exam trap

The trap here is that candidates often confuse `kubectl get pods -o wide` or `kubectl describe pod` with resource monitoring commands, but neither provides live CPU/memory metrics, which only `kubectl top pod` (with the Metrics Server) can deliver.

How to eliminate wrong answers

Option A is wrong because `kubectl get pods -o wide` shows pod details like node IP and pod IP, but does not include CPU or memory usage metrics. Option B is wrong because `kubectl logs pod` retrieves container logs, not resource usage statistics. Option D is wrong because `kubectl describe pod` provides detailed configuration and status information, but does not display live CPU or memory consumption data.

47
MCQhard

A deployment 'api-deploy' has resource limits set but is frequently being OOMKilled. The team suspects the memory limit is too low. Which approach should be taken to confirm this without causing downtime?

A.Create a new pod with a higher memory limit and delete the old pods manually.
B.Set the memory limit to unlimited by removing the limit section and restart the pod.
C.Use 'kubectl set resources' to increase the limit on the running pod dynamically.
D.Increase the memory limit in the deployment spec and apply the change; the rollout will automatically restart pods.
AnswerD

Editing the Deployment's pod template and applying the manifest updates the desired state, which makes the Deployment controller create a new ReplicaSet while scaling down the old one according to the configured strategy (default RollingUpdate). New pods are launched with the increased memory limit, and old pods are terminated only once the new ones are Healthy, keeping the service available throughout. Because the Pod spec is immutable, the template change is the declarative, supported path to alter resources without manual pod handling.

Why this answer

Updating the deployment spec triggers a rolling update, which replaces pods with new ones having the increased memory limit without downtime. This approach leverages Kubernetes' deployment controller to manage the rollout automatically, ensuring service continuity while adjusting resource limits.

Exam trap

The trap here is that candidates confuse 'kubectl set resources' with a dynamic in-place update, not realizing it modifies the deployment spec and requires a rollout to take effect, similar to editing the YAML directly.

How to eliminate wrong answers

Option A is wrong because manually creating and deleting pods bypasses the deployment's desired state management, risking configuration drift and potential downtime if not coordinated properly. Option B is wrong because removing the memory limit entirely can lead to resource starvation for other pods and violates Kubernetes best practices; it also requires restarting the pod, causing downtime. Option C is wrong because 'kubectl set resources' modifies the deployment spec, not the running pod directly; the pod must be recreated to apply the new limits, and the command triggers a rollout, not a dynamic in-place update.

48
Drag & Dropmedium

Sequence the steps to troubleshoot a Pod stuck in CrashLoopBackOff state.

Drag or tap steps into the slots.

Steps
Order
1Step 1
2Step 2
3Step 3
4Step 4

Why this order

Start by checking status, then inspect logs and events to diagnose. Fix the issue, then restart the Pod.

49
MCQeasy

Which command shows resource usage (CPU and memory) for pods in a namespace?

A.kubectl top node
B.kubectl top pod -n <namespace>
C.kubectl top pods
D.kubectl get pods --show-labels
AnswerB

This is the correct command because it directly queries the metrics API for pod-level CPU and memory usage from the Metrics Server. The `-n` flag scopes the output to a specific namespace, and when combined with a pod name or label selector it shows live resource consumption for those pods. Without `-n`, it defaults to the current namespace, but specifying it explicitly ensures you are viewing the intended namespace.

Why this answer

The `kubectl top pod` command is the correct way to view real-time CPU and memory usage for pods in a specific namespace. The `-n <namespace>` flag targets the desired namespace, and the command relies on the metrics-server to collect resource usage data from the kubelet's cAdvisor endpoint.

Exam trap

The trap here is that candidates often confuse `kubectl top pod` (which requires the metrics-server) with `kubectl describe pod` (which shows resource requests/limits, not actual usage), or they omit the `-n` flag and assume it works across all namespaces.

How to eliminate wrong answers

Option A is wrong because `kubectl top node` shows resource usage for nodes (the entire worker machine), not for individual pods within a namespace. Option C is wrong because `kubectl top pods` without a namespace flag defaults to the current context's namespace (often `default`), not the specified namespace, and is incomplete without `-n`. Option D is wrong because `kubectl get pods --show-labels` only lists pod metadata and labels, not CPU or memory usage metrics.

50
MCQmedium

You need to view the logs of a container that previously crashed and has been restarted. Which flag do you use with 'kubectl logs'?

A.--all-containers
B.--tail
C.--previous
D.-f
AnswerC

The --previous flag specifically tells kubectl to display logs from the prior container instance that ran in the pod, typically one that has terminated due to a crash or a restart. The kubelet retains the terminated container's logs in a separate file, and this flag directs kubectl to that historical log while ignoring the current container's output. This is exactly what you need to diagnose why a container previously crashed, as it shows the last output before the failure.

Why this answer

The `--previous` flag is used with `kubectl logs` to view logs from the previous instance of a container that has crashed and been restarted. This allows you to inspect the logs of the terminated container before the restart, which is essential for debugging crash loops.

Exam trap

CNCF often tests the distinction between flags that affect log output formatting (`--tail`, `-f`) versus flags that change which container instance's logs are accessed (`--previous`), leading candidates to confuse `--tail` or `-f` as solutions for viewing previous crash logs.

How to eliminate wrong answers

Option A is wrong because `--all-containers` is used to stream logs from all containers in a pod, not specifically from a previously crashed container. Option B is wrong because `--tail` limits the number of lines shown from the log output, but it does not retrieve logs from a previous container instance. Option D is wrong because `-f` (follow) streams logs in real-time, which is useful for live monitoring but does not access historical logs from a crashed container.

51
MCQeasy

A developer deployed a pod named 'web-pod' with a single container. Users report intermittent 502 errors. The developer wants to see CPU and memory consumption of that specific container to determine whether it is being throttled. Which command should be used?

A.kubectl describe pod web-pod
B.kubectl logs web-pod --timestamps
C.kubectl top pod web-pod --containers
D.kubectl get pod web-pod -o yaml
AnswerC

This command queries the Metrics Server through the metrics.k8s.io API and prints per-container CPU and memory usage for the named pod. The --containers flag is required to break the output down by container when a pod has more than one, and it works fine for single-container pods too, giving exactly the usage figures needed to spot throttling.

Why this answer

Live resource consumption for a running pod is exposed through the Metrics Server and surfaced by the kubectl top subcommand. Requesting a per-container breakdown with the --containers flag gives the developer actual CPU and memory numbers for the named pod. Comparing those numbers against the container's declared limits is how throttling or memory pressure is confirmed, which describe, get -o yaml, and logs cannot provide.

Exam trap

The trap here is assuming that kubectl describe reports live CPU and memory usage, when it only shows declared requests and limits plus events.

52
MCQeasy

You have a Deployment running a web server that takes 30 seconds to initialize. You want to ensure that the load balancer does not send traffic to the pod until it is ready. Which probe should you configure?

A.Readiness probe
B.Resource limit
C.Startup probe
D.Liveness probe
AnswerA

The readiness probe is the correct mechanism because it directly controls whether a pod is added to or removed from the endpoints of a Service. When the probe fails, the kubelet marks the pod as NotReady, and the endpoints controller immediately removes its IP from all backing Services, stopping new traffic. This is essential for deployments where the application needs time to warm up or load data before accepting requests, and it also enables zero-downtime rolling updates by holding back new pods until they are fully operational.

Why this answer

A Readiness probe is the correct choice because it determines whether a Pod is ready to serve traffic. In this scenario, the web server takes 30 seconds to initialize, so a Readiness probe (e.g., an HTTP GET on the application's health endpoint) will prevent the Service (and thus the load balancer) from sending requests until the probe succeeds, ensuring zero traffic is routed to an uninitialized Pod.

Exam trap

The trap here is that candidates confuse Startup probes with Readiness probes, thinking a Startup probe alone will gate traffic, but only the Readiness probe controls whether the Service routes traffic to the Pod.

How to eliminate wrong answers

Option B is wrong because a Resource limit (CPU/memory) controls resource usage and scheduling, not traffic routing; it does not prevent the load balancer from sending traffic to an unready Pod. Option C is wrong because a Startup probe checks if the application has started successfully and is used for slow-starting containers, but it does not control traffic routing from the load balancer; once the Startup probe succeeds, the Liveness and Readiness probes take over, and the Readiness probe is the one that gates traffic. Option D is wrong because a Liveness probe restarts the container if it fails, but it does not prevent traffic from being sent to an unready Pod; a Pod can be alive but not ready, and the Liveness probe would not stop traffic.

53
Multi-Selecthard

A production pod named 'api-pod' runs a single container whose liveness probe has begun failing after a configuration change, causing repeated restarts. An engineer must determine whether the failures are caused by the probe configuration itself or by the application inside the container. Which TWO actions best provide that evidence? (Choose two.)

Select 2 answers
A.Run kubectl get pod api-pod -o yaml and confirm the container's imagePullPolicy is set to Always.
B.Run kubectl rollout restart deployment api-pod to force a fresh container image pull and clear the restart counter.
C.Run kubectl describe pod api-pod and inspect the Events section for Liveness probe failed messages with the probe's reported error and port.
D.Run kubectl top pod api-pod to compare CPU and memory consumption against the container's declared limits.
E.Run kubectl exec into the container and query the probe endpoint locally to see whether the application answers correctly from inside the pod network namespace.
AnswersC, E

Probe failures are surfaced as events on the pod, and the message includes the probe type, the failure detail, and the endpoint being tested. That directly shows whether the kubelet is dialing the wrong port or path, or whether the application is returning a failing status, which is exactly the distinction the engineer needs before changing anything.

Why this answer

Separating a bad probe definition from a broken application requires evidence from two directions. Pod events show what the kubelet observed when the probe ran, including the failing endpoint and error text, which exposes misconfigured ports, paths, or thresholds. Testing the same endpoint from inside the container shows whether the application actually responds, which rules the application in or out.

Together they localize the fault; resource metrics, image pull policy, and a forced restart do not.

Exam trap

The trap here is treating a restart of the workload as a diagnostic step, when it destroys the events and container state that reveal why the probe failed.

54
MCQmedium

You want to run a command inside a running container to check environment variables. Which command should you use?

A.kubectl logs pod-name
B.kubectl exec pod-name -- env
C.kubectl describe pod pod-name
D.kubectl exec -it pod-name -- /bin/bash
AnswerB

kubectl exec pod-name -- env executes the env binary as a separate process inside the container's namespaces, printing all environment variables visible to that process. The -- delimiter tells kubectl that everything after it is a command to run inside the container, not a flag for kubectl itself. This non-interactive, single-command invocation is exactly suited for checking environment variables.

Why this answer

`kubectl exec pod-name -- env` runs the `env` command inside the specified container, which prints all environment variables set in the container's runtime environment. This is the most direct and efficient way to inspect environment variables without entering an interactive shell.

Exam trap

The trap here is that candidates may choose Option D thinking they need an interactive shell to run `env`, but the question asks for the command to check environment variables directly, and `kubectl exec pod-name -- env` is the precise, non-interactive approach that works even in containers without a shell.

How to eliminate wrong answers

Option A is wrong because `kubectl logs pod-name` retrieves the container's stdout/stderr logs, not environment variables. Option C is wrong because `kubectl describe pod pod-name` shows the pod's specification and status, including environment variables defined in the pod spec, but it does not show runtime environment variables injected by the container runtime (e.g., from secrets, configmaps, or the platform). Option D is wrong because `kubectl exec -it pod-name -- /bin/bash` opens an interactive shell inside the container, which can then be used to run `env`, but it is not the direct command to check environment variables; it requires an extra step and assumes the container has a shell like bash.

55
MCQhard

You want to configure a pod so that it receives a SIGTERM signal and has 60 seconds to shut down gracefully before being forcefully killed. Which field should you set?

A.terminationGracePeriodSeconds: 60
B.lifecycle.preStop.exec.command with sleep 60
C.livenessProbe.initialDelaySeconds: 60
D.resources.limits.cpu
AnswerA

This field is the authoritative control for how long the kubelet will wait between sending SIGTERM and SIGKILL to a container during pod termination. Setting it to 60 explicitly grants the main process a 60-second window to handle the signal and shut down gracefully, whereas without it the default is only 30 seconds. This is the only direct mechanism for ensuring the pod receives SIGTERM and has time to react.

Why this answer

The `terminationGracePeriodSeconds` field in the Pod spec defines the duration (in seconds) that Kubernetes waits after sending a SIGTERM to the primary container process before sending a SIGKILL. Setting it to 60 gives the pod 60 seconds to shut down gracefully, which is exactly what the question requires.

Exam trap

The trap here is that candidates often confuse `lifecycle.preStop` with the grace period itself, thinking a `sleep` command in the preStop hook will extend the shutdown time, when in reality it only delays the SIGTERM and the total time before SIGKILL is still governed by `terminationGracePeriodSeconds`.

How to eliminate wrong answers

Option B is wrong because `lifecycle.preStop.exec.command` with `sleep 60` only adds a 60-second delay before the SIGTERM is sent, but does not extend the total grace period; if the grace period is shorter, the pod will still be killed after that shorter time. Option C is wrong because `livenessProbe.initialDelaySeconds: 60` controls how long to wait before starting the liveness probe, not the shutdown grace period. Option D is wrong because `resources.limits.cpu` sets a CPU resource limit for the container and has no effect on termination behavior.

56
MCQmedium

Your team manages a microservices application on a Kubernetes cluster. A critical service 'order-service' is deployed with 3 replicas. Lately, customers have reported occasional timeouts when placing orders. You suspect that the service is overloaded during peak hours. You have configured a HorizontalPodAutoscaler (HPA) based on CPU utilization, but the autoscaler does not appear to be scaling up quickly enough. Upon inspection, you notice that the HPA is configured with a target CPU utilization of 80%, and the current CPU usage of the pods is around 70%. However, the pods' memory usage is high and growing. The application is also logging slow database queries. Which action is most likely to improve the responsiveness of the service during peak load?

A.Modify the HPA to also scale based on memory utilization, setting a target average value for memory.
B.Reduce the number of replicas to 2 to force the HPA to react more aggressively.
C.Increase the CPU target utilization to 90% so the HPA triggers earlier.
D.Optimize the database queries to reduce response time.
AnswerA

Relying solely on CPU utilization can miss memory-bound workloads, where pods degrade due to memory pressure long before CPU approaches its target. Adding a memory metric to the HPA—using targetAverageValue or targetAverageUtilization—makes the autoscaler react to actual resource exhaustion. Since memory is a non-compressible resource, Kubernetes cannot throttle it as it does with CPU, so the only effective mitigation is to add replicas when average memory consumption exceeds the configured threshold.

Why this answer

The HPA is configured only for CPU, but the symptom (high memory usage, slow DB queries) indicates memory pressure is the bottleneck. Adding a memory-based metric to the HPA allows it to scale when memory exceeds the target, addressing the root cause of overload during peak hours. The current CPU at 70% is below the 80% threshold, so the HPA won't trigger on CPU alone, but memory scaling can react to the actual resource constraint.

Exam trap

The trap here is that candidates often assume CPU is the only metric for HPA scaling, but the CKAD exam tests the ability to identify when other metrics (like memory) are more relevant based on application behavior and symptoms.

How to eliminate wrong answers

Option B is wrong because reducing replicas to 2 would decrease capacity, worsening the overload and timeouts, not improving responsiveness. Option C is wrong because increasing the CPU target to 90% would make the HPA trigger later (at higher CPU), not earlier, and CPU is already below 80%, so this change would not help. Option D is wrong because while optimizing database queries is a valid long-term fix, it does not address the immediate scaling issue; the HPA should be configured to scale based on the actual bottleneck (memory) to handle peak load now.

57
MCQmedium

You have a pod that is in a 'Pending' state. You run 'kubectl describe pod' and see the event: '0/3 nodes are available: 3 Insufficient cpu'. What is the most likely cause?

A.The pod's CPU request is larger than the available CPU on any node
B.The pod requires more memory than any node can provide
C.The pod's liveness probe is failing
D.All nodes are tainted and the pod does not tolerate the taints
AnswerA

When a pod's CPU request exceeds the total allocatable CPU capacity on every node in the cluster, the kube-scheduler cannot find a feasible node and leaves the pod in Pending state. The scheduler compares each node's allocatable CPU against the sum of requests for all pods, and a `FailedScheduling` event with `Insufficient cpu` is recorded. This is a scheduling failure, not a runtime failure, so the pod remains Pending until a node with enough free CPU becomes available.

Why this answer

The event '0/3 nodes are available: 3 Insufficient cpu' indicates that the Kubernetes scheduler attempted to place the pod on each of the three nodes but found that none had enough allocatable CPU capacity to satisfy the pod's CPU request. This means the sum of CPU requests across all pods on each node, plus the new pod's request, exceeds the node's CPU capacity. The pod remains in 'Pending' because the scheduler cannot find a suitable node until CPU resources are freed or the request is reduced.

Exam trap

CNCF often tests the distinction between resource requests (used for scheduling) and resource limits (used for throttling), and candidates mistakenly think 'Insufficient cpu' refers to limits or actual usage rather than the guaranteed request that the scheduler evaluates.

How to eliminate wrong answers

Option B is wrong because the event explicitly mentions 'Insufficient cpu', not memory; a memory shortage would produce 'Insufficient memory'. Option C is wrong because liveness probe failures occur after the pod is running (in 'Running' state), not while it is still 'Pending' and before scheduling. Option D is wrong because taints and tolerations produce events like '0/3 nodes are available: 3 node(s) had taint {key:value} that the pod didn't tolerate', not 'Insufficient cpu'.

58
Multi-Selectmedium

Which TWO commands can be used to view the logs of a pod that has crashed?

Select 2 answers
A.kubectl logs <pod> --tail=0 -f
B.kubectl logs <pod> -c <container>
C.kubectl logs <pod> --previous
D.kubectl logs <pod> -p
E.kubectl logs <pod>
AnswersC, D

The --previous flag explicitly instructs kubectl to retrieve the logs written by the most recent terminated container instance of the pod. When a container has crashed or restarted, this shows the complete stdout/stderr from the old instance, which is often the only source of diagnostic information about the failure. It is the straightforward, unambiguous long-form command for viewing previous container logs.

Why this answer

`kubectl logs <pod> --previous` retrieves logs from the previous instance of a container in a pod that has crashed and been restarted. This is essential for debugging crash loops, as the current container may have no logs or only post-crash output. The `--previous` flag accesses the terminated container's logs stored by the kubelet.

Exam trap

CNCF often tests the distinction between `--previous` (or `-p`) and `-c` flags, where candidates mistakenly think `-c` retrieves logs from a crashed container instead of specifying a container name in a multi-container pod.

59
MCQeasy

What is the purpose of the 'kubectl describe pod' command?

A.Display detailed information about a pod, including recent events
B.Execute a command inside a pod
C.Display resource usage of a pod
D.Show the logs of a pod
AnswerA

kubectl describe pod outputs a detailed, human-readable summary of a pod's current state, including its metadata, spec, status, conditions, container states, restart counts, and, notably, a tail of recent events from the Kubernetes event stream. This event history is essential for debugging because it reveals scheduler decisions, image pull outcomes, and liveness/readiness probe failures that are not visible in the pod's YAML or its logs.

Why this answer

The 'kubectl describe pod' command retrieves detailed metadata about a specific pod, including its current state, labels, annotations, container specifications, volumes, and a chronological list of recent events (e.g., image pull failures, container restarts, scheduling decisions). This aggregated information is essential for debugging pod lifecycle issues because it surfaces both static configuration and dynamic cluster-level events that are not shown in the pod's YAML manifest or logs.

Exam trap

CNCF often tests the distinction between 'describe' (detailed metadata + events) and 'get' (summary or YAML output), so the trap here is confusing 'kubectl describe' with 'kubectl logs' or 'kubectl exec', especially when a pod is failing and candidates instinctively reach for logs instead of first checking events for scheduling or image-related errors.

How to eliminate wrong answers

Option B is wrong because executing a command inside a pod is done with 'kubectl exec', not 'kubectl describe'. Option C is wrong because resource usage (CPU/memory) is displayed by 'kubectl top pod', which relies on the metrics-server, not by 'kubectl describe'. Option D is wrong because showing logs is the purpose of 'kubectl logs', which streams stdout/stderr from containers, whereas 'kubectl describe' provides configuration and event data, not log output.

60
Multi-Selecteasy

Which TWO of the following are valid reasons to use a readiness probe? (Select 2)

Select 2 answers
A.To prevent traffic from being sent to a pod that is not ready due to a dependency
B.To ensure the pod is not added to a Service until the application is ready
C.To monitor resource usage and scale the pod
D.To delay the start of the application until a database is available
E.To restart the container if it becomes unresponsive
AnswersA, B

A readiness probe determines whether a pod can accept requests by periodically executing a check (HTTP, TCP, or command) inside the container; if the check fails because a required dependency, such as a database or configuration service, is not yet available, the pod is marked NotReady. The kubelet then removes the pod's IP from all backing Service EndpointSlices, so live traffic is never forwarded to a container that would fail the request. This prevents users from hitting a pod that is running but still initializing its dependent components.

Why this answer

A readiness probe is used to determine whether a pod is ready to serve traffic. Option A is correct because it prevents traffic from being sent to a pod that is not ready due to a dependency, such as a database or cache that hasn't fully initialized. The kubelet uses the probe's success or failure to control whether the pod's IP address is added to the endpoints of a Service, ensuring only ready pods receive requests.

Exam trap

CNCF often tests the distinction between readiness, liveness, and startup probes; the trap here is confusing the purpose of a readiness probe (traffic routing) with that of a liveness probe (container restart) or a startup probe (delaying other probes).

61
MCQeasy

Which command shows the CPU and memory usage of all pods in the current namespace?

A.kubectl top node
B.kubectl top --all
C.kubectl top pod pod-name
D.kubectl top pod
AnswerD

kubectl top pod — correct because it directly invokes the top command with the pod resource type, without a specific pod name, which causes it to retrieve CPU and memory usage for all pods running in the current namespace from the metrics API. This is the exact syntax required to get a namespace-wide view of pod resource consumption.

Why this answer

`kubectl top pod` without a specific pod name retrieves CPU and memory usage metrics for all pods in the current namespace, as the command defaults to listing all pods when no pod name is provided. This relies on the metrics-server collecting resource usage data from the kubelet's cAdvisor endpoint via the Resource Metrics API.

Exam trap

CNCF often tests the misconception that `kubectl top pod` requires a pod name to show metrics, but omitting the pod name lists all pods in the current namespace, which is the correct syntax for the question's requirement.

How to eliminate wrong answers

Option A is wrong because `kubectl top node` shows resource usage for nodes, not pods, and does not filter by namespace. Option B is wrong because `kubectl top --all` is not a valid kubectl command; the `--all` flag is used with `kubectl get` to select resources across all namespaces, but `kubectl top` does not support that flag. Option C is wrong because `kubectl top pod pod-name` shows metrics for a single specific pod, not all pods in the namespace.

62
MCQhard

You have a Deployment with a liveness probe using an exec command. The probe currently runs 'cat /tmp/healthy' and fails after 3 failures. You notice the pod is being restarted even though the application is healthy. What is the most likely cause?

A.The readiness probe is misconfigured and is shutting down the pod
B.The liveness probe is using the wrong HTTP endpoint
C.The file /tmp/healthy does not exist or is not being updated by the application
D.The probe timeoutSeconds is set too low, causing the probe to fail before the command completes
AnswerC

The exec command 'cat /tmp/healthy' succeeds only if that file exists and is readable. If the application fails to create or regularly update this file, the command exits with a non-zero status, causing the liveness probe to fail. After the configured failureThreshold is exceeded, kubelet kills and restarts the container, matching the symptom of a restarting Deployment. This is the expected failure mode for this probe definition.

Why this answer

The liveness probe executes 'cat /tmp/healthy' and fails after 3 consecutive failures. If the file /tmp/healthy does not exist or is not being updated by the application, the command returns a non-zero exit code, causing the probe to fail and Kubernetes to restart the container even though the application process itself is running and healthy.

Exam trap

The trap here is that candidates confuse the liveness probe's exec command with an HTTP probe or assume the probe is failing due to timing, when the real issue is the command's exit code reflecting the absence or staleness of the file.

How to eliminate wrong answers

Option A is wrong because a readiness probe does not shut down pods; it only controls whether the pod receives traffic from Services. Option B is wrong because the liveness probe is explicitly configured as an exec command, not an HTTP endpoint, so the HTTP endpoint is irrelevant. Option D is wrong because if the command completes quickly (e.g., 'cat /tmp/healthy'), a low timeoutSeconds would not cause failure; the issue is the command's exit code, not its execution time.

63
Multi-Selectmedium

Which TWO statements are true about readiness probes? (Select two.)

Select 2 answers
A.Readiness probes are only executed when the pod is first started
B.Readiness probes can be configured as httpGet, exec, tcpSocket, or gRPC
C.A failing readiness probe causes the pod to be restarted
D.Readiness probes are defined in the pod spec under 'startupProbe'
E.A failing readiness probe removes the pod from the Service's endpoints
AnswersB, E

This statement is correct because readiness probes support the exact same four handler types as liveness probes: `httpGet` (sending an HTTP GET request to a specific path/port), `exec` (running a command in the container), `tcpSocket` (attempting a TCP connection to a port), and `gRPC` (performing a gRPC health check, available as a beta feature in recent Kubernetes versions). Each handler has its own configuration fields, but all are valid for determining container readiness. The readiness probe is defined under the `readinessProbe` key in the container spec.

Why this answer

Readiness probes support four handler types: httpGet, exec, tcpSocket, and gRPC (since Kubernetes 1.24). These are defined in the container spec under the `readinessProbe` field, allowing the kubelet to check container readiness using HTTP status codes, command exit codes, TCP port connectivity, or gRPC health checks.

Exam trap

The trap here is confusing readiness probes with liveness probes: candidates often think a failing readiness probe restarts the pod, but it only affects traffic routing, while liveness probes handle restarts.

64
Multi-Selecthard

You run 'kubectl get pods' and see a pod in 'CrashLoopBackOff' state. Which TWO conditions could cause this state?

Select 2 answers
A.The node is out of disk space
B.The container exits immediately with a non-zero exit code
C.The readiness probe is failing
D.The pod is pending because of insufficient resources
E.The liveness probe is failing and restarting the container
AnswersB, E

CrashLoopBackOff is the Kubernetes state when a container repeatedly starts, exits with an error, and is restarted by the kubelet. A non-zero exit code from the main process signals that the application failed during startup or at runtime, prompting a restart. After each successive failure, the kubelet applies an exponential backoff (10s, 20s, 40s, up to 5m) to prevent tight restart loops, and this cycle produces the CrashLoopBackOff status. This option is correct because an immediate non-zero exit is the direct mechanism driving the crash loop.

Why this answer

A container that exits immediately with a non-zero exit code causes Kubernetes to restart it repeatedly, leading to the CrashLoopBackOff state. The kubelet detects the exit code and increments the restart counter, applying an exponential backoff delay. This is the classic symptom of an application crash or misconfiguration.

Exam trap

The CKAD exam often tests the distinction between probe failures (which may or may not cause restarts) and immediate container exits (which always cause CrashLoopBackOff), so candidates mistakenly think any restart leads to CrashLoopBackOff, but only repeated restarts with backoff produce that specific state.

65
MCQmedium

A pod is stuck in 'Pending' state. You run 'kubectl describe pod' and see '0/1 nodes are available: 1 Insufficient cpu, 1 Insufficient memory.' What does this mean?

A.The container image is not available
B.The liveness probe is failing
C.The pod's resource requests exceed available resources on any node
D.The container is crashing due to an error
AnswerC

The scheduler filters nodes by checking whether each node's allocatable CPU and memory can accommodate the pod's declared requests. When every node fails that check, the events on the pod show '0/N nodes are available' with 'Insufficient cpu' or 'Insufficient memory', and the pod remains Pending until resources free up or the request is lowered.

Why this answer

The 'Pending' state indicates the pod has been accepted by the Kubernetes API server but cannot be scheduled onto a node. The message '0/1 nodes are available: 1 Insufficient cpu, 1 Insufficient memory' means the scheduler evaluated all nodes and found that none had enough allocatable CPU and memory to satisfy the pod's resource requests. This is a scheduling failure caused by the pod's requests exceeding the available resources on any node.

Exam trap

CNCF often tests the distinction between pod lifecycle phases (Pending, Running, CrashLoopBackOff) and the specific error messages in 'kubectl describe pod', leading candidates to confuse scheduling failures with runtime issues like image pull errors or probe failures.

How to eliminate wrong answers

Option A is wrong because an unavailable container image would cause the pod to stay in 'Pending' or 'ImagePullBackOff' state, but the error message would reference 'ImagePullBackOff' or 'ErrImagePull', not resource insufficiency. Option B is wrong because a failing liveness probe would cause the pod to be restarted (CrashLoopBackOff) or become 'Running' but unhealthy, not stuck in 'Pending' — liveness probes are only checked after the container starts. Option D is wrong because a container crashing due to an error would result in 'CrashLoopBackOff' or 'Error' state, not 'Pending', and the describe output would show crash loop backoff or exit code details, not resource insufficiency.

66
MCQmedium

A container in a pod is expected to shut down gracefully within 30 seconds when it receives SIGTERM. How should you configure the pod to ensure the container is given enough time to shut down before being forcefully killed?

A.Set spec.terminationGracePeriod: 35
B.Set spec.terminationGracePeriodSeconds: 35
C.Set spec.terminationGracePeriodSeconds: 300
D.Set spec.terminationGracePeriodSeconds: 20
AnswerB

Setting spec.terminationGracePeriodSeconds to 35 is appropriate because this pod-level field defines the maximum time allowed between the kubelet sending SIGTERM and forcibly sending SIGKILL. With an expected shutdown time around 35 seconds, this value gives the container sufficient time to complete graceful cleanup without delaying cluster operations.

Why this answer

terminationGracePeriodSeconds defines the time Kubernetes waits after sending SIGTERM before sending SIGKILL. Setting it to 35 seconds gives the container a 5-second buffer beyond the expected 30-second shutdown time. Option B is correct because 35 seconds provides sufficient time without being excessive.

Option A uses an invalid field name (terminationGracePeriod instead of terminationGracePeriodSeconds). Option C sets the grace period to 300 seconds, which is excessively long and could delay pod termination. Option D sets the grace period to 20 seconds, which is too short and may not allow the container to shut down gracefully within the expected 30 seconds.

67
MCQhard

A pod spec has terminationGracePeriodSeconds: 30. The main process ignores SIGTERM. After 30 seconds, what happens?

A.The pod remains running indefinitely
B.The pod enters a CrashLoopBackOff state
C.The pod is rescheduled to another node
D.SIGKILL is sent to forcefully terminate the container
AnswerD

Once the grace period has elapsed, the kubelet sends SIGKILL (signal 9) to the container’s main process to force immediate termination. SIGKILL cannot be caught, handled, or ignored by the application, so the process dies instantly and the container is removed. This is the final step in the termination sequence: SIGTERM is sent first, and SIGKILL is the escalation when the process has not voluntarily exited within the configured terminationGracePeriodSeconds.

Why this answer

When the main process in a container ignores SIGTERM, Kubernetes waits for the duration specified in `terminationGracePeriodSeconds` (30 seconds) and then sends SIGKILL to forcefully terminate the container. This ensures that pods do not hang indefinitely during shutdown, as SIGKILL cannot be ignored by any process.

Exam trap

The trap here is that candidates assume a process ignoring SIGTERM will cause the pod to hang forever, but Kubernetes enforces a hard kill after the grace period, making D the only correct answer.

How to eliminate wrong answers

Option A is wrong because Kubernetes does not allow a pod to run indefinitely after the grace period expires; it enforces termination with SIGKILL. Option B is wrong because CrashLoopBackOff is a state for pods that repeatedly crash after starting, not for pods that are gracefully terminated or killed. Option C is wrong because rescheduling to another node occurs only if the pod is deleted or evicted, not during a normal termination where the pod is simply stopped.

68
MCQmedium

You want to run a command inside an existing container 'app-container' in pod 'my-pod'. The pod has only one container. Which command enters an interactive shell?

A.kubectl exec my-pod -c app-container /bin/sh
B.kubectl exec -it my-pod -- /bin/sh
C.kubectl run -it my-pod --image=busybox
D.kubectl attach my-pod
AnswerB

kubectl exec -it my-pod -- /bin/sh attaches an interactive TTY to the pod's sole container and launches a shell, satisfying the stem's requirement to run a command inside the existing container. Omitting -c is valid because the pod has only one container, so no container name is needed.

Why this answer

The correct command is `kubectl exec -it my-pod -- /bin/sh` because it provides an interactive shell session within the only container of the pod. The `-it` flags are essential for interactive mode, allocating a pseudo-TTY and connecting stdin, while `--` delimits the command from kubectl arguments.

Exam trap

The trap here is that candidates often forget the `-it` flags for interactive sessions, or they confuse `kubectl exec` with `kubectl run` or `kubectl attach`, thinking those can also start an interactive shell in an existing container.

How to eliminate wrong answers

Option A is wrong because it omits the `-it` flags, so it runs `/bin/sh` without allocating a TTY or attaching stdin, resulting in a non-interactive session that will likely exit immediately. Option C is wrong because `kubectl run -it my-pod --image=busybox` attempts to create a new pod named 'my-pod', which will fail if the pod already exists, and it does not execute a command inside the existing container. Option D is wrong because `kubectl attach my-pod` attaches to the main process of the container (e.g., the process with PID 1), but if that process is not a shell, it will not provide an interactive shell; it only connects to the container's standard streams.

69
MCQmedium

You need to debug a Pod that is in CrashLoopBackOff. Which command should you run first?

A.kubectl get events --sort-by=.lastTimestamp
B.kubectl logs <pod-name>
C.kubectl exec -it <pod-name> -- sh
D.kubectl describe pod <pod-name>
AnswerB

kubectl logs <pod-name> streams the container's stdout and stderr, which is exactly where a crashing application typically writes the error or stack trace before exiting. Because CrashLoopBackOff means the process starts, fails, and restarts, the logs usually contain the root cause, such as a missing dependency or a failed readiness check. If the container has already restarted, you must add --previous to retrieve the crashed instance's output, making this the first, most direct diagnostic step.

Why this answer

When a Pod is in CrashLoopBackOff, the immediate priority is to see why the container is failing. `kubectl logs <pod-name>` retrieves the container's stdout/stderr output, which typically contains the error message (e.g., missing config, runtime exception, or startup failure). This is the fastest way to get the root cause without modifying the Pod state.

Exam trap

CNCF often tests the misconception that `kubectl describe pod` provides enough debugging information, but it only shows the exit code and a brief termination message, not the full application logs that reveal the actual error.

How to eliminate wrong answers

Option A is wrong because `kubectl get events --sort-by=.lastTimestamp` shows cluster-level events (e.g., scheduling, pulling images) but does not show the container's application logs, which are essential for debugging a crash loop. Option C is wrong because `kubectl exec -it <pod-name> -- sh` attempts to start an interactive shell inside a running container, but if the Pod is in CrashLoopBackOff, the container is not running, so exec will fail with an error like 'error: unable to upgrade connection: container not found'. Option D is wrong because `kubectl describe pod <pod-name>` provides metadata, status, and events, but it does not include the container's stdout/stderr logs; it only shows the last termination state and exit code, which is less detailed than the actual logs.

70
MCQmedium

You need to view events for a specific pod named 'web-1' in the 'default' namespace. Which command shows events related to this pod?

A.kubectl get events
B.kubectl describe pod web-1 --events
C.kubectl get events --field-selector involvedObject.name=web-1
D.kubectl get events --selector name=web-1
AnswerC

This command correctly narrows the event stream by using the field selector `involvedObject.name=web-1`, which matches the `involvedObject` metadata that every event carries about the resource it references. Field selectors operate on object fields, not labels, so this targets events whose involved object has exactly the name `web-1`. Since pod names are unique within a namespace, this returns all events for that pod, and you can further scope it with `--namespace` or `involvedObject.kind=Pod` if needed.

Why this answer

`kubectl get events --field-selector involvedObject.name=web-1` filters events by the `involvedObject.name` field, which directly matches the pod name. This is the precise way to retrieve only events related to a specific pod in Kubernetes, as events are associated with objects via the `involvedObject` field, not labels.

Exam trap

The trap here is that candidates confuse label selectors (`--selector`) with field selectors (`--field-selector`), assuming pod names are labels, when in fact events use the `involvedObject` field for association, not metadata labels.

How to eliminate wrong answers

Option A is wrong because `kubectl get events` returns all events in the namespace without any filtering, which is too broad and not specific to the pod 'web-1'. Option B is wrong because `kubectl describe pod web-1 --events` is not a valid command; the `--events` flag does not exist for `kubectl describe`, and even if it did, `describe` shows pod details but not a filtered list of events. Option D is wrong because `--selector name=web-1` uses label selectors, but events are not labeled with the pod's name; the pod name is stored in the `involvedObject.name` field, not as a label, so this selector would return no events or incorrect ones.

71
MCQeasy

A container in your pod takes a long time to start (up to 5 minutes). You want to avoid the container being restarted by the liveness probe during this period. What should you configure?

A.Set a long 'initialDelaySeconds' on the liveness probe
B.Add a readiness probe
C.Increase the failureThreshold on the liveness probe
D.Add a startup probe with a longer failure threshold
AnswerD

A startup probe is designed exactly for this scenario: it runs until it succeeds, and while it is active, the kubelet disables liveness and readiness probes. Configure failureThreshold high enough (e.g., 30) with a short periodSeconds, so the total startup allowance is failureThreshold * periodSeconds; once the startup probe succeeds, liveness and readiness probes resume normal operation. This cleanly decouples startup duration from liveness/readiness tuning and prevents restarts during slow initialization.

Why this answer

A startup probe is designed specifically for slow-starting containers. It runs at initialization and defers the liveness and readiness probes until it succeeds. By setting a high `failureThreshold` (e.g., 30) with a short `periodSeconds` (e.g., 10s), you allow up to 5 minutes for the container to start without the liveness probe killing it.

Exam trap

The trap here is that candidates confuse `initialDelaySeconds` (a static delay) with the startup probe (a dynamic, failure-tolerant mechanism), leading them to pick option A, which does not handle variable or long startup times reliably.

How to eliminate wrong answers

Option A is wrong because `initialDelaySeconds` only delays the start of the liveness probe by a fixed time, but if the container takes up to 5 minutes and the probe starts after that delay, it may still fail and restart the container before startup completes. Option B is wrong because a readiness probe controls traffic routing, not container restarts; it does not prevent the liveness probe from restarting the container during startup. Option C is wrong because increasing `failureThreshold` on the liveness probe only increases the number of consecutive failures allowed after the probe has started, but it does not prevent the probe from starting too early and potentially restarting the container before it is ready.

72
MCQeasy

You need to view the logs of the previous (terminated) instance of a container in a pod. Which command should you use?

A.kubectl describe pod pod-name | grep -A 10 'Last State'
B.kubectl logs pod-name --tail=100
C.kubectl logs pod-name -p
D.kubectl logs pod-name -f
AnswerC

The -p (or --previous) flag is the correct way to retrieve logs from the previous container instance, as it explicitly instructs kubectl to read from the retained log buffer of the last terminated container. This is the standard diagnostic step when a container is in CrashLoopBackOff, and it works because the kubelet preserves the terminated container's logs until the pod is deleted; note that if no previous instance exists, this command returns an error.

Why this answer

`kubectl logs pod-name -p` (or `--previous`) retrieves the logs from the previous terminated container instance in the pod. This flag specifically targets the last container that exited, allowing you to debug crashes or restarts without needing to access the current running container.

Exam trap

The CKAD exam often tests the distinction between `kubectl logs` with `-p` (previous) and `kubectl describe pod` (which shows state but not logs), leading candidates to mistakenly choose `describe` when they need actual log output.

How to eliminate wrong answers

Option A is wrong because `kubectl describe pod` shows the pod's metadata and last state details (e.g., exit code, reason), but it does not display the actual container logs — it only shows a summary of the termination state, not the log output. Option B is wrong because `kubectl logs pod-name --tail=100` fetches the last 100 lines from the current running container, not from a terminated instance; it has no mechanism to access previous container logs. Option D is wrong because `kubectl logs pod-name -f` streams logs from the current container in real time (follow mode), which is irrelevant for viewing logs of a terminated container.

73
MCQhard

You need to debug a pod that has no running containers because it is in a CrashLoopBackOff state. You want to start an ephemeral container with debugging tools in the same namespace. Which command accomplishes this?

A.kubectl run debug --image=busybox -it --restart=Never
B.kubectl attach pod-name
C.kubectl debug -it pod-name --image=busybox --target=container-name
D.kubectl exec -it pod-name -- /bin/sh
AnswerC

kubectl debug -it pod-name --image=busybox --target=container-name creates an ephemeral container inside the existing Pod's sandbox, so it shares the same network namespace, IPC namespace, and (when --target is specified) the target container's process namespace. The ephemeral container includes the provided busybox image, giving you a shell (via -it) and common debugging tools even though the original container lacks a shell or has crashed. Because ephemeral containers are managed by the kubelet, the original Pod's spec and lifecycle are unaffected, and if the Pod is not running, kubectl debug will create a copy, so this is the right tool when no containers are running. The --target flag is what lets you see the crashed container's processes, but for ordinary filesystem inspection the ephemeral container also mounts the Pod's volumes.

Why this answer

`kubectl debug` allows you to start an ephemeral container in an existing pod that is in a CrashLoopBackOff state. The `--target` flag attaches the ephemeral container to the same Linux namespace as the specified container, enabling debugging without restarting the pod. This is the only command that works when the pod has no running containers and `kubectl exec` fails.

Exam trap

The trap here is that candidates assume `kubectl exec` is the standard debugging tool, but it fails when no container is running; `kubectl debug` with `--target` is the correct approach for CrashLoopBackOff scenarios.

How to eliminate wrong answers

Option A is wrong because `kubectl run` creates a new standalone pod, not an ephemeral container in the existing pod, so it cannot debug the specific pod's namespace or filesystem. Option B is wrong because `kubectl attach` only connects to a running container's stdin/stdout/stderr, and it fails when the pod is in CrashLoopBackOff with no running containers. Option D is wrong because `kubectl exec` requires at least one running container in the pod to execute a command, which is not available in CrashLoopBackOff.

74
Multi-Selectmedium

Which TWO actions can you perform using 'kubectl describe'? (Select two.)

Select 2 answers
A.View the conditions and status of a node
B.Execute a command inside a container
C.View the logs of a container
D.View the events associated with a pod
E.View the YAML manifest of a resource
AnswersA, D

Running `kubectl describe node <name>` is a core diagnostic action: it renders a human-readable summary that includes the node's addresses, allocatable resources, and a Conditions table (e.g., Ready, MemoryPressure, DiskPressure, PIDPressure). The command also surfaces operational events such as reboots or kubelet failures, making it the standard first look when a node is NotReady or under-resourced.

Why this answer

`kubectl describe node <node-name>` displays detailed information about a node, including its conditions (e.g., Ready, DiskPressure, MemoryPressure) and status (e.g., capacity, allocatable resources). This command is essential for debugging node-level issues.

Exam trap

The trap here is that candidates confuse `kubectl describe` with `kubectl get -o yaml` (option E) or `kubectl logs` (option C), but `kubectl describe` is specifically for human-readable summaries and event inspection, not raw output or log streaming.

75
MCQhard

You need to configure a liveness probe that checks if the container port 8080 is open. Which probe type should you use?

A.tcpSocket
B.grpc
C.exec
D.httpGet
AnswerA

The tcpSocket probe instructs the kubelet to attempt a raw TCP connection to the specified port (e.g., `:8080`) and marks the container healthy if the three-way handshake completes successfully. It does not interpret any application-level response, so it is ideal for verifying that a listener is active on the port without requiring an HTTP or gRPC endpoint. This matches the requirement to check if the port is open and is therefore the correct choice.

Why this answer

A tcpSocket probe is the correct choice when you need to verify that a container is listening on a specific TCP port, such as port 8080. It works by attempting to open a TCP connection to the specified port; if the connection succeeds, the probe is considered successful. This is ideal for checking basic network-level readiness or liveness without requiring an HTTP endpoint or a custom command.

Exam trap

The trap here is that candidates often choose httpGet because they assume a web server on port 8080, but the question explicitly asks only to check if the port is open, not to validate an HTTP response, making tcpSocket the precise and minimal probe type.

How to eliminate wrong answers

Option B (grpc) is wrong because gRPC probes are used specifically for checking the health of gRPC services using the gRPC health checking protocol, not for verifying that a raw TCP port is open. Option C (exec) is wrong because exec probes run a command inside the container and check its exit code, which is unnecessary overhead when you only need to confirm a port is listening. Option D (httpGet) is wrong because httpGet probes require an HTTP endpoint that returns a valid status code (2xx or 3xx), and they cannot be used to simply check if a TCP port is open without an HTTP server.

Page 1 of 2 · 146 questions totalNext →

Ready to test yourself?

Try a timed practice session using only Application Observability and Maintenance questions.