← Back to posts

GCP ACE: Scaling in GKE — HPA, Cluster Autoscaler, and Node Auto-Provisioning

“Autoscaling” in GKE isn’t one mechanism — it’s three, operating at different levels, and the exam expects you to know which one does what.

Horizontal Pod Autoscaler (HPA) — scales Pod count

The HPA is a control loop that adjusts a workload’s replicas to match observed demand. It scales horizontally — adding or removing Pods — not vertically (changing a Pod’s own CPU/memory, which is a separate mechanism, VPA).

For CPU and memory metrics, the HPA needs the Metrics Server installed, and utilization is measured as a percentage of the container’s CPU request — meaning the target workload must set resources.requests.cpu, or the HPA has nothing to compute a percentage against.

Imperative creation:

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

Declarative:

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: php-apache
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: php-apache
  minReplicas: 1
  maxReplicas: 10
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 50
kubectl get hpa php-apache
kubectl describe hpa php-apache     # shows current metrics and scaling events — the first stop when it's not scaling as expected

The scaling formula:

desiredReplicas = ceil[ currentReplicas × ( currentMetricValue / desiredMetricValue ) ]

Example: 4 replicas, current average CPU utilization 200%, target 50% → ceil[4 × (200/50)] = 16 replicas.

Two stabilizers worth remembering for the exam:

If multiple metrics are defined, the HPA computes a desired count for each and uses the largest.

Cluster Autoscaler — scales node count within a pool

Different layer entirely: this resizes a node pool, adding or removing the actual VMs, between a minimum and maximum you set.

gcloud container clusters create example-cluster \
    --num-nodes=2 \
    --location=us-central1-a \
    --node-locations=us-central1-a,us-central1-b,us-central1-f \
    --enable-autoscaling --min-nodes=1 --max-nodes=4

Node auto-provisioning (NAP) — scales node pools themselves

One level up again: instead of resizing an existing pool, NAP creates and deletes entire node pools to match pending workload shapes (for example, a workload needing a GPU or TPU gets a new pool provisioned for it automatically, then removed when no longer needed). On Autopilot clusters, this is how node pools work by default — you never create one yourself.

A naming note: current GKE docs call the capability node pool auto-creation. Cluster-level node auto-provisioning (--enable-autoprovisioning, with cluster-wide CPU and memory limits) is one way to turn it on in Standard clusters; ComputeClasses are the other. Exam questions still use “node auto-provisioning”, so recognize both names.

HPACluster AutoscalerNode auto-provisioning
ScalesPod replica countNodes within an existing poolNode pools themselves
TriggerMetric vs. target (e.g. CPU %)Unschedulable Pods / underutilized nodesPending workloads needing a pool shape that doesn’t exist
BoundsminReplicas / maxReplicasPool’s min-nodes / max-nodesCluster-wide resource limits you configure

Exam Takeaways

Sources

↗ LinkedIn