Courseiva
Troubleshooting →easyMultiple Choice

CKA Troubleshooting Practice Question

You need to check the CPU and memory usage of all pods in the 'production' namespace. Which command should you use?

⚠ Common exam trap

Test-takers frequently confuse `kubectl top` with `kubectl get` or invent non-existent commands like `kubectl get resourceusage`, assuming there is a generic resource usage command, when only `kubectl top` provides live metrics.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

kubectl top pods -n production

The `kubectl top pods` command retrieves real-time CPU and memory metrics for pods from the metrics server, which is required for the CKA exam. The `-n production` flag restricts the output to the 'production' namespace, making option A the correct choice for checking resource usage of all pods in that namespace.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    kubectl top pods -n production

    Why this is correct

    kubectl top pods -n production is correct because it queries the metrics API (metrics.k8s.io) via the metrics-server and returns a live CPU and memory consumption report for every pod in the production namespace. The output shows CPU usage in cores (or millicores) and memory in bytes or MiB, which is exactly the resource usage data the task asks for. This command requires the metrics-server to be deployed and configured, otherwise it will return an error from the metrics API.

  • ✗

    kubectl get pods -n production --show-labels

    Why it's wrong here

    kubectl get pods -n production --show-labels is incorrect for this task because it lists pod metadata, including name, status, restart count, age, and any labels attached to the pods, but it does not report CPU or memory utilization. Labels are key-value pairs used for organization, selection, and service routing, and they have no relationship to live resource consumption. While the command is valid, it answers a targeting or filtering question rather than a monitoring question, so it fails the requirement to check cpu and memory usage.

  • ✗

    kubectl get resourceusage pods -n production

    Why it's wrong here

    kubectl get resourceusage pods -n production is incorrect because 'resourceusage' is not a recognized resource type in the Kubernetes API, and kubectl does not have a built-in subcommand called 'resourceusage'. Kubernetes exposes resource usage through the metrics.k8s.io API group, not through a standard REST resource named 'resourceusage', so this command will fail with an error like 'the server doesn't have a resource type resourceusage'. The correct analog for resource usage is 'kubectl top', not a 'kubectl get' variant with a nonexistent resource name.

  • ✗

    kubectl top nodes -n production

    Why it's wrong here

    kubectl top nodes -n production is incorrect because it aggregates resource usage at the node level, showing CPU and memory consumption for each worker node as a whole, rather than breaking it down per pod. The -n flag is also largely irrelevant for node-level metrics because nodes are cluster-scoped, not namespace-scoped, so the namespace filter does not change the output. To check per-pod usage in the production namespace, the 'pods' resource must be specified, as in 'kubectl top pods -n production', rather than the 'nodes' resource.

About these practice questions

This CKA question is part of Courseiva's 726-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This CKA practice question is part of Courseiva's free CNCF certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the CKA exam.