GKE and Cloud Run operations for the ACE exam: autoscaling, Autopilot and traffic splitting

13 min read

The Associate Cloud Engineer exam guide gives section 3, "Ensuring the successful operation of a cloud solution" (~30%), to managing what is already running. Item 3.1 is very specific: GKE node pools, horizontal and vertical Pod autoscaling, GKE Autopilot Pod resource requests, deploying new Cloud Run versions, traffic splitting and Cloud Run autoscaling. This article goes into the mechanics: why a Pod stays Pending even with autoscaling on, why a Pod shows ImagePullBackOff, what a Cloud Run rollback really does, and what each choice costs you. It comes with decision tables, short gcloud/kubectl commands and example practice questions. For the exam format and scope, see the Associate Cloud Engineer study guide.

Key takeaways

  • The cluster autoscaler adds nodes based on the resource requests of Pending Pods, not real CPU; the --max-nodes ceiling applies per zone.
  • ImagePullBackOff with a 403: the node pulls the image, so the node pool's service account needs roles/artifactregistry.reader.
  • A Cloud Run rollback sends traffic back to an old revision; after a split or rollback, use --to-latest so a later patch gets traffic.
  • Question keywords: every node means DaemonSet, immediately revert means route traffic back, plain text means Secret.

Autopilot or Standard: who manages the nodes

Every GKE operations question starts with the cluster mode, because it decides whether you touch nodes at all.

  • GKE Autopilot: Google manages the worker nodes. You don't create node pools or configure auto-upgrade or auto-repair. Your job is to declare resource requests (CPU, memory, ephemeral storage) for your Pods. If you don't, Autopilot applies defaults, and GKE checks the requests against the min/max limits of the compute class or hardware the workload picks. General-purpose Pods are billed by their resource requests, not by real usage: requests set too high mean paying for nothing.
  • GKE Standard: you manage node pools, groups of nodes with the same setup (machine type, disk, service account, Spot VMs…). You get more choices, and in return you look after the nodes yourself. To change the machine type, create a new node pool and move the workload over; you don't "edit" running nodes.

The trade-off: Autopilot removes operations work but you give up control over nodes. Standard is more flexible, but picking machine sizes, setting autoscaling ceilings and granting permissions to the node service account are your job.

Questions often use "minimize operational overhead" or "don't want to manage nodes" to point at Autopilot. Dedicated GPUs, a specific machine type or Spot VM node pools usually mean Standard.

The four layers of GKE autoscaling

Questions like to mix the autoscalers up. Separate them by asking "what grows":

What scalesMechanismUse when
Number of PodsHorizontal Pod Autoscaler (HPA)Load changes fast; scale on CPU, memory or custom metrics
CPU/memory request of each PodVertical Pod Autoscaler (VPA)Rightsizing a steady workload when you don't know the right request
Number of nodes in a node poolCluster autoscaler (Standard)Pods are pending for lack of resources; extra nodes are removed
New node pools based on Pod needsNode pool auto-creationA workload needs a node configuration that doesn't exist yet

The first three form a chain: the HPA adds Pods, new Pods need somewhere to sit, the cluster autoscaler adds nodes. Wherever the chain breaks, Pods get stuck.

Cluster autoscaler: what it looks at, and why a Pod stays Pending

The cluster autoscaler works per node pool. It doesn't look at the real CPU use of a node. It decides from the Pods' resource requests, and adds nodes only when a Pod can't be scheduled on any existing node. The consequence: Pods without requests make the autoscaler's math wrong, and it won't fix a request you set too low.

When a Pod sits in Pending even though the autoscaler is on, check two common causes:

  1. The node pool hit its ceiling. --min-nodes and --max-nodes apply per zone. A single-zone cluster with --max-nodes=3 tops out at 3 nodes; a three-zone cluster with --max-nodes=4 tops out at 12. For new clusters on GKE 1.24 or later you can use --total-min-nodes and --total-max-nodes to set totals for the whole node pool.
  2. Out of quota or IP space. When node creation fails for this reason, the system retries after 5 minutes, then backs off exponentially up to 30 minutes.

To see the reason, run kubectl describe pod and read the Events. The autoscaler records TriggeredScaleUp when it adds a node and NotTriggeredScaleUp when it couldn't do anything for that Pod.

Scaling down has limits too. A Standard cluster never scales itself down to 0 nodes. The autoscaler won't remove a node that runs a Pod not managed by a controller, a Pod with the annotation cluster-autoscaler.kubernetes.io/safe-to-evict: "false", or when removal would break a PodDisruptionBudget. Because Pods can be moved to other nodes, the docs recommend running multi-replica Deployments and not enabling the cluster autoscaler for apps that can't tolerate disruption.

Don't also enable Compute Engine autoscaling on the node managed instance group. The GKE docs say it conflicts with the cluster autoscaler and can stop the node pool from scaling.

HPA and VPA: two different directions

The HPA adds or removes replicas and reacts fast to changing load. The VPA changes the size of each Pod's request and suits steady workloads. The VPA is not meant for sudden spikes; that's the HPA's job.

