KubeVirt - gpillon/k4all GitHub Wiki

OFC, kubevirt WORKS! :D

From Version 1.4.0 Kubevirt is a selectable feature in k4all; just set

...
 "features": {
    "virt": {
      "enabled": "true",
      "emulation": "auto"
    }
  },
...

And then go to "https://kubevirt-mananger..nip.io" to open the dashboard

Upload n image

curl -O https://download.cirros-cloud.net/0.6.2/cirros-0.6.2-x86_64-disk.img
virtctl image-upload dv cirros --size=30000000 --image-path=cirros-0.6.2-x86_64-disk.img --insecure

in your config /etc/k4all-config.json and run script /usr/local/bin/setup-feature-virt.sh

Cirros Sample VM:

apiVersion: kubevirt.io/v1alpha3
kind: VirtualMachine
metadata:
  name: small-vm
  namespace: default
spec:
  running: true
  template:
    metadata:
      creationTimestamp: null
      labels:
        kubevirt.io/vm: small-vm
    spec:
      architecture: amd64
      dnsConfig:
        nameservers:
          - 1.1.1.1
          - 8.8.8.8
      dnsPolicy: None
      domain:
        devices:
          disks:
            - disk:
                bus: virtio
              name: rootdisk
          interfaces:
            - masquerade: {}
              name: default
        machine:
          type: q35
        resources:
          requests:
            memory: 512M
      networks:
        - name: default
          pod: {}
      # nodeSelector: # Optional Select the host to pin the vm
        # kubernetes.io/hostname: kube-control-0h3ob.mkt.local  # Optional Select the host to pin the vm
      volumes:
        - containerDisk:
            image: kubevirt/cirros-registry-disk-demo
          name: rootdisk

Sample Network Attachment Definition:

apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
  name: ovs-net-conf
  namespace: default
spec:
  config: |-
    {
     "cniVersion":"0.3.1",
     "type":"ovs",
     "bridge":"ovs-bridge",
     "ipam":{
        "type":"host-local",
        "subnet":"192.168.220.0/24",
        "rangeStart":"192.168.220.211",
        "rangeEnd":"192.168.220.213",
        "gateway":"192.168.220.1",
        "routes":[
           {
              "dst":"0.0.0.0/0"
           }
        ]
     }
    }

and then run

virtctl start small-vm
virtctl console small-vm

now enjoy your Cirros :)

OPNSense Example

curl -O https://mirror.ams1.nl.leaseweb.net/opnsense/releases/24.7/OPNsense-24.7-vga-amd64.img.bz2
bzip2 -d OPNsense-24.7-vga-amd64.img.bz2
virtctl image-upload pvc opnsense-24-7 --image-path=OPNsense-24.7-vga-amd64.img --size=12Gi --insecure
FQDN=$(hostname -f)
cat <<EOF | kubectl apply -f -
apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
  name: ovs-net-vlan7
  namespace: default
spec:
  config: >-
    { "cniVersion": "0.3.1", "type": "ovs", "bridge": "ovs-bridge", "vlan": 7,
    "ipam": { "type": "host-local", "subnet": "192.168.7.0/24" } }
---
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
  labels:
    fw.kubevirt-manager.io/vm-name: opnsesnee
    kubevirt-manager.io/managed: 'true'
    kubevirt.io/domain: opnsesnee
  name: opnsesnee
  namespace: default
spec:
  running: true
  template:
    metadata:
      creationTimestamp: null
      labels:
        fw.kubevirt-manager.io/vm-name: opnsesnee
        kubevirt-manager.io/managed: 'true'
        kubevirt.io/domain: opnsesnee
    spec:
      architecture: amd64
      domain:
        cpu:
          cores: 2
          sockets: 1
          threads: 1
        devices:
          disks:
            - disk: {}
              name: disk1
          interfaces:
            - bridge: {}
              name: ovs-net7
            - masquerade: {}
              name: default
          networkInterfaceMultiqueue: true
        firmware:
          bootloader:
            bios: {}
        machine:
          type: q35
        resources:
          requests:
            memory: 2Gi
      networks:
        - name: default
          pod: {}
        - multus:
            networkName: ovs-net-vlan7
          name: ovs-net7
      nodeSelector:
        kubernetes.io/hostname: $FQDN
      volumes:
        - dataVolume:
            name: opnsense-24-7-dv
          name: disk1
EOF
⚠️ **GitHub.com Fallback** ⚠️