Editing Google Compute Engine (GCE) Instance Settings

Few months ago I started the streetcred project on Google Cloud Platform, scheduling scraping tasks on Google Compute Engine. Here are some things I learnt about editing Google Compute Engine instance settings after instance creation, so that you don’t have to go through the same trouble if you’re ever starting a similar project of your own. Most of this information is probably in documentation somewhere but being lazy I missed them and learnt them the long way.

Pre-emptible Instances

Pre-emptible instances are compute instances that may be reclaimed by Google any time resources are required, or at the end of 24 hours. In exchange for that drawback, pre-emptible instances are much cheaper to run. They’re great for non-critical, fault tolerant jobs on a budget.

1. You cannot change the instance’s pre-emptiblity once the instance is set up

The only way to keep the same instance name and configuration and toggle between a regular and pre-emptible instance, is to delete the old instance and create a new one. The option is only available during initial set up.

2. Pre-emptible instances do not restart on their own

From experience the instances generally shutdown at the 24 hour mark (rather than earlier). To use them as (almost) always on instances, you’ll need a separate persistent instance running to check if your pre-emptible instance is down, and send a call to restart it. Not to worry about costs of the additional instance though, as you can use your free instance quota to run this task. Due to these reasons and more, I created gcloud-monitor to make the most out of pre-emptible instances. Read more about it here.

Machine Types

Here’s to select from pre-defined or custom machine types, from things like the number of vCPUs to the amount of RAM.

3. You’ll need to stop your instance to change its machine type

If your task cannot be stopped safely for a period of time once it is started, then you might consider it not possible to change your machine type, and need to select more carefully on creation. More on changing machine types here.

4. Don’t always trust performance recommendations

Sometimes instances crash if the recommendations are not followed and resource consumption explodes. Sometimes it doesn’t. If cost is a main concern you’ll need to dabble a little with the machine type configurations to get the hang of what is sufficient. Recommendations are not (always) critical warnings.

Persistent Disk

This refers to the persistent storage capacity of your instance.

5. Persistent disk capacity can be increased but not decreased

Once your instance is created, you won’t be able to reduce the size of the persistent disk. If cost is a concern in the running of your instance, then you may want to try with a small size and increasing it later on, rather than the other way round. More on resizing persistent disks here.

Editing Google Compute Engine Settings Post-creation

FieldCan edit without stopping instanceCan edit upon stopping instance
Machine configuration
Machine familyNoYes
Machine typeNoYes

CPU platform NoYes
Display deviceNoYes
Confidential VM service (Enable the Confidential Computing service on this VM instance.)NoNo
Container (Deploy a container image to this VM instance.)NoNo
Boot disk
Operating systemNoNo
Boot disk typeNoNo
SizeNoCan only increase, via ‘Disks’ page
Identity and API access
Service accountNoYes
Allow HTTP trafficYesYes
Allow HTTPS trafficYesYes
Management, security, disks, networking, sole tenancy
Description NoNo
Deletion protection (Enable deletion protection)YesYes
Reservations(Use an existing reservation when creating this VM instance)NoNo
Startup scriptNoNo
Metadata NoYes
Availability policy
On host maintenanceYesYes
Automatic restartNot available for pre-emptible instancesNot available for pre-emptible instances
Shielded VM
Turn on Secure BootNoYes
Turn on vTPMNoYes
Turn on Integrity MonitoringNoYes
SSH Keys
Block project-wide SSH keysYesYes
Public SSH keysYesYes
Boot disk Deletion rule Delete boot disk when instance is deletedYesYes
Encryption Data is encrypted automatically. Select an encryption key management solution.NoNo
Device name Used to reference the device for mounting or resizing.NoYes
Additional disksNoYes
Network tagsYesYes
Network interfacesYesYes
Sole tenancy
Node affinity labelsNoNo
CPU overcommit
Enable CPU overcommitNoOnly allowed for a machine type of 4 or more vCPUs.

Only allowed for VMs scheduled onto sole-tenant nodes enabled for CPU overcommit.

Leave a Reply

Your email address will not be published. Required fields are marked *