kubevirt/common-templates

Create a Template for Generic Linux OS

Closed this issue · 15 comments

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:

  • KubeVirt version (use virtctl version): Client Version: version.Info{GitVersion:"v1.2.0",Server Version: version.Info{GitVersion:"v1.1.1-78-gfc124cfdd"

  • Kubernetes version (use kubectl version): Server Version: v1.28.7+c1f5b34

  • common-templates version: 0.28.0

  • VM or VMI specifications:

  • Cloud provider or hardware configuration: Openshift

  • OS (e.g. from /etc/os-release):
    -NAME="Red Hat Enterprise Linux CoreOS"
    ID="rhcos"
    ID_LIKE="rhel fedora"
    VERSION="415.92.202403270524-0"
    VERSION_ID="4.15"
    VARIANT="CoreOS"
    VARIANT_ID=coreos
    PLATFORM_ID="platform:el9"
    PRETTY_NAME="Red Hat Enterprise Linux CoreOS 415.92.202403270524-0 (Plow)"
    ANSI_COLOR="0;31"
    CPE_NAME="cpe:/o:redhat:enterprise_linux:9::coreos"
    HOME_URL="https://www.redhat.com/"
    DOCUMENTATION_URL="https://docs.openshift.com/container-platform/4.15/"
    BUG_REPORT_URL="https://bugzilla.redhat.com/"
    REDHAT_BUGZILLA_PRODUCT="OpenShift Container Platform"
    REDHAT_BUGZILLA_PRODUCT_VERSION="4.15"
    REDHAT_SUPPORT_PRODUCT="OpenShift Container Platform"
    REDHAT_SUPPORT_PRODUCT_VERSION="4.15"
    OPENSHIFT_VERSION="4.15"
    RHEL_VERSION="9.2"
    OSTREE_VERSION="415.92.202403270524-0"

  • Kernel (e.g. uname -a): Linux 00-50-56-99-9a-59 5.14.0-284.59.1.el9_2.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Mar 19 09:41:26 EDT 2024 x86_64 x86_64 x86_64 GNU/Linux

  • Install tools:

  • Others:
    image
    In KVM there is an option to select Generic when import existing disk image option.

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?

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

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

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

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?

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

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.

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'?

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 ?

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/

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

/lifecycle stale

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

/lifecycle rotten

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

/close

@kubevirt-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.