$ oc edit vm <vm_name>
You can update a virtual machine (VM) configuration by using the OKD web console. You can update the YAML file or the VirtualMachine details page.
You can also edit a VM by using the command line.
To edit a VM to configure disk sharing by using virtual disks or LUN, see Configuring shared volumes for virtual machines.
You can edit a virtual machine (VM) by using the command line.
You installed the oc
CLI.
Obtain the virtual machine configuration by running the following command:
$ oc edit vm <vm_name>
Edit the YAML configuration.
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 vm <vm_name> -n <namespace>
You can add a virtual disk to a virtual machine (VM) by using the OKD web console.
Navigate to Virtualization → VirtualMachines in the web console.
Select a VM to open the VirtualMachine details page.
On the Disks tab, click Add disk.
Specify the Source, Name, Size, Type, Interface, and Storage Class.
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.
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.
Click Add.
If the VM is running, you must restart the VM to apply the change. |
Field | Description |
---|---|
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 ( |
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. |
The following advanced storage settings are optional and available for Blank, Import via URL, and Clone existing PVC disks.
If you do not specify these parameters, the system uses the default storage profile values.
Parameter | Option | Parameter description | |
---|---|---|---|
Volume Mode |
Filesystem |
Stores the virtual disk on a file system-based volume. |
|
Block |
Stores the virtual disk directly on the block volume. Only use |
||
Access Mode |
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.
|
You can mount a Windows driver disk on a virtual machine (VM) by using the OKD web console.
Navigate to Virtualization → VirtualMachines.
Select the required VM to open the VirtualMachine details page.
On the Configuration tab, click Storage.
Select the Mount Windows drivers disk checkbox.
The Windows driver disk is displayed in the list of mounted disks.
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.
The secret, config map, or service account that you want to add must exist in the same namespace as the target virtual machine.
Click Virtualization → VirtualMachines from the side menu.
Select a virtual machine to open the VirtualMachine details page.
Click Configuration → Environment.
Click Add Config Map, Secret or Service Account.
Click Select a resource and select a resource from the list. A six character serial number is automatically generated for the selected resource.
Optional: Click Reload to revert the environment to its last saved state.
Click Save.
On the VirtualMachine details page, click Configuration → Disks and verify that the resource is displayed in the list of disks.
Restart the virtual machine by clicking Actions → Restart.
You can now mount the secret, config map, or service account as you would mount any other disk.