KCNA Scheduling and Scaling 5 — Questions and Answers
Question 1: Which `kubectl` command scales a Deployment named `web` to 10 replicas immediately?
- kubectl scale deployment web --replicas=10 (Correct answer)
- kubectl patch deployment web -p '{"spec":{"replicas":10}}'
- kubectl set replicas deployment/web 10
- kubectl update deployment web --replicas=10
Correct answer: kubectl scale deployment web --replicas=10
`kubectl scale` is the dedicated imperative command for adjusting the replica count of a Deployment, ReplicaSet, or StatefulSet.
Question 2: What happens to pods on a node after `kubectl cordon <node>` is executed?
- Existing pods continue running; no new pods will be scheduled on the node (Correct answer)
- All pods are immediately evicted and rescheduled
- The node is removed from the cluster
- Existing pods are terminated but the node remains registered
Correct answer: Existing pods continue running; no new pods will be scheduled on the node
`cordon` marks the node as unschedulable (SchedulingDisabled) but does not touch currently running pods.
Question 3: Which metric server component must be installed for HPA to scale based on CPU and memory metrics?
- metrics-server (Correct answer)
- kube-state-metrics
- Prometheus adapter
- cAdvisor
Correct answer: metrics-server
HPA's built-in resource metrics (CPU/memory) rely on the `metrics-server` add-on, which aggregates resource usage from kubelets.
Question 4: A pod spec sets `resources.requests.cpu: 500m`. What does this guarantee?
- The scheduler will only place the pod on a node with at least 500 millicores of allocatable CPU available (Correct answer)
- The container will always use exactly 500 millicores of CPU
- The container cannot use more than 500 millicores of CPU
- The pod will be evicted if CPU usage drops below 500 millicores
Correct answer: The scheduler will only place the pod on a node with at least 500 millicores of allocatable CPU available
CPU requests are used by the scheduler to find nodes with sufficient allocatable capacity; they do not cap actual usage.
Question 5: What is the difference between `kubectl drain` and `kubectl cordon`?
- drain cordons the node AND evicts all pods; cordon only prevents new scheduling (Correct answer)
- cordon evicts pods; drain only prevents new pods
- drain deletes the node object; cordon just marks it unschedulable
- They are identical; drain is an alias for cordon
Correct answer: drain cordons the node AND evicts all pods; cordon only prevents new scheduling
`drain` first cordons the node (marks it unschedulable) and then safely evicts all pods while respecting PodDisruptionBudgets.
Question 6: Which pod scheduling feature ensures that two pods of the same application never land on the same node?
- Pod anti-affinity with requiredDuringSchedulingIgnoredDuringExecution (Correct answer)
- Pod affinity with preferredDuringSchedulingIgnoredDuringExecution
- topologySpreadConstraints with maxSkew=0
- nodeSelector with unique node labels
Correct answer: Pod anti-affinity with requiredDuringSchedulingIgnoredDuringExecution
Hard pod anti-affinity (`required...`) enforces that matching pods are never co-located on the same topology domain such as a node.
Question 7: In the context of KEDA, what is a `ScaledObject`?
- A custom resource that maps a Deployment to an event source and defines scaling parameters (Correct answer)
- A built-in Kubernetes object that replaces HPA for all workloads
- A controller that manages the Cluster Autoscaler configuration
- A metric adapter that exposes external metrics to the Kubernetes API server
Correct answer: A custom resource that maps a Deployment to an event source and defines scaling parameters
A ScaledObject is a KEDA CRD that links a target workload (like a Deployment) to one or more event source scalers with min/max replica bounds.
Which `kubectl` command scales a Deployment named `web` to 10 replicas immediately?