Prepare and test your skills

Prepare and test your skills

Selecting appropriate compute choices means matching workload control, scaling, and cost needs to the right Google Cloud service. Compute Engine (opens in a new tab) provides virtual machines with full operating system control, Google Kubernetes Engine (GKE) (opens in a new tab) provides managed Kubernetes orchestration, and Cloud Run (opens in a new tab) provides serverless containers with no clusters to manage. The same standard container image stored in Artifact Registry can run on GKE and Cloud Run without modification.
Google Kubernetes Engine (GKE) is a managed Kubernetes platform for deploying, scaling, and orchestrating containerized applications. GKE supports stateless and stateful applications and fits complex microservices with dependencies and specific resource needs. For stateful services, GKE attaches persistent volumes so data survives container restarts.
Responsibility for GKE is split between Google and the user. Google manages the Kubernetes control plane for security and availability, while the user handles cluster aspects such as node configuration, networking, scaling, and upgrades. In Autopilot mode Google provisions and scales nodes automatically and the user pays only for resources requested by workloads, while in Standard mode the user manages node pools directly. Capacity adjusts with Horizontal and Vertical Pod Autoscalers, which add or remove containers, and the cluster autoscaler, which adds or removes nodes.
Cloud Run is a fully managed platform that runs containers directly on Google's scalable infrastructure without clusters to manage. Cloud Run covers two models: Cloud Run services for code that responds to web requests, and Cloud Run jobs for code that performs background tasks and then exits. A request flows from the client to the Cloud Run service, Google starts a container instance to handle it, and the instance scales down when traffic stops.
With Cloud Run the user provides only source code or a container image, and Google manages the operating system, kernel, network setup, and capacity. Cloud Run adds or removes instances based on incoming requests or CPU use, with scale to zero when idle. Pricing is pay-per-use rounded up to the nearest 100 milliseconds, so cost follows actual use. Cloud Run functions (opens in a new tab) are lightweight, single-purpose functions hosted by Cloud Run that stay idle until an event invokes them, then scale automatically.
Choosing between GKE, Compute Engine, and Cloud Run depends on control needs, application type, and cost pattern. Choose Compute Engine when the workload needs full administrator access, custom kernels, or all available GPUs and TPUs. Choose GKE when deep Kubernetes control, custom networking, persistent storage, or complex orchestration is required, while choose Cloud Run when simplicity and automatic request-driven scaling are required.
A decision flowchart that branches on workload needs to choose between Compute Engine, GKE, and Cloud Run, showing the management responsibility and scaling model of each option.
| Option | Management | Choose when |
|---|---|---|
| Compute Engine | User manages OS, middleware, and apps | Full OS access or specialized hardware is required |
| GKE | Google manages control plane; user manages nodes and networking | Stateful apps or complex microservices need orchestration |
| Cloud Run | Google manages OS, network, and capacity | Stateless, request-driven services need minimal operations |
Exam tip: Choose GKE for stateful services needing persistent volumes and Kubernetes control; choose Cloud Run for stateless, request-driven services needing automatic scaling and pay-per-use billing.
Launching a Compute Engine instance means choosing machine resources, availability behavior, and secure access settings at creation time. A Compute Engine instance is a virtual machine or bare metal server in a project with a selected zone, machine type, and boot image. Security settings are configured in the Security pane, while automation and provisioning choices are configured in the Advanced pane.
Machine type and boot image configuration defines what an instance can do and what it costs to run. The machine type sets virtual CPUs and memory, and if the name ends in -metal the instance is a bare metal instance with no hypervisor; otherwise it is a virtual machine instance. You can choose predefined types such as e2-small or create a custom type with specific CPU and memory.
Boot disk selection configures the disk that contains the operating system used to start the instance. A public image is supplied and updated by Google, such as Debian or Ubuntu, with premium options like Windows adding an hourly fee. A custom image is created from your configured disk and lets every instance start from the same standardized environment. An instance template (opens in a new tab) captures machine type, image, network, and disks as a reusable blueprint.
Availability policy and provisioning models control how an instance handles maintenance, stops, and capacity cost. The provisioning type includes standard for regular capacity, spot for spare capacity that can be reclaimed, flex-start in Preview, and reservation-bound tied to reserved zonal capacity. Reservations let an instance consume reserved capacity to ensure better resource availability.
On-host maintenance and zonal resilience determine whether a workload stays running. A workload in a single zone stops serving if that zone fails, so protection requires spreading VMs across zones and distributing traffic with Cloud Load Balancing. Traffic flows from the load balancer to healthy backend instances, while an autoscaler adds or removes instances in a managed instance group as demand changes.
Secure access with IAM, SSH, and metadata controls who can reach an instance, what the instance can reach, and how it configures itself on boot. VM access combines Identity and Access Management roles with Secure Shell keys, so requests flow from the user through IAM checks to the instance and then through key authentication to the guest OS. The Security pane also provides Confidential Computing, which encrypts data in use, and Shielded VM features, which protect against boot-level malware.
Assigning a service account gives software on the instance an identity for calling Google Cloud APIs, and the instance can only access resources its service account allows. Custom metadata stores key-value data that software can read, while a startup script runs commands on every start and reboot to install packages or enforce settings. Creating an instance requires compute.instances.create, plus compute.instances.setMetadata, compute.instances.setServiceAccount, compute.instances.setTags, and compute.instances.setLabels for those fields.
Exam tip: A startup script runs each time the instance starts or reboots, not only on first creation.
Continue with this study guide: Launching a compute instance (e.g., availability policy, SSH keys)
Choosing storage for Compute Engine means matching persistence, availability, and performance controls to workload needs. Persistent Disk (opens in a new tab) is durable network block storage that stays preserved even if the instance is stopped or deleted. Google Cloud Hyperdisk (Hyperdisk) (opens in a new tab) is durable block storage with independently tunable performance and dynamic resizing.
Zonal Persistent Disk keeps one copy of data in one zone, and the virtual machine must run in that same zone so compute and data stay together. Compute Engine protects the disk inside the zone by spreading data across physical disks and verifying reads with checksums. Zonal disks fit general boot and data use when snapshot-based backup meets recovery needs.
Regional Persistent Disk keeps two synchronously replicated copies in two zones of the same region. A write flows from the VM to the replica in the local zone and then is synchronously replicated to the second zone. If one zone fails, a VM in the surviving zone can continue using the same disk without a restore. Regional disks provide lower Recovery Point Objective and Recovery Time Objective than snapshots but add cross-zone write work.
| Option | Storage scope | Recovery behavior |
|---|---|---|
| Zonal Persistent Disk | One copy in one zone | Recovery from zone loss depends on snapshots |
| Regional Persistent Disk | Two synchronous copies in two zones | Survives loss of one zone with immediate access to second replica |
Exam tip: Regional replication keeps the disk available in the surviving zone, but failover still requires a working VM in the surviving zone.
Hyperdisk performance tuning lets IOPS, throughput, and capacity scale independently instead of scaling with disk size. With Hyperdisk Balanced, IOPS and throughput can be provisioned separately and changed dynamically, so a small disk can still get high speed. This differs from Persistent Disk, where larger volume size provides more throughput and IOPS.
Hyperdisk types fit different performance shapes. Hyperdisk Balanced fits general workloads, Hyperdisk Extreme fits very high IOPS up to 350,000, Hyperdisk Throughput and Hyperdisk ML fit high sequential throughput, and Hyperdisk Balanced High Availability adds synchronous replication across two zones. Hyperdisk Balanced High Availability and Regional Persistent Disk both survive a zonal outage without restore. Regional disks attach only to E2, N1, N2, and N2D machine types, cannot be created from an OS image, can only be resized larger, and regional Standard disks have a 200 GiB minimum.
Snapshots and backup protection capture point-in-time state to recover from deletion, corruption, or user error. Snapshots are incremental by default, so only changed blocks are stored, which lowers cost. Snapshots can be created in minutes even while attached to a running VM, are stored redundantly with checksums, and can be copied across regions to recreate disks elsewhere.
For managed protection, Backup and DR Service creates and stores backups of VMs in application-readable format for direct restore. Shared data across many VMs can use a Filestore regional instance replicated across three zones. Use replicated disks to survive a zonal outage without restore, and use snapshots to recover from deletion or corruption.
Creating an autoscaled managed instance group means using a template to define identical VMs and a policy to scale them with demand. A managed instance group (MIG) (opens in a new tab) is a collection of virtual machines managed as a single entity from a common instance template. Only managed groups support autoscaling; unmanaged groups contain heterogeneous VMs you manage manually.
Instance template blueprint defines machine type, boot image, network, and disks for every VM in the group. If no settings are supplied, defaults include n1-standard-1, the latest Debian image, the default VPC network, and an ephemeral external IPv4 address. A regional template includes a region and can control subnet placement, while a global template can be used more broadly.
Boot disk choices trade speed for flexibility. A custom image with preinstalled apps starts more quickly and deterministically, while a public image with a startup script is more flexible for updates. An instance template cannot be updated after creation, so changes require creating a new template and updating the MIG to use it.
Autoscaling signals and limits tell the Compute Engine autoscaler when and how far to scale the group. Every policy must contain at least one scaling signal plus minimum and maximum instance counts. When multiple signals exist, the autoscaler calculates a size for each and applies the largest recommendation.
A new autoscaled MIG gets a CPU utilization signal by default, which can be kept or replaced with other signals:
Instance limits bound the group, while timers control speed. The initialization period defaults to 60 seconds and protects scale-out from incomplete startup data. The stabilization period controls scale-in with a default of 600 seconds, so longer values wait to verify lower load before removing VMs.
Regional scope, health checks, and load balancing determine availability and traffic flow for the group. A zonal MIG deploys to a single zone with a default limit of 1,000 VMs, while a regional MIG deploys across multiple zones in one region with a default limit of 2,000 VMs. Regional deployment lets traffic continue from surviving zones if one zone fails.
Health checks separate traffic routing from repair. Traffic flows from the load balancer to healthy instances, but a load balancing health check does not recreate VMs. Data flows from the MIG health check to the MIG manager as a recreate signal, so the manager deletes an UNHEALTHY instance and creates a replacement from the template. The MIG depends on the template for configuration, the load balancer for distribution, and the autoscaler for size changes.
Exam tip: Autoscaling works with maximum backend utilization and maximum requests per second per instance, but not with maximum requests per second per group.
Configuring OS Login (opens in a new tab) means linking Linux user accounts to Google identities so SSH access is controlled by IAM. OS Login is enabled by setting the metadata key enable-oslogin to TRUE in project metadata for all VMs or instance metadata for one VM. Once enabled, the VM stops using SSH keys in metadata and fetches keys and permissions from the OS Login service on every login.
Project versus instance activation controls which VMs use centralized access. Project metadata applies enable-oslogin=TRUE to all VMs in the project, while instance metadata applies it to one VM, including at creation time. Instance metadata takes precedence over project metadata for both enabling and disabling.
Setting enable-oslogin=FALSE on one VM disables OS Login for that VM even when the project enables it. When disabled, VMs return to accepting SSH keys stored in metadata. In the console the option appears as Control VM access through IAM permissions, while gcloud uses --metadata enable-oslogin=TRUE and Terraform uses the enable-oslogin metadata block.
Exam tip: Instance metadata overrides project metadata, so enable-oslogin=FALSE on one VM turns off OS Login for that VM even when the project enables it.
SSH key lifecycle with certificates replaces long-lived keys on VMs with centrally managed authentication. The guest agent fetches authorized keys from the OS Login service when a connection arrives, and Compute Engine checks IAM permissions on every login. If a role is removed, the next connection is denied even though the public key still exists in the profile.
Certificate-based login uses a short-lived signed certificate from the OS Login certificate authority. The flow runs from local key creation to POSIX account provisioning, username assignment in USERNAME_DOMAIN_SUFFIX format, public-key submission, certificate return, and presentation to the VM. Usernames over 32 characters are truncated, service account users get an sa_ prefix, and external organization users get an ext_ prefix.
IAM login roles and supporting permissions decide who can log in and what they can do. Both core roles allow login, but only one grants administrator control inside the guest OS.
| Role | Login | Privilege |
|---|---|---|
| roles/compute.osLogin | Yes | Regular user without sudo |
| roles/compute.osAdminLogin | Yes | Administrator with sudo |
Where roles are granted controls breadth. Project grants apply to all OS Login VMs, instance grants apply to one VM, and folder or organization grants flow down to contained projects. Complete connections may also need roles/iap.tunnelResourceAccessor for Identity-Aware Proxy TCP forwarding, roles/iam.serviceAccountUser on the attached service account because SSH allows acting as that account, and roles/compute.osLoginExternalUser for users from another organization. Two-factor authentication requires both enable-oslogin and enable-oslogin-2fa set to TRUE plus Google 2-Step Verification.
Continue with this study guide: Configuring OS Login
Configuring VM Manager (opens in a new tab) means enabling centralized patching, inventory, and policy enforcement for Compute Engine fleets. VM Manager depends on the OS Config API control-plane service, the OS Config agent inside each VM, a service account identity, and a network path between them. Data flows from the agent to the API, and control flows back to the agent after activation.
Enablement with API, metadata, and connectivity activates management on each VM. The project needs the OS Config API enabled and the agent activated with enable-osconfig=TRUE in project or instance metadata. By default the agent is idle and collects nothing until that key is set. On Linux activation shows as active (running) and on Windows as Running.
The VM needs an identity and route to reach osconfig.googleapis.com. The recommended setup creates a user-managed service account with least-privilege roles, attaches it to the VM, and sets the cloud-platform access scope. Changing service account or scopes requires stopping and restarting the VM. A private VM without public internet depends on Private Google Access to reach the API.
Patch jobs and recurring deployments deliver OS updates through the OS Config agent using native tools such as yum, apt, zypper, or Windows Update Agent. A patch job is a one-time run defining which VMs to patch, what updates to install, and reboot behavior. A patch deployment uses the same configuration plus a schedule that creates jobs automatically.
Jobs target VMs by zones, labels such as env:prod, or other properties, and can include pre-patch and post-patch scripts. Patch configuration differs by OS family, such as apt upgrades, yum security updates, zypper patches, and Windows classifications. Safe automation patches in small waves, such as dev before prod and zone by zone, and monitors compliance in the Patch dashboard.
Exam tip: Patch jobs run only within a single Google Cloud project, but compliance data can be viewed across projects, and MIG VMs are skipped unless patching of MIG instances is explicitly allowed.
Inventory visibility and vulnerability reporting track installed packages and known weaknesses without signing into each VM. Once the agent reports inventory, the service compares it against vendor sources and shows Common Vulnerabilities and Exposures findings in the console, Security Command Center, and Cloud Asset Inventory. Sources differ by OS, including Red Hat security data, Debian tracker, Ubuntu tracker, SUSE OVAL data, Rocky errata, and Microsoft Security Response Center data.
Reports require agent version 20201110 or later and appear within two hours of a package change and within 24 hours of a new vendor advisory. Inventory data is kept until the VM is deleted, but is deleted if the agent stops reporting for a few days. A repaired or autoscaled MIG VM recreated from its template can return to an unpatched state.
Continue with this study guide: Configuring VM Manager
Using Spot VMs and custom machine types means lowering cost by accepting reclaimable capacity and by sizing VMs precisely. A Spot VM (opens in a new tab) runs on excess Compute Engine capacity at discounts up to 91% off on-demand prices. A custom machine type lets you choose virtual CPUs independently of memory instead of using a fixed predefined size.
Spot preemption lifecycle describes how Compute Engine reclaims capacity. Compute Engine can preempt Spot VMs at any time, with low but varying probability by day, zone, and resource type. Spot VMs have no minimum or maximum runtime, no availability guarantee, and no Compute Engine SLA coverage.
Preemption follows an ordered sequence:
preempted to TRUE.The notice duration selected at creation is either 0 seconds by default or 120 seconds in Preview for longer checkpointing. With STOP the VM enters TERMINATED with no VM-hour charges but disks still incur storage charges; with DELETE the VM and auto-delete disks are removed. Preemption applies only while RUNNING; stopping then restarting resets the process.
Exam tip: The up-to-30-second shutdown period is best effort after the ACPI G2 Soft Off signal, while the 120-second option is a separate dedicated notice period before that signal that must be selected at creation.
Custom sizing and cost-efficient selection avoid paying for unused CPU or memory. Predefined types bundle fixed resources, while custom types provision cores independently of memory within hardware family ratios and zone availability. This helps limit per-core licensing costs and supports bring-your-own-license images.
Machine type recommendations guide sizing from the last 8 days of CPU and memory data averaged over 60-second intervals. Low use leads to smaller recommendations and high use leads to larger ones. For MIGs, Compute Engine protects the most loaded instance so others may be oversized if load is uneven.
| Option | Cost | Choose when |
|---|---|---|
| Standard with predefined | On-demand price | Steady availability fits a fixed size |
| Standard with custom | Lower than oversized predefined | Predictable needs require specific CPU-to-memory ratio |
| Spot VMs | Up to 91% discount | Fault-tolerant batch work can retry or mix with standard |
Spot capacity improves with regional MIGs across zones, multiple machine types, smaller sizes, and off-peak scheduling. Spot VMs consume standard quota unless preemptible quota is granted.
Continue with this study guide: Using Spot VM instances and custom machine types
Installing and configuring kubectl means setting up the Google Cloud CLI, adding the Kubernetes tool, and connecting it to the right cluster. The Google Cloud CLI provides gcloud commands for projects and clusters, while the kubectl component sends cluster operations to the GKE control plane. Initialization with gcloud init signs in the account and sets default project and location.
CLI installation and kubectl setup place the tools on the local machine and keep them updated. On Linux the archive workflow downloads the SDK tarball, extracts google-cloud-sdk, runs install.sh to add PATH and completion, refreshes the shell, runs gcloud init, and adds extra components. The Debian and Ubuntu apt package contains only core tools such as gcloud, gsutil, and bq, so kubectl must be installed separately as an additional component.
Keeping tools current uses gcloud components update to retrieve supported versions of the CLI and kubectl. Before installing on Debian or Ubuntu, the system needs a supported release, a recent package index, and helper packages ca-certificates, gnupg, and curl. Python 3.10 to 3.15 is required for archive installation.
Exam tip: The Debian and Ubuntu apt package does not include kubectl — install kubectl separately as an additional component after installing the Google Cloud CLI.
Kubeconfig contexts and credential retrieval let kubectl find and authenticate to the correct cluster. A kubeconfig file is a YAML file at $HOME/.kube/config that stores clusters, users, and namespaces. Each context groups a cluster, user, and namespace, and the current context is the default cluster for commands.
Retrieving credentials populates kubeconfig with endpoint and authentication data. The get-credentials command contacts the GKE Multi-Cloud API, fetches the endpoint, and adds a new context. For GKE on AWS the pattern uses gcloud container aws clusters get-credentials, and for GKE on Azure it uses gcloud container azure clusters get-credentials, with cluster name and Google Cloud location. After success kubectl uses the same Google identity as gcloud, including the userinfo.email scope.
Connection paths and verification prove kubectl can reach and use the control plane. Traffic flows from kubectl to the kube-apiserver over TCP port 443. The recommended path is the Connect gateway, where traffic flows from kubectl to connectgateway.googleapis.com and the gke-connect-agent forwards it to the private endpoint. The alternative is a private endpoint where kubectl sends directly to the control-plane DNS name inside the virtual network.
| Connection option | Traffic path | Requirement |
|---|---|---|
| Connect gateway | Kubectl to Google, then agent to control plane | Outbound connectivity from cluster; no direct VPC route needed |
| Private endpoint | Kubectl directly to private endpoint | Workstation routing to VPC plus firewall access |
Checking configuration uses kubectl config view to list contexts and kubectl config current-context to show the default. Running get-credentials switches the default to the new cluster, while --cluster targets one command without changing the default. A read such as kubectl get pod confirms connectivity and RBAC authorization, with gateway users needing roles such as roles/gkehub.viewer plus gateway reader, editor, or admin access.
Deploying a GKE cluster means choosing a mode and availability architecture that fits operational control and resilience needs. A GKE cluster includes at least one control plane machine and multiple worker nodes that are Compute Engine VMs running Kubernetes processes. Applications run on the nodes while the control plane manages them.
Autopilot versus Standard mode selection balances simplified management against direct node control. GKE Autopilot clusters are always regional and are created with gcloud container clusters create-auto using a cluster name and region. Creation takes several minutes before the control plane and nodes are ready.
With Autopilot, resource provisioning starts from name and region and GKE assembles control plane and nodes. With Standard, planning involves direct node-pool decisions because nodes are VMs you configure and size. Workloads needing minimal node planning align with Autopilot, while workloads with specific node requirements need Standard capacity and VM cost planning.
Zonal and regional architectures control where control planes and nodes run. A zonal cluster runs a single control plane instance in one Compute Engine zone, with nodes in one zone or spread multi-zonally in the same region. If the control-plane zone fails, the Kubernetes API becomes unavailable even if multi-zonal nodes keep running.
A regional cluster replicates its control plane across multiple zones in one region, with nodes reaching it through a load balancer. By default nodes spread evenly across three zones, such as nine nodes with three per zone, reducible to one per zone. A regional cluster can also use a single-zone node pool while keeping a replicated control plane. After creation a cluster cannot change between zonal and regional.
| Architecture | Control plane | Node placement |
|---|---|---|
| Zonal cluster | Single instance in one zone | Single zone or multi-zonal in same region |
| Regional cluster | Replicated across zones in one region | By default spread across three zones |
Exam tip: Choose a regional cluster for production workloads that need control plane redundancy, and remember that multi-zonal nodes alone do not make a zonal control plane highly available.
Private networking with intranode visibility makes Pod-to-Pod traffic visible to the VPC network for consistent enforcement. When intranode visibility (opens in a new tab) is enabled, the VPC processes all packets between Pods, even on the same node. This lets VPC firewall rules and hierarchical policies apply regardless of Pod location.
Enabling uses --enable-intra-node-visibility at creation or an update to an existing cluster, or the Enable intranode visibility checkbox in Networking settings. Updating an existing cluster restarts control-plane and node components and recreates nodes, which can disrupt workloads. Connectivity tests can verify legitimate traffic is not blocked, Pod-to-Pod communication must remain allowed for network policy, and ip-masq-agent custom ranges must include node and Pod ranges.
Deploying a containerized application to GKE means storing images centrally, declaring desired workload state, and exposing it through a stable Service. A Kubernetes Service groups Pod endpoints behind a stable IP and port, so clients send to the Service address while GKE routes to changing Pods. The Service controller watches the manifest and creates load balancer, IP, and firewall resources automatically.
Workload declarations with Deployments keep stateless applications running as uniform Pods. A stateless application stores no data on the cluster, so any Pod can serve any request and replicas can change safely. The Deployment controller reconciles actual Pods with desired replica count, image version, and labels.
A Deployment manifest declares replicas, selector.matchLabels, Pod template labels, and container image, such as three Pods labeled run: my-app running hello-app:1.0 from Artifact Registry. The selector must match the template labels or the Deployment cannot associate its Pods. Applying uses kubectl directly or Cloud Build gke-deploy at gcr.io/cloud-builders/gke-deploy, which updates image digests, adds labels, retrieves credentials, and waits for readiness.
| Workload type | Storage | Controller |
|---|---|---|
| Stateless application | No cluster storage, state with client | Deployment with uniform Pods |
| Stateful application | Uses persistent storage | StatefulSet with unique identities |
Exam tip: The value in spec.selector.matchLabels must match the value in spec.template.metadata.labels, such as run: my-app, or the Deployment cannot associate its Pods with the replica count.
Service types for access match who must reach the app to what GKE provisions. The Service uses a label selector such as app: products to find Pods and separates port clients use from targetPort containers listen on. GKE supports ClusterIP, NodePort, LoadBalancer, ExternalName, and Headless types.
A ClusterIP Service gets a stable internal IP reachable only inside the cluster. A NodePort Service opens the same port on every node, so traffic flows from client to node IP plus NodePort to a Pod. A LoadBalancer Service adds a cloud load balancer with an external IP that forwards to Pods, which may take minutes to provision. For HTTP routing by host or path, GKE recommends Ingress with HTTP(S) load balancing rather than a basic LoadBalancer Service.
| Service type | Who can reach it | How GKE exposes it |
|---|---|---|
| ClusterIP | Inside cluster only | Stable cluster IP, no external frontend |
| NodePort | Clients reaching node IPs | Same port on every node forwarding to Pods |
| LoadBalancer | External clients | Cloud load balancer with external IP |
Image storage and secure pulls centralize versioned images and control who can deploy them. Artifact Registry stores Docker and OCI images in Docker repositories under the pkg.dev domain, with multiple repositories per project for teams or stages. Images built by Cloud Build can be stored there and deployed to GKE, Cloud Run, Compute Engine, and App Engine flexible environment.
Secure pulls use IAM permissions plus access scopes. GKE nodes use the default Compute Engine service account to pull same-project images unless automatic role grants were disabled. Cross-project or custom service accounts need explicit configuration. Local Docker authentication uses gcloud auth configure-docker, while remote private clusters use a service account with roles/artifactregistry.reader and a downloaded key. Tags such as v1 identify builds, attachments store SBOMs and vulnerability results, and Pub/Sub gcr notifications signal repository changes.
Continue with this study guide: Deploying a containerized application to GKE
Deploying to serverless platforms means running containers or functions without managing servers and routing cloud events to them as requests. Cloud Run (opens in a new tab) is a fully managed platform where container images run in autoscaling instances that scale to zero by default. Eventarc (opens in a new tab) routes events from providers such as Pub/Sub and Cloud Storage to destinations such as Cloud Run, Cloud Functions, and Workflows.
Cloud Run services, jobs, and traffic controls define how serverless code executes and updates safely. A Cloud Run service is an HTTPS endpoint on a *.run.app domain with managed TLS, supporting WebSockets, HTTP/2, and gRPC. Each revision scales out to as many as one thousand instances or more and then removes idle containers, with minimum-instances keeping warm instances and maximum-instances limiting cost or downstream load.
Cloud Run offers four resource shapes that share the same environment:
Traffic management supports gradual rollouts, rollback, and splitting across revisions. Containers are ephemeral, so files come from memory and persistent data must flow to Cloud Storage, Firestore, Cloud SQL, Spanner, or Memorystore. Services are private by default and need the Cloud Run Invoker role for Eventarc delivery.
Cloud Functions deployment packages code with a runtime, entry point, and trigger so Google runs it without servers. In the console you create a 2nd gen function, set name and region, add an Eventarc trigger, set runtime such as Node.js 24 and entry point such as slackNotifier, provide code, and deploy. With gcloud you deploy source and receive status such as ACTIVE and timeout such as 60s.
An HTTP-triggered function starts from a direct HTTP request to its URL for user actions or webhooks. A background function starts when Eventarc forwards a system event, such as a Pub/Sub message or Cloud Storage object change, without polling. For Pub/Sub the flow moves from publisher to topic through the trigger to the function, using event type google.pubsub.topic.publish. For Storage the direct type google.cloud.storage.object.v1.finalized covers creation, with additional types for deletion, archiving, and metadata updates.
Exam tip: Choose the Direct event type such as google.cloud.storage.object.v1.finalized when both direct and audit log events are available for the same Google provider.
Event routing, messaging, and secure delivery connect sources to sinks with filtering and least-privilege identity. An Eventarc trigger listens for one event type and sends matches as HTTP POST in CloudEvents format. Filtering uses exact match without wildcards, filters cannot be edited after creation, and trigger, resource, and destination should share a region for lower latency. A new trigger can take up to two minutes to become functional.
Pub/Sub acts as decoupled transport where publishers send once to a topic such as projects/PROJECT_ID/topics/TOPIC_ID and Eventarc delivers to each matching destination. Subscriptions persist and do not expire by default, and retry can be enabled for failed deliveries. Each trigger needs an identity, defaulting to the Compute Engine default service account, with roles for Pub/Sub Publisher, Pub/Sub Subscriber, Cloud Run Invoker, and sometimes Service Account Token Creator. Without Invoker permission, authenticated delivery fails even when topic and trigger are correct.
enable-oslogin=TRUE, where instance metadata overrides project metadata and roles/compute.osAdminLogin adds sudo over roles/compute.osLogin.Choose Google Kubernetes Engine (GKE) for stateful services and complex microservices that need Kubernetes orchestration, persistent volumes, and custom networking, and choose Cloud Run for stateless, request-driven services that need automatic scaling with minimal operations. GKE attaches persistent volumes so data survives container restarts and adjusts capacity with Horizontal and Vertical Pod Autoscalers and the cluster autoscaler, while Cloud Run adds or removes instances based on incoming requests or CPU use, scales to zero when idle, and uses pay-per-use billing rounded up to the nearest 100 milliseconds.
A zonal Persistent Disk keeps one copy of data in one zone and requires the virtual machine to run in that same zone, while a regional Persistent Disk keeps two synchronously replicated copies in two zones of the same region. If one zone fails, a virtual machine in the surviving zone can continue using the same regional disk without a restore, while recovery from zonal disk loss depends on snapshots. Regional disks provide lower Recovery Point Objective and Recovery Time Objective than snapshots but add cross-zone write work.
Only managed instance groups support autoscaling, and every autoscaling policy must contain at least one scaling signal plus minimum and maximum instance counts. When multiple signals exist, the autoscaler calculates a size for each signal and applies the largest recommendation, with a new autoscaled group getting a CPU utilization signal by default. The initialization period defaults to 60 seconds to protect scale-out from incomplete startup data, and the stabilization period controls scale-in with a default of 600 seconds to verify lower load before removing virtual machines.
OS Login links Linux user accounts to Google identities by setting the metadata key enable-oslogin to TRUE in project metadata for all virtual machines or instance metadata for one virtual machine. Instance metadata takes precedence over project metadata, so setting enable-oslogin to FALSE on one virtual machine disables OS Login for that machine even when the project enables it. The role roles/compute.osLogin allows login as a regular user without sudo, while roles/compute.osAdminLogin allows login as an administrator with sudo.
Last updated