Kubernetes Container Orchestration Scheduling and Scaling 2 — Questions and Answers
Question 1: Which field in a Pod spec prevents the scheduler from placing it on any node until explicitly set to false?
- spec.unschedulable
- spec.schedulerName
- spec.nodeName
- spec.schedulingGates (Correct answer)
Correct answer: spec.schedulingGates
schedulingGates block a Pod from being scheduled until all gates are removed, allowing external controllers to control scheduling timing.
Question 2: A HorizontalPodAutoscaler targets 60% CPU utilization. Current usage is 90% across 4 replicas. How many replicas will HPA scale to?
- 5
- 6 (Correct answer)
- 7
- 8
Correct answer: 6
HPA formula: ceil(4 * (90/60)) = ceil(6.0) = 6 replicas.
Question 3: What does the `podAntiAffinity` rule with `requiredDuringSchedulingIgnoredDuringExecution` guarantee?
- Pods are evicted if the rule is violated at runtime
- Pods are never scheduled on nodes where matching pods already run (Correct answer)
- Pods prefer nodes without matching pods but may still be placed there
- Pods only run on nodes with matching pods
Correct answer: Pods are never scheduled on nodes where matching pods already run
requiredDuringSchedulingIgnoredDuringExecution is a hard constraint enforced at scheduling time but not re-evaluated after placement.
Question 4: Which Kubernetes resource lets you limit the total number of pods from a deployment that can be simultaneously unavailable during a voluntary disruption?
- PodDisruptionBudget (Correct answer)
- LimitRange
- ResourceQuota
- PriorityClass
Correct answer: PodDisruptionBudget
A PodDisruptionBudget (PDB) defines minAvailable or maxUnavailable to limit disruptions during voluntary actions like node drains.
Question 5: When using Vertical Pod Autoscaler (VPA) in 'Off' mode, what happens?
- VPA evicts and restarts pods with new resource values
- VPA only provides recommendations without applying them (Correct answer)
- VPA disables resource requests on the pod
- VPA sets both requests and limits to zero
Correct answer: VPA only provides recommendations without applying them
In 'Off' mode, VPA computes and stores resource recommendations in its status but never modifies or restarts pods.
Question 6: A node has the taint `dedicated=gpu:NoSchedule`. Which pod configuration allows scheduling on that node?
- nodeSelector: dedicated: gpu
- tolerations: [{key: dedicated, value: gpu, effect: NoSchedule}] (Correct answer)
- affinity.nodeAffinity with matchExpressions on dedicated=gpu
- priorityClassName: gpu-priority
Correct answer: tolerations: [{key: dedicated, value: gpu, effect: NoSchedule}]
A toleration matching the taint's key, value, and effect allows a pod to be scheduled on a tainted node.
Question 7: What metric type must be registered with the Kubernetes metrics API for HPA to scale on custom application metrics?
- Resource metrics via metrics-server
- External metrics from cloud providers only
- Custom metrics via a custom metrics API adapter (Correct answer)
- Kubernetes event metrics
Correct answer: Custom metrics via a custom metrics API adapter
Custom metrics require a custom metrics API adapter (e.g., Prometheus Adapter) that implements the custom.metrics.k8s.io API.
Which field in a Pod spec prevents the scheduler from placing it on any node until explicitly set to false?