Instance template
When creating a group, you need to describe an instance template, which is the basic instance configuration used for deploying all the instances in the group.
The template description and policy description are passed to the CLI in a YAML file when creating or updating an instance group with the --file
flag. This is convenient for passing values that consist of multiple strings. For more information, see Create a fixed-size instance group.
You can set the values of variables for the instance template. For more information, see Variables in an instance template.
Computing resources
When describing a template, you specify the computing resources to allocate to each instance: the number and guaranteed performance of processor cores (vCPUs) and the amount of RAM. You can choose the computing resources that are appropriate for the expected load. For more information, see vCPU performance levels.
You can also use the template to enable the creation of preemptible instances, which are cheaper than the regular instances. Preemptible instances can only be auto-healed if the computing resources in the availability zone allow for this. If the resources are insufficient, Instance Groups will resume auto-healing as soon as the resources become available, but this may take a long time.
Disks
At least one disk must be attached to each instance: the boot disk. Each boot disk is created automatically and attached to only one instance when creating an instance group.
You can also attach additional disks to each instance. You can create an additional disk along with an instance group. The new disk can be empty, or you can restore it from a snapshot or image. You can only attach or detach additional disks when creating or updating a group. For more information, see Disks.
Alert
When you delete a VM, its disks are deleted from the group. VMs can be deleted during the scaling and automatic recovery process.
Network
When creating a group, you can:
- Set the network for the group itself.
- Set subnets for each instance in the group.
You can create a group without specifying any subnets for its instances if the availability zone selected for each instance contains exactly one subnet for the specified network.
You can also configure a public IP address for each instance. This allows the instance to interact with other services over the internet. For more information, see Network on a VM.
You can specify the appropriate security groups in a template or configure them individually for each instance in the group.
Note
Security groups are at the Preview stage stage. If they aren't available in your network, all incoming and outgoing traffic will be allowed for the VM and no additional setup is required.
Metadata
The template can be used to describe the metadata for the instances in the group. For example, you can use the user-data
key to describe the system users to be created on new instance startup. Read more about the metadata supported by Compute Cloud in VM instance metadata.
Template description in a YAML file
A template describes the configuration of the base instance. It is defined in the instance_template
key in a YAML file.
Example of a YAML file entry:
...
instance_template:
platform_id: standard-v3
resources_spec:
memory: 2G
cores: 2
core_fraction: 20
boot_disk_spec:
mode: READ_WRITE
disk_spec:
image_id: ff8nb7ecsbrj76dfaa8b
type_id: network-hdd
size: 50G
network_interface_specs:
- network_id: rnp6rq7pmi0542gtuame
subnet_ids:
- e9b9v2v5f3rrpuot2mvl
primary_v4_address_spec: {
one_to_one_nat_spec: {
ip_version: IPV4
}
}
metadata:
user-data: |-
#cloud-config
write_files:
- path: /var/lib/cloud/scripts/per-boot/01-run-load-generator.sh
permissions: '0555'
content: |
#!/bin/bash
docker run -d --net=host -p 80:80 openresty/openresty:alpine
users:
- name: my-user
groups: sudo
shell: /bin/bash
sudo: ['ALL=(ALL) NOPASSWD:ALL']
ssh-authorized-keys:
- ssh-rsa AAAAB3...
...
The disk size is specified in bytes by default. 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 |
Keys (the table lists keys that directly define the base instance's configuration):
Key | Value |
---|---|
platform_id |
ID of the instance's hardware platform. |
memory |
The amount of RAM available to the instance, specified in bytes. The maximum value is 274877906944 (275 GB). |
cores |
The number of cores available to the instance. The value depends on the platform type. |
core_fraction |
Basic vCPU performance level. |
mode |
Disk access mode.– READ_ONLY : Read access.– READ_WRITE : Read and write access. |
image_id |
ID of the image that will be used for disk creation. |
type_id |
ID of the disk type. To get a list of available disk types, use the request diskTypes request. |
size |
Size of the disk, specified in bytes. Acceptable values are in the range from 4194304 (4 MB) to 4398046511104 (4 TB). |
network_id |
ID of the network. |
subnet_ids |
IDs of cloud subnets. |
ip_version |
IP version for the public IP address. |
metadata |
Metadata for a template instance. Read more in VM instance metadata. |
user-data |
Additional settings for instance initialization. In the example, the settings are described for the cloud-init program. |
For information about the technical restrictions of Instance Groups, see Quotas and limits in Compute Cloud.