3 years ago 250 views

passing params

use nocloud bios method

qemu option -smbios type=1,serial=ds=nocloud-net;s=http://10.10.0.1:8000/

looks for /user-data and /meta-data end points at url

store data in consul

make kv structure config/qemu/vm1/user-data

nginx proxy adn rewrite

server {
    listen       80;

    location / {
        rewrite ^/(.*)$ /v1/kv/qemu/$1?raw break;
        proxy_pass http://consul.service.consul.angrybear.com:8500;
    }

    location /status {
        return 200;
    }


}

qemu fixes

fix bridge allow

mkdir -i /etc/qemu
echo "allow br0" >> /etc/qemu/bridges.conf

nomad task

    task "ubuntu-bionc" {
      driver = "qemu"

      config {
        image_path = "local/focal-server-cloudimg-amd64.img"
        accelerator = "kvm"
        graceful_shutdown = true
        args = ["-smbios", "type=1,serial=ds=nocloud-net;s=https://www.lane-fu.com/qemu-nocloud/vm1/", "-netdev", "bridge,br=br0,id=n1", "-device", "virtio-net,netdev=n1"]
      }

       artifact {
         source = "https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img"
      }

nomad task for arm

required: cd /usr/bin;sudo ln -s qemu-system-aarch64 qemu-system-x86_64


   task "cent8arm64-bionc" {
     driver = "qemu"

     config {
       image_path = "local/CentOS-8-GenericCloud-8.1.1911-20200113.3.aarch64.qcow2"
       #accelerator = "kvm"
       graceful_shutdown = true
       port_map {
         cent8arm64_ssh = 22
       }
       args = ["-enable-kvm", "-M", "virt", "-cpu", "host", "-smbios", "type=1,serial=ds=nocloud-net;h=cent8arm64;s=https://www.lane-fu.com/qemu-nocloud/vm1/", "-bios", "local/QEMU_EFI.fd", "-smp", "2"]
     }

      artifact {
        source = "https://cloud.centos.org/centos/8/aarch64/images/CentOS-8-GenericCloud-8.1.1911-20200113.3.aarch64.qcow2"
     }
      artifact {
        source = "https://releases.linaro.org/components/kernel/uefi-linaro/latest/release/qemu64/QEMU_EFI.fd"
     }

      resources {
        memory = 700
        network {
          mbits = 20
          port "cent8arm64_ssh" {}
       }
    }

making the bridge accept traffic with docker involved

sudo apt-get install iptables-persistent

/etc/iptables/rules.v4

*filter
:DOCKER-USER - [0:0]
-A DOCKER-USER -i br0 -j ACCEPT
-A DOCKER-USER -j RETURN
COMMIT

qemu without. nomad breadcrumb

packages

apt install qemu-kvm qemu-efi ipxe-qemu 

an image and a bios

wget https://releases.linaro.org/components/kernel/uefi-linaro/latest/release/qemu64/QEMU_EFI.fd
wget https://cloud.centos.org/centos/8/aarch64/images/CentOS-8-GenericCloud-8.1.1911-20200113.3.aarch64.qcow2

launch

with port forward

/usr/bin/qemu-system-aarch64 -name CentOS-8-GenericCloud-8.1.1911-20200113.3.aarch64.qcow2 -m 700M -drive file=CentOS-8-GenericCloud-8.1.1911-20200113.3.aarch64.qcow2 -nographic -enable-kvm -M virt -cpu host -bios local/QEMU_EFI.fd -netdev user,id=user.0,hostfwd=udp::31783-:22,hostfwd=tcp::31783-:22 -device virtio-net,netdev=user.0