This section walks through a minimal scenario: you create an Ubuntu 24.04 image, a disk from that image, and a virtual machine (VM), connect to it over the console, and then delete the created resources.
- Using the CLI
- Using the web interface
-
Create a VirtualImage from an external source:
d8 k apply -f - <<EOF apiVersion: virtualization.deckhouse.io/v1alpha2 kind: VirtualImage metadata: name: ubuntu spec: storage: ContainerRegistry dataSource: type: HTTP http: url: https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img EOF -
Create a VirtualDisk from that image. Make sure the cluster has a default StorageClass, then apply the manifest:
d8 k apply -f - <<EOF apiVersion: virtualization.deckhouse.io/v1alpha2 kind: VirtualDisk metadata: name: linux-disk spec: dataSource: type: ObjectRef objectRef: kind: VirtualImage name: ubuntu EOF -
Create a VirtualMachine. The example uses a cloud-init script that creates the
clouduser:d8 k apply -f - <<EOF apiVersion: virtualization.deckhouse.io/v1alpha2 kind: VirtualMachine metadata: name: linux-vm spec: virtualMachineClassName: generic cpu: cores: 1 memory: size: 1Gi provisioning: type: UserData userData: | #cloud-config ssh_pwauth: True users: - name: cloud passwd: <PASSWORD_HASH> shell: /bin/bash sudo: ALL=(ALL) NOPASSWD:ALL lock_passwd: False blockDeviceRefs: - kind: VirtualDisk name: linux-disk EOFWhere
<PASSWORD_HASH>is the hash of the user password, in quotes. Generate it withmkpasswd --method=SHA-512 --rounds=4096: the command prompts for the password and prints the ready value. The script format is described in the cloud-init documentation. -
Verify that the image and the disk are created and the VM is running. Resources don’t become ready instantly, so wait for the expected values in the
PHASEcolumn:d8 k get vi,vd,vmExample output:
NAME PHASE CDROM PROGRESS AGE virtualimage.virtualization.deckhouse.io/ubuntu Ready false 100% 7h50m NAME PHASE CAPACITY VIRTUALMACHINE AGE virtualdisk.virtualization.deckhouse.io/linux-disk Ready 4Gi linux-vm 7h40m NAME PHASE UPTIME NODE IPADDRESS AGE virtualmachine.virtualization.deckhouse.io/linux-vm Running 7h30m virtlab-pt-2 10.66.10.2 7h46m -
Connect to the VM over the console:
d8 v console linux-vmExample output:
Successfully connected to linux-vm console. The escape sequence is ^] linux-vm login: cloud Password: ... cloud@linux-vm:~$To exit the console, press
Ctrl+]. -
Delete the created resources:
d8 k delete vm linux-vm d8 k delete vd linux-disk d8 k delete vi ubuntu
-
Create an image from an external source:
- Go to the Projects tab and select the project you need.
- Go to Virtualization → Images.
- Click Create.
- In the Source block, select By link.
- In the form that opens, enter
ubuntuin the Image name field. - In the Storage block, select
ContainerRegistryin the Storage type field. - In the URL field, paste
https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img. - Click Create.
- Check the image status on its page.
-
Create a disk from that image. You can skip this step and create the disk while creating the VM.
- Go to Virtualization → Disks.
- Click Create.
- In the form that opens, enter
linux-diskin the Disk name field. - In the Source field, select the
ubuntuimage from the drop-down list. - If required, specify a larger size in the Size field, for example
5Gi. - In the Storage class field, select a StorageClass or keep the default one.
- Click Create.
- Check the disk status on its page.
If the selected StorageClass uses the
WaitForFirstConsumermode, the disk waits for the VM that uses it. Until then, the disk shows the “CREATING 0%” status, but you can already select it when creating a VM. -
Create a virtual machine:
- Go to Virtualization → Virtual machines.
- Click Create.
- In the form that opens, enter
linux-vmin the Name field. - In the Platform and Resources sections, keep the default settings.
-
In the Disks section, click Add.
If the disk is already created, select Existing in the Disks / Images window that opens and pick
linux-diskfrom the list.If the disk isn’t created, select Create from in the same window and set the parameters:
- In the Name field, enter
linux-disk. - In the Source field, select the
ubuntuimage from the drop-down list. The list shows the resource type. - If required, specify a larger size in the Size field, for example
5Gi. - In the Storage field, select a StorageClass or keep the default one.
Click Add.
- In the Name field, enter
- Scroll down to the Cloud-init toggle and enable it.
-
Paste the script into the field that appears, replacing
<PASSWORD_HASH>with the password hash in quotes, generated withmkpasswd --method=SHA-512 --rounds=4096:#cloud-config ssh_pwauth: True users: - name: cloud passwd: <PASSWORD_HASH> shell: /bin/bash sudo: ALL=(ALL) NOPASSWD:ALL lock_passwd: False - Click Create.
- Check the VM status on its page.
-
Connect to the VM over the console:
- Go to Virtualization → Virtual machines.
- Select the VM from the list and click its name.
- In the form that opens, go to the TTY tab and log in to the console window.
-
Delete the created resources:
- Go to Virtualization and select the section you need, for example Virtual machines, Disks, or Images.
- In the resource row, click the ellipsis button and select Delete. In some lists, for example in the list of VM snapshots, deletion is a separate button.
- In the confirmation window, click Delete or cancel the action with Don’t delete.
Important: Deleting a resource is irreversible. A disk attached to a running virtual machine can’t be deleted, and the Delete item is inactive for it.