KubeVirt: Difference between revisions
Line 40: | Line 40: | ||
====Loading ISOs into the cluster==== | ====Loading ISOs into the cluster==== | ||
====Windows==== | ====Windows==== | ||
* Deploy the example manifest below. | |||
* During the install, you will need to load the `viostor` driver. | |||
* After install, load the remaining drivers using device manager. | |||
* Then you can remove the ''cdrom'' and ''windows-guest-tools'' disks. | |||
{{hidden | Example manifest | | |||
<syntaxhighlight lang="yaml"> | |||
apiVersion: v1 | |||
kind: PersistentVolume | |||
metadata: | |||
name: windows10vm-pv | |||
spec: | |||
capacity: | |||
storage: 100Gi | |||
accessModes: | |||
- ReadWriteMany | |||
nfs: | |||
server: 192.168.1.44 | |||
path: "/media/mergerfs1/Services/kubernetes_services/vms/windows10vm/" | |||
--- | |||
apiVersion: v1 | |||
kind: PersistentVolumeClaim | |||
metadata: | |||
name: windows10vm-pvc | |||
spec: | |||
storageClassName: "" | |||
volumeName: windows10vm-pv | |||
accessModes: | |||
- ReadWriteMany | |||
resources: | |||
requests: | |||
storage: 100Gi | |||
--- | |||
apiVersion: kubevirt.io/v1alpha3 | |||
kind: VirtualMachine | |||
metadata: | |||
name: windows10vm | |||
spec: | |||
running: false | |||
template: | |||
metadata: | |||
labels: | |||
kubevirt.io/domain: win10vm1 | |||
spec: | |||
terminationGracePeriodSeconds: 300 | |||
domain: | |||
cpu: | |||
cores: 4 | |||
resources: | |||
requests: | |||
memory: 8G | |||
devices: | |||
disks: | |||
- bootOrder: 1 | |||
cdrom: | |||
bus: sata | |||
name: cdrom | |||
- name: maindrive | |||
bootOrder: 1 | |||
disk: | |||
bus: virtio | |||
- name: windows-guest-tools | |||
bootOrder: 2 | |||
cdrom: | |||
bus: sata | |||
interfaces: | |||
- masquerade: {} | |||
model: e1000e | |||
name: nic-0 | |||
sound: | |||
name: audio | |||
model: ich9 | |||
networks: | |||
- name: nic-0 | |||
pod: {} | |||
volumes: | |||
- name: cdrom | |||
persistentVolumeClaim: | |||
claimName: iso-win10 | |||
- name: maindrive | |||
persistentVolumeClaim: | |||
claimName: windows10vm-pvc | |||
- containerDisk: | |||
image: quay.io/kubevirt/virtio-container-disk | |||
name: windows-guest-tools | |||
</syntaxhighlight> | |||
==Resources== | ==Resources== | ||
* [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] |
Revision as of 19:51, 13 February 2022
KubeVirt lets you setup and manage virtual machines on your kubernetes cluster.
Getting Started
Background
KubeVirt creates two new types of resources on your cluster: VirtualMachine
(vm) and VirtualMachineInstance
(vmi).
VirtualMachine
defines how to create VMIs. VirtualMachineInstance
represent a running virtual machine.
Similar to deployments-pods, you will typically not create VirtualMachineInstance
manually.
Instead you define VirtualMachine
in your manifests and control them using virtctl
. Then KubeVirt will automatically create VirtualMachineInstance
.
Requirements
See requirements
- You need a kubernetes cluster with
kubectl
set up. - You do not need to install
qemu-kvm libvirt-daemon-system
on the nodes.
Install KubeVirt
See installation
Install commands
# Get the latest version string
export VERSION=$(curl -s https://api.github.com/repos/kubevirt/kubevirt/releases | grep tag_name | grep -v -- '-rc' | sort -r | head -1 | awk -F': ' '{print $2}' | sed 's/,//' | xargs)
echo $VERSION
# Deploy operator
kubectl create -f https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-operator.yaml
# Deploy custom resources
kubectl create -f https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-cr.yaml
# Install virtctl
VERSION=$(kubectl get kubevirt.kubevirt.io/kubevirt -n kubevirt -o=jsonpath="{.status.observedKubeVirtVersion}")
ARCH=$(uname -s | tr A-Z a-z)-$(uname -m | sed 's/x86_64/amd64/') || windows-amd64.exe
echo ${ARCH}
curl -L -o virtctl https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/virtctl-${VERSION}-${ARCH}
chmod +x virtctl
sudo install virtctl /usr/local/bin
Creating a VM
Loading ISOs into the cluster
Windows
- Deploy the example manifest below.
- During the install, you will need to load the `viostor` driver.
- After install, load the remaining drivers using device manager.
- Then you can remove the cdrom and windows-guest-tools disks.
{{hidden | Example manifest |
apiVersion: v1
kind: PersistentVolume
metadata:
name: windows10vm-pv
spec:
capacity:
storage: 100Gi
accessModes:
- ReadWriteMany
nfs:
server: 192.168.1.44
path: "/media/mergerfs1/Services/kubernetes_services/vms/windows10vm/"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: windows10vm-pvc
spec:
storageClassName: ""
volumeName: windows10vm-pv
accessModes:
- ReadWriteMany
resources:
requests:
storage: 100Gi
---
apiVersion: kubevirt.io/v1alpha3
kind: VirtualMachine
metadata:
name: windows10vm
spec:
running: false
template:
metadata:
labels:
kubevirt.io/domain: win10vm1
spec:
terminationGracePeriodSeconds: 300
domain:
cpu:
cores: 4
resources:
requests:
memory: 8G
devices:
disks:
- bootOrder: 1
cdrom:
bus: sata
name: cdrom
- name: maindrive
bootOrder: 1
disk:
bus: virtio
- name: windows-guest-tools
bootOrder: 2
cdrom:
bus: sata
interfaces:
- masquerade: {}
model: e1000e
name: nic-0
sound:
name: audio
model: ich9
networks:
- name: nic-0
pod: {}
volumes:
- name: cdrom
persistentVolumeClaim:
claimName: iso-win10
- name: maindrive
persistentVolumeClaim:
claimName: windows10vm-pvc
- containerDisk:
image: quay.io/kubevirt/virtio-container-disk
name: windows-guest-tools