XenServer 6.5 & Containers -Â âHello Worldâ Edition
In between calls on Friday while skimming my Twitter feed, I stumbled across an interesting announcement, Preview of XenServer support for Docker and Container Management, which led me to, How to Get Started with Container Monitoring on CoreOS. Curious, having seen a brief demo in January, I decided to jump in and see if I could get it running in my lab. Containers are quick and easy, right?
Pre-Requesites
First things first, head over to the XenServer Pre-Release Downloads and under the Docker Integration section youâll need to grab both the supplemental pack and updated XenCenter. Once downloaded, use an SFTP client to copy the ISO onto your XenServer(s) -- Iâm fond of ForkLift on Mac OS X. Youâll also need to run the XenCenter installer, but its your basic Next, Next, Next ordeal.
With the ISO copied onto your XenServer and your XenCenter updated, weâll start having some fun.
The Basics
Installing the supplemental pack is a simple ordeal. Run the following command in whichever directory you copied the ISO file:
xe-install-supplemental-pack xscontainer-6.5.0-100205c.iso
Since we've already installed the preview version of XenCenter, weâre essentially done. Your XenServer now includes a new guest template for CoreOS and the updated XenCenter includes:
New VM Wizard - CoreOS cloud-config/config-drive support
VM Properties - Container Management / Cloud-Config Parameters
Probably more, but those are the visible differences I noted
Of course, weâre not stopping there, letâs dig deeper and see how the new features look.
Your First CoreOS VM
If, like me, youâre new to CoreOS youâll want to head to their download page and grab an ISO. While not exactly required, as Iâve learned through additional research, its how I got up and running and works for this âHello Worldâ example. Donât forget to copy the ISO to your ISO Storage Repository so we can do some installing.
Head over to XenCenter so we can create a new VM.
My first pass was pretty much Next, Next, Next (and serves as a learning opportunity). I gave it a name, took the default CPU/Memory/Disk (1 vCPU, 1GB RAM and 5GB disk) and left the Cloud-Config Parameters unchanged. This is important, but Iâll explain why in a second. Make sure to select the new ISO for the installation source and boot the VM when the wizard completes. After a quick provisioning, your new VM should be up and running and will automatically boot into the console.
Run the following command to install CoreOS to the disk:
sudo coreos-install -d /dev/xvda -o xen -C stable
Once the installation is finished, eject the ISO (using XenCenter) and reboot your VM (from its console):
sudo reboot
You now have a purpose built OS runtime for containers, but whatâs next?
XenCenter Enhancements
In order for XenCenter to monitor and control our containers, we need to enable Container Management. Right-click on the new VM and open its Properties.
Thereâs also another set of options called Cloud-Config Parameters. As I mentioned previously, the preview release supports both cloud-config and config-drive, for automated configuration of CoreOS VMs.
Accessing a CoreOS VM
At some point weâll want to connect to the VM and actually use it. Assuming you went the Next, Next, Next route and didnât add your SSH public keys, thereâs not much you can do until you rectify the situation (as I learned). We need to revisit the Cloud-Config Parameters and add at least one SSH public key of our own.
If youâre not familiar with using public/private keys for SSH authentication, Ubuntu has some good documentation. I ran the following command on my Mac, to setup a new keypair, accepting the default file location and creating a passphrase:
ssh-keygen -t rsa -C âfor CoreOS testingâ
To insert the key into your cloud-config, we need to use good ole copy/paste. Print the public key you just created, so we can highlight and copy (everything between âssh-rsaâ and your comment, âfor CoreOS testingâ in my case):
cat ~/.ssh/id_rsa.pub
Now, make sure the VM is shutdown and open the Cloud-Config Parameters again. Paste your public key at the end of the â- ssh-rsaâ line, just under the âssh_authorized_keys:â line. Pay close attention to the comments regarding the %XSCONTAINERRSAPUB% line, its what enables a new daemon in dom0 to monitor/control containers.
With those changes complete, you should be able to SSH from your local machine to the CoreOS VM. I elected not to save my passphrase in my Macâs keychain, hence the error âSaving password to keychain failedâ.
Launching a Few Containers
Once connected, you can create a couple containers, like so:
docker run --name hello -d busybox /bin/sh -c âwhile true; do echo Hello World; sleep 1; doneâ
docker run --name goodbye -d busybox /bin/sh -c âwhile true; do echo Goodbye World; sleep 1; doneâ
Flipping back to XenCenter, you should now see the containers grouped under your CoreOS VM.
The Payoff
All told, I was able to go from start to finish in about 30 minutes. The XenServer installation was dead simple and getting started with CoreOS/Docker was pretty intuitive. Thereâs a lot more under the hood to investigate, thatâs for sure, so expect more updates in the future (like how do you view/interact with each container, using fleet for container management, etc).











