A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://cloud.google.com/compute/docs/instance-groups/limit-vm-runtime-in-migs below:

Limit the run time of VMs in a MIG | Compute Engine Documentation

This document describes how to automatically terminate virtual machines (VMs) in a managed instance group (MIG) by specifying a time limit for the VMs. It also describes how time limit works for VMs in a MIG.

You can optimize temporary workloads by specifying a time limit for the VMs in a MIG. When a VM reaches its time limit, the MIG automatically terminates (deletes) that VM. Limiting the run time of VMs in a MIG by a time limit helps to minimize costs and free up quota.

Note: GPU VMs that are configured to be automatically deleted after a predefined run time of 7 days or less can consume either preemptible or standard allocation quotas. This behavior is intended to help you improve the obtainability of allocation quota for temporary-but-uninterrupted workloads. For more information about this behavior, see GPU VMs and preemptible allocation quotas.

To learn about specifying a time limit for a standalone VM, see Limit the run time of a VM. If you want a MIG to automatically add or delete VMs based on your workloads, see Autoscaling groups of instances.

Before you begin Limit the run time of VMs in a MIG

You can limit the run time of VMs in a MIG by specifying a time limit in the instance template used for the MIG. When the MIG creates VMs based on the template, the time limit is applied to each VM.

You can specify one of two types of time limits:

To specify a time limit for the VMs in a MIG, follow these steps:

  1. Create an instance template with a run duration for VMs or with a termination time for VMs.

  2. Use the instance template to create a MIG or update an existing MIG.

Limitations Create an instance template with a run duration for VMs

To automatically terminate VMs in a MIG after they run for a certain duration, set a maximum run duration (maxRunDuration) in the instance template.

Console
  1. In the Google Cloud console, go to the Instance templates page.

    Go to Instance templates

  2. Click Create instance template.

  3. Select the Location as follows:

  4. If you chose regional, then select the Region where you want to create your instance template.

  5. In the Availability policies section, expand VM provisioning model advanced settings.

  6. Select the Set a time limit for the VM checkbox.

  7. In the Time limit type field, select By hours (default) to specify the time limit as a duration. In the next field, enter the duration in hours.

  8. In the On VM termination list, select Delete.

  9. For the other fields, either accept the default values or modify them as required.

  10. Click Create.

gcloud

Use the instance-templates create command. To automatically delete VMs after a specific duration, include the --max-run-duration flag and set the--instance-termination-action flag to DELETE as follows:

  gcloud compute instance-templates create INSTANCE_TEMPLATE_NAME \
      --max-run-duration=DURATION \
      --instance-termination-action=DELETE

Replace the following:

Terraform

To create an instance template using Terraform, use the google_compute_instance_template resource. To create an instance template that automatically deletes VMs after a specific duration, you must include the max_run_duration argument and set the instance_termination_action argument to DELETE.

For more information, see the Terraform documentation for the google_compute_instance_template resource.

REST

Use the instanceTemplates.insert method. To automatically delete VMs after a specific duration, include the maxRunDuration field and set theinstanceTerminationAction field to DELETE as follows:

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/instanceTemplates

{
  "name": "INSTANCE_TEMPLATE_NAME",
  "properties": {
    "machineType": "MACHINE_TYPE",
    "networkInterfaces": [
      {
        "network": "global/networks/default",
        "accessConfigs": [
          {
            "name": "external-IP",
            "type": "ONE_TO_ONE_NAT"
          }
        ]
      }
    ],
    "disks": [
      {
        "type": "PERSISTENT",
        "boot": true,
        "mode": "READ_WRITE",
        "initializeParams":
        {
          "sourceImage": "projects/IMAGE_PROJECT/global/images/IMAGE"
        }
      }
    ]
    "scheduling": {
      "maxRunDuration":
      {
        "seconds": DURATION
      },
      "instanceTerminationAction": "DELETE"
    }
  }
}

Replace the following:

Create an instance template with a termination time for VMs

To automatically terminate VMs in a MIG at a specific time, set a termination time (terminationTime) in the instance template. You can set a date and time at which you want a MIG to terminate the VMs.

Console
  1. In the Google Cloud console, go to the Instance templates page.

    Go to Instance templates

  2. Click Create instance template.

  3. Select the Location as follows:

  4. If you chose regional, then select the Region where you want to create your instance template.

  5. In the Availability policies section, expand VM provisioning model advanced settings.

  6. In the Time limit type field, select By date to specify the time limit as a time and date. In the next field, click date_rangeSelect date and time and select the date, time, and timezone for automatic termination.

  7. In the On VM termination list, select Delete.

  8. For the other fields, either accept the default values or modify them as required.

  9. Click Create.

gcloud

Use the instance-templates create command. To automatically delete VMs at a specific time, include the --termination-time flag and set the--instance-termination-action flag to DELETE as follows:

  gcloud compute instance-templates create INSTANCE_TEMPLATE_NAME \
      --termination-time=TIME \
      --instance-termination-action=DELETE

Replace the following:

REST

Use the instanceTemplates.insert method. To automatically delete VMs at a specific time, include the terminationTime field and set theinstanceTerminationAction field to DELETE as follows:

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/instanceTemplates

{
  "name": "INSTANCE_TEMPLATE_NAME",
  "properties": {
    "machineType": "MACHINE_TYPE",
    "networkInterfaces": [
      {
        "network": "global/networks/default",
        "accessConfigs": [
          {
            "name": "external-IP",
            "type": "ONE_TO_ONE_NAT"
          }
        ]
      }
    ],
    "disks": [
      {
        "type": "PERSISTENT",
        "boot": true,
        "mode": "READ_WRITE",
        "initializeParams":
        {
          "sourceImage": "projects/IMAGE_PROJECT/global/images/IMAGE"
        }
      }
    ]
    "scheduling": {
      "terminationTime": TIME,
      "instanceTerminationAction": "DELETE"
    }
  }
}

Replace the following:

How time limit works for VMs in a MIG

When you specify a time limit for VMs in a MIG, the time at which a MIG will terminate a VM is automatically set in the termination timestamp (terminationTimestamp) field of the VM.

Based on the type of time limit that you specify, the termination timestamp of a VM is set as follows:

During a VM refresh, the termination timestamp doesn't change. For example, if you set the disruption level for updates to REFRESH, then the termination timestamp is retained whenever the MIG updates the VM.

When you suspend or stop a VM in a MIG, the termination timestamp is automatically cleared irrespective of the type of time limit. When you resume or start a VM, the termination timestamp is set again based on the type of time limit as explained earlier in this section.

How autoscaling works when a time limit is set

Autoscaling lets your MIG automatically add or remove VMs based on increases or decreases in load. When a MIG deletes VMs that have reached their termination timestamps, the MIG creates new VMs to maintain the recommended size by the autoscaler. The new VMs run for the specified time limit. If the autoscaler recommendation is to reduce the number of VMs, then the MIG deletes VMs even before they reach their time limits.

If you've configured scaling schedules, the VMs run only until the end of a schedule or until a VM reaches its termination timestamp, whichever comes first.

What's next

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4