[Yandex Cloud documentation](../../index.md) > [Yandex Managed Service for YTsaurus](../index.md) > [Step-by-step guides](index.md) > Updating a cluster

# Updating a YTsaurus cluster

After creating a cluster, you can edit its basic and advanced settings.

{% list tabs group=instructions %}

- Management console {#console}

    To change the cluster settings:

    1. Open the [folder dashboard](https://console.yandex.cloud).
    1. Navigate to **Managed Service for YTsaurus**.
    1. Select your cluster and click **Edit** in the top panel.
    1. Under **Basic parameters**:

        * Edit the cluster name and description.
        * Delete or add new [labels](../../resource-manager/concepts/labels.md).

    1. Under **Storage**, change the number of disks.
    1. Under **Exec node configuration**, change the number of exec nodes.
    1. Click **Save changes**.

- Terraform {#tf}

    To change the cluster settings:

    1. Open the current Terraform configuration file with the infrastructure plan.

        To learn how to create this file, refer to [Creating a cluster](cluster-create.md).

    1. Edit the cluster settings by changing the value of the relevant field in the configuration file. You can only edit a single setting per cluster resource update operation.

        {% note alert %}

        Do not change the cluster name and ID using Terraform. This will delete the existing cluster and create a new one.

        {% endnote %}

        Here is an example of the configuration file structure:

        ```hcl
        resource "yandex_ytsaurus_cluster" "my_cluster" {
          description         = "<cluster_description>"
          name                = "my-ytsaurus-cluster"
          folder_id           = "b1gmioovukmd********"

          labels = {
            <label_list>
          }
          ...
          spec = {
            ...
            storage = {
              hdd = {
                ...
                "count": "<number_of_HDDs>"
              },
              ssd = {
                ...
                "count": "<number_of_SSDs>",
              }
            }
            compute = [{
              ...
              scale_policy = {
                fixed = {
                  size = <number_of_exec_nodes>
                }
              }
            }]
            ...
            odin = {
              checks_ttl = "<TTL_of_checks_by_Odin>"
            }
          }
        }
        ```

        Where:

        * `description`: Cluster description.
        * `labels`: List of labels. Provide labels in `<key> = "<value>"` format.
        * `spec`: Configuration of YTsaurus cluster components.

            * `storage`: Storage settings:

               * `hdd.count`: Number of HDDs. You can only increase the number; reducing it is not supported.
               * `ssd.count`: Number of SSDs. You can only increase the number; reducing it is not supported.

            * `compute`: Configuration of exec nodes:

               * `scale_policy.fixed.size`: Number of exec nodes for the fixed scaling policy. Currently, this is the only policy YTsaurus supports.

            * `odin.checks_ttl`: Frequency of checks by Odin, an internal monitoring tool. Provide with units of measurement: `h` (hours), `m` (minutes), `s` (seconds).

    1. Make sure the settings are correct.

        1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
        1. Run this command:
        
           ```bash
           terraform validate
           ```
        
           Terraform will show any errors found in your configuration files.

    1. Confirm resource changes.

        1. Run this command to view the planned changes:
        
           ```bash
           terraform plan
           ```
        
           If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
        
        1. If everything looks correct, apply the changes:
           1. Run this command:
        
              ```bash
              terraform apply
              ```
        
           1. Confirm updating the resources.
           1. Wait for the operation to complete.

    For more information, see [this Terraform provider guide](https://terraform-provider.yandexcloud.net/resources/ytsaurus_cluster).

- REST API {#api}

    To change the cluster settings:

    1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

        ```bash
        export IAM_TOKEN="<IAM_token>"
        ```

    1. You can only edit a single setting per cluster update operation. Create a file named `body.json` with the required setting from the example below. This example only shows settings to update; for the full list of available settings, see [this API guide](../api-ref/Cluster/update.md#yandex.cloud.ytsaurus.v1.UpdateClusterRequest).

        ```json
        {
          "clusterId": "<cluster_ID>",
          "updateMask": "<name_of_setting_to_update>",
          "name": "<cluster_name>",
          "description": "<cluster_description>",
          "labels": { <label_list> },
          "spec": {
            "storage": {
              "hdd": {
                "count": "<number_of_HDDs>"
              },
              "ssd": {
                "count": "<number_of_SSDs>"
              }
            },
            "compute": [
              {
                "scalePolicy": {
                  "fixed": {
                    "size": "<number_of_exec_nodes>"
                  }
                }
              }
            ],
            "odin": {
              "checksTtl": "<TTL_of_checks_by_Odin>"
            }
          }
        }
        ```

        Where:

        * `clusterId`: Cluster ID. You can get it from the [list of clusters in the folder](cluster-list.md#list-clusters).
        * `updateMask`: Name of the setting you are updating.
        * `name`: Cluster name.
        * `description`: Cluster description.
        * `labels`: List of labels provided in `"<key>": "<value>"` format.
        * `spec`: Configuration of YTsaurus cluster components.

            * `storage`: Storage settings:

               * `hdd.count`: Number of HDDs. You can only increase the number; reducing it is not supported.
               * `ssd.count`: Number of SSDs. You can only increase the number; reducing it is not supported.

            * `compute`: Configuration of exec nodes.

               * `scalePolicy.fixed.size`: Number of exec nodes for the fixed scaling policy. Currently, this is the only policy YTsaurus supports.

            * `odin.checksTtl`: TTL of checks by Odin, an internal monitoring tool. Provide the value with measurement units: `s` (seconds).

    1. Call the [Cluster.Update](../api-ref/Cluster/update.md) method, e.g., via the following [cURL](https://curl.se/) request:

        ```bash
        curl \
            --request PATCH \
            --header "Authorization: Bearer $IAM_TOKEN" \
            --url 'https://ytsaurus.api.cloud.yandex.net/ytsaurus/v1/clusters'
            --data '@body.json'
        ```

    1. View the [server response](../api-ref/Cluster/update.md#yandex.cloud.operation.Operation) to make sure your request was successful.

- gRPC API {#grpc-api}

    To change the cluster settings:

    1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

        ```bash
        export IAM_TOKEN="<IAM_token>"
        ```

    1. Clone the [cloudapi](https://github.com/yandex-cloud/cloudapi) repository:
       
       ```bash
       cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
       ```
       
       Below, we assume that the repository contents reside in the `~/cloudapi/` directory.

    1. You can only edit a single setting per cluster update operation. Create a file named `body.json` with the required setting from the example below. This example only shows settings to update; for the full list of available settings, see [this API guide](../api-ref/Cluster/update.md#yandex.cloud.ytsaurus.v1.UpdateClusterRequest).

        ```json
        {
          "cluster_id": "<cluster_ID>",
          "update_mask": "<name_of_setting_to_update>",
          "name": "<cluster_name>",
          "description": "<cluster_description>",
          "labels": { <label_list> },
          "spec": {
            "storage": {
              "hdd": {
                "count": "<number_of_HDDs>"
              },
              "ssd": {
                "count": "<number_of_SSDs>"
              }
            },
            "compute": [
              {
                "scale_policy": {
                  "fixed": {
                    "size": "<number_of_exec_nodes>"
                  }
                }
              }
            ],
            "odin": {
              "checks_ttl": "<TTL_of_checks_by_Odin>"
            }
          }
        }
        ```

        Where:

        * `cluster_id`: Cluster ID. You can get it with the [list of clusters in the folder](cluster-list.md#list-clusters).
        * `update_mask`: List of settings to update as an array of strings (`paths[]`).

            In this case, the array consists of a single element.

            {% cut "Format for listing settings" %}

            ```yaml
            "update_mask": {
                "paths": [
                    "<name_of_setting_to_update>"
                ]
            }
            ```

            {% endcut %}

        * `name`: Cluster name.
        * `description`: Cluster description.
        * `labels`: List of labels provided in `"<key>": "<value>"` format.
        * `spec`: Configuration of YTsaurus cluster components.

            * `storage`: Storage settings:

               * `hdd.count`: Number of HDDs. You can only increase the number; reducing it is not supported.
               * `ssd.count`: Number of SSDs. You can only increase the number; reducing it is not supported.

            * `compute`: Configuration of exec nodes.

               * `scale_policy.fixed.size`: Number of exec nodes for the fixed scaling policy. Currently, this is the only policy YTsaurus supports.

            * `odin.checks_ttl`: TTL of checks by Odin, an internal monitoring tool. Provide the value with measurement units: `s` (seconds).

    1. Call the [ClusterService/Update](../api-ref/grpc/Cluster/update.md) method, e.g., via the following [gRPCurl](https://github.com/fullstorydev/grpcurl) request:

        ```bash
        grpcurl \
            -format json \
            -import-path ~/cloudapi/ \
            -import-path ~/cloudapi/third_party/googleapis/ \
            -proto ~/cloudapi/yandex/cloud/ytsaurus/v1/cluster_service.proto \
            -rpc-header "Authorization: Bearer $IAM_TOKEN" \
            -d @ \
            ytsaurus.api.cloud.yandex.net:443 \
            yandex.cloud.ytsaurus.v1.ClusterService.Update \
            < body.json
        ```

    1. Check the [server response](../api-ref/grpc/Cluster/update.md#yandex.cloud.operation.Operation) to make sure your request was successful.

{% endlist %}