Thursday, May 20, 2010

Easily test or demo Ubuntu Enterprise Cloud (UEC) in EC2 instance

Consider the following items:
  • recent efforts by Robert Collins, Dustin Kirkland and others have enabled running all components of UEC on a single system.
  • while performance suffers greatly, Eucalyptus can easily be made to use qemu rather than kvm for virtualization without hardware virtualization extensions
  • Ubuntu server images are quickly launchable on EC2

Now, re-read those, but do so while thinking about wanting to provide people with an easy way to test UEC.

Thats right, if you have $0.40 per hour, and an EC2 account, you can play with UEC. No real hardware required.

This nested virtualization is obviously not going to provide you with the worlds fastest performing cloud, but it will provide a functional system for test or demo purposes.

I've put some copy-and-paste shell code in commands.txt in a bzr branch uec-on-ec2.

  • check out the bzr branch: lp:~smoser/+junk/uec-on-ec2

    bzr branch lp:~smoser/+junk/uec-on-ec2

  • follow 'commands.txt', copy and pasting its content bit by bit in a root shell (run 'sudo -s').
  • Publish and run an instance (do this as 'ubuntu' user):

    $ uec-publish-tarball fastboot-amd64-0.11.tar.gz fastboot-amd64-0.11 amd64
    # the above creates an emi, see its output
    $ ( umask 066 ; euca-add-keypair mykey > mykey.pem )
    $ euca-run-instances --addressing private --key mykey emi-4D6C12BF
    # soon this will enter 'running' state and have an IP address associated with it.
    $ ssh -i mykey ubuntu@${IPADDR}


Your instance should now be functional.

There are a couple things that could be cleaned up on this, patches are very welcome:
* ideally all of the setup could be done from a '#!' user data script, I've just not worked out all the timing yet.
* separate the node out, allowing for multiple nodes
* fix the requirement of private addressing for functional nodes
* fix the issue with the NC being eventually discovered 3 times (with each of its 3 IP addresses)

That said, you should be able to test this and try out UEC on EC2 in a m1.large for less than $0.40 per hour.

Sunday, May 9, 2010

UDS Maverick: Call for Participation

The Ubuntu Developer Summit (UDS) is the event in which the Ubuntu community discusses and plans the upcoming Ubuntu release. UDS Maverick begins Monday, May 10 (tomorrow) in Brussels.

If you've not yet made plans to attend physically, then its unlikely that you'll be present in the rooms. However, the Canonical IS does an outstanding job of making remote participation possible. For more information, on how you can participate remotely, read the Remote Participation document. In short, you join an IRC channel, listen to a live high quality audio stream from the room, and can see edits to a live gobby document.

The comprehensive list of all sessions is available through the summit schedule, or a filtered list of only the Ubuntu Server sessions.

Below is short, self centered, list that you might find interesting. The Ubuntu Community would love to have your participation.

  • Running cloud images outside UEC or EC2 (Tuesday 11:00 UTC+1): The UEC images that we produce to run in EC2 or UEC are ready-to-go filesystem image of Ubuntu Server. It seems that these images might also serve a more general purpose as a live demo of ubuntu server, or a very convenient starting point for customizing your own. Here we'll discuss other ways these images could be used, and what would need to be done to make that possible.
  • Improvements for cloud-init (Tuesday, 09:00 UTC+1) : This session will cover ways in which the cloud images can be made more user friendly. If you've ever booted one of the Ubuntu images, or re-bundled one, I'd like to know what we could do to the images to make that easier.
  • Handling kernel upgrades in EC2 and UEC (Wednesday 11:00 UTC+1): When a user starts a UEC/EC2 instance, they specify they have the option of specifying the kernel/ramdisk to use with it or use the default associated with the instance. Afterwards, the instance has no ability to modify that initial selection. We'll discuss ways that we could improve the user experience by making that limitation more clear, or possibly providing ways to overcome it.
  • Improve cloud libraries in ubunt (Thursday, 10:00 UTC+1): Throughout the 10.04 release, we packaged some popular libraries for interaction with AWS. We'd like to continue that work in Maverick. If you have suggestions on libraries you use that are not present in Ubuntu, please let us know
  • Utilties for easier interaction with UEC or EC2 (Tuesday, 10:00 UTC+1): If you have ideas on utilities that would make your life using Ubuntu on EC2 or UEC easier, please attend this session and let us know.
  • server-maverick-conffiles-and-puppetThis should be an interesting session discussing how Ubuntu can improve the management of conffiles. Soren Hansen has sent an email with more information
  • Discussion on plans for vmbuilder (17:10 UTC+1): Many people have used vmbuilder to build virtual machine images. In this session we'll discuss where vmbuilder is and where it is going.

