This document describes how to create a managed instance group (MIG) that uses preemptible virtual machine (VM) instances. Preemptible VMs are useful if your workload can tolerate disruptions and you want to take advantage of the cost-savings associated with preemptible VMs.
You can also read about other basic scenarios for creating a MIG.
Select the tab for how you plan to use the samples on this page:
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
Install the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:
gcloud initIf you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
To use the Terraform samples on this page in a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.
Install the Google Cloud CLI.
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
For more information, see Set up authentication for a local development environment.
To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.
Install the Google Cloud CLI.
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
For more information, see Authenticate for using REST in the Google Cloud authentication documentation.
To see the full list of MIG limitations, which varies based on the configuration that you use, see MIG limitations.
You can use a zonal or regional MIG to quickly create multiple preemptible VMs, which can reduce the costs of the VMs in your managed instance groups. For example, you can create a group of preemptible VMs, use them to run a batch processing task, and then delete the group when the task is complete.
To create a group of preemptible VMs, set the preemptible option in an instance template, and then use the template to create the MIG.