### Creating Test Environment Source: https://github.com/deckhouse/virtualization/blob/main/test/performance/README.md This example demonstrates the steps to set up a test environment, including creating a namespace, applying resources, and starting monitoring and stress testing tools. ```bash # 1. Create namespace kubectl create namespace perf # 2. Create 50 VMs with disks task apply COUNT=50 NAMESPACE=perf # 3. Start monitoring cd tools/statistic && task run # 4. Start stress testing cd tools/shatal && task run ``` -------------------------------- ### Automate Agent Installation with Cloud-Init Source: https://github.com/deckhouse/virtualization/blob/main/docs/USER_GUIDE.md Example cloud-config script to automate agent installation and service activation. ```yaml #cloud-config package_update: true packages: - qemu-guest-agent runcmd: - systemctl enable --now qemu-guest-agent.service ``` -------------------------------- ### Configure virtual disk templates with reclaim policies Source: https://github.com/deckhouse/virtualization/blob/main/docs/USER_GUIDE.md Examples demonstrating ephemeral disk setup, reusable disks with retention limits, and indefinitely retained disks. ```yaml # Ephemeral disk: removed with the replica (Delete is the default). - name: root spec: persistentVolumeClaim: { size: 30Gi } dataSource: { type: ObjectRef, objectRef: { kind: VirtualImage, name: ubuntu } } # Reusable disk: keep 3 warm for fast scale-up, collect the rest after 1h idle. - name: cache reclaim: onScaleDown: Retain keep: 3 ttl: 1h spec: persistentVolumeClaim: { size: 100Gi } # Reusable disk kept indefinitely: reused forever, never auto-collected (no ttl). - name: data reclaim: onScaleDown: Retain spec: persistentVolumeClaim: { size: 20Gi } ``` -------------------------------- ### Install qemu-guest-agent Source: https://github.com/deckhouse/virtualization/blob/main/docs/FAQ.md Install the guest agent package based on the Linux distribution. ```bash yum install -y qemu-guest-agent ``` ```bash apt-get update apt-get install -y qemu-guest-agent ``` -------------------------------- ### Start Virtual Machine Source: https://github.com/deckhouse/virtualization/blob/main/src/cli/README.md Start a virtual machine, optionally waiting for the process to complete. ```shell d8 v start myvm.mynamespace --wait d8 v start myvm -n mynamespace ``` -------------------------------- ### Storage Classes Output Example Source: https://github.com/deckhouse/virtualization/blob/main/docs/USER_GUIDE.md Example output showing storage class details including provisioner, reclaim policy, and volume binding mode. ```txt NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE rv-thin-r1 (default) replicated.csi.storage.deckhouse.io Delete Immediate true 48d rv-thin-r2 replicated.csi.storage.deckhouse.io Delete Immediate true 48d nfs-4-1-wffc nfs.csi.k8s.io Delete WaitForFirstConsumer true 30d ``` -------------------------------- ### Enable and start qemu-guest-agent Source: https://github.com/deckhouse/virtualization/blob/main/docs/FAQ.md Ensure the guest agent service is active. ```bash systemctl enable qemu-guest-agent systemctl start qemu-guest-agent ``` -------------------------------- ### Install packages and services via Cloud-Init Source: https://github.com/deckhouse/virtualization/blob/main/docs/USER_GUIDE.md Updates package lists, installs software, and enables system services on first boot. ```yaml #cloud-config package_update: true packages: - nginx - qemu-guest-agent runcmd: - systemctl daemon-reload - systemctl enable --now nginx.service - systemctl enable --now qemu-guest-agent.service ``` -------------------------------- ### View USBDevice output example Source: https://github.com/deckhouse/virtualization/blob/main/docs/USER_GUIDE.md Example output showing the status of USB devices within a namespace. ```console NAME NODE MANUFACTURER PRODUCT SERIAL ATTACHED AGE logitech-webcam node-2 Logitech Webcam C920 ABC123456 False 10m ``` -------------------------------- ### View NodeUSBDevice output example Source: https://github.com/deckhouse/virtualization/blob/main/docs/USER_GUIDE.md Example output showing the status of discovered USB devices. ```console NAME NODE READY ASSIGNED NAMESPACE AGE usb-flash-drive node-1 True False 10m logitech-webcam node-2 True True my-project 15m ``` -------------------------------- ### Disk size output example Source: https://github.com/deckhouse/virtualization/blob/main/docs/USER_GUIDE.md Example output showing the capacity of a virtual disk. ```txt NAME PHASE CAPACITY AGE linux-vm-root Ready 10Gi 10m ``` -------------------------------- ### Provisioning status output Source: https://github.com/deckhouse/virtualization/blob/main/docs/USER_GUIDE.md Example output showing the progression of a VirtualImage through the Provisioning phase. ```txt NAME PHASE CDROM PROGRESS AGE ubuntu-24-04 Provisioning false 4s ubuntu-24-04 Provisioning false 0.0% 4s ubuntu-24-04 Provisioning false 28.2% 6s ubuntu-24-04 Provisioning false 66.5% 8s ubuntu-24-04 Provisioning false 100.0% 10s ubuntu-24-04 Provisioning false 100.0% 16s ubuntu-24-04 Ready false 100% 18s ``` -------------------------------- ### Create a VirtualMachine resource Source: https://github.com/deckhouse/virtualization/blob/main/docs/USER_GUIDE.md Deploys a VirtualMachine using the d8 CLI with a specified cloud-init configuration for user setup and package installation. ```yaml d8 k apply -f - < en-US 0409:00000409 en-US en-US en-US E:\amd64\w11 E:\NetKVM\w11\amd64 0 true 1 Primary 250 2 EFI ``` -------------------------------- ### Enable Virtualization Module Configuration Source: https://github.com/deckhouse/virtualization/blob/main/README.md Example ModuleConfig to enable the virtualization module. Specifies DVCR storage size and virtual machine CIDRs. Enabling this module may restart kubelet/containerd. ```yaml apiVersion: deckhouse.io/v1alpha1 kind: ModuleConfig metadata: name: virtualization spec: enabled: true settings: dvcr: storage: persistentVolumeClaim: size: 50G # size of DVCR storage type: PersistentVolumeClaim virtualMachineCIDRs: - 10.66.10.0/24 - 10.66.20.0/24 - 10.66.30.0/24 version: 1 ``` -------------------------------- ### Configure memory and per-core memory sizing Source: https://github.com/deckhouse/virtualization/blob/main/docs/ADMIN_GUIDE.md Examples of setting fixed memory ranges versus per-core memory scaling within a sizing policy. ```yaml - cores: min: 1 max: 4 memory: min: 2Gi max: 8Gi ``` ```yaml - cores: min: 1 max: 4 memory: perCore: min: 1Gi max: 2Gi ``` -------------------------------- ### VirtualMachine status output Source: https://github.com/deckhouse/virtualization/blob/main/docs/USER_GUIDE.md Example output showing the phase, node assignment, and IP address of a running virtual machine. ```txt NAME PHASE NODE IPADDRESS AGE linux-vm Running virtlab-pt-2 10.66.10.12 11m ``` -------------------------------- ### Windows Answer File XML Configuration Source: https://github.com/deckhouse/virtualization/blob/main/docs/FAQ.md XML configuration for disk partitioning, image installation, and system setup commands. Ensure the structure matches the required Windows deployment schema. ```xml 100 3 MSR 128 4 Primary true 1 1 NTFS de94bba4-06d1-4d40-a16a-bfd50179d6ac 2 2 FAT32 3 4 C NTFS OnError 0 4 VK7JG-NPHTM-C97JM-9MPGT-3V66T OnError true false 1 powershell.exe -NoProfile -Command "$xml = [xml]::new(); $xml.Load('C:\Windows\Panther\unattend.xml'); $sb = [scriptblock]::Create( $xml.unattend.Extensions.ExtractScript ); Invoke-Command -ScriptBlock $sb -ArgumentList $xml;" 2 powershell.exe -NoProfile -Command "Get-Content -LiteralPath 'C:\Windows\Setup\Scripts\Specialize.ps1' -Raw | Invoke-Expression;" 3 reg.exe load "HKU\DefaultUser" "C:\Users\Default\NTUSER.DAT" 4 powershell.exe -NoProfile -Command "Get-Content -LiteralPath 'C:\Windows\Setup\Scripts\DefaultUser.ps1' -Raw | Invoke-Expression;" 5 reg.exe unload "HKU\DefaultUser" 0409:00000409 en-US en-US en-US cloud cloud Administrators cloud true</PlainText> </Password> </LocalAccount> <LocalAccount wcm:action="add"> <Name>User</Name> <DisplayName>user</DisplayName> <Group>Users</Group> <Password> <Value>user</Value> <PlainText>true</PlainText> </Password> </LocalAccount> ``` -------------------------------- ### Verify QEMU Guest Agent Version Source: https://github.com/deckhouse/virtualization/blob/main/docs/USER_GUIDE.md Check the installed version of the QEMU Guest Agent within the guest OS. ```bash qemu-guest-agent --version ``` -------------------------------- ### Configure Windows XP Virtual Machine Source: https://github.com/deckhouse/virtualization/blob/main/docs/USER_GUIDE.md Example configuration for a legacy Windows XP virtual machine requiring BIOS and disabled paravirtualization. ```yaml spec: osType: Legacy bootloader: BIOS enableParavirtualization: false # other parameters... ``` -------------------------------- ### Install Caddy and DVCR in Remote Cluster Source: https://github.com/deckhouse/virtualization/blob/main/images/virtualization-artifact/DEVELOPMENT.md Task to install Caddy and DVCR components into a remote cluster. ```bash task dev:up:remote ``` -------------------------------- ### Define VirtualMachineClass Sizing Policy Source: https://github.com/deckhouse/virtualization/blob/main/docs/USER_GUIDE.md Example configuration for defining core ranges, memory limits, and allowed core fractions within a VirtualMachineClass. ```yaml spec: sizingPolicies: - cores: min: 1 max: 4 memory: min: 1Gi max: 8Gi coreFractions: [5, 10, 20, 50, 100] - cores: min: 5 max: 8 memory: min: 5Gi max: 16Gi coreFractions: [20, 50, 100] ``` -------------------------------- ### Example Branch Names Source: https://github.com/deckhouse/virtualization/blob/main/CONTRIBUTING.md Examples of branch names that adhere to the project's naming conventions. These illustrate the correct structure for feature and chore branches. ```text feat/disks/support-new-image-source ``` ```text chore/ci/speed-up-builds ``` -------------------------------- ### Create a disk snapshot via CLI Source: https://github.com/deckhouse/virtualization/blob/main/docs/USER_GUIDE.md Use the d8 k apply command to create a VirtualDiskSnapshot resource with consistency enabled. ```bash d8 k apply -f - <<EOF apiVersion: virtualization.deckhouse.io/v1alpha2 kind: VirtualDiskSnapshot metadata: name: linux-vm-root-$(date +%s) spec: requiredConsistency: true virtualDiskName: linux-vm-root EOF ``` -------------------------------- ### Prepare image for container registry Source: https://github.com/deckhouse/virtualization/blob/main/docs/ADMIN_GUIDE.md Steps to download, package, and push an image to a container registry. ```bash curl -L https://cloud-images.ubuntu.com/minimal/releases/noble/release/ubuntu-24.04-minimal-cloudimg-amd64.img -o ubuntu2404.img ``` ```Dockerfile FROM scratch COPY ubuntu2404.img /disk/ubuntu2404.img ``` ```bash docker build -t docker.io/<username>/ubuntu2404:latest ``` ```bash docker push docker.io/<username>/ubuntu2404:latest ``` -------------------------------- ### Example Commit Messages Source: https://github.com/deckhouse/virtualization/blob/main/CONTRIBUTING.md Illustrative examples of commit messages adhering to the project's conventions. These demonstrate the correct usage of type, scope, and subject. ```text feat(api): bump resource version to v1beta1 ``` ```text feat(images): implement ImageLost phase ``` ```text feat(images, vi): add PVC as a storage ``` ```text fix(vm, vmclass): fix unsupported type of class ``` ```text refactor(core): rename 3rd party resources ``` ```text docs(module): describe how to install module ``` ```text chore(core): use alt linux as base image ``` ```text chore: update go dependencies ``` -------------------------------- ### Pull Request Naming Convention Example Source: https://github.com/deckhouse/virtualization/blob/main/CONTRIBUTING.md Examples of pull request titles that clearly reflect the changes introduced, following a conventional commit message format. ```text feat(vm): add live migration capability ``` ```text docs(api): update REST API documentation for clarity ``` -------------------------------- ### Create VirtualImage or ClusterVirtualImage Source: https://github.com/deckhouse/virtualization/blob/main/docs/FAQ.md Register the prepared disk as a VirtualImage or ClusterVirtualImage resource. ```bash d8 k apply -f -<<EOF apiVersion: virtualization.deckhouse.io/v1alpha2 kind: VirtualImage metadata: name: <image-name> namespace: <namespace> spec: dataSource: type: ObjectRef objectRef: kind: VirtualDisk name: <source-disk-name> EOF ``` ```bash d8 k apply -f -<<EOF apiVersion: virtualization.deckhouse.io/v1alpha2 kind: ClusterVirtualImage metadata: name: <image-name> spec: dataSource: type: ObjectRef objectRef: kind: VirtualDisk name: <source-disk-name> namespace: <namespace> EOF ``` -------------------------------- ### PVC-based VirtualImage status output Source: https://github.com/deckhouse/virtualization/blob/main/docs/USER_GUIDE.md Example output for a VirtualImage stored in a PVC. ```txt NAME PHASE CDROM PROGRESS AGE ubuntu-24-04-pvc Ready false 100% 23h ``` -------------------------------- ### Run Evicter Migration Tool Source: https://github.com/deckhouse/virtualization/blob/main/test/performance/README.md Execute the Evicter tool with specified target percentage, duration, and namespace for continuous VM migration. ```bash ./evicter --target=20 --duration=1h --ns=perf ``` -------------------------------- ### Delete NodeGroupConfiguration manifest Source: https://github.com/deckhouse/virtualization/blob/main/docs/FAQ.md Remove the temporary manifest after the registry module has successfully started. ```bash d8 k delete -f containerd-dvcr-remove-old-config.yaml ``` -------------------------------- ### Basic Deployment and Cleanup Tasks Source: https://github.com/deckhouse/virtualization/blob/main/test/performance/README.md Use these tasks for initial resource creation and subsequent removal. COUNT specifies the number of resources to create. ```bash task apply:all COUNT=30 ``` ```bash task destroy:all ``` -------------------------------- ### Check Ready Conditions Source: https://github.com/deckhouse/virtualization/blob/main/docs/USER_GUIDE.md Use this command to identify resources blocking a VM from transitioning out of the Pending phase. ```bash d8 k get vm <vm-name> -o json | jq '.status.conditions[] | select(.type | test(".*Ready"))' ``` -------------------------------- ### Trace image creation process Source: https://github.com/deckhouse/virtualization/blob/main/docs/ADMIN_GUIDE.md Monitor the provisioning progress of an image in real-time. ```bash d8 k get cvi ubuntu-24-04 -w ``` ```console NAME PHASE CDROM PROGRESS AGE ubuntu-24-04 Provisioning false 4s ubuntu-24-04 Provisioning false 0.0% 4s ubuntu-24-04 Provisioning false 28.2% 6s ubuntu-24-04 Provisioning false 66.5% 8s ubuntu-24-04 Provisioning false 100.0% 10s ubuntu-24-04 Provisioning false 100.0% 16s ubuntu-24-04 Ready false 100% 18s ``` -------------------------------- ### Verify default class assignment Source: https://github.com/deckhouse/virtualization/blob/main/docs/ADMIN_GUIDE.md Example output confirming the default class has been updated. ```console $ d8 k get vmclass NAME PHASE ISDEFAULT AGE generic Ready 1d host-passthrough-custom Ready true 1d ``` -------------------------------- ### Initialize disk for upload Source: https://github.com/deckhouse/virtualization/blob/main/docs/USER_GUIDE.md Create a VirtualDisk resource with the Upload data source type to prepare for manual data transfer. ```yaml d8 k apply -f - <<EOF apiVersion: virtualization.deckhouse.io/v1alpha2 kind: VirtualDisk metadata: name: uploaded-disk spec: dataSource: type: Upload EOF ``` -------------------------------- ### Start DVCR deployment Source: https://github.com/deckhouse/virtualization/blob/main/docs/FAQ.md Scales the DVCR deployment back to one replica after storage changes. ```shell d8 k -n d8-virtualization scale deployment dvcr --replicas=1 ``` -------------------------------- ### Configure disk, filesystem, and mounts via cloud-config Source: https://github.com/deckhouse/virtualization/blob/main/docs/FAQ.md Automate disk partitioning, filesystem creation, and mounting of secondary storage devices. ```yaml #cloud-config # Disk partitioning setup disk_setup: /dev/sdb: # Disk device table_type: gpt # Partition table type (gpt or mbr) layout: true # Automatically create partitions overwrite: false # Do not overwrite existing partitions # Filesystem setup fs_setup: - label: data # Filesystem label filesystem: ext4 # Filesystem type device: /dev/sdb1 # Partition device partition: auto # Automatically detect partition # Filesystem mounting mounts: # [device, mount_point, fs_type, options, dump, pass] - ["/dev/sdb1", "/mnt/data", "ext4", "defaults", "0", "2"] ``` -------------------------------- ### Example output for attachment status Source: https://github.com/deckhouse/virtualization/blob/main/docs/USER_GUIDE.md Shows the expected output format when checking the status of an attachment. ```console NAME PHASE VIRTUAL MACHINE NAME AGE attach-blank-disk Attached linux-vm 3m7s ``` -------------------------------- ### Disable Paravirtualization Source: https://github.com/deckhouse/virtualization/blob/main/docs/USER_GUIDE.md Example configuration snippet for disabling paravirtualization to use standard device emulation. ```yaml spec: enableParavirtualization: false # other parameters... ``` -------------------------------- ### Create VirtualMachine with cloud-init Source: https://github.com/deckhouse/virtualization/blob/main/docs/USER_GUIDE.md Deploys a VirtualMachine with specified CPU/memory resources and a cloud-init UserData configuration, attaching a previously created VirtualDisk. ```yaml 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: "$6$rounds=4096$saltsalt$fPmUsbjAuA7mnQNTajQM6ClhesyG0.yyQhvahas02ejfMAq1ykBo1RquzS0R6GgdIDlvS.kbUwDablGZKZcTP/" shell: /bin/bash sudo: ALL=(ALL) NOPASSWD:ALL lock_passwd: False blockDeviceRefs: - kind: VirtualDisk name: linux-disk EOF ``` -------------------------------- ### Specify VirtualMachineClass in VM manifest Source: https://github.com/deckhouse/virtualization/blob/main/docs/ADMIN_GUIDE.md Example of referencing a VirtualMachineClass by name within a VirtualMachine specification. ```yaml apiVersion: virtualization.deckhouse.io/v1alpha2 kind: VirtualMachine metadata: name: linux-vm spec: virtualMachineClassName: generic # VirtualMachineClass resource name. ... ``` -------------------------------- ### Bootstrap Local Cluster Source: https://github.com/deckhouse/virtualization/blob/main/images/virtualization-artifact/DEVELOPMENT.md Use the task utility to bootstrap the local development cluster. ```bash task dev:up ``` -------------------------------- ### Define default storage class settings Source: https://github.com/deckhouse/virtualization/blob/main/test/e2e/README.md Example configuration for the default cluster storage class. ```yaml settings: defaultClusterStorageClass: linstor-thin-r1 ``` -------------------------------- ### Get Virtualization Resources Source: https://github.com/deckhouse/virtualization/blob/main/images/virtualization-artifact/DEVELOPMENT.md Check the status of VirtualMachine, VirtualDisk, and ClusterVirtualImage resources in the 'vm' namespace. ```bash kubectl -n vm get virtualization NAME PHASE virtualmachine.virtualization.deckhouse.io/linux-vm Running NAME CAPACITY PHASE PROGRESS virtualdisk.virtualization.deckhouse.io/linux-disk 10Gi Ready NAME CDROM PHASE PROGRESS clustervirtualimage.virtualization.deckhouse.io/linux-iso false Ready ``` -------------------------------- ### Define VirtualMachine with SysprepRef Source: https://github.com/deckhouse/virtualization/blob/main/docs/FAQ.md YAML configuration for a VirtualMachine resource that utilizes a Sysprep secret for automated installation. ```yaml apiVersion: virtualization.deckhouse.io/v1alpha2 kind: VirtualMachine metadata: name: win-vm namespace: default labels: vm: win spec: virtualMachineClassName: generic provisioning: type: SysprepRef sysprepRef: kind: Secret name: sysprep-config runPolicy: AlwaysOn osType: Windows bootloader: EFI cpu: cores: 6 coreFraction: 50% memory: size: 8Gi enableParavirtualization: true blockDeviceRefs: - kind: VirtualDisk name: win-disk - kind: ClusterVirtualImage name: win-11-iso - kind: ClusterVirtualImage name: win-virtio-iso ``` -------------------------------- ### Create ClusterVirtualImage resources for ISOs Source: https://github.com/deckhouse/virtualization/blob/main/docs/FAQ.md Defines external ISO sources for the Windows installer and VirtIO drivers. ```yaml apiVersion: virtualization.deckhouse.io/v1alpha2 kind: ClusterVirtualImage metadata: name: win-11-iso spec: dataSource: type: HTTP http: url: "http://example.com/win11.iso" ``` ```yaml apiVersion: virtualization.deckhouse.io/v1alpha2 kind: ClusterVirtualImage metadata: name: win-virtio-iso spec: dataSource: type: HTTP http: url: "https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso" ``` -------------------------------- ### Utility Tasks for Project Management Source: https://github.com/deckhouse/virtualization/blob/main/test/performance/README.md These tasks assist in managing the project, from previewing configurations to installing dependencies. ```bash task render ``` ```bash task help ``` ```bash task check_or_install_software ``` -------------------------------- ### Build and Run with New Changes Source: https://github.com/deckhouse/virtualization/blob/main/images/virtualization-artifact/DEVELOPMENT.md Build and deploy your latest changes to the local cluster using the task utility. ```bash task dev:converge ``` -------------------------------- ### Node USB Device Status Output Source: https://github.com/deckhouse/virtualization/blob/main/docs/USER_GUIDE.md Example output showing the status and attributes of a NodeUSBDevice resource. ```console Name: logitech-webcam Namespace: Labels: <none> Annotations: <none> API Version: virtualization.deckhouse.io/v1alpha2 Kind: NodeUSBDevice Metadata: Creation Timestamp: 2024-01-15T10:30:00Z Generation: 1 UID: abc123-def456-ghi789 Spec: Assigned Namespace: my-project Status: Node Name: node-2 Attributes: Bus: 1 Device Number: 2 Manufacturer: Logitech Name: Webcam C920 Product: Webcam C920 Product ID: 082d Serial: ABC123456 Vendor ID: 046d Conditions: Type: Ready Status: True Reason: Ready Message: Device is ready to use Type: Assigned Status: True Reason: Assigned Message: Namespace is assigned for the device Observed Generation: 1 ```