An engineer is configuring a GKE cluster and wants to enable Horizontal Pod Autoscaling (HPA) for a deployment named 'web-frontend'. The deployment currently has 3 replicas. The engineer wants to automatically scale the number of pods based on CPU utilization, targeting 50% average CPU utilization. Which command should the engineer run?
kubectl autoscale creates a HorizontalPodAutoscaler targeting the deployment, with --cpu-percent=50 setting the target utilisation and --min=3 --max=10 bounding replica count. This satisfies the requirement to scale web-frontend automatically on CPU, starting from its current 3 replicas.
Why this answer
The correct command is 'kubectl autoscale deployment web-frontend --cpu-percent=50 --min=3 --max=10', which creates an HPA targeting 50% average CPU utilization with a minimum of 3 and maximum of 10 replicas. The 'kubectl autoscale' subcommand is the standard imperative way to create an HPA for a deployment. The flags --cpu-percent, --min, and --max are the correct parameters for this command.
Exam trap
The trap is confusing cluster autoscaling (node-level, gcloud) with Horizontal Pod Autoscaling (pod-level, kubectl), and mixing up the --cpu-percent flag with invalid alternatives like --cpu or --max-cpu.
How to eliminate wrong answers
Option A is wrong because 'gcloud container clusters autoscale' configures cluster autoscaling (node-level), not Horizontal Pod Autoscaling, and uses node-oriented flags like --min-nodes and --max-nodes. Option B is wrong because '--max-cpu=50' is not a valid flag for kubectl autoscale; the correct flag is --cpu-percent. Option D is wrong because '--cpu=50' is not a valid flag; the correct flag is --cpu-percent.