[Yandex Cloud documentation](../../index.md) > [Yandex Managed Service for Apache Spark™](../index.md) > [Step-by-step guides](index.md) > Clusters > Apache Spark™ version upgrade

# Apache Spark™ version update

You can change the Apache Spark™ version to any of the versions [supported](#available-versions) by Managed Service for Apache Spark™. You can only upgrade versions.

Updates and fixes within a version are installed automatically during maintenance.

## Get a list of available versions {#available-versions}

{% list tabs group=instructions %}

- Management console {#console}

    1. Open the [folder dashboard](https://console.yandex.cloud).
    1. Navigate to **Managed Service for Apache Spark™**.
    1. Select a cluster and click **Edit** on the top panel. This will open the cluster editing page.
      
        You can see the list of available versions in the **Version** field.

{% endlist %}

## Before a version upgrade {#before-update}

Make sure the upgrade will not disrupt your applications:

1. Check the Apache Spark™ [release notes](https://spark.apache.org/news/) to learn how upgrades may affect your applications.
1. Try upgrading the Apache Spark™ version on a test cluster.

## Upgrading the version {#update}

{% list tabs group=instructions %}

- Management console {#console}

    1. Open the [folder dashboard](https://console.yandex.cloud).
    1. Navigate to **Managed Service for Apache Spark™**.
    1. Select a cluster and click **Edit** on the top panel.
    1. Under **Basic parameters**, select Apache Spark™.
    1. Click **Save changes**.

- CLI {#cli}

    If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).

    The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

    To change the Apache Spark™ version:

    1. View the description of the CLI command for updating a cluster:

        ```bash
        yc managed-spark cluster update --help
        ```

    1. Change the version by running this command:

        ```bash
        yc managed-spark cluster update <cluster_name_or_ID> \
          --spark-version <Apache_Spark_version>
        ```

        You can get the cluster name and ID with the [list of clusters](cluster-list.md#list-clusters) in the folder.   

- Terraform {#tf}

    1. Open the current Apache Spark™ configuration file with the infrastructure plan.

        To learn how to create this file, refer to [Creating a cluster](cluster-create.md).
        
    1. Edit the `spark_version` parameter in the cluster's description:
      
        ```hcl
        resource "yandex_spark_cluster" "<cluster_name>" {
          ...
          config = {
            ...
            spark_version = "<Apache_Spark_version>"
            ...
          }
          ...
        }
        ```

    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.

- gRPC API {#grpc-api}

    1. [Get an IAM token for API authentication](../api-ref/authentication.md) and place it in 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. Create a file named `body.json` and paste the following code into it:

        ```json
        {
          "cluster_id": "<cluster_ID>",
          "update_mask": {
            "paths": [
              "config_spec.spark_version"
            ]
          },
          "config_spec": {
            "spark_version": "<Apache_Spark_version>"
          }
        }
        ```

        Where:

        * `cluster_id`: Cluster ID.
            
            You can get the cluster ID with the [list of clusters](cluster-list.md#list-clusters) in the folder.

        * `update_mask`: List of parameters to update as an array of strings (`paths[]`).

            {% cut "Format for listing settings" %}

            ```yaml
            "update_mask": {
              "paths": [
                "<setting_1>",
                "<setting_2>",
                ...
                "<setting_N>"
              ]
            }
            ```

            {% endcut %}

            {% note warning %}

            When you update a cluster, all parameters of the object you are modifying will be reset to their defaults unless explicitly provided in the request. To avoid this, list the settings you want to change in the `update_mask` parameter.

            {% endnote %}

        * `spark_version`: Apache Spark™ version.

    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/spark/v1/cluster_service.proto \
          -rpc-header "Authorization: Bearer $IAM_TOKEN" \
          -d @ \
          spark.api.cloud.yandex.net:443 \
          yandex.cloud.spark.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 %}