- Pre-install packages and system dependencies
- Prepare versioned images for repeated VM creation
- Standardize environments across teams or workloads
Before you start
- Install Packer.
-
Make sure your project has sufficient quotas for image creation:
- Number of images
- Total storage capacity of all images
-
Set up authentication by using one of the following methods.
-
Service account
-
Create a service account and generate a key pair.
The key pair is saved to a JSON file, for example,
~/.nebius/<service_account_ID>_credentials.json. -
Open the file and copy the value of the
private_keyfield. -
Save the key to the
private.pemfile: - Use the values from the JSON file in your Packer configuration.
-
Create a service account and generate a key pair.
The key pair is saved to a JSON file, for example,
-
Access token
Generate an access token:
An access token is valid for 12 hours. After it expires, create a new one.
-
Service account
Steps
Install the Nebius Packer plug-in
-
Create the
config.pkr.hclfile and add the Nebius plug-in configuration: -
Initialize the plug-in in the directory that contains your Packer configuration files:
Build the disk image
The Nebius image builder creates a VM from a base image, provisions it over SSH and publishes a new image.-
Create the
build.pkr.hclfile and add thenebius-imagesource to it:Thenebius-imagesource has the following parameters: General parameterscommunicator(optional): Specifies how Packer connects to the VM. Supported value:ssh(default).parent_id: ID of the project where the resulting image will be created.ssh_username: Username used to connect to the VM.
service_account.private_key_file: Path to the private key file.service_account.public_key_id: ID of the public key.service_account.account_id: Service account ID.token: Access token used for authentication. Use this as an alternative toservice_account.
disk.size_gibibytes: Size of the disk in GiB.
base_image.family: Image family name.base_image.id: Specific image ID.
network.subnet_id(optional): ID of an existing subnet that will be used to create a VM. If not provided, the plug-in attempts to find the project’s default network.network.associate_public_ip_address(optional): Assigns a public IP address. Use a public IP if your build environment connects directly via SSH.
instance.platform: VM platform.instance.preset: VM platform preset (number of GPUs and vCPUs, RAM size).
image.name: Image name.image.version(optional): Image version.image.image_family(optional): Image family identifier.image.image_family_human_readable(optional): Display name for the image family.image.cpu_architecture(optional): CPU architecture.
-
Add the build block to the
build.pkr.hclfile: -
From the directory with the configuration files, run:
Check the image
- In the web console, go to
Storage → Disks.
- Go to the Images tab and locate your image.
Example: CUDA® 13.1 image
The following example builds an image with CUDA 13.1 from a driverless image. It uses a single configuration file that includes both the plug-in and build configuration.file and shell provisioners are used to copy files to the VM and execute commands during the build. Create your own scripts depending on the software and configuration you want to include in the image.