OnCallReady

Commands

kubectl autoscale - Auto-scale a deployment, replica set, stateful set, or replication controller

kubectl autoscale (-f FILENAME | TYPE NAME | TYPE/NAME) [--min=MINPODS] --max=MAXPODS [--cpu=TARGET] [--memory=TARGET]

Options you will use

--max=N
upper limit for the number of pods. Required.
--min=N
lower limit; if not specified the server applies its default (1).
--cpu=70%|500m
target CPU: a percentage is average UTILIZATION of the pods' CPU requests; a quantity is an average VALUE. Without --cpu/--memory the server default is 80% CPU utilization.
--memory=60%|200Mi
target memory, same two forms
--cpu-percent=N
deprecated in 1.34: use --cpu=N%
--name=NAME
name of the HPA (default: the target's name)
--dry-run=client -o yaml
print the autoscaling/v2 HorizontalPodAutoscaler instead of creating it

Examples

$ kubectl autoscale deployment php-apache --cpu=50% --min=1 --max=10

the upstream walkthrough

$ kubectl get hpa -w

watch TARGETS and REPLICAS change

$ kubectl describe hpa php-apache

Conditions and Events explain every decision (or why it cannot decide)

Gotchas

Try kubectl autoscale in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.