A favorite exam point: the GKE docs say that unless you use HPA rightsizing with VPA (Preview), don't run the HPA together with the standard VPA on CPU or memory. Both change the same number and fight each other. A common real-world mistake: turning on a CPU-based HPA but forgetting to set a CPU request on the container, so the HPA has no baseline to compute a percentage from.

Commands to know

# Add a node pool with autoscaling (Standard)
gcloud container node-pools create pool-2 \
  --cluster=web --location=us-central1 \
  --machine-type=e2-standard-4 \
  --enable-autoscaling \
  --min-nodes=1 --max-nodes=5

# HPA for a Deployment on CPU
kubectl autoscale deployment web \
  --cpu-percent=60 --min=2 --max=10

# Why is a Pod Pending? Read the Events
kubectl describe pod POD_NAME

Picking the right Kubernetes workload

Requirement in the questionKubernetes objectNotes
Stateless app, many replicas, rolling updatesDeploymentPair with an HPA to scale Pod count
Each Pod needs a stable identity and its own diskStatefulSetDatabases, self-managed queues
One Pod on every node, including nodes the autoscaler addsDaemonSetLog, monitoring and security agents
Passwords, API keysSecretNever plain text in YAML or in the image
Non-sensitive configurationConfigMapEnvironment variables, config files
Expose the app outside the clusterService (LoadBalancer) or Gateway/IngressGateway API supports weighted traffic splitting

Why does a DaemonSet win the "one Pod per node" question? A Deployment promises a number of replicas, not where they land. A DaemonSet ties Pods to nodes: whenever a node appears, including one the autoscaler adds, its Pod is created.

Secrets and ConfigMaps: keeping configuration in the right place

A ConfigMap is for settings that aren't sensitive (service addresses, feature flags). A Secret is for things that must not leak (database passwords, API keys, tokens). The most common mistake is writing the password straight into env in the YAML: anyone who can see the file or the repo can read it. The right way is to create a Secret and let the container reference it.

kubectl create secret generic db-pass \
  --from-literal=password='S3cret!'

# In the Deployment's container spec:
# env:
# - name: DB_PASSWORD
#   valueFrom:
#     secretKeyRef:
#       name: db-pass
#       key: password
  • A Secret is not a vault. Values are only base64-encoded, so anyone who can read the Secret can decode it, which is why access control (RBAC) still matters. GKE encrypts customer content at rest by default, Secrets included; for an extra layer you can enable application-layer Secrets encryption with a Cloud KMS key.
  • Environment variable or mounted file? Environment variables are read only when the container starts, so changing the password means restarting the Pod. A Secret mounted as a file is updated when the Secret changes.
  • Calling Google Cloud APIs from a Pod: don't download a service account JSON key and put it in a Secret. Use Workload Identity Federation for GKE to link a Kubernetes service account to IAM permissions; there's no key to leak.

Keeping the cluster healthy: upgrades, repairs and image-pull permissions