If you have input for any session, but are not able to attend in real time, feel free to send me input at smoser at sign ubuntu dot com, and I'll try to make sure it gets brought up.

Oh, and if you're reading this on Sunday, May 9, don't forget Mother's Day.

Update 2010-05-10: Added times for sessions and used the titles rather than blueprint names so you can find them on the schedule

Wednesday, May 5, 2010

Ubuntu 10.04 LTS - Lucid Lynx available in all EC2 Regions

I'm a bit late to the party. Ubuntu 10.04 LTS (Lucid Lynx) was released almost a week ago at this point. Multitudes of others have blogged, reviewed, used, etcetera.

That said, I wanted to announce it here, and point out a few things. To get a list of AMI ids for Ubuntu 10.04 LTS Server, look at either:

Now, some miscellaneous items I wanted to mention:
  • 10.04 LTS was released on EC2 in all 4 regions (us-east-1, us-west-1, eu-west-1, and the new ap-southeast-1) at the same time as all other Ubuntu releases. The 10.04 LTS images were available on the ap-southeast-1 region less than 24 hours after it was officially announced.
  • The published EC2 images do not have a ramdisk associated with them. This is by design. The kernel has enough smarts built in to find the root filesystem and boot the system. The end result is that we only have to update and manage 2 pieces instead of 3, and the instances should boot faster.
  • In addition to 10.04 images, we also populated the ap-southeast-1 region with the latest released versions of 8.04 and 9.10 images.

Thursday, April 22, 2010

Upgrading an EBS Instance

Update 20110323: If you are reading this article, you almost certainly should be reading my Migrating to pv-grub kernels for kernel upgrades. The process described here will still work for 10.04 images, but the process described there is ultimately much easier. If you are using 10.10, or 11.04 images, you do not need to do anything, simply 'apt-get update && apt-get dist-upgrade && reboot' to get a new kernel.

For the majority of the existence of EC2 there was no way to change the kernel that an instance was using. With the addition of EBS instances, that changed. I wanted to explain how you can take advantage of that EBS feature by upgrading a Ubuntu 10.04 LTS (Lucid Lynx) instance launched from a Beta-2 AMI to the Release Candidate. This same basic process should also allow you to upgrade across a release, perhaps from a 9.04 Alestic instance to Ubuntu 10.04 LTS.

In reality, if you're hoping to upgrade you're kernel and EBS instance, its because you already have one running and need to upgrade. But for the sake of this excercise, we'll launch a new instance based on the Beta-2 image in the us-east-1 region and then connect to it.

$ ec2-run-instances --key mykey ami-4be50b22
# wait a bit
$ ec2-describe-instances | awk '-F\t' '$1 == "INSTANCE" { print $4 }'
ec2-184-73-101-171.compute-1.amazonaws.com
$ ssh -i mykey.pem ubuntu@ec2-184-73-101-171.compute-1.amazonaws.com

Now, on the instance we'll go ahead and do the upgrade. Whenever I'm working on ec2, I like to use GNU screen to protect against lost network.
% screen -S upgrade

This is the same basic process as upgrading any Ubuntu system. First update and then upgrade. Here, I've run '--dry-run' to point out that there would be kernel upgrades.

Also, the ec2 images suffer from a bug where grub will be installed and prompt you for some information even though its of no value. Because I know what those prompts will be, I'm go ahead and set them here so you're not interrupted during the dist-upgrade.

