CKA CKA Logging and Monitoring 2 — Questions and Answers
Question 1: Which component must be deployed in a cluster before `kubectl top nodes` works?
- kube-proxy
- Metrics Server (Correct answer)
- kube-state-metrics
- Prometheus
Correct answer: Metrics Server
The Metrics Server must be installed to aggregate resource usage data and enable `kubectl top` commands.
Question 2: What command shows CPU and memory usage for all pods in the 'production' namespace?
- kubectl top pods -n production (Correct answer)
- kubectl usage pods -n production
- kubectl metrics pods -n production
- kubectl get resources -n production
Correct answer: kubectl top pods -n production
`kubectl top pods -n <namespace>` displays real-time CPU and memory usage for pods in that namespace.
Question 3: Which flag with `kubectl top pods` breaks down usage per container instead of per pod?
- --containers (Correct answer)
- --show-containers
- --expand
- --all-containers
Correct answer: --containers
The `--containers` flag shows per-container CPU and memory usage within each listed pod.
Question 4: Which Kubernetes object sets default resource limits and requests for containers within a namespace?
- ResourcePolicy
- LimitRange (Correct answer)
- ResourceQuota
- PodPolicy
Correct answer: LimitRange
A LimitRange object defines default, min, and max resource limits and requests for containers in a namespace.
Question 5: What does a ResourceQuota object restrict in a Kubernetes namespace?
- Number of nodes in the cluster
- Total resource consumption and object count (Correct answer)
- Pod scheduling priority
- Network bandwidth per pod
Correct answer: Total resource consumption and object count
ResourceQuota limits the total compute resources consumed and the number of Kubernetes objects that can exist in a namespace.
Question 6: Which command displays resource usage (CPU/memory) broken down by each node in the cluster?
- kubectl get nodes --resources
- kubectl describe nodes
- kubectl top nodes (Correct answer)
- kubectl node-metrics
Correct answer: kubectl top nodes
`kubectl top nodes` shows current CPU and memory usage for every node in the cluster.
Which component must be deployed in a cluster before `kubectl top nodes` works?