Making a VM preemptible
You can create a preemptible VM or change the type of an existing one.
Creating a preemptible VM
To create a preemptible VM:
-
In the list of services in the management console
, select Compute Cloud. -
Click Create VM at the top right.
-
Under Basic parameters:
-
Enter a name for the VM. The naming requirements are as follows:
- The length can be from 3 to 63 characters.
- It may contain lowercase Latin letters, numbers, and hyphens.
- The first character must be a letter. The last character can't be a hyphen.
Note
The VM name is used to generate an internal FQDN only once: when creating a VM. If the internal FQDN is important to you, choose an appropriate name for the VM at the creation stage.
-
Select an availability zone to place your VM in.
-
-
Under Image/boot disk selection, select one of the images.
-
(Optional) Under Disks, select the Disks tab and configure a boot disk:
-
Select the disk type.
-
Specify the required disk size.
If you want to create a VM from an existing disk, under Disks, add a disk:
- Click Add disk.
- Enter the disk name.
- Select the disk type.
- Specify the desired disk size.
-
(Optional) Enable the Delete with the VM option if you need to automatically delete the disk when deleting the VM it will be attached to.
-
Select
Disk
as content. -
Click Add.
-
-
(Optional) Under Disks and file storages, select the File storages tab and attach the file storage:
- Click Attach file storage.
- In the window that opens, select a file store.
- Enter the device name.
- Click Attach file storage.
-
Under Computing resources:
- Choose a platform.
- Specify the required number of vCPUs, as well as the amount of RAM.
- Enable Preemptible.
-
Under Network settings:
- (Optional) Select the Public IP checkbox to assign the VM a public IP address.
-
Under Access, specify the information required to access the instance:
-
Enter the username in the Login field.
Alert
Do not use the
root
username or other names reserved by the operating system. To perform operations that require superuser permissions, use thesudo
command. -
In the SSH key field, paste the contents of the public key file.
In public Linux images provided by Nebius AI, the functionality of connecting over SSH using login and password is disabled by default.
-
-
Click Create VM.
The VM appears in the list.
If you don't have the Nebius AI 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 create VM command:
ncp compute instance create --help
-
Prepare a key pair (public and private keys) for SSH access to the VM.
-
Select a Linux-based public image from Nebius AI Marketplace, e.g., CentOS 7.
To get a list of available images using the Nebius AI CLI, run this command:
ncp compute image list --folder-id standard-images
Result:
+----------------------+-------------------------------------+--------------------------+----------------------+--------+ | ID | NAME | FAMILY | PRODUCT IDS | STATUS | +----------------------+-------------------------------------+--------------------------+----------------------+--------+ ... | fdvk34al8k5n******** | centos-7-1549279494 | centos-7 | dqni65lfhvv2den5gtv9 | READY | | fdv7ooobjfl3******** | windows-2016-gvlk-1548913814 | windows-2016-gvlk | dqnnc72gj2ist3ktjj1p | READY | | fdv4f5kv5cvf******** | ubuntu-1604-lts-1549457823 | ubuntu-1604-lts | dqnnb6dc7640c5i968ro | READY | ... +----------------------+-------------------------------------+--------------------------+----------------------+--------+
-
Create a VM:
ncp compute instance create \ --name first-preemptible-instance \ --zone eu-north1-c \ --network-interface subnet-name=default-eu-north1-c,nat-ip-version=ipv4 \ --preemptible \ --create-boot-disk image-folder-id=standard-images,image-family=centos-7 \ --ssh-key ~/.ssh/id_ed25519.pub
This command creates a preemptible VM with the following characteristics:
- Named
first-preemptible-instance
. - Running CentOS 7.
- In the
eu-north1-c
availability zone. - In the
default-a
subnet. - With a public IP address.
To create a VM without a public IP address, disable the
nat-ip-version=ipv4
option.VM naming requirements:
- The length can be from 3 to 63 characters.
- It may contain lowercase Latin letters, numbers, and hyphens.
- The first character must be a letter. The last character can't be a hyphen.
Note
The VM name is used to generate an internal FQDN only once: when creating a VM. If the internal FQDN is important to you, choose an appropriate name for the VM at the creation stage.
- Named
When a VM is created, it is assigned an IP address and hostname (FQDN). This data can be used for SSH access.
Changing a VM's type
To change the type of a VM, for example, make it preemptible:
- In the management console
, select the folder where the VM is located. - In the list of services, select Compute Cloud.
- In the line with the appropriate VM, click
- In the window that opens, click Stop. The VM status changes to
Stopped
. - In the line with the appropriate VM, click
- Under Computing resources, disable the Preemptible option.
- Click Save changes.
- At the top right, click Start.
- In the window that opens, click Start.
If you don't have the Nebius AI 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 stop a VM:
ncp compute instance stop --help
-
Get a list of all VMs in the default folder:
ncp compute instance list
Result:
+----------------------+-----------------+---------------+---------+ | ID | NAME | ZONE ID | STATUS | +----------------------+-----------------+---------------+--------- | fhm0b28lgfp4tkoa3jl6 | first-instance | eu-north1-c | RUNNING | | fhm9gk85nj7gcoji2f8s | second-instance | eu-north1-c | RUNNING | +----------------------+-----------------+---------------+---------
-
Select the VM
ID
orNAME
(for example,first-instance
). -
Stop the VM:
ncp compute instance stop <VM ID or name>
Result:
done (15s)
-
Edit the VM parameters:
ncp compute instance update <VM ID or name> \ --preemptible=false
Result:
done (1s) id: fhm0b28lgfp4tkoa3jl6 folder_id: b1ghgf288nvg541tgu73 ... network_settings: type: STANDARD placement_policy: {}
-
Start the VM again:
ncp compute instance start <VM ID or name>
Result:
done (11s) id: fhm0b28lgfp4tkoa3jl6 folder_id: b1ghgf288nvg541tgu73 ... network_settings: type: STANDARD placement_policy: {}