Eucalyptus Beginner’s Guide – UEC 10.10 & Eucalyptus 2.0-Image Management
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:
- creating a virtual disk image
- installing the OS
- installing required applications
- making the OS ready to run under UEC
- registering the images with UEC
- 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!”
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.
The new images that have been uploaded can be seen by using euca-describe-images command.
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.