Creating a placement group
Create a placement group.
You can work with placement groups with the partition placement strategy using the CLI and API.
-
In the management console
, select the folder to create your placement group in. -
In the list of services, select Compute Cloud.
-
In the left-hand panel, select
Placement groups. -
Go to the Virtual machine placement groups tab.
-
In the top-right corner, click Create and choose Virtual machine placement group.
-
Enter a name for the placement group. The naming requirements are as follows:
- The name must be from 3 to 63 characters long.
- It may contain lowercase Latin letters, numbers, and hyphens.
- The first character must be a letter and the last character cannot be a hyphen.
-
(Optional) Add a placement group description.
-
Click Create.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
-
View the description of the CLI command to create a placement group:
yc compute placement-group create --help
-
Create a placement group in the default folder with one of the placement strategies:
-
yc compute placement-group create \ --spread-strategy \ --name <placement_group_name>
Where:
--spread-strategy
: Shows that the spread placement strategy is selected.--name
: Placement group name.
-
yc compute placement-group create \ --partitions <partition_count> \ --name <placement_group_name>
Where:
--partitions
: Shows that the partition placement strategy is selected with the number of partitions specified: from1
to5
.--name
: Placement group name.
-
-
Check that the placement group was added:
yc compute placement-group list
Result:
+----------------------+----------+----------+ | ID | NAME | STRATEGY | +----------------------+----------+----------+ | fd83bv4rnsna******** | my-group | SPREAD | +----------------------+----------+----------+
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the documentation on the Terraform
If you don't have Terraform, install it and configure the Yandex Cloud provider.
-
In the configuration file, describe the placement group parameters:
-
name
: Placement group name. The name format is as follows:- The name must be from 3 to 63 characters long.
- It may contain lowercase Latin letters, numbers, and hyphens.
- The first character must be a letter and the last character cannot be a hyphen.
-
folder_id
: ID of the folder to create a placement group in. -
description
: Placement group description.
Here is an example of the configuration file structure:
resource "yandex_compute_placement_group" "group1" { name = "<placement_group_name>" folder_id = "<folder_ID>" description = "<placement_group_description>" }
For more information about the
yandex_compute_placement_group
resource parameters in Terraform, see the provider documentation . -
-
In the command line, go to the directory with the Terraform configuration file.
-
Check the configuration using this command:
terraform validate
If the configuration is correct, you will get this message:
Success! The configuration is valid.
-
Run this command:
terraform plan
The terminal will display a list of resources with parameters. No changes will be made at this step. If the configuration contains any errors, Terraform will point them out.
-
Apply the configuration changes:
terraform apply
-
Confirm the changes: type
yes
into the terminal and press Enter.All the resources you need will then be created in the specified folder. You can check the new resources and their settings using the management console
or this CLI command:yc compute placement-group list
Use the create REST API method for the PlacementGroup resource or the PlacementGroupService/Create gRPC API call.