[Yandex Cloud documentation](../../index.md) > [Yandex Managed Service for Kubernetes](../index.md) > [Step-by-step guides](index.md) > Installing applications from Yandex Cloud Marketplace using Terraform

# Installing applications from Yandex Cloud Marketplace using Terraform

With the [Helm Terraform provider](https://github.com/hashicorp/terraform-provider-helm), you can install apps from [Cloud Marketplace](https://yandex.cloud/en/marketplace), as well as any other Helm charts, in your Yandex Managed Service for Kubernetes cluster using Terraform manifests.

For more information about the provider resources, see the relevant provider reference on the [Terraform website](https://registry.terraform.io/providers/hashicorp/helm/latest/docs).

## Getting started {#before-you-begin}

1. [Create](kubernetes-cluster/kubernetes-cluster-create.md) a Managed Service for Kubernetes cluster using any method of your choice.

1. [Install kubect](https://kubernetes.io/docs/tasks/tools/install-kubectl) and [configure it to work with the new cluster](connect/index.md#kubectl-connect).

## Activating the provider {#configure-provider}

1. In a separate directory, create a file named `provider.tf` with the Helm provider settings:

    ```hcl
    terraform {
      required_providers {
        helm = {
          source  = "hashicorp/helm"
          version = "~> 2.13"
        }
      }
      required_version = ">= 1.4.0"
    }

    provider "helm" {
      kubernetes {
        config_path = "~/.kube/config"
        config_context = "<context_name>"
      }
    }
    ```

    You can get a list of all contexts by running the `kubectl config get-contexts` command; to find out the current context, run `kubectl config current-context`.

1. Initialize the Helm provider:

   ```bash
   terraform init
   ```

## Installing applications with Terraform {#install-app}

To install applications, use the [helm_release](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) Terraform resource.

Below we give an example of installing the [GitLab Runner](https://yandex.cloud/en/marketplace/products/yc/gitlab-runner) application.

1. In the directory housing the `provider.tf` file, create a file named `gitlab-runner.tf`:

    ```hcl
    resource "helm_release" "gitlab_runner" {
      name             = "gitlab-runner"
      chart            = "oci://cr.yandex/yc-marketplace/yandex-cloud/gitlab-org/gitlab-runner/chart/gitlab-runner"
      version          = "0.54.0-8"
      namespace        = "gitlab-runner"
      create_namespace = true


      values = [yamlencode({
        gitlabDomain            = "https://***.gitlab.yandexcloud.net"
        runnerRegistrationToken = "<registration_token>"

        replicas     = 2
        nodeSelector = { nodepool = "runners" }
        resources = {
          requests = { cpu = "200m", memory = "256Mi" }
          limits   = { cpu = "500m", memory = "512Mi" }
        }
      })]
    }
    ```

    Where:

    * `name`: Application name.
    * `chart`: Link to the Helm chart.
    * `version`: Application version.
    * `namespace`: New namespace to install your application in. If you specify the default namespace, GitLab Runner may work incorrectly.
    * `values`: Parameters from the `values.yaml` Helm chart configuration file:

      * `gitlabDomain`: GitLab instance domain.
      * `runnerRegistrationToken`: Registration token. [Learn more about obtaining a token](applications/gitlab-runner.md#before-you-begin).
      * `replicas`: Number of application pods.
      * `nodeSelector`: Assigning pods to nodes with the `nodepool = "runners"` label.
      * `resources`: Minimum and maximum amount of resources to allocate to the application.

    To request a list of all parameters from `values.yaml`, run this command:

    ```bash
    helm show values <Helm_chart_link> --version <application_version>
    ```

1. Install the application:

   1. View the planned changes:
   
      ```bash
      terraform plan
      ```
   
   1. If the changes are acceptable, apply them:
   
      ```bash
      terraform apply
      ```

{% note tip %}

To install applications from Cloud Marketplace, you can also use the [Terraform module by Yandex Cloud](https://github.com/terraform-yc-modules/terraform-yc-kubernetes-marketplace).

[Learn more about using modules](../../terraform/concepts/modules.md).

{% endnote %}