APIs Explorer Quickstart—Update a cluster

This page shows you how to use an inline Google APIs Explorer template to update a Dataproc cluster to change the number of workers in a cluster. You can learn how to do the same task using the Google Cloud Console in Quickstart Using the Console or using the command line in Quickstart using the gcloud command-line tool.

Before you begin

This quickstart assumes you have already created a Dataproc cluster. You can use the APIs Explorer, the Google Cloud 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:

  1. Enter you project ID (project name) in the projectID field.
  2. The following fields are filled in for you:

    1. region = a "us-central1". If you created your cluster (see APIs Explorer—Create a cluster) in a different region, replace "us-central1" with the name of your cluster's region.
    2. clusterName = "example-cluster". This is the name of the 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.
    3. 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).
    4. Patch body config.workerConfig.numInstances = "5". This sets (updates) the number of workers in the cluster.
  3. Click EXECUTE. A dialog will ask you to confirm the default https://www.googleapis.com/auth/cloud-platform scope. 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 Cloud Console—Clusters.

Congratulations! You've used the Google APIs Explorer to update a Dataproc cluster.

Clean up

To avoid incurring charges to your Google Cloud account for the resources used in this quickstart, follow these steps.

  1. If you plan on using the cluster, you can use the above template to restore the cluster to its default configuration with two workers (in the Patch body field, change numInstances to "2", fill in the projectID, then click Authorize and Execute).

  2. If you don't need the cluster, use the APIs Explorer, the Google Cloud Console, or the Cloud SDK gcloud command-line tool to delete a cluster.

  3. 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/**

What's next