Installing applications from Yandex Cloud Marketplace using Terraform
With the Helm Terraform provider
For more information about the provider resources, see the relevant provider reference on the Terraform website
Getting started
-
Create a Managed Service for Kubernetes cluster using any method of your choice.
-
Install kubect
and configure it to work with the new cluster.
Activating the provider
-
In a separate directory, create a file named
provider.tfwith the Helm provider settings: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-contextscommand; to find out the current context, runkubectl config current-context. -
Initialize the Helm provider:
terraform init
Installing applications with Terraform
To install applications, use the helm_release
Below we give an example of installing the GitLab Runner application.
-
In the directory housing the
provider.tffile, create a file namedgitlab-runner.tf: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 thevalues.yamlHelm chart configuration file:gitlabDomain: GitLab instance domain.runnerRegistrationToken: Registration token. Learn more about obtaining a token.replicas: Number of application pods.nodeSelector: Assigning pods to nodes with thenodepool = "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:helm show values <Helm_chart_link> --version <application_version> -
-
Install the application:
-
View the planned changes:
terraform plan -
If the changes are acceptable, apply them:
terraform apply
-
Tip
To install applications from Cloud Marketplace, you can also use the Terraform module by Yandex Cloud