Removing an instance from a placement group
Remove a VM instance from a placement group.
You can permanently delete the removed VM or add it back to the 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 the placement group belongs to. - In the list of services, select Compute Cloud.
- In the left-hand panel, select
Placement groups. - Go to the Virtual machine placement groups tab.
- Select the placement group you want to remove the VM instance from.
- Go to the List of VMs panel.
- In the line with the VM instance, click
and select Delete from group. - In the window that opens, click Delete from group.
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 a list of VMs in the placement group:
yc compute placement-group list-instances --name my-group
Result:
+----------------------+---------------------+-------------------+---------+-------------+-------------+ | ID | NAME | ZONE ID | STATUS | EXTERNAL IP | INTERNAL IP | +----------------------+---------------------+-------------------+---------+-------------+-------------+ | epdep2kq6dt5******** | instance-in-group-1 | ru-central1-a | RUNNING | | 10.129.0.5 | | epdlv1pp5401******** | instance-in-group-2 | ru-central1-a | RUNNING | | 10.129.0.30 | +----------------------+---------------------+-------------------+---------+-------------+-------------+
-
Stop the VM instance you want to remove:
yc compute instance stop instance-in-group-2
Result:
id: epdlv1pp5401******** ... status: STOPPED
-
Remove the VM instance from the placement group by updating the VM instance, leaving
placement-group-name
blank:yc compute instance update --name instance-in-group-2 --placement-group-name=""
-
Check that the VM instance was removed from the placement group:
yc compute placement-group list-instances --name my-group
Result:
+----------------------+---------------------+-------------------+---------+-------------+-------------+ | ID | NAME | ZONE ID | STATUS | EXTERNAL IP | INTERNAL IP | +----------------------+---------------------+-------------------+---------+-------------+-------------+ | epdep2kq6dt5******** | instance-in-group-1 | ru-central1-a | RUNNING | | 10.129.0.5 | +----------------------+---------------------+-------------------+---------+-------------+-------------+
Terraform
For more information about the provider resources, see the documentation on the Terraform
If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.
If you don't have Terraform, install it and configure the Yandex Cloud provider.
To remove a VM created with Terraform from a placement group:
-
Open the VM configuration file and delete the
placement_group_id
parameter.Here is a sample configuration file structure:
... resource "yandex_compute_instance" "vm-1" { name = "my-vm" platform_id = "standard-v3" placement_policy { placement_group_id = "${yandex_compute_placement_group.group1.id}" } } resource "yandex_compute_placement_group" "group1" { name = "test-pg" } ...
-
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.You can check the changes in the management console
.
Use the update REST API method for the Instance resource or the InstanceService/Update gRPC API call.