Yandex Cloud
Search
Contact UsTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • 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
© 2026 Direct Cursus Technology L.L.C.
Yandex Managed Service for Kubernetes
  • Comparing with other Yandex Cloud services
  • Getting started
    • Resource relationships
    • Release channels and updates
    • Support for Kubernetes versions
    • Zones of control in Managed Service for Kubernetes
    • Updating node group OS
    • Encryption
      • Node group autoscaling
      • Node group deploy policy
      • Evicting pods from nodes
      • Dynamic resource allocation for a node
      • Node groups with GPUs
      • Reserved instance pools for node groups
      • Variables in a node template
    • Networking in Managed Service for Kubernetes
    • Network settings and cluster policies
    • Autoscaling
    • Audit policy
    • External cluster nodes
    • Quotas and limits
    • Recommendations on using Managed Service for Kubernetes
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes

In this article:

  • Examples
  • See also
  1. Concepts
  2. Node group
  3. Variables in a node template

Variables in a Yandex Managed Service for Kubernetes node template

Written by
Yandex Cloud
Updated at April 28, 2026
  • Examples
    • See also

Managed Service for Kubernetes creates groups of same-type cluster nodes from a template. To use different specifications for such nodes, use the substitution of template variables.

System and user-defined variables are supported.

For more information about variables and their substitution steps, see Variables in an instance template.

For example, you can use variables to create a multi-zone group of nodes from reserved instance pools located in different availability zones.

You can use variables via the CLI, Terraform, and API.

ExamplesExamples

In this example, we will create a node group in three availability zones with one node from reserved instance pools per zone.

CLI
Terraform
yc managed-kubernetes node-group create \
  --name k8s-multizone-reserved-ng \
  --cluster-id <cluster_ID> \
  --platform-id standard-v4a \
  --cores 4 \
  --memory 8 \
  --disk-size 64 \
  --disk-type network-ssd \
  --fixed-size 3 \
  --location zone=ru-central1-a,subnet-id=<subnet_ID_in_zone_a> \
  --location zone=ru-central1-b,subnet-id=<subnet_ID_in_zone_b> \
  --location zone=ru-central1-d,subnet-id=<subnet_ID_in_zone_d> \
  --network-interface security-group-ids=[<security_group_IDs>] \
  --reserved-instance-pool-id '{pool_{instance.zone_id}}' \
  --variables \
pool_ru-central1-a=<pool_ID_in_zone_a>,\
pool_ru-central1-b=<pool_ID_in_zone_b>,\
pool_ru-central1-d=<pool_ID_in_zone_d>

Where:

  • --cluster-id: Cluster ID.
  • --location: Availability zones and their relevant subnet IDs.
  • --network-interface security-group-ids: Security group IDs.
  • --reserved-instance-pool-id: Reserved instance pool IDs you will get as a result of substituting the instance.zone_id system variable (availability zone of a specific node) and the user-defined variables specified in the --variables parameter.
  • --variables: User-defined variables with IDs of reserved instance pools in different availability zones.
resource "yandex_kubernetes_node_group" "k8s-multizone-reserved-ng" {
  cluster_id = "<cluster_ID>"
  name       = "k8s-multizone-reserved-ng"

  # Variables for reserved instance pools
  variables = {
    pool_ru-central1-a = "<reserved_instance_pool_ID_in_zone_a>"
    pool_ru-central1-b = "<reserved_instance_pool_ID_in_zone_b>"
    pool_ru-central1-d = "<reserved_instance_pool_ID_in_zone_d>"
  }

  instance_template {
    name = "test-{instance.zone_id}-{instance.index}"
    # instance.zone_id: System variable with the zone ID
    reserved_instance_pool_id = "{pool_{instance.zone_id}}"
    platform_id = "standard-v4a"

    resources {
      cores = 4
      memory = 8
    }

    boot_disk {
      size = 64
      type = "network-ssd"
    }

    network_interface {
      nat = true
      subnet_ids = [
        "<subnet_ID_in_zone_a>",
        "<subnet_ID_in_zone_b>",
        "<subnet_ID_in_zone_d>"
      ]
      security_group_ids = ["<security_group_IDs>"]
    }
  }

  scale_policy {
    fixed_scale {
      size = 3
    }
  }

  allocation_policy {
    location {
      zone = "ru-central1-a"
    }

    location {
      zone = "ru-central1-b"
    }

    location {
      zone = "ru-central1-d"
    }
  }
}

Where:

  • cluster_id: Cluster ID.
  • variables: User-defined variables with IDs of reserved instance pools in different availability zones.
  • name: Node name in the group, generated using the following system variables: instance.zone_id (the node’s availability zone) and instance.index (unique node number in the group, starting from 1).
  • reserved_instance_pool_id: Reserved instance pool IDs you will get as a result of substituting the instance.zone_id system variable and the user-defined variables specified in the variables parameter.
  • subnet_ids: Subnet IDs.
  • security_group_ids: Security group IDs.

See Reserved instance pools for node groups for examples for a group of nodes from a reserved instance pool in a single availability zone.

See alsoSee also

  • Variables in an instance template
  • Reserved instance pools for Yandex Managed Service for Kubernetes node groups
  • Creating a group with nodes from a Yandex Compute Cloud reserved instance pool

Was the article helpful?

Previous
Reserved instance pools for node groups
Next
Networking in Managed Service for Kubernetes
© 2026 Direct Cursus Technology L.L.C.