This page shows you how to use an inline Google APIs Explorer template to update a Cloud Dataproc cluster to change the number of workers in a cluster. You can learn how to do the same task using the Google Cloud Platform Console in Quickstart Using the Console or using the command line in Quickstart using the gcloud command-line tool.
Before you beginThis quickstart assumes you have already created a Cloud Dataproc cluster. You can use the APIs Explorer, the Google Cloud Platform Console, or the Cloud SDK gcloud command-line tool to create a cluster.
Update a cluster
To update the number of workers in your cluster, fill in and execute the APIs Explorer template, below, as follows:
- Enter you project ID (project name) in the
The following fields are filled in for you:
region= a "global".
globalis the default region when a Cloud Dataproc cluster is created. This is a special multi-region namespace that is capable of deploying instances into all Compute Engine zones globally when a Cloud Dataproc cluster is created. If you created your cluster (see APIs Explorer—Create a cluster) in a different region, replace "global" with the name of your cluster's region.
clusterName= "example-cluster". This is the name of the Cloud Dataproc cluster (created in the previous quickstarts—see APIs Explorer—Create a cluster) that will be updated. Replace this name with the name of your cluster if it is different.
updateMask= "config.worker_config.num_instances". This is the query parameter's JSON PATH relative to the cluster. This parameter specifies the number of worker instances in a cluster(see next item).
- Patch body
config.workerConfig.numInstances= "5". This sets (updates) the number of workers in the cluster.
Click EXECUTE. A dialog will ask you to confirm the default
https://www.googleapis.com/auth/cloud-platformscope. Click the dialog's ALLOW to send the request to the service. After less than one second (typically), the JSON response showing that the example-cluster is pending appears below the template.
You can confirm that the number of workers in the cluster has been updated by going to GCP Console—Clusters.
Congratulations! You've used the Google APIs Explorer to update a Cloud Dataproc cluster.
To avoid incurring charges to your GCP account for the resources used in this quickstart:
If you plan on using the cluster, you can use the above template to restore the cluster to it default configuration with two workers (in the
Patch bodyfield, change
numInstancesto "2", fill in the
projectID, then click Authorize and Execute).
If you delete your cluster, you should also remove any Cloud Storage buckets that were created by the cluster. To do this, run the following command in a local terminal window or in Cloud Shell:
gsutil rm gs://bucket/subdir/**