Perform administrative tasks for your autoscalers, such as creating, listing, getting, updating, and deleting an autoscaler using the instructions provided here.
Before you begin
- If you want to use the command-line examples in this guide:
- Install or update to the latest version of the gcloud command-line tool.
- Set a default region and zone.
- If you want to use the API examples in this guide, set up API access.
- Read the Autoscaling documentation.
Create an autoscaler
Creating an autoscaler is slightly different depending on which autoscaling policy you want to use. For instructions on creating an autoscaler, see:
- Scaling Based on CPU or Load Balancing Serving Capacity
- Scaling Based on Stackdriver Monitoring Metrics
Get information about an autoscaler
To get more information about a particular autoscaler, or to confirm that an
autoscaler was successfully created, use the
instance-groups managed describe
sub-command or the get() method in the API.
gcloud
In the gcloud tool, use the describe sub-command:
gcloud compute instance-groups managed describe GROUP
API
In the API, make a GET request:
GET https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-f/autoscalers/example-autoscaler
200 OK{
"kind": "compute#autoscaler", "name": "", "target": "https://www.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://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-f/autoscalers/example-autoscaler" }
Update an autoscaler
Update an autoscaler using the set-autoscaling command in the gcloud
command-line tool, or using the PUT method in the API.
When you update 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.
For example, if you want to update a new value for the maximum number of replicas and minimum number of replicas but do not explicitly define any other configuration parameters, such as the target CPU utilization, the cool down period, and so on, the undefined parameters will all be reset to the default values.
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.
gcloud
The same required fields for creating an autoscaler are also required for all update requests:
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.
API
To update your autoscaler, provide an update request body
using the PUT
method:
PUT https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-f/autoscalers/example-autoscaler
{
"name": "example-autoscaler",
"autoscalingPolicy": {
"cpuUtilization": {
"utilizationTarget": 0.5
},
"maxNumReplicas": 20
},
"target": "https://www.googleapis.com/replicapool/v1beta2/projects/myproject/zones/us-central1-f/instanceGroupManagers/test-managed-group"
}
200 OK{ "kind": "autoscaler#operation", "name": "example-autoscaler", "operationType": "update", "targetLink": "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-f/autoscalers/example-autoscaler", "targetId": "2335397567958752451", "status": "DONE", "progress": 100 }
When you perform any requests that modify data, a Zone Operation resource is returned, and you can query the operation to check the status of your change.
Stop an autoscaler
gcloud
Use the stop-autoscaling
sub-command to stop an autoscaler.
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 will also be deleted.
API
In the API, make a request using the
DELETE method
to delete an autoscaler:
DELETE https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-f/autoscalers/example-autoscaler


