kubevirt / common-templates

Templates for running VMs on KubeVirt
Apache License 2.0
71 stars 59 forks source link

Create a Template for Generic Linux OS #576

Open prabhulc opened 1 month ago

prabhulc commented 1 month ago

Is this a BUG REPORT or FEATURE REQUEST?: FEATURE REQUEST

Uncomment only one, leave it on its own line:

/kind bug /kind enhancement

What happened: I'd like to provision a virtual machine using a template suitable for a generic operating system. However, upon reviewing the common templates available, I couldn't find one specifically designed for this purpose.

What you expected to happen: It would be beneficial to include a generic template or explore alternative options to accomplish provisioning a virtual machine with a generic operating system.

How to reproduce it (as minimally and precisely as possible):

Anything else we need to know?:

Environment:

0xFelix commented 1 month ago

I'm not sure about the usefulness of a generic template. What settings would you include that differ from a bare VirtualMachine? What boot source should the template require?

0xFelix commented 1 month ago

Maybe an InstanceType without Preference would be more beneficial to your needs?

https://github.com/kubevirt/common-instancetypes

prabhulc commented 1 month ago

Hi @0xFelix , Thank you for replying.

I would like to boot this OS (SS attached) image

For this KVM image to function properly, it requires an OS template that is generic. I've confirmed its functionality within KVM. However, upon migration to Openshift virtualization, I couldn't find a corresponding option for a generic OS template

prabhulc commented 1 month ago

image

0xFelix commented 1 month ago

My point is, what would you like to see in a generic template? A template contains OS specific settings and points to a specific boot source. Can't you create a template yourself for this use case or alternatively just use a plain VirtualMachine pointing to your boot volume?

Edit: Do you want to have a GUI workflow?

prabhulc commented 1 month ago

I attempted to create a plain VirtualMachine, but it booted into the dracut shell instead. I'm new to this and uncertain if I made a mistake. (Screenshot and vm.yaml attached)

apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
  annotations:    
    kubevirt.io/latest-observed-api-version: v1
    kubevirt.io/storage-observed-api-version: v1    
  generation: 1
  labels:
    app: generic-vm-8
    app1: morp    
  name: generic-vm-8
  namespace: default  
spec:  
  running: true
  template:
    metadata:
      annotations:
        vm.kubevirt.io/flavor: small        
      creationTimestamp: null
      labels:
        kubevirt.io/domain: generic-vm-8
        kubevirt.io/size: small
    spec:
      architecture: amd64
      domain:
        cpu:
          cores: 8
          sockets: 1
          threads: 1
        devices:
          disks:
          - disk:
              bus: virtio
            name: rootdisk
          - disk:
              bus: virtio
            name: cloudinitdisk
          inputs:
          - bus: virtio
            name: tablet
            type: tablet
          interfaces:          
          - masquerade: {}
            model: virtio
            name: default
          logSerialConsole: false
          networkInterfaceMultiqueue: true
          rng: {}        
        memory:
          guest: 24Gi
        resources: {}
      networks:
      - name: default
        pod: {}
      terminationGracePeriodSeconds: 180
      volumes:
      - dataVolume:
          name: generic-vm8-pvc
        name: rootdisk
      - cloudInitNoCloud:
          userData: |-
            #cloud-config
            user: generic-vm
            password: ***
            chpasswd: { expire: False }
        name: cloudinitdisk

image

0xFelix commented 1 month ago

From a VirtualMachine definition perspective this looks right and the VM was also able to boot the volume. I can't tell what your booted volume expects though. To me it looks like it could not find a specific LVM volume.

Also, if you want to create VMs virtctl create vm could be of help.

prabhulc commented 1 month ago

Hi @0xFelix, I discovered why it ended up in the dracut shell screen. The Generic OS I am booting expects the disk bus driver to be 'ide'. Is there a way to use the 'ide' disk bus driver instead of 'virtio'?

fabiand commented 1 month ago

IDE is very old. Does sata work?

prabhulc commented 1 month ago

I tried and its not working, The KVM image is expecting it to be IDE. Is there any way I can use the 'ide' bus driver ?

0xFelix commented 1 month ago

Unfortunately, ide is not supported by KubeVirt. You could potentially modify the VM's libvirt XML with a sidecar, but that's unsupported territory and generally not advisable.

https://kubevirt.io/user-guide/operations/hook-sidecar/