This is a cache of https://docs.okd.io/4.13/virt/virtual_machines/virt-edit-vms.html. It is a snapshot of the page at 2024-11-27T01:26:25.108+0000.
Editing virtual machines - Virtual machines | Virtualization | OKD 4.13
×

Editing a virtual machine in the web console

You can edit a virtual machine by using the OKD web console or the command line interface.

Procedure
  1. Navigate to VirtualizationVirtualMachines in the web console.

  2. Select a virtual machine to open the VirtualMachine details page.

  3. Click any field that has the pencil icon, which indicates that the field is editable. For example, click the current Boot mode setting, such as BIOS or UEFI, to open the Boot mode window and select an option from the list.

  4. Click Save.

If the virtual machine is running, changes to Boot Order or Flavor will not take effect until you restart the virtual machine.

You can view pending changes by clicking View Pending Changes on the right side of the relevant field. The Pending Changes banner at the top of the page displays a list of all changes that will be applied when the virtual machine restarts.

Editing a virtual machine YAML configuration using the web console

You can edit the YAML configuration of a virtual machine in the web console. Some parameters cannot be modified. If you click Save with an invalid configuration, an error message indicates the parameter that cannot be changed.

Navigating away from the YAML screen while editing cancels any changes to the configuration you have made.

Procedure
  1. Click VirtualizationVirtualMachines from the side menu.

  2. Select a virtual machine.

  3. Click the YAML tab to display the editable configuration.

  4. Optional: You can click Download to download the YAML file locally in its current state.

  5. Edit the file and click Save.

A confirmation message shows that the modification has been successful and includes the updated version number for the object.

Editing a virtual machine YAML configuration using the CLI

Use this procedure to edit a virtual machine YAML configuration using the CLI.

Prerequisites
  • You configured a virtual machine with a YAML object configuration file.

  • You installed the oc CLI.

Procedure
  1. Run the following command to update the virtual machine configuration:

    $ oc edit <object_type> <object_ID>
  2. Open the object configuration.

  3. Edit the YAML.

  4. If you edit a running virtual machine, you need to do one of the following:

    • Restart the virtual machine.

    • Run the following command for the new configuration to take effect:

      $ oc apply <object_type> <object_ID>

Adding a virtual disk to a virtual machine

Use this procedure to add a virtual disk to a virtual machine.

Procedure
  1. Click VirtualizationVirtualMachines from the side menu.

  2. Select a virtual machine to open the VirtualMachine details page.

  3. On the Configuration → Disks tab, click Add disk.

  4. Specify the Source, Name, Size, Type, Interface, and Storage Class.

    1. Optional: You can enable preallocation if you use a blank disk source and require maximum write performance when creating data volumes. To do so, select the Enable preallocation checkbox.

    2. Optional: You can clear Apply optimized StorageProfile settings to change the Volume Mode and Access Mode for the virtual disk. If you do not specify these parameters, the system uses the default values from the kubevirt-storage-class-defaults config map.

  5. Click Add.

If the virtual machine is running, the new disk is in the pending restart state and will not be attached until you restart the virtual machine.

The Pending Changes banner at the top of the page displays a list of all changes that will be applied when the virtual machine restarts.

To configure storage class defaults, use storage profiles. For more information, see Customizing the storage profile.

Storage fields

Name Selection Description

Source

Blank (creates PVC)

Create an empty disk.

Import via URL (creates PVC)

Import content via URL (HTTP or HTTPS endpoint).

Use an existing PVC

Use a PVC that is already available in the cluster.

Clone existing PVC (creates PVC)

Select an existing PVC available in the cluster and clone it.

Import via Registry (creates PVC)

Import content via container registry.

Container (ephemeral)

Upload content from a container located in a registry accessible from the cluster. The container disk should be used only for read-only filesystems such as CD-ROMs or temporary virtual machines.

Name

