Yandex Cloud
Search
Contact UsTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • AI for business
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2025 Direct Cursus Technology L.L.C.
Yandex Managed Service for Kubernetes
  • Comparing with other Yandex Cloud services
  • Getting started
    • All guides
    • Connecting to a node over SSH
    • Connecting to a node via OS Login
    • Updating Kubernetes
    • Configuring autoscaling
    • Activating a Kubernetes Terraform provider
    • Installing applications from Yandex Cloud Marketplace using Terraform
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes

In this article:

  • Getting started
  • Activating the provider
  • See also
  1. Step-by-step guides
  2. Activating a Kubernetes Terraform provider

Activating the Kubernetes Terraform provider

Written by
Yandex Cloud
Updated at June 11, 2025
  • Getting started
  • Activating the provider
  • See also

You can use Terraform manifests to create Kubernetes resources. To do this, activate the kubernetes Terraform provider. It supports Terraform resources that are mapped to YAML configuration files for various Kubernetes resources.

For more information about the provider resources, see the relevant provider reference on the Terraform website.

Getting startedGetting started

To connect the kubernetes provider, create a Kubernetes cluster using Terraform.

Warning

Do not delete Terraform configuration files after creating the cluster as you will need them to activate the provider.

The kubernetes provider is initialized only after creating and setting up a Kubernetes cluster for the following reasons:

  • The provider requires the cluster data.
  • The provider is used to create Kubernetes resources. You can only create them when the cluster is ready.

Activating the providerActivating the provider

  1. Navigate to the working directory with Terraform files.

  2. Open the .tf file with yandex provider settings you used when creating the Kubernetes cluster. It must have the following structure:

    terraform {
      required_providers {
        yandex = {
          source = "yandex-cloud/yandex"
        }
      }
    
      required_version = ">= 0.13"
    }
    
    provider "yandex" {
      token     = "<IAM_token>"
      cloud_id  = "<cloud_ID>"
      folder_id = "<folder_ID>"
      zone      = "<default_availability_zone>"
    }
    
  3. In the file, specify the parameters required for the kubernetes provider to operate:

    1. Under required_providers, add:

      kubernetes = {
        source = "hashicorp/kubernetes"
      }
      
    2. Under required_providers, change required_version to ">= 0.14.8".

    3. Add a new section at the end of the file:

      data "yandex_client_config" "client" {}
      
      provider "kubernetes" {
        host                   = yandex_kubernetes_cluster.<Kubernetes>_cluster_name.master[0].external_v4_endpoint
        cluster_ca_certificate = yandex_kubernetes_cluster.<Kubernetes>_cluster_name.master[0].cluster_ca_certificate
        token                  = data.yandex_client_config.client.iam_token
      }
      
  4. Make sure the resulting file looks like this:

    terraform {
      required_providers {
          yandex = {
              source = "yandex-cloud/yandex"
          }
          kubernetes = {
              source = "hashicorp/kubernetes"
          }
      }
      required_version = ">= 0.14.8"
    }
    
    provider "yandex" {
      token     = "<IAM_token>"
      cloud_id  = "<cloud_ID>"
      folder_id = "<folder_ID>"
      zone      = "<default_availability_zone>"
    }
    
    data "yandex_client_config" "client" {}
    
    provider "kubernetes" {
      host                   = yandex_kubernetes_cluster.<Kubernetes>_cluster_name.master[0].external_v4_endpoint
      cluster_ca_certificate = yandex_kubernetes_cluster.<Kubernetes>_cluster_name.master[0].cluster_ca_certificate
      token                  = data.yandex_client_config.client.iam_token
    }
    
  5. Initialize the kubernetes provider:

    terraform init
    

See also {see-also}See also

Managing Kubernetes resources via the Terraform provider.

Was the article helpful?

Previous
Configuring autoscaling
Next
Installing applications from Yandex Cloud Marketplace using Terraform
© 2025 Direct Cursus Technology L.L.C.