Auto-upgrade and auto-repair: two different jobs

  • Node auto-upgrade keeps node versions in line with the control plane. It is on by default when you create a cluster or node pool in the console or with gcloud, and always on (it can't be turned off) in Autopilot. During an upgrade, nodes are drained and re-created, so changes made directly on a node's boot disk are lost. Choosing "the latest version" when you create the cluster doesn't keep it up to date later.
  • Node auto-repair fixes unhealthy nodes: a node that reports NotReady or stays silent for about 10 minutes, or whose boot disk is full for about 30 minutes. It doesn't deal with Kubernetes versions. Autopilot always repairs nodes; Standard enables it by default on new node pools.

ImagePullBackOff: who pulls the image, and with what permission

ImagePullBackOff means the kubelet (the software on the node) failed to pull the image and is retrying with a growing delay of up to 5 minutes. Run kubectl describe pod and read the error. If you see 403 Forbidden, it's a permissions problem.

The deciding point: the node pulls the image, not the app in the Pod. Per the GKE docs, unless you use an imagePullSecret, the node pool's service account needs read access to the repository. For Artifact Registry that is the role roles/artifactregistry.reader. Two common situations:

  • The Compute Engine default service account: if your organization turned off the automatic Editor grant for it (Google recommends this, and it is the default for organizations created after 3 May 2024), you must grant roles/artifactregistry.reader yourself. Then GKE can pull images from repositories in the same project.
  • A dedicated service account for the node pool: safer because it has fewer permissions, but you must grant each one you need, including Artifact Registry read access. This is why moving to a dedicated service account often causes ImagePullBackOff.
gcloud artifacts repositories add-iam-policy-binding \
  web-images --location=us-central1 \
  --member=serviceAccount:SA_EMAIL \
  --role=roles/artifactregistry.reader

Cloud Run: the revision is the unit of deployment

Every deploy or configuration change creates an unchangeable revision. The service's traffic is split between revisions by percentage. So a rollback on Cloud Run is not "deploy the old version again"; it's sending traffic back to the old revision.

ScenarioHowClues in the question
Try a new version before real users see itgcloud run deploy --no-traffic --tag, test via the tag URL"test in production without serving users"
Canary 5–10%update-traffic --to-revisions or --to-tags with percentages"gradually", "small percentage of users"
New version is broken, go back nowSend 100% of traffic to the previous revision"immediately revert", "no redeploy"
Send all traffic to the newest revisionupdate-traffic --to-latest"all traffic to the latest revision"

What a rollback really does

A rollback changes routing configuration, so you don't rebuild or redeploy. The docs give two things to remember. First, requests already being processed run to completion and aren't dropped, and may reach either the new or the old revision during the transition. Second, a rollback updates routing immediately and doesn't re-run health checks or verify external dependencies. If the new version changed the database structure in a way the old version can't read, a fast rollback is not necessarily a safe one.

Step-by-step releases, and the "traffic pattern sticks" trap

# 1. Deploy the new version with no traffic, add a tag
gcloud run deploy web --image=IMAGE_URL \
  --no-traffic --tag=green
# Test at https://green---web-abcdef.a.run.app

# 2. Canary 10% via the tag
gcloud run services update-traffic web \
  --to-tags=green=10

# 3. If it's good, send 100% to the newest revision
gcloud run services update-traffic web --to-latest

# Rollback: 100% to an older revision
gcloud run services update-traffic web \
  --to-revisions=web-00041-xyz=100

Step 3 is not optional. The docs say that once you've split traffic or pointed it at an older revision, every later deployment follows that pattern. A real-world mistake: roll back, fix the bug, deploy the patch, then wonder why users still see the old version. The patch exists but traffic is still pinned to the old revision.

Tags have their own cost: if you set minimum instances at the revision level, every tagged revision is kept running and billed even with no requests. The docs recommend service-level minimum instances, or removing tags you no longer need.

The same thinking applies to App Engine: every deploy is a version, and you roll back by sending 100% of traffic to the previous version on the Versions page; there is no "restore" command. Older App Engine questions still appear in the question bank.

Cloud Run autoscaling: three knobs

  • Min instances: defaults to 0, meaning the service scales to zero with no requests. Set min instances to keep an instance warm and reduce cold starts; the price is paying for the waiting instance.
  • Max instances: caps the instance count, for example to stay within the connections Cloud SQL can handle. If min and max conflict, max wins.
  • Concurrency: the maximum number of simultaneous requests per instance, up to 1,000. A new service created with gcloud or Terraform defaults to 80 × the number of vCPUs (applied only when the service is created); created in the console it defaults to 80. Lower concurrency makes Cloud Run start more instances for the same load. Set it to 1 if the code can't handle parallel requests, but the docs warn that 1 makes scaling less smooth during sudden spikes. Higher concurrency means fewer instances and lower cost, as long as the code can take it.

Where to split traffic

PlatformWhat receives trafficHow to split
Cloud Run, Cloud Run functionsRevisiongcloud run services update-traffic or the Revisions tab in the console
App EngineVersionTraffic splitting on the Versions page
GKEThe Service behindGateway API (weighted HTTPRoute) or run two Deployments side by side

Common traps

  • A monitoring Pod on every node, cluster has an autoscaler: DaemonSet, because new nodes get the Pod automatically. See practice question #30.
  • Keep the cluster on a supported Kubernetes version: node auto-upgrade, not auto-repair or choosing the newest version at creation. See question #39.
  • Database password in plain text in the manifest: move it to a Secret and load it into the Pod; ConfigMaps are not for sensitive data. See question #42.
  • Buggy release, revert immediately: route 100% of traffic to the previous version/revision instead of redeploying or creating a new app. See question #45.
  • Always 3 idle instances while still scaling on requests: automatic scaling with a minimum number of idle instances, not manual scaling. On App Engine that is min_idle_instances: instances that run in addition to the number App Engine computes from load (computes 5, set 2, runs 7), and you pay for them whether or not they get traffic. The docs also require warmup requests to be enabled and handled. Cloud Run has min instances. See question #9.
  • Pods Pending even with autoscaling on: check the per-zone --max-nodes ceiling, quota and the NotTriggeredScaleUp event before adding nodes by hand.
  • A node pool needs a different machine type: create a new node pool, move the workload, then delete the old pool.

Reading the question

  • Find the phrase that decides the answer: every node (DaemonSet), without managing nodes (Autopilot), gradually (traffic splitting), immediately revert (route traffic to the old version), pending Pods (cluster autoscaler), not plain text (Secret).
  • Separate "who does it": the node pulls the image (node pool service account permission), while the app in the Pod calls Google Cloud APIs (Workload Identity).
  • Older questions may mention Container Registry; current docs use Artifact Registry for images.

Start practicing

Try the 60 free ACE questions and watch for the GKE, Cloud Run and App Engine ones, then a timed exam (Pro). For the exam overview, see the Associate Cloud Engineer study guide, and for service-choice tables see the ACE decision tables.

Official sources