[Yandex Cloud documentation](../index.md) > [Yandex Managed Service for Apache Spark™](index.md) > Getting started

# Getting started with Yandex Managed Service for Apache Spark™

To get started:

* [Get your cloud ready](#prepare-cloud).
* [Set up your infrastructure](#prepare-infrastructure).
* [Create a cluster](#cluster-create).
* [Prepare a PySpark job](#prepare-task).
* [Run the job in the cluster](#run-task).
* [Check the job completion](#check-task).

## Required paid resources {#paid-resources}

The cost of infrastructure support includes a fee for a Yandex Object Storage bucket (see [Object Storage pricing](../storage/pricing.md)).

## Get your cloud ready {#prepare-cloud}

1. Navigate to the [management console](https://console.yandex.cloud) and log in to Yandex Cloud, or sign up if you have not already.

1. If you do not have a folder yet, create one:

   1. In the [management console](https://console.yandex.cloud), in the top panel, click ![image](../_assets/console-icons/layout-side-content-left.svg) or ![image](../_assets/console-icons/chevron-down.svg) and select the [cloud](../resource-manager/concepts/resources-hierarchy.md#cloud).
   1. To the right of the cloud name, click ![image](../_assets/console-icons/ellipsis.svg).
   1. Select ![image](../_assets/console-icons/plus.svg) **Create folder**.
   
      ![create-folder1](../_assets/resource-manager/create-folder-1.png)
   
   1. Give your [folder](../resource-manager/concepts/resources-hierarchy.md#folder) a name. The naming requirements are as follows:
   
       * Length: between 3 and 63 characters.
       * It can only contain lowercase Latin letters, numbers, and hyphens.
       * It must start with a letter and cannot end with a hyphen.
   
   1. Optionally, specify the description for your folder.
   1. Select **Create a default network**. This will create a [network](../vpc/concepts/network.md#network) with subnets in each availability zone. Within this network, you will also have a [default security group](../vpc/concepts/security-groups.md#default-security-group), within which all network traffic will be allowed.
   1. Click **Create**.
   
      ![create-folder2](../_assets/resource-manager/create-folder-2.png)

1. [Assign](../iam/operations/roles/grant.md) the following roles to your Yandex Cloud account:

    * [managed-spark.admin](security.md#managed-spark-admin): To create a cluster.
    * [vpc.user](../vpc/security/index.md#vpc-user): To use the cluster [network](../vpc/concepts/network.md#network).
    * [iam.serviceAccounts.user](../iam/security/index.md#iam-serviceAccounts-user): To assign a service account to a cluster.

    {% note info %}
    
    If you cannot manage roles, contact your cloud or organization administrator.
    
    {% endnote %}

## Set up your infrastructure {#prepare-infrastructure}

1. [Create a service account](../iam/operations/sa/create.md#create-sa) and assign the following roles to it:

   * `managed-spark.integrationProvider`: For Yandex Managed Service for Apache Spark™ to interact with other system components, e.g., for sending logs and metrics.
   * [storage.editor](../storage/security/index.md#storage-editor): For accessing PySpark job files in an Object Storage bucket.

1. [Create a Object Storage](../storage/operations/buckets/create.md) bucket.

1. Grant the service account access to the Object Storage that will be storing your code and data for cluster-specific jobs:

   1. In the [management console](https://console.yandex.cloud), select the relevant folder.
   1. Navigate to **Object Storage**.
      1. Open the bucket you [created](#create-s3-bucket).
      1. Navigate to **Objects**.
      1. Click ![image](../_assets/console-icons/ellipsis.svg) and select **Configure ACL**.
      1. In the **ACL editing** window that opens:

         1. Start typing the service account name [you created earlier](#before-you-begin) and select it from the drop-down list.
         1. Select the READ and WRITE  access permissions.
         1. Click **Add**.
         1. Click **Save**.

## Create a cluster {#cluster-create}

{% list tabs group=instructions %}

- Management console

  1. In the management console, select the folder where you want to create a cluster.
  1. Navigate to **Managed Service for Apache Spark™**.
  1. Click **Create cluster**.
  1. Give the cluster a name.
  1. In the **Service account** field, select the [previously created](#before-you-begin) service account.
  1. Under **Network settings**, select a network, subnet, and security group for the cluster.
  1. Set up computing resources for hosts to run drivers and workers.
  1. Under **Advanced settings**, configure logging:

     1. Enable the **Write logs** setting.
     1. In the **Destination** field, select where the log destination: **Folder**.
     1. In the **Folder** field, select your folder from the list.
     1. Select **Min. logging level**: **INFO**.

  1. Click **Create**.
  1. Wait until the cluster is ready: its status on the Yandex Managed Service for Apache Spark™ dashboard will change to **Running** and its state, to **Alive**. This may take a while.

{% endlist %}

## Prepare a PySpark job {#prepare-task}

1. Save the [pi.py](https://github.com/apache/spark/blob/master/examples/src/main/python/pi.py) file, that contains the job code, to a local computer from the Apache Spark™ repository. This code calculates the approximate value of pi using the Monte Carlo method.

1. Upload the file to the Object Storage bucket [you created earlier](#before-you-begin).

## Run your PySpark job {#run-task}

1. In the [management console](https://console.yandex.cloud), open the cluster you created earlier.
1. Navigate to **Jobs**.
1. Click **Create job**.
1. Select the **Job type**: **PySpark**.
1. In the **Main python file** field, specify the path to `pi.py` in the following format: `s3a://<Object_Storage_bucket_name>/<file_name>`.
1. Click **Submit job**.

## Check the job completion {#check_task}

1. Wait for the job to become **Running**.
1. Navigate to the **Logs** tab.
1. In the logs, look for a line with the job results, such as the following:

   ```
   Pi is roughly 3.144720
   ```