Create an instance in a placement group
Written by
Create an instance in a placement group.
CLI
API
If you don't 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 description of the CLI command to create a placement group:
$ yc compute placement-group create --help
-
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
.
- Named
-
View the description of the CLI command for creating a VM:
$ yc compute instance create --help
-
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.
- Named
-
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 API Create method.