Creating a group with nodes from a Yandex Compute Cloud reserved instance pool
Warning
Reserved instance pools are billable: you pay for the whole unused volume of reserved computing resources of VMs, GPU clusters, and software accelerated networks according to the Yandex Compute Cloud pricing policy. For more information, see Using reserved instance pools.
The reserved instance pool feature is at the Preview stage.
A reserved instance pool is the total of computing resources reserved by the user in a given availability zone to secure their guaranteed availability to the user for the purpose of creating VMs of a particular configuration in this availability zone.
In Managed Service for Kubernetes, you can use reserved instance pools for fixed-size node groups. This ensures resource availability for cluster nodes.
For more information, see Reserved instance pools for Yandex Managed Service for Kubernetes node groups and Reserved instance pools in Compute Cloud.
Warning
Reserved instance pools are not supported for node groups with the following properties:
Creating a node group in a single availability zone with nodes from a reserved instance pool in that zone
-
Create a reserved instance pool with a configuration you want to use for Managed Service for Kubernetes cluster nodes.
Note
Make sure the following properties are identical in the node group and reserved instance pool configurations:
- Platform
- Number of vCPUs
- Amount of RAM
- Availability zone
The number of group nodes in each availability zone must not exceed the size of the reserved instance pools in those zones.
-
Create a Managed Service for Kubernetes cluster.
-
Create a node group:
CLITerraformIf you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating the CLI profile. To change the default folder, use the
yc config set folder-id <folder_ID>command. You can also set a different folder for any specific command using the--folder-nameor--folder-idoptions.In the terminal, run this command:
yc managed-kubernetes node-group create \ --name k8s-reserved-ng \ --cluster-id <cluster_ID> \ --platform-id standard-v4a \ --cores 4 \ --memory 8 \ --disk-size 64 \ --disk-type network-ssd \ --fixed-size 2 \ --location zone=ru-central1-a,subnet-id=<subnet_ID> \ --network-interface security-group-ids=[<security_group_IDs>] \ --reserved-instance-pool-id <reserved_instance_pool_ID>Where:
--cluster-id: Cluster ID.--location: Availability zone and subnet ID.--network-interface security-group-ids: Security group IDs.--reserved-instance-pool-id: Reserved instance pool ID.
For more information about this command, see the CLI reference.
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
-
In the configuration file, describe the node group parameters:
resource "yandex_kubernetes_node_group" "k8s-reserved-ng" { cluster_id = "<cluster_ID>" name = "k8s-reserved-ng" instance_template { platform_id = "standard-v4a" reserved_instance_pool_id = "<reserved_instance_pool_ID>" resources { cores = 4 memory = 8 } boot_disk { size = 64 type = "network-ssd" } network_interface { subnet_ids = ["<subnet_ID>"] security_group_ids = ["<security_group_IDs>"] nat = true } } scale_policy { fixed_scale { size = 2 } } allocation_policy { location { zone = "ru-central1-a" } } }Where:
cluster_id: Cluster ID.subnet_ids: Subnet ID.security_group_ids: Security group IDs.reserved_instance_pool_id: Reserved instance pool ID.
-
Create a node group:
-
In the terminal, navigate to the configuration file directory.
-
Make sure the configuration is correct using this command:
terraform validateIf the configuration is valid, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors in the configuration.
-
Apply the configuration changes:
terraform apply -
Type
yesand press Enter to confirm the changes.
-
For more information about
yandex_kubernetes_node_group, see this Terraform reference.
Creating a node group in three availability zones with nodes from reserved instance pools in each zone
-
Create a reserved instance pool with a configuration you want to use for Managed Service for Kubernetes cluster nodes.
Note
Make sure the following properties are identical in the node group and reserved instance pool configurations:
- Platform
- Number of vCPUs
- Amount of RAM
- Availability zone
The number of group nodes in each availability zone must not exceed the size of the reserved instance pools in those zones.
-
Create a Managed Service for Kubernetes cluster.
-
Create a node group:
Tip
Reserved instance pools are created in a specific availability zone. To automate the distribution of multi-zone group nodes across reserved instance pools of a specific availability zone, use the node template variables.
CLITerraformIf you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating the CLI profile. To change the default folder, use the
yc config set folder-id <folder_ID>command. You can also set a different folder for any specific command using the--folder-nameor--folder-idoptions.In the terminal, run this command:
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 theinstance.zone_idsystem variable (availability zone of a specific node) and the user-defined variables specified in the--variablesparameter.--variables: User-defined variables with IDs of reserved instance pools in different availability zones.
For more information about this command, see the CLI reference.
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
-
In the configuration file, describe the node group parameters:
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) andinstance.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 theinstance.zone_idsystem variable and the user-defined variables specified in thevariablesparameter.subnet_ids: Subnet IDs.security_group_ids: Security group IDs.
-
Create a node group:
-
In the terminal, navigate to the configuration file directory.
-
Make sure the configuration is correct using this command:
terraform validateIf the configuration is valid, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors in the configuration.
-
Apply the configuration changes:
terraform apply -
Type
yesand press Enter to confirm the changes.
-
For more information about
yandex_kubernetes_node_group, see this Terraform reference.