A HorizontalPodAutoscaler changes a Deployment's (or StatefulSet's) replica count to keep a metric near a target. For CPU, utilization is usage as a percentage of the request, averaged over the Pods, and the desired count is roughly ceil(current replicas × current utilization ÷ target), kept between minReplicas and maxReplicas.
kubectl autoscale deployment NAME --min=2 --max=10 --cpu-percent=60 creates one; kubectl get hpa shows TARGETS as current/target. The metrics come from the metrics server, the same source as kubectl top.
Three things go wrong often. Without a CPU request the HPA shows <unknown>, because there is nothing to divide by. At its maximum it stops, and describe says ScalingLimited with TooManyReplicas. And scaling the Deployment by hand fights the HPA, which sets the count back; change the HPA instead. Real clusters also wait a stabilization window before scaling down; this cluster settles at once.
Create, watch the target, read the conditions.