0
0
GCPcloud~30 mins

Preemptible and Spot VMs in GCP - Mini Project: Build & Apply

Choose your learning style9 modes available
Using Preemptible and Spot VMs on Google Cloud
📖 Scenario: You are managing a cloud project on Google Cloud Platform (GCP). You want to save costs by using special virtual machines called Preemptible and Spot VMs. These VMs are cheaper but can be stopped by Google at any time. You will create a simple configuration to launch a Spot VM instance.
🎯 Goal: Build a Google Cloud VM instance configuration that uses a Spot VM to reduce costs. You will create the basic VM setup, add a config for Spot VM usage, apply the core VM creation logic, and finalize the configuration with the required properties.
📋 What You'll Learn
Create a VM instance configuration dictionary with a name and machine type
Add a config variable to specify the VM as a Spot VM
Use the core logic to include the Spot VM configuration in the instance
Complete the configuration with the required scheduling property for Spot VMs
💡 Why This Matters
🌍 Real World
Many companies use Spot or Preemptible VMs to save money on cloud costs for batch jobs, testing, or flexible workloads.
💼 Career
Understanding how to configure Spot VMs is useful for cloud engineers and developers aiming to optimize cloud infrastructure costs.
Progress0 / 4 steps
1
Create the basic VM instance configuration
Create a dictionary called vm_instance with these exact entries: 'name': 'cost-saving-vm' and 'machine_type': 'e2-medium'.
GCP
Need a hint?

Think of vm_instance as a simple dictionary holding the VM's name and type.

2
Add the Spot VM configuration variable
Create a variable called spot_config and set it to a dictionary with the key 'preemptible' set to True.
GCP
Need a hint?

This config tells Google Cloud to treat the VM as a Spot VM that can be stopped anytime.

3
Add the Spot VM config to the VM instance
Add a new key 'scheduling' to the vm_instance dictionary and set its value to the spot_config dictionary.
GCP
Need a hint?

This step links the Spot VM settings to the VM instance configuration.

4
Complete the VM configuration with required Spot VM property
Add the key 'on_host_maintenance' with the value 'TERMINATE' inside the spot_config dictionary to complete the Spot VM scheduling configuration.
GCP
Need a hint?

This property ensures the VM stops properly when Google Cloud needs to maintain the host.