---
title: "Resource selectel_mks_nodegroup_v1"
sidebar_label: "selectel_mks_nodegroup_v1"
description: "Creates and manages a node group in Selectel Managed Kubernetes using public API v1"
sidebar_position: 29
---

# Resource selectel\_mks\_nodegroup\_v1

:::info

This instruction is a copy of the Selectel Terraform provider documentation in the [Terraform Registry](https://registry.terraform.io/providers/selectel/selectel/latest/docs).

:::

Creates and manages a Managed Kubernetes node group using public API v1. For more information about node groups, see the [official Selectel documentation](/managed-kubernetes/node-groups/).

## Example usage \{#example-usage}

```hcl
resource "selectel_mks_nodegroup_v1" "nodegroup_1" {
  cluster_id        = selectel_mks_cluster_v1.cluster_1.id
  project_id        = selectel_mks_cluster_v1.cluster_1.project_id
  region            = selectel_mks_cluster_v1.cluster_1.region
  availability_zone = "ru-7a"
  nodes_count       = 3
  cpus              = 2
  ram_mb            = 4096
  volume_gb         = 20
  volume_type       = "fast.ru-7a"

  install_nvidia_device_plugin = false
  preemptible                  = false

  labels            = {
    "label-key0": "label-value0",
    "label-key1": "label-value1",
    "label-key2": "label-value2",
  }
  taints {
    key    = "test-key-0"
    value  = "test-value-0"
    effect = "NoSchedule"
  }
  taints {
    key    = "test-key-1"
    value  = "test-value-1"
    effect = "NoExecute"
  }
  taints {
    key    = "test-key-2"
    value  = "test-value-2"
    effect = "PreferNoSchedule"
  }
}
```

## Argument Reference \{#argument-reference}

* `cluster_id` - (Required) Unique identifier of the associated Managed Kubernetes cluster. Changing this creates a new node group. Retrieved from the [selectel\_mks\_cluster\_v1](/terraform/selectel-provider-reference/resources/mks_cluster_v1) resource.

* `project_id` - (Required) Unique identifier of the associated project. Changing this creates a new node group. Retrieved from the [selectel\_vpc\_project\_v2](/terraform/selectel-provider-reference/resources/vpc_project_v2) resource. Learn more about [Projects](/access-control/projects/about-projects/).

* `region` - (Required) Pool where the cluster is located, for example, `ru-7`. Changing this creates a new node group. Learn more about available pools in the [Availability matrix](/infrastructure/availability-matrix/#managed-kubernetes).

* `availability_zone` - (Required) Pool segment where all nodes of the node group are located. Changing this creates a new node group. Learn more about available pool segments in the [Availability matrix](/infrastructure/availability-matrix/#managed-kubernetes).

* `nodes_count` - (Required) Number of worker nodes in the node group. Changing this resizes the node group if `enable_autoscale` is false.

* `install_nvidia_device_plugin` - (Required) Enables or disables installation of the NVIDIA Device Plugin and GPU drivers.<br />Boolean flag:
  * `true` — for flavors with GPU enables installation of the NVIDIA Device Plugin and GPU drivers.
  * `false` — for flavors without GPU and flavors with GPU, it disables installation of the NVIDIA Device Plugin and GPU drivers. Learn more about [manual installation of GPU drivers](/managed-kubernetes/node-groups/gpu-drivers/#install-gpu-drivers).

* `preemptible` - (Optional) Enables or disables the use of preemptible nodes for the node group. Boolean flag, the default value is false. Learn more about [Preemptible node groups](/managed-kubernetes/node-groups/preemptible-node-groups/).

* `cpus` - (Optional) Number of vCPUs for each node. Can be skipped only when `flavor_id` is set. Changing this creates a new node group. Learn more about [Configurations](/managed-kubernetes/node-groups/configurations/).

* `ram_mb` - (Optional) Amount of RAM in MB for each node. Can be skipped only when `flavor_id` is set. Changing this creates a new node group. Learn more about [Configurations](/managed-kubernetes/node-groups/configurations/).

* `volume_gb` - (Optional) Volume size in GB for each node. Can be skipped only when flavor\_id is set and local\_volume is `true`. Changing this creates a new node group.Learn more about [Configurations](/managed-kubernetes/node-groups/configurations/).

* `volume_type` - (Optional) Type of an OpenStack Block Storage volume for each node. Can be skipped only when `flavor_id` is set and the flavor properties contain additional specifications for a local volume. Changing this creates a new node group. Available volume types are `fast`, `basic`, and `universal`. The format is `<volume_type>.<availability_zone>`. Learn more about [Network volumes](/cloud-servers/volumes/about-network-volumes/).

* `local_volume` - (Optional) Specifies if nodes use a local volume. Cannot be used with the flavors that have specifications for a local volume. Changing this creates a new node group. Boolean flag, the default value is false.

* `flavor_id` - (Optional) Unique identifier of an OpenStack flavor for all nodes in the node group. Changing this creates a new node group. Learn more about [Flavors](/managed-kubernetes/node-groups/create-node-group/#view-flavors-pool-list).

* `labels` - (Optional) List of Kubernetes labels applied to each node in the node group.

* `taints` - (Optional) List of Kubernetes taints applied to each node in the node group. Contains a key-value pair and an effect applied for the taint. Available effects are `NoSchedule`, `PreferNoSchedule`, and `NoExecute`. Learn more about [Taints](/managed-kubernetes/node-groups/add-taints/).

* `keypair_name` - (Optional) Name of the SSH key added to all nodes. Changing this creates a new node group.

* `user_data` - (Optional) Base64-encoded script that worker nodes run on the first boot. Changing this creates a new node group. Learn more about [User data](/managed-kubernetes/node-groups/user-data/).

* `affinity_policy` - (Optional) Specifies affinity policy of the nodes. Changing this creates a new node group. Available values are `soft-anti-affinity` and `soft-affinity`. The default value is `soft-anti-affinity`. For more information about affinity and anti-affinity, see the [official Kubernetes documentation](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity).

* `enable_autoscale` - (Optional) Enables or disables autoscaling of the node group. Boolean flag, the default value is false. `autoscale_min_nodes` and `autoscale_max_nodes` must be specified. Learn more about [Autoscaling](/managed-kubernetes/node-groups/autoscaling/).

  * `autoscale_min_nodes` - (Optional) Minimum number of worker nodes in the node group.

  * `autoscale_max_nodes` - (Optional) Maximum number of worker nodes in the node group.

## Attributes Reference \{#attributes-reference}

* `nodes` - List of nodes in the node group.

* `nodegroup_type` - Type of the node group. Available values are `STANDARD` and `GPU`.

* `status` - Status of the node group.

## Import \{#import}

You can import a node group:

```shell
export OS_DOMAIN_NAME=<account_id>
export OS_USERNAME=<username>
export OS_PASSWORD=<password>
export INFRA_PROJECT_ID=<selectel_project_id>
export INFRA_REGION=<selectel_pool>
terraform import selectel_mks_nodegroup_v1.nodegroup_1 <cluster_id>/<nodegroup_id>
```

where:

* `<account_id>` — Selectel account ID. The account ID is in the top right corner of the [Control panel](https://my.selectel.ru/). Learn more about [Registration](/account/registration/).

* `<username>` — Name of the service user. To get the name, in the [Control panel](https://my.selectel.ru/iam/users_management/users?type=service), go to **Identity & Access Management** ⟶ **User management** ⟶ the **Service users** tab ⟶ copy the name of the required user. Learn more about [Service users](/access-control/access-management/).

* `<password>` — Password of the service user.

* `<selectel_project_id>` — Unique identifier of the associated project. To get the ID, in the [Control panel](https://my.selectel.ru/vpc/mks), go to **Cloud Platform** ⟶ project name ⟶ copy the ID of the required project. Learn more about [Projects](/access-control/projects/about-projects/).

* `<selectel_pool>` — пул, in котором расположен кластер, например, `ru-7`. Чтобы узнать пул, in [панели управления](https://my.selectel.ru/mks/) перейдите in раздел **Продукты and услуги** ⟶ **Managed Kubernetes**. Пул указан in колонке **Пул**.

* `<cluster_id>` — уникальный идентификатор кластера, например, `b311ce58-2658-46b5-b733-7a0f418703f2`. Чтобы узнать ID кластера, in [панели управления](https://my.selectel.ru/mks/) перейдите in раздел **Продукты and услуги** ⟶ **Managed Kubernetes** ⟶ нажмите on нужный кластер ⟶ скопируйте ID in верхней части страницы под названием кластера, рядом with регионом and пулом.

* `<nodegroup_id>` — уникальный идентификатор группы узлов, например, `63ed5342-b22c-4c7a-9d41-c1fe4a142c13`. Чтобы узнать ID группы узлов, in [панели управления](https://my.selectel.ru/mks/) перейдите in раздел **Продукты and услуги** ⟶ **Managed Kubernetes**. Нажмите on нужный кластер. ID группы узлов находится in верхней части карточки группы узлов, рядом with пулом.
