Creating an instance group 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.
You can use reserved pools for instance groups. This guarantees the availability of resources for the instance group.
Reserved instance pools are incompatible with dedicated hosts, preemptible VMs, and VMs with vCPU performance levels below 100%. At present, reserved instance pools do not support placement groups.
Reserved instance pools are created in specific availability zones. To automate the distribution of multi-zone group instances across reserved instance pools of a specific availability zone, use the instance template variables.
For more information, see Reserved instance pools in Compute Cloud.
Creating a group in a single availability zone with instances from a reserved instance pool in that zone
-
Create a service account with the compute.admin role which the group will use to manage instances.
-
Create a reserved instance pool with a configuration you want to use for the instance group.
Note
The configuration of the instance reserve pool must match the configuration of the instance group you want to create in terms of:
- Platform
- Number of vCPUs
- Amount of RAM
- Availability zone
The number of VMs in each availability zone must not exceed the size of the reserved instance pools in those zones.
-
Create an instance group:
CLITerraformAPIIf 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 specify a different folder for any command using--folder-nameor--folder-id. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.-
Create the
specification.yamlfile containing the instance group specification, for example:name: first-fixed-group service_account_id: <service_account_ID> instance_template: platform_id: standard-v4a resources_spec: memory: 2g cores: 2 boot_disk_spec: mode: READ_WRITE disk_spec: image_id: fd83esfomhq25p2ono90 type_id: network-hdd size: 20g network_interface_specs: - network_id: <network_ID> primary_v4_address_spec: {} subnet_ids: - <subnet_ID> security_group_ids: - <security_group_ID> reserved_instance_pool_id: <reserved_instance_pool_ID> deploy_policy: max_unavailable: 1 max_expansion: 0 scale_policy: fixed_scale: size: 3 allocation_policy: zones: - zone_id: ru-central1-aWhere:
service_account_id: ID of the service account you created earlier.network_id: Network ID.subnet_ids: Subnet ID.security_group_ids: Security group ID.reserved_instance_pool_id: Reserved instance pool ID you created earlier.zone_id: Availability zone.
For more information about the instance group parameters, see Specification of an instance group in YAML format.
-
Apply the specification by running this command in the terminal:
yc compute instance-group create \ --file specification.yamlFor 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 instance group parameters:
resource "yandex_compute_instance_group" "first-fixed-group" { name = "first-fixed-group" service_account_id = "<service_account_ID>" instance_template { platform_id = "standard-v4a" resources { memory = 2 cores = 2 } boot_disk { mode = "READ_WRITE" initialize_params { image_id = "fd83esfomhq25p2ono90" } } network_interface { network_id = "<network_ID>" subnet_ids = ["<subnet_ID>"] security_group_ids = ["<security_group_ID>"] } reserved_instance_pool_id = "<reserved_instance_pool_ID>" } scale_policy { fixed_scale { size = 3 } } allocation_policy { zones = ["ru-central1-a"] } deploy_policy { max_unavailable = 1 max_expansion = 0 } }Where:
service_account_id: ID of the service account you created earlier.network_id: Network ID.subnet_ids: Subnet ID.security_group_ids: Security group ID.reserved_instance_pool_id: Reserved instance pool ID you created earlier.zones: Availability zone.
For more information about the instance group parameters, see Specification of an instance group in YAML format.
-
Create an instance 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_compute_instance_group, see this Terraform reference.Use the create REST API method for the InstanceGroup resource or the InstanceGroupService/Create gRPC API call.
To specify the reserved pool, use the
instanceTemplate.reservedInstancePoolId(instance_template.reserved_instance_pool_id) parameter. -
Creating a group in three availability zones with VMs from the reserve pools of each zone
-
Create a service account with the compute.admin role which the group will use to manage instances.
-
Create reserved instance pools in three availability zones using a configuration you want to use for the instance group.
Note
The configuration of the instance reserve pool must match the configuration of the instance group you want to create in terms of:
- Platform
- Number of vCPUs
- Amount of RAM
- Availability zone
The number of VMs in each availability zone must not exceed the size of the reserved instance pools in those zones.
-
Create an instance group:
CLITerraformAPIIf 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 specify a different folder for any command using--folder-nameor--folder-id. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.-
Create the
specification.yamlfile containing the instance group specification, for example:name: first-fixed-group service_account_id: <service_account_ID> variables: - key: pool_ru-central1-a value: <reserved_instance_pool_ID_in_zone_a> - key: pool_ru-central1-b value: <reserved_instance_pool_ID_in_zone_b> - key: pool_ru-central1-d value: <reserved_instance_pool_ID_in_zone_d> instance_template: platform_id: standard-v4a resources_spec: memory: 2g cores: 2 boot_disk_spec: mode: READ_WRITE disk_spec: image_id: fd83esfomhq25p2ono90 type_id: network-hdd size: 20g network_interface_specs: - network_id: <network_ID> primary_v4_address_spec: {} subnet_ids: - <subnet_ID_in_zone_a> - <subnet_ID_in_zone_b> - <subnet_ID_in_zone_d> security_group_ids: - <security_group_ID> reserved_instance_pool_id: "{pool_{instance.zone_id}}" deploy_policy: max_unavailable: 1 max_expansion: 0 scale_policy: fixed_scale: size: 3 allocation_policy: zones: - zone_id: ru-central1-a - zone_id: ru-central1-b - zone_id: ru-central1-dWhere:
service_account_id: ID of the service account you created earlier.network_id: Network ID.subnet_ids: Subnet IDs.security_group_ids: Security group ID.variables: User-defined variables with IDs of reserved instance pools in different availability zones.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 instance) and the user-defined variables specified in thevariablesparameter.zone_id: Availability zone.
For more information about the instance group parameters, see Specification of an instance group in YAML format.
-
Apply the specification by running this command in the terminal:
yc compute instance-group create \ --file specification.yamlFor 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 instance group parameters:
resource "yandex_compute_instance_group" "ig-1" { name = "fixed-group" service_account_id = "<service_account_ID>" # 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 { platform_id = "standard-v4a" resources { memory = 2 cores = 2 } boot_disk { mode = "READ_WRITE" initialize_params { image_id = "fd83esfomhq25p2ono90" } } network_interface { network_id = "<network_ID>" subnet_ids = ["<subnet_ID_in_zone_a>", "<subnet_ID_in_zone_b", "<subnet_ID_in_zone_d>"] security_group_ids = ["<security_group_ID>"] } # instance.zone_id: System variable with the zone ID reserved_instance_pool_id = "{pool_{instance.zone_id}}" } scale_policy { fixed_scale { size = 3 } } allocation_policy { zones = ["ru-central1-a", "ru-central1-b", "ru-central1-d"] } deploy_policy { max_unavailable = 1 max_expansion = 0 } }Where:
service_account_id: ID of the service account you created earlier.network_id: Network ID.subnet_ids: Subnet IDs.security_group_ids: Security group ID.variables: User-defined variables with IDs of reserved instance pools in different availability zones.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 instance) and the user-defined variables specified in thevariablesparameter.zones: Availability zones.
For more information about the instance group parameters, see Specification of an instance group in YAML format.
-
Create an instance 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_compute_instance_group, see this Terraform reference.Use the create REST API method for the InstanceGroup resource or the InstanceGroupService/Create gRPC API call.
To specify the reserved pool, use the
instanceTemplate.reservedInstancePoolId(instance_template.reserved_instance_pool_id) parameter.Variables are set in the
variablesparameter. -