% sudo apt-get update
% sudo apt-get dist-upgrade --dry-run | grep "linux.*ec2"
  libparted0debian1 linux-image-2.6.32-21-virtual linux-image-2.6.32-305-ec2
  libpolkit-gobject-1-0 libpython2.6 libss2 libudev0 linux-ec2 linux-firmware
  linux-image-ec2 linux-image-virtual linux-virtual locales module-init-tools
Inst linux-image-2.6.32-305-ec2 (2.6.32-305.9 Ubuntu:10.04/lucid)
Inst linux-ec2 [2.6.32.304.5] (2.6.32.305.6 Ubuntu:10.04/lucid) []
Inst linux-image-ec2 [2.6.32.304.5] (2.6.32.305.6 Ubuntu:10.04/lucid)
Conf linux-image-2.6.32-305-ec2 (2.6.32-305.9 Ubuntu:10.04/lucid)
Conf linux-image-ec2 (2.6.32.305.6 Ubuntu:10.04/lucid)
Conf linux-ec2 (2.6.32.305.6 Ubuntu:10.04/lucid)

% echo grub-pc grub2/linux_cmdline string | sudo debconf-set-selections
% echo grub-pc grub-pc/install_devices_empty boolean true | sudo debconf-set-selections

% sudo apt-get dist-upgrade
..
94 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 84.1MB of archives.
..

Above, If you were upgrading from a previous release to 10.04, then you would use 'do-release-upgrade' from the 'update-manager-core' package.

At this point we've got 2 kernels installed, the new one and the old one. Unsurprisingly, we're booted into the old one.

% dpkg-query --show | grep "linux.*ec2"
linux-ec2       2.6.32.305.6
linux-image-2.6.32-304-ec2      2.6.32-304.8
linux-image-2.6.32-305-ec2      2.6.32-305.9
linux-image-ec2 2.6.32.305.6
% uname -r
2.6.32-304-ec2

Above, we can see that the 2.6.32-305.9 version of the kernel is the newest one. Its installed locally, but to boot it we have to find the aki of the version that is published by Ubuntu to ec2. The Ubuntu kernels are registered in ec2 such that you can correlate the dpkg version to the registered aki. We're going to query all the images, save that output to a file and then search for results that are owned by the Canonical user, and match our version string and arch.

$ owner=099720109477; # this is the canonical user's id
$ ver=2.6.32-305.9; arch=i386
$ ec2-describe-images --all > /tmp/images.list
$ awk '-F\t' '$4 == o && $3 ~ v && $8 == a { print $2, $3 }' \
   a=${arch} "o=${owner}" "v=${ver}" /tmp/images.list
aki-1f02ec76 099720109477/ubuntu-kernels-milestone/ubuntu-lucid-i386-linux-image-2.6.32-305-ec2-v-2.6.32-305.9-kernel
aki-d324caba 099720109477/ubuntu-kernels-testing/ubuntu-lucid-i386-linux-image-2.6.32-305-ec2-v-2.6.32-305.9-kernel

That shows us that we have 2 kernels available matching that explicit version. One is "testing", and one is "milestone". These are actually the same thing. We label the kernels differently so the user easily knows what is testing and what is "released". The released kernel version will be labeled with 'ubuntu-kernels'. The RC kernel version gets labeled "ubuntu-kernels-milestone".

In order to change the kernel, we have to stop the instance, modify the 'kernel' attribute, and then start it up again.
$ ec2-stop-instances i-23453048
$ ec2-modify-instance-attribute --kernel aki-1f02ec76
kernel   i-23453048  aki-1f02ec76

$ ec2-start-instances i-23453048
# wait a bit
$ ec2-describe-instances | awk '-F\t' '$1 == "INSTANCE" { print $4 }'
ec2-184-73-116-205.compute-1.amazonaws.com

So, in theory, we should have booted into our nice and shiny-new kernel. Lets test that theory:
$ ssh ubuntu@ec2-184-73-116-205.compute-1.amazonaws.com 'uname -r'
2.6.32-305-ec2

