Adding a VM to a placement group

Add an existing instance to a placement group.

If you don't have the Yandex.Cloud command line interface yet, install 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.

  1. Create a virtual machine:

    $ yc compute instance create --zone ru-central1-b --name instance-in-group-2
    id: epdlv1pp54019j09fhue
    ...
    

    This command creates a VM instance with the following characteristics:

    • Named instance-in-group-2.
    • In the ru-central1-b availability zone.
  2. View a list of VM instances in the placement group:

    $ yc compute placement-group list-instances --name my-group
    +----------------------+---------------------+---------------+---------+-------------+-------------+
    |          ID          |        NAME         |    ZONE ID    | STATUS  | EXTERNAL IP | INTERNAL IP |
    +----------------------+---------------------+---------------+---------+-------------+-------------+
    | epdep2kq6dt5uekuhcrd | instance-in-group-1 | ru-central1-b | RUNNING |             | 10.129.0.5  |
    +----------------------+---------------------+---------------+---------+-------------+-------------+
    
  3. Stop the VM:

    $ yc compute instance stop instance-in-group-2
    id: epdlv1pp54019j09fhue
    ...
    status: STOPPED
    
  4. Add a VM instance to the placement group:

    $ yc compute instance update --name instance-in-group-2 --placement-group-name my-group
    id: epdlv1pp54019j09fhue
    ...
    placement_policy:
      placement_group_id: fd83bv4rnsna2sjkiq4s
    

    This command adds the instance-in-group-2 instance to the my-group placement group.

  5. Check that the instance was added to the placement group:

    $ yc compute placement-group list-instances --name my-group
    +----------------------+---------------------+---------------+---------+-------------+-------------+
    |          ID          |        NAME         |    ZONE ID    | STATUS  | EXTERNAL IP | INTERNAL IP |
    +----------------------+---------------------+---------------+---------+-------------+-------------+
    | epdep2kq6dt5uekuhcrd | instance-in-group-1 | ru-central1-b | RUNNING |             | 10.129.0.5  |
    | epdlv1pp54019j09fhue | instance-in-group-2 | ru-central1-b | STOPPED |             | 10.129.0.30 |
    +----------------------+---------------------+---------------+---------+-------------+-------------+
    
  6. Start the VM:

    $ yc compute instance stop instance-in-group-2
    id: epdlv1pp54019j09fhue
    ...
    status: RUNNING
    

Use the update API method.

See also