Creating a VM in a group of dedicated hosts
The VM you create will be linked to one of the dedicated hosts in the group. When the VM is stopped, it will not be available on the group hosts, and when it is restarted, it may be linked to a different host of the group.
If you do not have a group of dedicated hosts, create one.
To create a VM:
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.
-
Get the group ID for the dedicated host group where you need to create the VM:
yc compute host-group list
Result:
+------------------------------+-------+--------------+-------+---------------+ | ID | CORES | MEMORY | DISKS | DISK SIZE | +------------------------------+-------+--------------+-------+---------------+ ... | intel-6338-c108-m704-n3200x6 | 108 | 755914244096 | 6 | 3198924357632 | +------------------------------+-------+--------------+-------+---------------+
-
Get a list of available subnets:
yc vpc subnet list
Result:
+----------------------+-----------------------+----------------------+----------------+---------------+-----------------+ | ID | NAME | NETWORK ID | ROUTE TABLE ID | ZONE | RANGE | +----------------------+-----------------------+----------------------+----------------+---------------+-----------------+ | b0c6n43f9lgh******** | default-ru-central1-d | enpe3m3fa00u******** | | ru-central1-d | [10.130.0.0/24] | | e2l2da8a20b3******** | default-ru-central1-b | enpe3m3fa00u******** | | ru-central1-b | [10.129.0.0/24] | | e9bnlm18l70a******** | default-ru-central1-a | enpe3m3fa00u******** | | ru-central1-a | [10.128.0.0/24] | +----------------------+-----------------------+----------------------+----------------+---------------+-----------------+
-
Run the following command to create a VM:
yc compute instance create \ --host-group-id <dedicated_host_group_ID> \ --zone <availability_zone> \ --platform <platform_ID> \ --network-interface subnet-name=<subnet_name> \ --attach-local-disk size=<disk_size>
Where:
-
--host-group-id
: ID of the dedicated host group. -
--zone
: Availability zone where the group of dedicated hosts resides. -
--platform
: Platform that be the same as the platform for the group of dedicated hosts:standard-v3
: For hosts based on Intel® Ice Lake.standard-v2
: For archived hosts based on Intel Cascade Lake.
-
--network-interface
: VM network interface description:subnet-name
: Name of the subnet in the availability zone.
-
--attach-local-disk
: Properties of the local disk being attached to the VM:size
: Disk size in bytes. You can find the possible values in the list of dedicated host types and theyc compute host-type list
command output. For example, for theintel-6338-c108-m704-n3200x6
host type, you should specify3198924357632
(~ 2.91 TB). You cannot set a size different from the host disk size.
The
--attach-local-disk
parameter is optional. To attach multiple local disks, specify the parameter as many times as required. For more information, see Local and network disks.
To specify other VM properties, use the
yc compute instance create
command parameters as described in the CLI reference. For more information, see VMs in Compute Cloud and Creating VMs.Result:
done (20s) id: fhmbdt1jj2k3******** folder_id: m4n56op78mev******** created_at: "2020-10-13T07:41:19Z" zone_id: ru-central1-a ... placement_policy: host_affinity_rules: - key: yc.hostGroupId op: IN values: - abcdefg1hi23********
-
- Find out the ID of the dedicated host group using the list REST API method for the HostGroup resource or the HostGroupService/List gRPC API call.
- Create a VM instance using the create REST API method for the Instance resource or the InstanceService/Create gRPC API call.
If you attached local disks to your VM, partition and mount them after the VM is created.
Example of creating a VM with a local disk in a group of dedicated hosts
Before creating a VM:
- Create a dedicated host group and get its ID using the
yc compute host-group list
CLI command. - Generate a key pair to connect to the VM via SSH.
Create a VM with the following characteristics:
- Location: Dedicated host group
- Platform: Intel Ice Lake
- Number of vCPUs: 64
- Amount of RAM: 704 GB
- Number of local disks: 2
- Size of a single local disk: 3,198,924,357,632 B (~2.91 TB)
- Operating system: Ubuntu 22.04 LTS
To do this, follow these steps:
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.
Run the following command to create a VM:
yc compute instance create \
--cloud-id <cloud_ID> \
--folder-id <folder_ID> \
--zone <availability_zone> \
--name <VM_name> \
--platform standard-v3 \
--cores 64 \
--memory 704 \
--host-group-id <dedicated_host_group_ID> \
--network-interface subnet-id=<subnet_ID> \
--attach-local-disk "size=3198924357632" \
--attach-local-disk "size=3198924357632" \
--ssh-key <path_to_public_SSH_key_file> \
--create-boot-disk name=boot-disk,size=1000,image-folder-id=standard-images,image-family=ubuntu-2204-lts
Where:
--cloud-id
: Cloud ID.--folder-id
: Folder ID.--zone
: Availability zone where the group of dedicated hosts resides.--name
: VM name.--platform
: VM platform.--cores
: Number of vCPUs.--memory
: Amount of RAM.--host-group-id
: ID of the dedicated host group.--network-interface
: VM network interface description:subnet-id
: ID of the subnet in the availability zone hosting the VM.
--attach-local-disk
: Description of the local disk being attached:size
: Disk size.
--ssh-key
: Public SSH key path. The VM will automatically create a user namedyc-user
for this key.--create-boot-disk
: Boot disk parameters.
Result:
done (20s)
id: fhmbdt1jj2k3********
folder_id: m4n56op78mev********
created_at: "2023-01-16T12:46:50Z"
zone_id: ru-central1-a
...
placement_policy:
host_affinity_rules:
- key: yc.hostGroupId
op: IN
values:
- abcdefg1hi23********
Intel is a trademark of Intel Corporation or its subsidiaries.