Managing autoscalers

Perform administrative tasks for your autoscalers, such as creating, describing, updating, stopping, and deleting an autoscaler using the instructions provided here.

Before you begin

Creating an autoscaler

Creating an autoscaler is slightly different depending on which autoscaling policy you want to use. For instructions on creating an autoscaler, see:

Getting information about an autoscaler

To get more information about a particular autoscaler, or to confirm that an autoscaler was successfully created, use the console, the gcloud compute instance-groups managed describe sub-command, or the get method in the API for a zonal or regional autoscaler resource.

console

  1. Go to the Instance Groups page in the Cloud Console.

    Go to the Instance Groups page

  2. Click the name of an instance group from the list to open the instance group details page.
  3. Click Details to view the group's details, including its autoscaling settings.

gcloud

In the gcloud command-line tool, use the describe sub-command:

gcloud compute instance-groups managed describe GROUP

API

To retrieve details about an autoscaler resource for a zonal managed instance group, use the autoscaler's get method. For a regional managed instance group, use the regionAutoscaler's get method.

GET https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-f/autoscalers/example-autoscaler
200 OK

{

 "kind": "compute#autoscaler",
 "name": "",
 "target": "https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-f/instanceGroupManagers/test-managed-group",
 "autoscalingPolicy": {
  "minNumReplicas": 2,
  "maxNumReplicas": 10,
  "coolDownPeriodSec": 60,
  "cpuUtilization": {
   "utilizationTarget": 0.8
  }
 },
 "id": "14869149674555507326",
 "creationTimestamp": "2015-03-25T01:56:56.084711335+00:00",
 "selfLink": "https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-f/autoscalers/example-autoscaler"
}

Updating an autoscaler

To update an autoscaler, use the console, the gcloud tool, or the API.

When you update an autoscaler, it may take some time for the changes to propagate, and it may be a couple of minutes before your new autoscaler settings are reflected.

console

  1. Go to the Instance Groups page in the Cloud Console.

    Go to the Instance Groups page

  2. Click the name of an instance group from the list to open the instance group details page.
  3. Click Edit group to view and update the group's current configuration, including its autoscaling settings.
  4. Click Save when you are done.

gcloud

Use the set-autoscaling sub-command.

You must set all configuration settings for your autoscaler in your request as if you are creating the autoscaler for the first time. Otherwise, any settings not explicitly defined in your request will reset to the default values.

gcloud compute instance-groups managed set-autoscaling GROUP \
    --max-num-replicas MAX_NUM ...

For instructions on how to create an autoscaler, see Scaling based on Stackdriver Monitoring metrics or Scaling based on CPU or load balancing serving capacity.

API

To update an autoscaler resource for a zonal managed instance group, use the zonal autoscaler's patch method. For a regional managed instance group, use the regionAutoscaler's patch method. Provide a request body that contains the new configuration.

PATCH https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-f/autoscalers/example-autoscaler

{
 "autoscalingPolicy": {
  "maxNumReplicas": 20
 }
}
200 OK

{
 "kind": "compute#operation",
 "id": "4244494732310423322",
 "name": "operation-1556912627871-58800f8216ed7-74ab1720-7d360603",
 "zone": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-f",
 "operationType": "compute.autoscalers.patch",
 "targetLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-f/autoscalers/example-autoscaler",
 "targetId": "340775527929467142",
 "status": "RUNNING",
 ...
}

When you perform any requests that modify data, a zoneOperations resource is returned, and you can query the operation to check the status of your change.

Turning off or restricting an autoscaler (beta)

Turn off an autoscaler to temporarily prevent it from scaling your instance group, or restrict your autoscaler so that it can only scale up your instance group. This feature is useful when you want to:

  • Investigate instances without interference from downscaling.
  • Reconfigure multiple properties of your managed instance group without scaling actions being triggered while your group is only partially reconfigured.
  • Maintain instance group capacity for a fast rollback while redirecting a workload to a new instance group.

If and when you re-enable the autoscaler, the autoscaler automatically returns to normal operation.

In the console, the gcloud tool, or the API, set an autoscaler's mode to:

  • OFF: Temporarily disables autoscaling. Use this mode to prevent automatic changes of the instance group size. The autoscaling configuration remains intact so you can re-enable autoscaling later.
  • ONLY_UP: Restrict autoscaling only to adding new instances. Use this mode to protect the group from shrinking and allow the group to provision extra VMs when load increases.
  • ON: Enables all autoscaling operations per its policy.

console

  1. Go to the Instance Groups page in the Cloud Console.

    Go to the Instance Groups page

  2. Click the name of an instance group from the list to open the instance group details page.
  3. Click Edit group to view the group's current configuration, including its autoscaling settings.
  4. Under Autoscaling, set the Autoscaing mode to disable or restrict autoscaling for the group, or to turn the autoscaler back on.

gcloud

Use the beta set-autoscaling sub-command with the --mode flag, to turn off, restrict, or turn on an an autoscaler.

You must set all configuration settings for your autoscaler in your request as if you are creating the autoscaler for the first time. Otherwise, any settings not explicitly defined in your request will reset to the default values.

gcloud beta compute instance-groups managed set-autoscaling GROUP \
    --mode [MODE] ...

Where:

  • [MODE] is:
    • OFF to disable the autoscaler but maintain its configuration.
    • ONLY_UP to restrict the autoscaler to adding instances only.
    • ON to re-enable all autoscaler activities according to its policy.

API

To update the mode of an autoscaler resource for a zonal managed instance group, use the autoscaler's patch method. For a regional managed instance group, use the regionAutoscaler's patch method. Provide a request body that includes the autoscalingPolicy.mode property.

PATCH https://www.googleapis.com/compute/beta/projects/my-project/regions/us-central1-f/autoscalers?autoscaler=my-autoscaler

{
  "autoscalingPolicy": {
    "mode":"[MODE]"
  }
}

Where:

  • [MODE] is:
    • OFF to disable the autoscaler but maintain its configuration.
    • ONLY_UP to restrict the autoscaler to adding instances only.
    • ON to re-enable all autoscaler activities according to its policy.

Contact us at mig-discuss@google.com to provide feedback on the Autoscaler modes: OFF, ON, and ONLY_UP.

Deleting an autoscaler

You can permanently delete your autoscaler resource using the console, the gcloud tool, or the API. If you want to temporarily stop autoscaling and keep your autoscaler resource and its configuration, turn off your autoscaler instead.

console

  1. Go to the Instance Groups page in the Cloud Console.

    Go to the Instance Groups page

  2. Click the name of an instance group from the list to open the instance group details page.
  3. Click Edit group to view the group's current configuration, including its autoscaling settings.
  4. Under Autoscaling, click Delete autoscaling configuration to stop the autoscaler and delete its configuration.

gcloud

Use the stop-autoscaling sub-command to stop an autoscaler and delete its configuration.

gcloud compute instance-groups managed stop-autoscaling GROUP

Stopping an autoscaler deletes it from the managed instance group. If you want to restart the autoscaler, you must recreate it using the set-autoscaling command.

If you delete a managed instance group using the gcloud tool, any autoscalers attached to the managed instance group are also deleted.

API

In the API, make a request using the DELETE method to stop an autoscaler and delete its configuration:

 DELETE https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-f/autoscalers/example-autoscaler

क्या यह पेज उपयोगी था? हमारे काम के बारे में अपनी राय दें:

निम्न के बारे में फ़ीडबैक भेजें...