KubeVirt: Difference between revisions
| (17 intermediate revisions by the same user not shown) | |||
| Line 47: | Line 47: | ||
{{hidden | Example manifest | | {{hidden | Example manifest | | ||
<syntaxhighlight lang="yaml"> | <syntaxhighlight lang="yaml"> | ||
apiVersion: v1 | apiVersion: v1 | ||
kind: PersistentVolumeClaim | kind: PersistentVolumeClaim | ||
| Line 78: | Line 65: | ||
name: windows10vm | name: windows10vm | ||
spec: | spec: | ||
runStrategy: Manual | |||
template: | template: | ||
metadata: | metadata: | ||
| Line 93: | Line 80: | ||
devices: | devices: | ||
disks: | disks: | ||
- bootOrder: 1 | - name: cdrom | ||
bootOrder: 1 | |||
cdrom: | cdrom: | ||
bus: sata | bus: sata | ||
- name: maindrive | - name: maindrive | ||
bootOrder: | bootOrder: 2 | ||
disk: | disk: | ||
bus: virtio | bus: virtio | ||
- name: windows-guest-tools | - name: windows-guest-tools | ||
bootOrder: | bootOrder: 3 | ||
cdrom: | cdrom: | ||
bus: sata | bus: sata | ||
interfaces: | interfaces: | ||
- | - name: nic-0 | ||
model: | model: virtio | ||
masquerade: {} | |||
sound: | sound: | ||
name: audio | name: audio | ||
| Line 122: | Line 109: | ||
persistentVolumeClaim: | persistentVolumeClaim: | ||
claimName: windows10vm-pvc | claimName: windows10vm-pvc | ||
- containerDisk: | - name: windows-guest-tools | ||
containerDisk: | |||
image: quay.io/kubevirt/virtio-container-disk | image: quay.io/kubevirt/virtio-container-disk | ||
</syntaxhighlight> | </syntaxhighlight> | ||
}} | |||
==vGPU== | |||
===Intel GVT-g=== | |||
This is deprecated. Additionally, I don't recommend this due to [https://github.com/intel/gvt-linux/issues/153 stability issues]. | |||
{{hidden | Instructions | | |||
See [https://kubevirt.io/2021/intel-vgpu-kubevirt.html#fedora-workstation-prep intel-vgpu-kubevirt] and [[Archwiki:Intel GVT-g]]. | |||
;Setup the nodes | |||
Run the following on each node with an Intel GPU. | |||
<syntaxhighlight lang="bash"> | |||
# Enable kvmgt and iommu | |||
sudo sh -c "echo kvmgt > /etc/modules-load.d/gpu-kvmgt.conf" | |||
sudo sed -i 's/^GRUB_CMDLINE_LINUX_DEFAULT="/&intel_iommu=on i915.enable_gvt=1/' /etc/default/grub | |||
sudo update-grub | |||
sudo reboot | |||
# Check that kvmgt modules are loaded | |||
sudo lsmod | grep kvmgt | |||
# Create two vGPUs | |||
pci_id=$(sudo lspci | grep -oP '([\d:\.]+)(?=\sVGA)') | |||
uuid1=$(uuidgen) | |||
cat > ~/gvtg-enable.service << EOF | |||
[Unit] | |||
Description=Create Intel GVT-g vGPU | |||
[Service] | |||
Type=oneshot | |||
ExecStart=/bin/sh -c "echo '${uuid1}' > /sys/devices/pci0000:00/0000:${pci_id}/mdev_supported_types/i915-GVTg_V5_8/create" | |||
ExecStop=/bin/sh -c "echo '1' > /sys/devices/pci0000:00/0000:${pci_id}/${uuid1}/remove" | |||
RemainAfterExit=yes | |||
[Install] | |||
WantedBy=multi-user.target | |||
EOF | |||
sudo mv ~/gvtg-enable.service /etc/systemd/system/gvtg-enable.service | |||
sudo systemctl enable gvtg-enable --now | |||
</syntaxhighlight> | |||
Notes | |||
* There are two sizes of vGPU you can create: | |||
** <code>i915-GVTg_V5_4</code> supports up to 1920x1200 | |||
** <code>i915-GVTg_V5_8</code> supports up to 1024x768 | |||
** See <code>cat /sys/devices/pci0000:00/0000:00:02.0/mdev_supported_types/i915-GVTg_V5_8/description</code> to get a description of the vgpu. | |||
** On my nodes, I can create a single <code>i915-GVTg_V5_4</code> or two <code>i915-GVTg_V5_8</code> | |||
* See [[Archwiki:Intel GVT-g]] for details | |||
;Add GPU to your VMs | |||
<syntaxhighlight lang="yaml"> | |||
spec: | |||
template: | |||
spec: | |||
domain: | |||
devices: | |||
gpus: | |||
- deviceName: intel.com/U630 | |||
name: gpu1 | |||
virtualGPUOptions: | |||
display: | |||
enabled: false | |||
</syntaxhighlight> | |||
}} | |||
==Networking== | |||
===Bridge (Macvtap)=== | |||
This allows your VM to get an IP from the host network. | |||
# Install [https://github.com/k8snetworkplumbingwg/multus-cni multus-cni] | |||
# Enable macvtap [https://kubevirt.io/user-guide/operations/activating_feature_gates/#how-to-activate-a-feature-gate instructions] | |||
# Follow the remaining instructions [https://kubevirt.io/user-guide/virtual_machines/interfaces_and_networks/ here] | |||
==Resources== | ==Resources== | ||
* [https://kubevirt.io/api-reference/master/ KubeVirt API] | |||
* [https://kubevirt.io/2021/intel-vgpu-kubevirt.html#fedora-workstation-prep intel-vgpu-kubevirt] | * [https://kubevirt.io/2021/intel-vgpu-kubevirt.html#fedora-workstation-prep intel-vgpu-kubevirt] | ||