There you have it! This process can be applied to upgrading the RC to Release (which likely won't have a kernel change), or, eventually to upgrading your 10.04 LTS instance to a Maverick one.

Monday, March 29, 2010

Introducing cloud-init's cloud-config syntax

Since this is my first post on a brand new blog, *and* I'm fairly new to the Ubuntu community, I figure I should introduce myself. My name is Scott Moser, I've been a member of the Ubuntu Server team for the past 9 months or so. The majority of my time has been focused on Ubuntu's cloud efforts, both on ec2 and on the Ubuntu Enterprise Cloud (UEC).

Thats enough personal introduction, now on to the content.

The cloud-init package provides "first boot" functionality for the Ubuntu UEC images. It is in charge of taking the generic filesystem image that is booting and customizing it for this particular instance. That includes things like:
  • setting the hostname
  • putting the provided ssh public keys into ~ubuntu/.ssh/authorized_keys
  • running a user provided script or otherwise modifying the image
If you have used the Official Ubuntu Images for Hardy or Karmic, you may be aware that the above functionality was previously provided by ec2-init. The cloud-init is package is largely a "cloud agnostic" replacement for ec2-init. The AWS specific portion of the name didn't fit with UEC at the moment, and seemed limiting for the future. We hope to have it working on other cloud offerings as well.

Setting hostname and configuring a system so the person who launched it can actually log into it are not terribly interesting. The interesting things that can be done with cloud-init are made possible by data provided at launch time called user-data.

ec2-init, cloud-init, and the Alestic images support customization through user-data in one very simple yet effective manner. If the user-data starts with '#!', then it will be stored and executed as root late in the boot process of the instance's first boot (similar to a traditional 'rc.local' script). Output from the script is directed to the console. For example:

$ cat ud.txt
#!/bin/sh
echo ========== Hello World: $(date) ==========
echo "I have been up for $(cut -d\  -f 1 < /proc/uptime) sec"

$ ec2-run-instances ami-a908e7c0 --key mykey.us-east-1 \
   --user-data-file=ud.txt
# wait now for the system to come up and console to be available

$ ec2-get-console-output i-97fc7afc | grep --after-context=1 Hello
========== Hello World: Mon Mar 29 18:05:05 UTC 2010 ==========
I have been up for 28.26 sec

The simple approach shown above gives a great deal of power. The user-data can contain a script in any language where an interpreter already exists in the image (#!/bin/sh, #!/usr/bin/python, #!/usr/bin/perl, #!/usr/bin/awk ... ).

For many cases, the user may not be interested in writing a program. For this case, cloud-init provides "cloud-config", a configuration based approach towards customization. To utilize the cloud-config syntax, the supplied user-data must start with a '#cloud-config'. For example:

$ cat cloud-config.txt
#cloud-config
apt_upgrade: true
apt_sources:
- source: "ppa:smoser/ppa"

packages:
- build-essential
- pastebinit

runcmd:
- echo ======= Hello World =====
- echo "I have been up for $(cut -d\  -f 1 < /proc/uptime) sec"

$ ec2-run-instances ami-a908e7c0 --key mykey.us-east-1 \
   --user-data-file=cloud-config.txt

Now, when the above system is booted, it will have:
  • added my personal ppa
  • run an upgrade to get all updates available
  • installed the 'build-essential' and 'pastebinit' packages
  • printed a similar message to the script above

The 'runcmd' commands are run at the same point in boot that the '#!' script would run in the previous example. It is present to allow you to get the full power of a scripting language if you need it without abandoning cloud-config.

Note, that in this case the fairly large amount of output to the console from 'apt-get upgrade' ended up scrolling our 'Hello World' message off the ec2-console buffer, so it didn't appear there. That is something that will need to be addressed in lucid+1.

For more information on what kinds of things can be done with cloud-config, see doc/examples in the source.

cloud-init supports a couple other formats of user-data which provide more customization possibilities. I hope to write another blog entry covering those other formats soon.