Prepare and test your skills

Prepare and test your skills

Evaluating use cases and modernization pathways means matching workload traits to virtual machines (VMs) or containers and picking the Google Cloud path toward cloud-native operations. Compute Engine runs VMs that keep the existing operating system and management model, while containers package an application and its dependencies into a lightweight, portable unit that runs consistently across environments. Modernization often moves in order from lift-and-shift of VMs to containerization on managed platforms and then to re-architected services.
Virtual machines remain the preferred choice when the goal is to preserve the current operating system, configuration, and management practices with minimal change. Migrate to VMs moves VM workloads into Compute Engine instances and modernizes only the underlying infrastructure while the application keeps running as before. This pathway fits a single VM, testing and development work, workloads that must run in privileged mode, and teams less familiar with managed or serverless options.
Staying on VMs can still add stronger Compute Engine features without restructuring the application. These features include instance templates, managed instance groups with autoscaling, autohealing, regional deployments, and auto-updating. For running containers directly on VMs, startup scripts fit basic cases on one VM, while cloud-init fits multiple containers on one VM, multiple VMs or managed instance groups, and advanced setup such as creating users, importing files, mounting disks, or using privileged mode. Using startup scripts or cloud-init does not inherently change Compute Engine costs because the team still pays for the underlying VM resources and owns VM setup, security, and maintenance.
Containers are the preferred choice when density, portability, elasticity, and fast operations matter more than keeping one full VM per workload. A container holds an application plus all its dependencies, so many containers can run efficiently on the same host with fine-grained resource allocation. Compared with running an application directly on a VM, containers run more consistently across environments and make it easier to move from one monolith to focused microservices.
Container benefits on Google Cloud center on lower operational work and better resource use:
Migrate to Containers (opens in a new tab) is the tool that containerizes existing VM-based applications to run on GKE, GKE Autopilot, GKE Enterprise, or Cloud Run. The tool extracts an image from the VM workload and builds a Docker image and related artifacts, so modernization does not require source code access, rewriting, or rearchitecting. The containerized workload then gains modern orchestration and application management from the GKE ecosystem while preserving legacy behavior.
A common modernization sequence moves through three stages in order:
A horizontal timeline showing lift-and-shift to Compute Engine VMs, then containerization on GKE and Cloud Run, then re-architecting with managed services.
Windows containers show how the middle step helps teams that do not want to migrate .NET Framework applications to .NET but still want agility, portability, and control. After containerization, a Kubernetes cluster adds cluster autoscaling, regional clusters, highly available control planes, and hybrid and multi-cloud support with GKE Enterprise. Packing multiple Pods onto the same VMs can reduce VM count and lower Windows licensing costs, while declarative Kubernetes management simplifies operations for Windows and Linux containers.
The choice of container deployment option depends on whether the team keeps direct VM control or moves to a managed service, plus workload shape and operational effort. Staying on VMs keeps control of the VM lifecycle, while Cloud Run, Batch, and GKE shift VM management, patching, and scaling to Google Cloud. Managed services automatically adjust resources with demand, can cost less than over-provisioned or idle VMs, and offer a free tier for smaller workloads or testing.
| Solution | Best for | Cost and management tradeoff |
|---|---|---|
| VMs with startup scripts or cloud-init | Single VM, testing and development, privileged mode, multiple containers on one VM, or multiple VMs and managed groups with advanced setup | No added cost beyond Compute Engine VMs; team owns VM setup, security, and maintenance |
| Cloud Run | Stateless applications and small to medium jobs with variable traffic | No to low cost for smaller workloads; platform handles infrastructure and elasticity, but apps should be request-driven and stateless |
| Batch | Batch jobs with a definite end state that need extra compute | Cost depends on workload and configuration; platform manages job execution, but apps should fit a job-based model |
| Google Kubernetes Engine (GKE) | Existing GKE cluster or workloads needing advanced control and scalability | Cost depends on workload and configuration; team uses Kubernetes manifests and cluster management for powerful orchestration |
Moving to Cloud Run or Batch may require adapting applications to be stateless and to use external state services. Moving to GKE requires adopting Kubernetes principles, defining workloads with manifest files, and managing cluster resources. That upfront change supports long-term gains in efficiency, scalability, and cost-effectiveness for fluctuating or cloud-native workloads.
Deployment and management in Google Cloud divides into VM models where the customer controls infrastructure and managed container models where Google handles more of it. Compute Engine (opens in a new tab) provisions individual VMs or groups of VMs, while Cloud Run and Google Kubernetes Engine (GKE) run containers without requiring direct management of each VM. The choice changes who patches and scales the system, how costs accrue when idle, and how easily an application moves between environments.
Compute Engine virtual machines use an infrastructure-as-a-service model where VMs are managed as individual resources or as one group. VMs are created directly or from an instance template with the Google Cloud CLI or Compute Engine API, and identical VMs can be grouped into managed instance groups (MIGs) for autoscaling, autohealing, rolling updates, multi-zone deployment, and load balancing. This model fits when full control is needed over machine type, image, zone, VPC network, start-stop schedule, or failure handling, including stateful workloads that preserve session data or instance metadata across reboots.
Workload planning for Compute Engine starts with application state, provisioning needs, and resilience. A stateful application stores client or session data until it is no longer needed, such as a shopping cart, while a stateless application closes the session after serving a request, such as a simple web server. Planning also decides whether VMs can share one zone and subnet, whether they need mixed machine types, whether they must scale automatically with load, and whether they must survive a zonal failure by running in other zones in the same region.
Running containers on Compute Engine means packaging software with its libraries so it stays isolated from the host operating system. Installing software directly on a VM combines application setup with operating system setup, so library conflicts must be resolved manually if two apps need different versions of the same library. A container carries its app and required libraries together and is isolated from OS apps and libraries, so it can move between environments without fixing version conflicts on each host.
Container deployment on Compute Engine follows an ordered workflow:
docker run configuration in a startup script or cloud-init configuration when creating the VM or instance template for a MIG.cloud-init pulls the container image from the registry and starts the container on the VM.The older konlet agent that used the gce-container-declaration metadata key is deprecated. Container-Optimized OS images are not deprecated, but new versions no longer support konlet, so containers on VMs and MIGs must use docker run commands in a startup script or use cloud-init. Initial setup with a startup script typically takes 1-2 hours with later deployments taking minutes, and costs do not change because charges still apply for the underlying VM resources even when idle.
Cloud Run is the lightweight managed service for deploying stateless containers and small to medium jobs without managing VMs. A Cloud Run service is a regional resource that is replicated across multiple zones in the selected region, which supports availability without configuring MIGs. Google Cloud handles the underlying VMs, patching, and scaling, and the service automatically adjusts resources based on demand.
This automation changes scaling and cost compared with Compute Engine. Traffic flows from incoming requests to Cloud Run, which adds capacity when demand rises and reduces it when demand falls, so peak load does not require over-provisioned VMs. Unlike VMs that incur charges even when idle, Cloud Run can be more cost-effective for fluctuating or low-traffic workloads, and it offers a free tier for smaller workloads or testing.
Google Kubernetes Engine (GKE) is the managed Kubernetes environment for deploying, managing, and scaling containerized applications, especially large numbers of microservices. The GKE environment consists of multiple Compute Engine instances grouped to form a cluster, and GKE manages orchestration across that cluster instead of requiring manual start and stop of each container. Running each microservice on its own Compute Engine VM can make operating system overhead a large part of cost, while GKE places multiple containers on each instance to use host resources more efficiently.
GKE adds automation for scaling, repair, and operations across the cluster boundary. The control plane manages node pools, load balancing, node auto-repair, automatic scaling and upgrades, logging, and monitoring, while application containers run on the nodes inside the cluster. GKE is the choice when advanced control and scalability, faster container startup at scale, or Kubernetes orchestration is needed beyond what Cloud Run or a single VM provides, accepting greater upfront effort such as making the app stateless.
Managed container services trade direct VM control for less operational work, automatic elasticity, and better efficiency for idle or variable loads. The shared effects are consistent across Cloud Run, Batch, and GKE:
The following options map workload needs to management and cost effects:
| Option | Use when | Management and cost effect |
|---|---|---|
| Startup scripts or cloud-init on Compute Engine | Staying on VMs or MIGs, single-VM workload, or testing and development | Team manages the VM and pays for the VM even when idle; setup is fastest |
| Cloud Run | Stateless apps and small to medium jobs | Google manages VMs, patching, and scaling; scales with demand and saves cost for idle or variable traffic |
| Batch | Batch job with a definite end state that needs extra compute | Google manages execution and scaling; efficient for finite jobs with free tier for small work |
| GKE | Advanced control and scalability needed or other options do not meet requirements | Google provides cluster orchestration with auto repair, scaling, and upgrades; higher upfront effort but efficient for many microservices |
Exam tip: Stay on Compute Engine with startup scripts to keep VM control, choose Cloud Run for stateless services, Batch for jobs with a definite end state, and GKE for advanced control across many containers.
Structural differences between virtual machines and containers explain their operational tradeoffs in resource use, startup, and isolation. A virtual machine (VM) includes a complete operating system, while a container packages only an application and its required libraries and relies on the host machine's operating system. That single difference makes containers lighter, denser, and faster to start, while each VM carries its own full OS.
A virtual machine (VM) on Compute Engine runs a full operating system image with software installed on top of that OS. Deploying software directly to a VM through a startup script, cloud-init, or a custom boot disk image combines application configuration with operating system setup. The developer must track runtime dependencies, so if two apps need different versions of one library, both versions must be installed and referenced through system variables.
A container carries the application software and the libraries it needs and is isolated from the operating system's apps and libraries. Because a container does not include its own operating system, it can move between deployment environments without library conflicts between the container and the host OS. This isolation is what gives containers portability across development, testing, and production hosts.
Resource consumption differs because containers are much lighter than VMs without an included operating system. Containers require considerably fewer compute and memory resources, so a cluster can run greater workload density with fine-grained resource allocations, which lowers overall infrastructure costs. This density advantage grows as the number of services increases.
Running each microservice on its own Compute Engine instance can make operating system overhead a significant part of cost. Google Kubernetes Engine (GKE) lets multiple containers and groups of containers share each instance, so host resources are allocated more efficiently to microservices with a smaller footprint. The result is higher utilization of the same underlying VM capacity.
Startup time favors containers when many services must launch or scale quickly. GKE is the recommended option when faster container startup is required, alongside running many microservices and using Kubernetes automation such as auto upgrades, node auto repair, and autoscaling. Containers start from images pulled from a registry and launched by the container runtime when the instance boots, rather than from a full operating system install.
This image-based start supports rapid scaling and recovery. When demand rises, new containers can launch quickly from existing images, and failed containers can be recreated automatically under orchestration. VMs still provide full OS control, but they carry more startup weight because each VM boots its own system.
Workload isolation in containers separates the application and its libraries from host operating system apps and libraries, which enables portability between deployment environments. On Compute Engine, direct container deployment carries specific limits that shape where this method fits:
These boundaries mean Compute Engine container deployment suits simple, single-container cases. Workloads needing multi-container density, custom port mapping, or API-driven automation should move to Cloud Run, Batch, or GKE.
Deploying a container on Compute Engine follows an ordered process that starts with the image and ends with a running container. The flow moves from the registry to instance metadata to the Container-Optimized OS runtime on the VM:
docker run configuration when creating an instance or an instance template for a managed instance group (MIG).gce-container-declaration metadata key.docker run configuration, pulls the container image from the repository, and starts the container.The container startup agent (konlet) (opens in a new tab) that deployed containers on VMs during VM creation is deprecated. New container workloads must use alternatives by July 31, 2026, and all existing container workloads must be migrated by July 31, 2027. Replacement paths use docker run commands in a startup script or use the cloud-init tool.
Exam tip: Container-Optimized OS images are not deprecated — only the konlet container startup agent is. Keep using Container-Optimized OS, but start containers with a startup script or cloud-init instead of the gce-container-declaration metadata key.
Deployment options differ in the workload they fit and in how much infrastructure the platform manages. Staying on VMs keeps a VM-centric model where the team manages infrastructure, while managed services shift patching, scaling, and host management to Google Cloud. Managed services adjust resources automatically with demand and can cost less for fluctuating or low traffic, but applications may need to become stateless.
| Option | Choose when | Cost and management |
|---|---|---|
Startup scripts or cloud-init on VMs or MIGs | Keeping containers on VMs or MIGs, testing and development, or single-VM workload | Compute Engine costs do not change; team still pays for underlying VM resources |
| Cloud Run | Stateless container applications and small to medium jobs | Fully managed; scales automatically and can be more cost-effective for variable usage |
| Batch | Container is a batch job with a definite end state that needs extra compute | Fully managed; offers a free tier for smaller workloads |
| GKE | Advanced control and scalability needed, or other options cannot meet requirements | Fully managed; offers a free tier and handles infrastructure, patching, and scaling |
Moving from VMs to managed options requires greater upfront investment because the model shifts from infrastructure-as-a-service to platform-as-a-service. Unlike VMs, which incur costs even when idle, managed services reduce overhead by handling infrastructure and elasticity, which improves long-term efficiency for cloud-native workloads.
A virtual machine includes a complete operating system with software installed on top of it, while a container packages only an application and its required libraries and relies on the host machine's operating system. Because containers omit a full operating system, they use fewer compute and memory resources, allow greater workload density, and start faster from registry images.
Virtual machines remain the preferred choice when the goal is to preserve the current operating system, configuration, and management practices with minimal change. This pathway fits a single virtual machine, testing and development work, workloads that must run in privileged mode, and teams less familiar with managed or serverless options, with Migrate to VMs moving the workload into Compute Engine instances while modernizing only the underlying infrastructure.
Cloud Run is for stateless applications and small to medium jobs with variable traffic, Batch is for a batch job that has a definite end state and needs extra computing resources, and Google Kubernetes Engine (GKE) is for when there is already a GKE cluster or the workload needs advanced control and scalability. Managed services handle virtual machines, patching, and scaling and can be more cost-effective than Compute Engine virtual machines that charge even when idle.
A software development company is modernizing an application suite by moving away from deploying individual services on separate virtual machines (VMs), where operating system overhead has increased costs. The engineering team wants to adopt a container-based deployment model in Google Cloud that meets the following requirements:
Which Google Cloud compute deployment option should the company choose?
Google Kubernetes Engine (GKE) in Standard mode
Google Kubernetes Engine (GKE) in Autopilot mode
Cloud Run
Compute Engine with Managed Instance Groups (MIGs)
Last updated