Tools installation
yum install targetcli sg3_utils
Create loopback scsi target
modprobe tcm_loop
mount -t configfs configfs /sys/kernel/config/
mkdir -p /disks
<domain type='kvm' id='1'> | |
<name>default_vm-fedora</name> | |
<uuid>c9dc132f-1bb1-5f88-9891-deed35a6d803</uuid> | |
<metadata> | |
<kubevirt xmlns="http://kubevirt.io"> | |
<uid>990631c2-166a-401d-90e6-7a19b5fb2f18</uid> | |
<graceperiod> | |
<deletionGracePeriodSeconds>0</deletionGracePeriodSeconds> | |
</graceperiod> | |
</kubevirt> |
#!/bin/bash | |
IMAGE="gcr.io/google-containers/ubuntu-slim:0.14" | |
COMMAND="/bin/bash" | |
SUFFIX=$(date +%s | shasum | base64 | fold -w 10 | head -1 | tr '[:upper:]' '[:lower:]') | |
usage_exit() { | |
echo "Usage: $0 [-c command] [-i image] PVC ..." 1>&2 | |
exit 1 | |
} |
$ kubectl get pvc | |
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE | |
pvc-test Bound local-pv-25a396e8 34Gi RWO local 52m | |
$ kubectl apply -f expose-pvc-nbd.yaml | |
service/virt configured | |
pod/virt configured | |
# In another console | |
$ kubectl port-forward pod/virt 8080:8080 | |
Handling connection for 8080 |
kubectl apply -f import-original-image.yaml | |
# Wait until the DV import has finished. Now you have imported the original image on your k8s cluster | |
# Modify the initial image with virt-customizee by using virtctl guestfs command. You can install additional packages or modify certain files | |
$ virtctl guestfs pvc-with-cloud-init | |
Use image: registry:5000/kubevirt/libguestfs-tools@sha256:4cfe1c07cc33999ed05bd43873b7a30b1b9127a4ae4922333e68a1bcd35169ce | |
The PVC has been mounted at /disk | |
If you don't see a command prompt, try pressing enter. | |
$ ls /disk/ | |
disk.img | |
virt-customize --run-command 'echo "My awesome image" > /tmp/hello' --install cloud-init -a /disk/disk.img |
apiVersion: kubevirt.io/v1 | |
kind: VirtualMachine | |
metadata: | |
labels: | |
kubevirt.io/vm: test-ign | |
name: test-ign | |
spec: | |
dataVolumeTemplates: | |
- metadata: | |
name: rhcos-dv |
Tools installation
yum install targetcli sg3_utils
Create loopback scsi target
modprobe tcm_loop
mount -t configfs configfs /sys/kernel/config/
mkdir -p /disks
1. Create a k8s cluster with DRA enabled. We use latest minikube (v1.30.1) as at the moment of writing this, it is only one of the few providing already k8s 1.27 | |
```bash | |
$ minikube start --driver=kvm2 --feature-gates=DynamicResourceAllocation=true \ | |
--kubernetes-version=v1.27.0-rc.0 \ | |
--extra-config=apiserver.runtime-config='resource.k8s.io/v1alpha2=true' | |
``` | |
2. Example: | |
```yaml | |
apiVersion: resource.k8s.io/v1alpha2 |