CSS Corp Open Source Services

Eucalyptus Beginner’s Guide – UEC 10.10 & Eucalyptus 2.0-Image Management

with 2 comments

We have noticed a few changes in the way Eucalyptus 1.6 (UEC on Ubuntu 10.04 Lucid Lynx) and 2.0 (UEC on Ubuntu 10.10 Maverick Meerkat) launch instances. These changes have an impact on the bundling procedure. This article takes these changes into account and may be helpful for users of UEC on Ubuntu 10.10 and Eucalyptus 2.0

Eucalyptus Machine Image(EMI)

A Eucalpyptus Machine Image(EMI) is a combination of a virtual disk image(s), kernel and ramdisk images as well as an xml file containing meta data about the image. These images reside on WS3 and used as templates for creating instances on UEC. Each Linux EMI is a combination of the following:

  • An XML file with a name like “jaunty.img.manifest.xml” with information about one or more hard disk images, a kernel image and a ram disk image (id – emi-65440E7E)
  • An XML file with a name like “vmlinuz-2.6.28-11-server.manifest.xml” with information about the corresponding kernel image(id – eki-39FC1244)
  • An XML file with a name like “initrd.img-2.6.28-11-server.manifest.xml” with information about the corresponding ramdisk image(id – eri-71ED1322)

Each of these images has its own ID that can be used while running the instances. More on this in the chapter on “Managing Instances”
From the web interface of Eucalyptus, you can view a list of EMIs in the “Store” tab of the web UI. These are the EMIs listed from Canonical or partners. You can choose to download and install any of these images directly from Canonical’s site.
Since most enterprise/individual users of Eucalyptus have a need for bringing up instances based on custom images, image management plays a key role in Eucalyptus administration. Such images could be based on a preferred version/variant of a preferred OS distribution with a set of required applications pre-installed.
Bundling an EMI is a multi-step process involving the following:

  1. creating a virtual disk image
  2. installing the OS
  3. installing required applications
  4. making the OS ready to run under UEC
  5. registering the images with UEC
  6. testing the image etc.

Bundling Linux Image

Client1 is machine used for the purpose of working on creation of the image. Please note that we had installed KVM on Client1.

Creating a new disk Image

This will represent the main HDD of the virtual machine, so make sure to give it as much space as you will need.

uecadmin@client1:~$ kvm-img create -f raw image.img 5G

Important note: The option “qcow2” doesn’t work on UEC-Maverick Meerkat and Eucalyptus 2.0 installations. Hence it is important to create the KVM image in raw format, as eucalyptus starts the instance in raw option. If the image is created using qcow2 format,then while running the instance the console log of the instance gives an error saying “ALERT! /dev/sda1 does not exist. Dropping to a shell!”

OS Installation

Download the iso file of the Linux distribution you want installed in the image. The example below refers to creating a Maverick Meerkat 64-bit server image.

uecadmin@client1:~$ wget http://releases.ubuntu.com/10.10/ubuntu-10.10-server-amd64.iso 

And start the installation process:

uecadmin@client1:~$ sudo kvm -m 256 -cdrom ubuntu-10.10-server-amd64.iso -drive file=image.img,if=scsi,index=0 -boot d -net nic -net user -nographic -vnc :0

If your installation process requires more than 256MB of RAM change the -m option, and if you need more processors available, you can use the ‘-c’ option.The command above will boot a new KVM instance, with the disk image you’ve created as the primary HDD and the iso as the first bootable device. Also the ‘-nographic’ option will not display any graphical output. You can connect to the instance through VNC (use display number :0) and finish the installation.

For Ex: vncviewer A.B.C.D :0, where A.B.C.D is the IP address of Client1.

After finishing the installation, relaunch the VM by executing the following command.

uecadmin@client1:~$ sudo kvm -m 256 -drive file=image.img,if=scsi,index=0,boot=on -boot c -net nic -net user -nographic -vnc :0

At this point you can add all the packages you want to have installed, update the installation, add users and any settings that need to be present in your new UEC instances.

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install mediawiki

Integrating with Eucalyptus

An instance running under Eucalyptus needs to know what IP it has and also, it needs to have the public key of the user allowed to do a passwordless access through SSH. This is accomplished by using a restful interface provided by the cloud. The interface is available under this URL: http://169.254.169.254/latest/meta-data and accessible from within the Instance.
Eucalyptus node controller is set up to prevent automatic key injection if the system is in MANAGED or MANAGED-NOVLAN mode. Instead, it is assumed that the instance will use the above meta-data service to retrieve the public keys when running in these modes. You will need to facilitate this by installing curl and adding a script that will run on each boot.
Install curl on the VM.

$ sudo apt-get install curl

Now add the following lines to /etc/rc.local of the image.

depmod -a
modprobe acpiphp
# simple attempt to get the user ssh key using the meta-data service
# assuming “user” is the username of an account that has been created
mkdir -p /home/user/.ssh
echo >> /home/user/.ssh/authorized_keys
curl -m 10 -s http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key | grep 'ssh-rsa' >> /home/user/.ssh/authorized_keys
echo "AUTHORIZED_KEYS"
echo "************************"
cat /home/user/.ssh/authorized_keys
echo "************************"

Add the above lines before the “exit 0” in /etc/rc.local
Also remove the network persistent rules from /etc/udev/rules.d, so that the instance always comes up with eth0 as the interface name as expected by eucalyptus.

$ sudo rm -rf /etc/udev/rules.d/70-persistent-net.rules

This completes the process of customizing the OS installed as a reference image.

Registering with Eucalyptus

The last step would be to upload the images to Eucalyptus. The files that need to be uploaded for the above sample setup are: vmlinuz-2.6.28-11-server, initrd.img-2.6.28-11-server, image.img.
Copy the kernel and the initrd image from the VM image to some place outside. These will be used later for creating and uploading a complete virtual image to Eucalyptus.

$ scp /boot/initrd.img-2.6.35-22-server user@A.B.C.D:
$ scp /boot/vmlinuz-2.6.35-22-server user@A.B.C.D:

Before starting the upload process shut down the VM.

Registering kernel image

Execute the following commands to bundle and register the kernel image (vmlinuz-2.6.28-11-server)

uecadmin@client1:~$ euca-bundle-image -i vmlinuz-2.6.35-22-server --kernel true
uecadmin@client1:~$ euca-upload-bundle -b mybucket -m /tmp/vmlinuz-2.6.35-22-server.manifest.xmluecadmin@client1:~$ euca-register mybucket/vmlinuz-2.6.35-22-server.manifest.xml

Save the output produced by the last command above (eki-XXXXXXXX), which will be needed while registering the disk image.

Registering ramdisk image

Execute the following commands to bundle and register the ramdisk image (initrd.img-2.6.28-11-server)

uecadmin@client1:~$ euca-bundle-image -i  initrd.img-2.6.35-22-server
uecadmin@client1:~$ euca-upload-bundle -b mybucket -m /tmp/initrd.img-2.6.35-22-server.manifest.xml
uecadmin@client1:~$ euca-register mybucket/initrd.img-2.6.35-22-server.manifest.xml

Save the output produced by the last command above (eri-XXXXXXXX), which will be needed while registering the disk image.

Registering disk image

Execute the following commands to bundle and register the ramdisk image (image.img)

uecadmin@client1:~$ euca-bundle-image -i image.img --kernel eki-XXXXXXXX --ramdisk eri-XXXXXXXX
uecadmin@client1:~$ euca-upload-bundle -b mybucket -m /tmp/image.img.manifest.xml
uecadmin@client1:~$ euca-register mybucket/image.img.manifest.xml

Replace eki-XXXXXXXX and eri-XXXXXXXX with the exact values you have saved earlier.

Image Listing

The new images that have been uploaded can be seen by using euca-describe-images command.
For Ex:

uecadmin@client1:~$ euca-describe-images
IMAGE   emi-70B70EC0    mybucket/image.img.manifest.xml                     admin   available        public  x86_64  machine
IMAGE   eri-A2BE13EC    mybucket/initrd.img-2.6.35-22-server.manifest.xml   admin    available       public  x86_64  ramdisk
IMAGE   eki-685F1306    mybucket/vmlinuz-2.6.35-22-server.manifest.xml      admin    available       public  x86_64  kernel

More details on managing the instances in later chapters.

Advertisements

2 Responses

Subscribe to comments with RSS.

  1. Thank you….you guys totally rock. Do you actually discuss configuring for virtIO?

    And what I am sure multiple people will like and appreciate is an answer to the question of why a straight KVM fully functional image is a single file which can be modified yet a cloud image has this obfuscated build process and can not easily be updated after creation. The instructor I had for the RHEV cert course said the whole eri and eki are throw back to a XEN day gone by. I believe RHEL can take the qcow image and push it out to the ‘cloud’. So, architecturally, why are there different build techniques with different run time benefits/contraints, i.e. virsh image can be easily modifed but only one run per image whereas an emi can be instantiated N times but can’t be modified.

    Walt

    November 13, 2010 at 5:32 am

  2. images created with the above instructions will not work in eucalyptus running in system mode and native filesystem ext4. Use instructions above in combination with http://open.eucalyptus.com/wiki/creating-images-iso-kvm

    Thank you for sharing

    Andreas Papadopoulos

    November 14, 2011 at 8:28 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: