A combination of ASP.Net 5 held in a Docker container, running under the light weight CoreOS Linux, hosted with Hyper-V on my Windows 8.1 laptop sounded like a cheap way to create something. I’m also excited about using this as a hosting solution with a very light footprint, my own free to use PaaS set up.
Part 1 – Getting CoreOS running on Hyper-V
We will start by performing a Bare Metal install of CoreOS. You’ll need to Download the CoreOS ISO.
Follow the Microsoft guide here: http://windows.microsoft.com/en-au/windows-8/hyper-v-run-virtual-machines
Set up Hyper-V networking
- Run the Hyper-V manager (start -> type Hyper-V).
- Select Virtual Switch Manager on the right, then select Internal and click Create Virtual Switch. Call it Hyper-V Network.
- Run View network status and tasks (start -> type Network Status).
- Click Change adapter settings in the top left. Right click -> Properties on the internet connection you wish to share with Hyper-V. Be careful selecting which ethernet / wifi connection to share with Hyper-V. At first I chose the wrong one, and that resulted in the bare metal install not responding, with no obvious error.
- From there select Allow other network users to connect through this computer’s internet connection, and in the Home networking connection drop-down, select the virtual interface you created earlier called Hyper-V Network. Click OK .
Create the Hyper-V CoreOS virtual machine
- From Hyper-V manager select New -> Virtual Machine in the top right. Call it whatever you like, e.g. CoreOS. Click Next.
- Select Generation 1, click Next.
- Set the memory for your machine, click Next.
- Select your virtual network called Hyper-V Network under the Connection dropdown, click Next.
- Create a virtual hard disk of the appropriate size, click Next.
- Tell Hyper-V to Install an operating system from a bootable CD/DVD-ROM and select the ISO you just downloaded, Click Finish.
- Select the new Virtual Machine and click Connect.
- In the new window click the Green power button in the top left, the VM will now boot to the ISO.
This is where I deviate from other guides slightly, and have hopefully saved you some effort. Now that the CoreOS install has booted:
- Sudo to root:
sudo su - root
- We need to pay close attention to the cloud-config.yml requirement.A lot of people use private keys when they SSH into CoreOs, but I wanted to go direct in with Hyper-V and thought a password would be easier. I haven’t found a quick way to generate a password but some options can be found here (see generating a password hash):https://coreos.com/docs/cluster-management/setup/cloudinit-cloud-config/I have created a generic enough (with a weak password hash!) yaml file to download and get things going. This is not safe to be internet facing! I generated the password in Cygwin. You can grab it with:
If your network sharing isn’t configured correctly the wget will fail and time out. Ping something if you’re unsure of your net connectivity. Now use Vi or similar to edit it to your needs. A guide to your options is here:
I’d recommend you validate any config before using it, yaml is sensitive! Use the CoreOS validator and not just a yaml validator:
- Once you’re happy with the config use
coreos-install -d /dev/sda -c cloud-config.yml
to begin the install.
- Once it’s installed, shutdown with
shutdown -h now
then unmount the ISO (Media -> DVD Drive -> Eject).
- Power up the VM again and you should then be able to login with User: core, Password: password.You should also be able to SSH with Putty or similar to the machine called “CoreOS” on your network.
You may bump into problems, instead of going round and round in reinstall circles there is a guide to troubleshooting at the bottom of this page:
I kept tweaking my config, re-uploading it, booting with the ISO, mounting the device (in my case it’s /dev/sda9):
sudo mount /dev/sda9 /mnt
and then overwriting it with an updated version
sudo wget -O /mnt/var/lib/coreos-install/user_data http://russtaylor.co.uk/files/cloud-config.yml
or edit it by hand. I then shutdown, unmounted the ISO, and restarted trying the new config.
I’m new to this, so the config will need tweaking for Docker I’m sure, any improvements are greatly received.
Thanks go to these blogs that helped me write this:
General Hyper V and CoreOS: http://silarsis.blogspot.co.uk/2015/01/docker-coreos-hyper-v.html
Cloud-config.yml explanation: http://stevieholdway.tumblr.com/post/90167512059/coreos-bare-metal-iso-install-tutorial
CoreOS Bare Metal Install: https://coreos.com/docs/running-coreos/bare-metal/installing-to-disk/
Next post, Part 2 – Getting Docker and ASP.Net 5 running with HelloWeb example.