GCP Associate Cloud Engineer Practice Question 68: HPA CPU Pod Scaling
Google Cloud Associate Cloud Engineer · Test 7 · question 8 of 10
A Deployment named web runs on a GKE Standard cluster whose node pool already has the cluster autoscaler enabled, so the node count adjusts automatically. Traffic to web varies throughout the day, and each container already declares a CPU request. You want the number of pod replicas to rise and fall automatically between 3 and 10 based on average CPU utilization, with the least amount of setup.
Show answer and explanation
Answer:
kubectl autoscale creates a HorizontalPodAutoscaler object that watches the Deployment's average CPU utilization against the container's CPU requests and adds or removes replicas within the given minimum and maximum, which is exactly the pod-count scaling the scenario asks for.
Option A sets a fixed replica count once; it does not react to changing load, so pods would be wasted at quiet times and insufficient at busy times. Option B changes how many nodes the cluster can run, which is node-level capacity already handled by the cluster autoscaler in this scenario, not the number of running pods. Option D resizes each pod's CPU and memory requests over time rather than changing how many pods are running, and combining it with an HPA on the same CPU metric is not recommended.
Reference: Autoscale a Deployment's pods based on CPU or memory usage