Creating an instance group in a placement group
You can create an instance group in a placement 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 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.
-
-
View the description of the CLI command to create an instance group:
yc compute instance-group create --help
-
Make sure the folder contains at least one network:
yc vpc network list
If there are none, create a network.
-
Select one of the Yandex Cloud Marketplace public images, e.g., CentOS 7.
To get a list of available images using the CLI, run this command:
yc compute image list --folder-id standard-images
Result:
+----------------------+-------------------------------------+--------------------------+----------------------+--------+ | ID | NAME | FAMILY | PRODUCT IDS | STATUS | +----------------------+-------------------------------------+--------------------------+----------------------+--------+ ... | fdvk34al8k5n******** | centos-7-1549279494 | centos-7 | dqni65lfhvv2******** | READY | | fdv7ooobjfl3******** | windows-2016-gvlk-1548913814 | windows-2016-gvlk | dqnnc72gj2is******** | READY | | fdv4f5kv5cvf******** | ubuntu-1604-lts-1549457823 | ubuntu-1604-lts | dqnnb6dc7640******** | READY | ... +----------------------+-------------------------------------+--------------------------+----------------------+--------+
Where:
-
ID
: Image ID. -
NAME
: Image name. -
FAMILY
: ID of the image family the image belongs to. -
PRODUCT IDS
: IDs of Yandex Cloud Marketplace products associated with the image. -
STATUS
: Current status of the image. It may take one of the following values:STATUS_UNSPECIFIED
: Image status is not defined.CREATING
: Image is being created.READY
: Image is ready to use.ERROR
: You cannot use the image due to an issue.DELETING
: Image is being deleted.
-
-
Create a YAML file with any name, e.g.,
specification.yaml
. -
In the created file, indicate the following:
-
General information about the instance group:
name: first-fixed-group service_account_id: <service_account_ID> description: "This instance group was created from YAML config."
Where:
-
name
: Instance group name. The name must be unique within the folder. The name may contain lowercase Latin letters, numbers, and hyphens. The first character must be a letter. The last character cannot be a hyphen. The name may be up to 63 characters long. -
service_account_id
: Service account ID.You cannot delete a service account while it is linked to an instance group.
-
description
: Instance group description.
-
-
Instance template, such as:
instance_template: platform_id: standard-v3 resources_spec: memory: 2g cores: 2 boot_disk_spec: mode: READ_WRITE disk_spec: image_id: fdvk34al8k5n******** type_id: network-hdd size: 32g network_interface_specs: - network_id: c64mknqgnd8a******** primary_v4_address_spec: {} security_group_ids: - enps0ar5s3ti******** scheduling_policy: preemptible: false placement_policy: placement_group_id: fdvte50kv3nc********
By default, the disk size is specified in bytes. You can specify a different unit of measurement using the applicable suffix.
Suffix Prefix and multiplier Example k
kilo- (210) 640k
= 640 × 210 =655360
m
mega- (220) 48m
= 48 × 220 =50331648
g
giga- (230) 10g
= 10 × 230 =10737418240
t
tera- (240) 4t
= 4 × 240 =4398046511104
p
peta- (250) 2p
= 2 × 250 =2251799813685248
Where:
-
platform_id
: Platform ID. -
memory
: Amount of memory (RAM). -
cores
: Number of processor cores (vCPUs). -
mode
: Disk access mode.READ_ONLY
: Read-only access.READ_WRITE
: Read/write access.
-
image_id
: Public image ID. You can view image IDs in the management console when creating a VM or in Cloud Marketplace on the image page under Product IDs. -
type_id
: Disk type. -
size
: Disk size. -
network_id
:default-net
network ID. -
primary_v4_address_spec
: IPv4 specification. You can allow public access to the group's instances by specifying the IP version for the public IP address. For more information, see Template description in a YAML file. -
security_group_ids
: List of security group IDs. -
scheduling_policy
: Scheduling policy configuration. -
preemptible
: Flag for creating preemptible instances.true
: Create a preemptible instance.false
(default): Create a regular instance.
When creating a preemptible instance group, keep in mind that the VM instances will terminate after 24 hours of continuous operation or earlier. Instance Groups may not be able to restart them immediately due to insufficient resources. This may occur in the event of a sharp increase in the use of Yandex Cloud computing resources.
-
placement_policy
: Instance placement group parameters:placement_group_id
: Placement group ID.
-
-
deploy_policy: max_unavailable: 1 max_expansion: 0 scale_policy: fixed_scale: size: 3 allocation_policy: zones: - zone_id: ru-central1-a instance_tags_pool: - first - second - third
Where:
deploy_policy
: Instance deployment policy for the group.scale_policy
: Instance scaling policy for the group.allocation_policy
: Instance allocation policy between availability zones.
Full code for the
specification.yaml
file:name: first-fixed-group service_account_id: ajed6ilf11qg******** description: "This instance group was created from YAML config." instance_template: platform_id: standard-v3 resources_spec: memory: 2g cores: 2 boot_disk_spec: mode: READ_WRITE disk_spec: image_id: fdvk34al8k5n******** type_id: network-hdd size: 32g network_interface_specs: - network_id: c64mknqgnd8a******** primary_v4_address_spec: {} security_group_ids: - enps0ar5s3ti******** scheduling_policy: preemptible: false placement_policy: placement_group_id: fdvte50kv3nc******** deploy_policy: max_unavailable: 1 max_expansion: 0 scale_policy: fixed_scale: size: 3 allocation_policy: zones: - zone_id: ru-central1-a instance_tags_pool: - first - second - third
-
-
Create an instance group in the default folder:
yc compute instance-group create --file specification.yaml
This command creates a group of three same-type instances with the following configuration:
- Name:
first-fixed-group
- OS: CentOS 7
- Network:
default-net
- Placement group:
my-group
- Availability zone:
ru-central1-a
- vCPUs: 2; RAM: 2 GB
- Network HDD: 32 GB
- Name:
Use the create REST API method for the InstanceGroup resource or the InstanceGroupService/Create gRPC API call.