Skip to content

Commit

Permalink
Add new example VMI (vmi-kernel-boot) for testing
Browse files Browse the repository at this point in the history
Signed-off-by: Itamar Holder <[email protected]>
  • Loading branch information
iholder101 committed May 21, 2021
1 parent eead144 commit a941e54
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
23 changes: 23 additions & 0 deletions examples/vmi-kernel-boot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
apiVersion: kubevirt.io/v1
kind: VirtualMachineInstance
metadata:
labels:
special: vmi-kernel-boot
name: vmi-kernel-boot
spec:
domain:
devices: {}
firmware:
kernelBoot:
container:
image: registry:5000/kubevirt/alpine-ext-kernel-boot-demo:devel
initrdPath: /boot/initramfs-virt
kernelPath: /boot/vmlinuz-virt
kernelArgs: console=ttyS0
machine:
type: ""
resources:
requests:
memory: 1Gi
terminationGracePeriodSeconds: 0
33 changes: 33 additions & 0 deletions tools/vms-generator/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const (
VmiPVC = "vmi-pvc"
VmiBlockPVC = "vmi-block-pvc"
VmiWindows = "vmi-windows"
VmiKernelBoot = "vmi-kernel-boot"
VmiSlirp = "vmi-slirp"
VmiMasquerade = "vmi-masquerade"
VmiSRIOV = "vmi-sriov"
Expand Down Expand Up @@ -90,6 +91,7 @@ const (
imageCirros = "cirros-container-disk-demo"
imageFedora = "fedora-cloud-container-disk-demo"
imageMicroLiveCD = "microlivecd-container-disk-demo"
imageKernelBoot = "alpine-ext-kernel-boot-demo"
)
const windowsFirmware = "5d307ca9-b3ef-428c-8861-06e72d69f223"
const defaultInterfaceName = "default"
Expand Down Expand Up @@ -188,6 +190,23 @@ func addContainerDisk(spec *v1.VirtualMachineInstanceSpec, image string, bus str
return spec
}

func addKernelBootContainer(spec *v1.VirtualMachineInstanceSpec, image, kernelArgs, kernelPath, initrdPath string) *v1.VirtualMachineInstanceSpec {
if spec.Domain.Firmware == nil {
spec.Domain.Firmware = &v1.Firmware{}
}

spec.Domain.Firmware.KernelBoot = &v1.KernelBoot{
KernelArgs: kernelArgs,
Container: &v1.KernelBootContainer{
Image: image,
KernelPath: kernelPath,
InitrdPath: initrdPath,
},
}

return spec
}

func addNoCloudDisk(spec *v1.VirtualMachineInstanceSpec) *v1.VirtualMachineInstanceSpec {
return addNoCloudDiskWitUserData(spec, "#!/bin/sh\n\necho 'printed from cloud-init userdata'\n")
}
Expand Down Expand Up @@ -573,6 +592,20 @@ func GetVMIWindows() *v1.VirtualMachineInstance {
return vmi
}

func GetVMIKernelBoot() *v1.VirtualMachineInstance {
vmi := getBaseVMI(VmiKernelBoot)

image := fmt.Sprintf("%s/%s:%s", DockerPrefix, imageKernelBoot, DockerTag)
KernelArgs := "console=ttyS0"
kernelPath := "/boot/vmlinuz-virt"
initrdPath := "/boot/initramfs-virt"

addKernelBootContainer(&vmi.Spec, image, KernelArgs, kernelPath, initrdPath)

vmi.Spec.Domain.Resources.Requests[k8sv1.ResourceMemory] = resource.MustParse("1Gi")
return vmi
}

func getBaseVM(name string, labels map[string]string) *v1.VirtualMachine {
baseVMISpec := getBaseVMISpec()
running := false
Expand Down
1 change: 1 addition & 0 deletions tools/vms-generator/vms-generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ pciHostDevices:
utils.VmiHostDisk: utils.GetVMIHostDisk(),
utils.VmiGPU: utils.GetVMIGPU(),
utils.VmiMacvtap: utils.GetVMIMacvtap(),
utils.VmiKernelBoot: utils.GetVMIKernelBoot(),
}

var vmireplicasets = map[string]*v1.VirtualMachineInstanceReplicaSet{
Expand Down

0 comments on commit a941e54

Please sign in to comment.