Skip to content

Instantly share code, notes, and snippets.

@mfojtik
Created November 7, 2018 10:58
Show Gist options
  • Save mfojtik/e8289033a67215a2bc34830e494b3907 to your computer and use it in GitHub Desktop.
Save mfojtik/e8289033a67215a2bc34830e494b3907 to your computer and use it in GitHub Desktop.
POC: Run RHCOS via xhyve on OSX with ignition
# These have to be extracted from the qcow2 image
# TODO: Provide these via docker image?
KERNEL="vmlinuz-3.10.0-862.14.4.el7.x86_64"
INITRD="initramfs-3.10.0-862.14.4.el7.x86_64.img"
# This is where the magic happens
#
# To change the ignition (node type), you can use 'bootstrap', 'master' or 'worker'
# coreos.config.url=http://192.168.0.168:8080/bootstrap.ign
#
# You can generate the .ign files using: openshift-install create ignition-configs --dir=/tmp/cluster-ignition
# Then you can run simple HTTP server to serve them:
# $ cd /tmp/cluster-ignition && python -m SimpleHTTPServer 8080
#
# NOTE: Change the IP address to your Mac IP address?
#
# This is needed to run ignition on first boot to fetch the .ign files:
# coreos.first_boot=detected
#
CMDLINE="earlyprintk=serial no_timer_check console=ttyS0 acpi=off root=/dev/vda1 root=UUID=75616629-8d7a-4a1d-93bc-47af28547d57 net.ifnames=0 biosdevname=0 rd.neednet=1 ip=eth0:dhcp ostree=/ostree/boot.0/rhcos/a381c1c06a830fa21f4ca0566064f141d5afdb11f2b94c93cef7845e37984238/0 rw coreos.config.url=http://192.168.0.168:8080/bootstrap.ign coreos.first_boot=detected"
# To get qcow support you need hyperkit from Docker that has some experimental patches.
# However, running bootkube on this setup will likely give you kernel panic, so I recommend to convert
# the qcow to 'raw' format and use the official latest 'xhyve' binary?
IMG_HDD="-s 2,virtio-blk,file:///Users/mfojtik/test-installer/rhcos-qemu.qcow2,format=qcow"
# UUID makes the DHCP server give this VM the same IP address. If you run multiple VM's you probably want to
# adjust this and store somewhere?
UUID="-U 8e7af180-c54d-4aa2-9bef-59d94a1ac572"
# VM config, nothing interesting here
MEM="-m 4G"
NET="-s 3:0,virtio-net,en0"
PCI_DEV="-s 0:0,hostbridge -s 31,lpc"
LPC_DEV="-l com1,stdio"
ACPI="-A"
# TODO: Use xhyve instead of hyperkit unless we want to deal with weird kernel panics ;)
#
sudo hyperkit $UUID $ACPI $MEM $PCI_DEV $LPC_DEV $NET $IMG_CD $IMG_HDD -f kexec,$KERNEL,$INITRD,"$CMDLINE"
@praveenkumar
Copy link

I will try same on xhyve side tomorrow and provide some feedback.

@praveenkumar
Copy link

praveenkumar commented Nov 12, 2018

@mfojtik how did you extracted the vmlinuz and initrd file from qcow2. I tried something following but didn't work well :( . sha256 is not as it should be but I didn't get any error during downloading the image also.

$ wget -c https://releases-rhcos.svc.ci.openshift.org/storage/releases/maipo/47.90/redhat-coreos-maipo-47.90-qemu.qcow2
--2018-11-12 16:53:58--  https://releases-rhcos.svc.ci.openshift.org/storage/releases/maipo/47.90/redhat-coreos-maipo-47.90-qemu.qcow2
Resolving releases-rhcos.svc.ci.openshift.org (releases-rhcos.svc.ci.openshift.org)... 35.196.103.194
Connecting to releases-rhcos.svc.ci.openshift.org (releases-rhcos.svc.ci.openshift.org)|35.196.103.194|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://d26v6vn1y7q7fv.cloudfront.net/releases/maipo/47.90/redhat-coreos-maipo-47.90-qemu.qcow2 [following]
--2018-11-12 16:54:00--  https://d26v6vn1y7q7fv.cloudfront.net/releases/maipo/47.90/redhat-coreos-maipo-47.90-qemu.qcow2
Resolving d26v6vn1y7q7fv.cloudfront.net (d26v6vn1y7q7fv.cloudfront.net)... 13.35.129.165, 13.35.129.54, 13.35.129.196, ...
Connecting to d26v6vn1y7q7fv.cloudfront.net (d26v6vn1y7q7fv.cloudfront.net)|13.35.129.165|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 726789269 (693M) [binary/octet-stream]
Saving to: ‘redhat-coreos-maipo-47.90-qemu.qcow2’
redhat-coreos-maipo-47.90-qemu.qcow2        100%[========================================================================================>] 693.12M  3.82MB/s    in 5m 19s  
2018-11-12 16:59:19 (2.18 MB/s) - ‘redhat-coreos-maipo-47.90-qemu.qcow2’ saved [726789269/726789269]

$ sha256sum redhat-coreos-maipo-47.90-qemu.qcow2 
92e3a81fa5bf3993ef3de5a316caa13027302cbf182e44adb648c598afcb6fb5  redhat-coreos-maipo-47.90-qemu.qcow2

$ curl https://releases-rhcos.svc.ci.openshift.org/storage/releases/maipo/47.90/meta.json | jq '. | {images}'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2184  100  2184    0     0    999      0  0:00:02  0:00:02 --:--:--   999
{
  "images": {
    "qemu": {
      "path": "redhat-coreos-maipo-47.90-qemu.qcow2",
      "sha256": "cc1508f3d160b16bf03befb0f24d1dc4d7b52e68b77583b39aff380befd386cb"
    }
  }
}

$ sudo guestmount -a redhat-coreos-maipo-47.90-qemu.qcow2 -m /dev/sda --ro /mnt/test/ -o allow_other
libguestfs: error: mount_options: mount exited with status 32: mount: /sysroot: wrong fs type, bad option, bad superblock on /dev/sda, missing codepage or helper program, or other error.
guestmount: ‘/dev/sda’ could not be mounted.
guestmount: Did you mean to mount one of these filesystems?
guestmount: 	/dev/sda (unknown)

@praveenkumar
Copy link

https://gist.github.com/praveenkumar/17e481780ba3506d949346d124214827 Here is the detail about how to get those vmlinuz and initrd files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment