CKA Resource Monitoring 2 — Questions and Answers
Question 1: Which kubectl command shows the CPU and memory consumption of all pods in a specific namespace?
- kubectl top pods -n <namespace> (Correct answer)
- kubectl describe pods -n <namespace>
- kubectl get pods -o wide -n <namespace>
- kubectl logs pods -n <namespace>
Correct answer: kubectl top pods -n <namespace>
The 'kubectl top pods -n <namespace>' command uses the Metrics Server API to display real-time CPU and memory usage for pods in the specified namespace.
Question 2: What does the 'kubectl top node' command report as the BASIS for percentage calculations?
- The node's allocatable capacity (Correct answer)
- The node's total physical capacity
- The sum of all pod requests on the node
- The node's limit capacity
Correct answer: The node's allocatable capacity
kubectl top node reports CPU and memory usage as a percentage of the node's allocatable capacity, not total physical capacity.
Question 3: A pod's container has no resource requests set. How does the Kubernetes scheduler treat this pod during placement?
- The pod can be scheduled on any node regardless of available resources (Correct answer)
- The pod is rejected by the scheduler
- The pod is assigned default requests from the LimitRange
- The pod is placed in a Pending state until requests are defined
Correct answer: The pod can be scheduled on any node regardless of available resources
Without resource requests, the scheduler does not account for the container's resource needs, so it can land on any node; however, a LimitRange can inject defaults if configured.
Question 4: Which Kubernetes object can automatically set default resource requests and limits for containers in a namespace?
- LimitRange (Correct answer)
- ResourceQuota
- PodDisruptionBudget
- PriorityClass
Correct answer: LimitRange
A LimitRange object can define default request and limit values that are automatically applied to containers that do not specify their own.
Question 5: A container's memory usage exceeds its memory limit. What does Kubernetes do?
- The container is OOMKilled and restarted according to the restart policy (Correct answer)
- The pod is evicted from the node
- The container is throttled until memory usage drops
- The node is cordoned to prevent further scheduling
Correct answer: The container is OOMKilled and restarted according to the restart policy
When a container exceeds its memory limit, the Linux kernel OOM killer terminates the process, and Kubernetes restarts it based on the pod's restartPolicy.
Question 6: What is the correct unit for specifying 500 millicores of CPU in a resource request?
- 500m (Correct answer)
- 0.5K
- 500Mi
- 500c
Correct answer: 500m
CPU resources in Kubernetes are expressed in cores or millicores; '500m' means 500 millicores, which equals 0.5 CPU cores.
Question 7: Which component of the Kubernetes control plane is responsible for evicting pods when a node is under memory pressure?
- kubelet (Correct answer)
- kube-scheduler
- kube-controller-manager
- kube-apiserver
Correct answer: kubelet
The kubelet monitors node-level resource usage and performs pod eviction when the node experiences memory or disk pressure based on eviction thresholds.
Which kubectl command shows the CPU and memory consumption of all pods in a specific namespace?