Creating an instance in a placement group

Create an instance in 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. View a description of the CLI command to create a placement group:

    $ yc compute placement-group create --help
    
  2. Create a placement group:

    $ yc compute placement-group create --spread-strategy --name my-group
    id: fdvte50kv3nclagfknoc
    folder_id: aoeieef3k7ppari05ajo
    created_at: "2019-12-20T08:59:44Z"
    name: my-group
    spread_placement_strategy: {}
    

    This command creates a placement group with the following characteristics:

    • Named my-group.
    • Placement strategy spread.
  3. View the description of the CLI command for creating a VM:

    $ yc compute instance create --help
    
  4. Create a virtual machine:

    $ yc compute instance create --zone ru-central1-b --name instance-in-group-1 --placement-group-name my-group
    id: epdep2kq6dt5uekuhcrd
    ...
    placement_policy:
      placement_group_id: fd83bv4rnsna2sjkiq4s
    

    This command creates a VM instance with the following characteristics:

    • Named instance-in-group-1.
    • In the ru-central1-b availability zone.
    • In the my-group placement group.
  5. Check that the instance was created and 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  |
    +----------------------+---------------------+---------------+---------+-------------+-------------+
    

Use the create API method.

See also