CompTIA Cloud+ (CV0-004)DevOps FundamentalsHard
A Kubernetes Horizontal Pod Autoscaler (HPA) is configured with a target CPU utilization of 50%. There are currently 4 replicas running, and the HPA measures the average CPU utilization across those pods at 80%. Using the formula desiredReplicas = ceil(currentReplicas × (currentMetricValue ÷ desiredMetricValue)), how many replicas will the HPA scale the deployment to?
- A8
- B7
- C5
- D6
Show answer & explanationAnswer & explanation
Correct answer: B. 7
Using the formula: desiredReplicas = ceil(4 × (80 ÷ 50)) = ceil(4 × 1.6) = ceil(6.4) = 7. The HPA always rounds up to ensure enough capacity is provisioned to bring average utilization back toward the target.
Why the other options are wrong
- A. 8 overestimates the required scale-up beyond the calculated 6.4 value.
- C. 5 is too low; it does not satisfy the calculated ratio of 1.6x the current replicas.
- D. 6 results from truncating instead of rounding up (ceiling) 6.4.
Horizontal Pod Autoscaler (HPA) Formula
Kubernetes HPA calculates the desired replica count as the ceiling of current replicas multiplied by the ratio of current metric value to target (desired) metric value.
- Formula: ceil(currentReplicas × currentMetric/desiredMetric)
- Always rounds up to avoid under-provisioning
- Commonly driven by CPU or custom metrics
Memory trick: HPA always rounds UP - like a bouncer letting in extra pods just in case.