Name of the disk. The name can contain lowercase letters (a-z), numbers (0-9), hyphens (-), and periods (.), up to a maximum of 253 characters. The first and last characters must be alphanumeric. The name must not contain uppercase letters, spaces, or special characters.

Size

Size of the disk in GiB.

Type

Type of disk. Example: Disk or CD-ROM

Interface

Type of disk device. Supported interfaces are virtIO, SATA, and SCSI.

Storage Class

The storage class that is used to create the disk.

Advanced storage settings

The following advanced storage settings are optional and available for Blank, Import via URL, and Clone existing PVC disks. Before OKD Virtualization 4.11, if you do not specify these parameters, the system uses the default values from the kubevirt-storage-class-defaults config map. In OKD Virtualization 4.11 and later, the system uses the default values from the storage profile.

Use storage profiles to ensure consistent advanced storage settings when provisioning storage for OKD Virtualization.

To manually specify Volume Mode and Access Mode, you must clear the Apply optimized StorageProfile settings checkbox, which is selected by default.

Name Mode description Parameter Parameter description

Volume Mode

Defines whether the persistent volume uses a formatted file system or raw block state. Default is Filesystem.

Filesystem

Stores the virtual disk on a file system-based volume.

Block

Stores the virtual disk directly on the block volume. Only use Block if the underlying storage supports it.

Access Mode

Access mode of the persistent volume.

ReadWriteOnce (RWO)

Volume can be mounted as read-write by a single node.

ReadWriteMany (RWX)

Volume can be mounted as read-write by many nodes at one time.

This is required for some features, such as live migration of virtual machines between nodes.

ReadOnlyMany (ROX)

Volume can be mounted as read only by many nodes.

Adding a secret, config map, or service account to a virtual machine

You add a secret, config map, or service account to a virtual machine by using the OKD web console.

These resources are added to the virtual machine as disks. You then mount the secret, config map, or service account as you would mount any other disk.

If the virtual machine is running, changes do not take effect until you restart the virtual machine. The newly added resources are marked as pending changes at the top of the page.

Prerequisites
  • The secret, config map, or service account that you want to add must exist in the same namespace as the target virtual machine.

Procedure
  1. Click VirtualizationVirtualMachines from the side menu.

  2. Select a virtual machine to open the VirtualMachine details page.

  3. Click ConfigurationEnvironment.

  4. Click Add Config Map, secret or Service Account.

  5. Click Select a resource and select a resource from the list. A six character serial number is automatically generated for the selected resource.

  6. Optional: Click Reload to revert the environment to its last saved state.

  7. Click Save.

Verification
  1. On the VirtualMachine details page, click ConfigurationDisks and verify that the resource is displayed in the list of disks.

  2. Restart the virtual machine by clicking ActionsRestart.

You can now mount the secret, config map, or service account as you would mount any other disk.

Additional resources for config maps, secrets, and service accounts

Adding a network interface to a virtual machine

Use this procedure to add a network interface to a virtual machine.

Procedure
  1. Click VirtualizationVirtualMachines from the side menu.

  2. Select a virtual machine to open the VirtualMachine details page.

  3. On the Configuration → Network interfaces tab, click Add Network Interface.

  4. In the Add Network Interface window, specify the Name, Model, Network, Type, and MAC Address of the network interface.

  5. Click Add.

If the virtual machine is running, the new network interface is in the pending restart state and changes will not take effect until you restart the virtual machine.

The Pending Changes banner at the top of the page displays a list of all changes that will be applied when the virtual machine restarts.

Networking fields

Name Description

Name

Name for the network interface controller.

Model

Indicates the model of the network interface controller. Supported values are e1000e and virtio.

Network

List of available network attachment definitions.

Type

List of available binding methods. Select the binding method suitable for the network interface:

  • Default pod network: masquerade

  • Linux bridge network: bridge

  • SR-IOV network: SR-IOV

MAC Address

MAC address for the network interface controller. If a MAC address is not specified, one is assigned automatically.