Cloud Run, GKE, Pub/Sub and authentication for the Professional Cloud Developer exam: decision tables

4 min read

Most Professional Cloud Developer questions come down to three decisions: where the code runs (Cloud Run, GKE or Compute Engine), how components talk (sync or async; Pub/Sub, Eventarc, Cloud Tasks, Workflows), and how code authenticates to Google Cloud services (service accounts, ADC, Workload Identity Federation, Secret Manager). This article turns those decisions into quick-reference tables with practice questions.

Key takeaways

  • Most PCD questions revolve around three decisions: where the code runs, how components talk to each other, and how code authenticates to Google Cloud services.
  • A stateless container answering HTTP that should scale to zero with low operations points to Cloud Run; sidecars, a service mesh or StatefulSets point to GKE; software that needs a full OS points to Compute Engine.
  • To control the call rate to an endpoint, Cloud Tasks has per-queue rate limits while Pub/Sub does not; Pub/Sub handlers must be idempotent because messages can be duplicated.
  • Don't keep secrets in hard-coded environment variables or in the image; use Secret Manager.

Choosing a runtime

PlatformChoose whenPoor fit when
Cloud Run (service)Stateless containers serving HTTP, gRPC or events; scale to zero, low ops; deploy from sourceYou need node access, long-running non-HTTP protocols, detailed Kubernetes configuration
Cloud Run functions (formerly Cloud Functions)Small code responding to events (a new object in a bucket, a Pub/Sub message, HTTP)Large apps with many routes or needing container control
Cloud Run jobsRun-to-completion tasks (batch, migrations, file processing) that don't serve requestsServices that must always accept requests
GKE (Autopilot or Standard)Many microservices needing Kubernetes features: sidecars, service mesh, StatefulSets, network policies, HPA on custom metricsSmall teams, simple apps, minimal ops
Compute EngineSoftware needing a full OS, machine-bound licenses, legacy apps not yet containerizedNew cloud-native apps

Cloud Run settings that come up

  • Concurrency: concurrent requests per instance; raise it to save money, lower it if the code isn't thread-safe.
  • Minimum instances: reduce cold starts for latency-sensitive services at the cost of idle spend.
  • Ingress and authentication: restrict ingress to internal, require IAM (the Cloud Run Invoker role) for service-to-service calls.
  • Revisions and traffic: deploy a new revision with no traffic, shift percentages gradually; roll back by sending traffic to the old revision.
  • VPC access: Direct VPC egress to reach private-IP resources such as Cloud SQL or Memorystore.

Release strategies

StrategyCloud RunGKE
Rolling updateBy default all traffic moves to the new revision when it's readyDeployment RollingUpdate with maxSurge/maxUnavailable (practice question #20)
CanarySend a small share of traffic to the new revision (question #9)Two Deployments behind one Service, or weighted routing via Gateway/service mesh
Blue/greenTag the new revision, switch 100% after testingTwo environments, switch the Service selector
A/B testingPercentage splits between revisionsHeader- or weight-based routing

Async integration: which service

ServiceModelUse when
Pub/SubPublish/subscribe, many subscribers, at-least-onceDecoupling producers and consumers, fan-out, high-volume event streams
EventarcRoutes events from Google Cloud services (audit logs or direct events) to Cloud Run, GKE, Workflows"When a bucket, object or record is created, call a service" (question #378)
Cloud TasksA task queue delivering to a specific handler with rate and retry controlRate limiting, scheduling individual tasks, calling rate-limited external APIs
WorkflowsOrchestrates multi-step flows with conditions, waits and error handlingMulti-service processes that need ordering and state
Cloud SchedulerManaged cronPeriodic HTTP calls or Pub/Sub publishes

Pub/Sub points to remember

  • Push vs pull: push sends HTTP to an endpoint such as Cloud Run; pull lets consumers fetch at their own pace.
  • At-least-once: messages can be redelivered, so handlers must be idempotent; exactly-once delivery is available only for pull subscriptions.
  • Ordering keys: preserve order for messages with the same key.
  • Dead-letter topics: move repeatedly failing messages aside for later handling.

For a UI calling a slow third-party API, calling it asynchronously and hiding the result widget on timeout keeps the page responsive (question #26).

Authentication and secrets

NeedRecommended approach
Code on Google Cloud calling Google APIsAttach a dedicated service account to the resource and use Application Default Credentials; grant the narrowest role (question #42)
GKE Pods calling Google APIsWorkload Identity Federation for GKE (Kubernetes service accounts mapped to IAM permissions)
Code outside Google Cloud (AWS, Azure, external CI)Workload Identity Federation instead of JSON keys
Local developmentgcloud auth application-default login so ADC uses your account
Database passwords, API keysSecret Manager with versions and rotation; mount into Cloud Run as env vars or volumes
Connecting to Cloud SQL, AlloyDBCloud SQL Auth Proxy or AlloyDB Auth Proxy (or language connectors), IAM database authentication
Temporary access to a private file for a userTime-limited Cloud Storage signed URLs
Protecting an internal web appIdentity-Aware Proxy
End users signing in to your appIdentity Platform (OAuth 2.0, OpenID Connect, JWT)

Choosing data stores as a developer

  • User state and flexible profiles: Firestore (question #37).
  • Images and static files at low cost and latency: Cloud Storage behind Cloud CDN (question #38).
  • Caching read-heavy data: Memorystore for Redis.
  • Relational transactions: Cloud SQL, AlloyDB; global and strongly consistent means Spanner.
  • Analytics: write to BigQuery (streaming or batch).

Common traps

  • Using Pub/Sub when you need to control the call rate to one endpoint: Cloud Tasks has per-queue rate limits.
  • Non-idempotent Pub/Sub handlers: duplicates get processed twice.
  • Using the Compute Engine default service account with Editor: violates least privilege.
  • Hard-coding secrets in env vars or images: use Secret Manager.

Start practicing

Try the 60 free Professional Cloud Developer questions, then a timed exam (Pro). For the exam overview, see the Professional Cloud Developer study guide.

Official sources