Wiki

Version 115 (Nikos Skalkotos, 05/21/2013 03:58 pm) → Version 116/133 (Nikos Skalkotos, 05/27/2013 10:50 am)

h2. snf-image

!snf-image-logo.png!

h2. Introduction - Features

snf-image is a "Ganeti":http://code.google.com/p/ganeti/ OS Definition, primarily used by "Synnefo":https://code.grnet.gr/projects/synnefo .

It is rewritten from scratch and allows Ganeti to launch instances from predefined or untrusted custom Images. The whole process of deploying an Image onto the block device, as provided by Ganeti, is done in complete isolation from the physical host, enhancing robustness and security.

snf-image supports KVM and Xen based ganeti clusters.

There are also additional hooks that can be enabled at image deployment. They allow for:

* changing the password of root or arbitrary users
* injecting files at arbitrary locations inside the filesystem, e.g., SSH keys
* setting a custom hostname
* re-creating SSH host keys to ensure the image uses unique keys

snf-image has been used successfully to deploy many major Linux distributions (Debian, Ubuntu/Kubuntu, CentOS, Fedora), as well as Windows 2008 R2 & Windows Server 2012.

The snf-image Ganeti OS Definition is released under [[Licence|GNU Generic Public Lisence version 2]].

h2. Ganeti OS Interface

snf-image requires ganeti-os-interface v20 to operate.
It introduces the following OS parameters:

* @img_id@ (_required if @config_url@ is missing_): the URI used to identify the image (see [[Image IDs and Storage Back Ends|here]])
* @img_format@ (_required if @config_url@ is missing_): the image format type (see [[Image Format|here]])
* @img_passwd@ (_required if @config_url@ is missing_): the passwd to be injected inside the image
* @img_properties@ (_optional_): additional image properties used to customize the image ([[Image_Format#Image-Properties|details]])
* @img_personality@ (_optional_): files to be injected into the image filesystem ([[Personality OS Parameter|details]]).
* @config_url@ (_optional_): the url to download configuration data from

h2. Architecture

snf-image is split in two components: The main program running on the Ganeti host, with full root privilege (@snf-image@ previously @snf-image-host@), and a part running inside an unprivileged, helper VM (@snf-image-helper@).

h3. snf-image

This part implements the Ganeti OS interface. It extracts the Image onto the Ganeti-provided block device, using streaming block I/O (@dd@ with @oflag=direct@), then passes control to @snf-image-helper@ running inside a helper VM. The helper VM is created using KVM, runs as an unprivileged user, @nobody@ by default.

There is no restriction on the distribution running inside the helper VM, as long as it executes the @snf-image-helper@ component automatically upon bootup. The @snf-image-update-helper@ script is provided with @snf-image@ to automate the creation of a helper VM image based on Debian Stable, using @multistrap@.

The @snf-image-helper@ component is spawned inside a specific hardware environment:

* The VM features a virtual floppy, containing an @ext2@ filesystem with all parameters needed for image customization.
* The hard disk of the VM being deployed is accessible as the first @virtio@ hard disk.
* All kernel/console output is redirected to the first virtual serial console, and eventually finds its way into the OS definition log files that Ganeti maintains.
* The helper VM is expected to output "SUCCESS" to its second serial port if image customization was successful inside the VM.
In any other case, execution of the helper VM or @snf-image-helper@ has failed.
* The helper VM is expected to shutdown automatically once it is done. Its execution is time-limited; if it has not terminated after a number of seconds, configurable via @/etc/default/snf-image@, it is sent a @SIGTERM@ and/or a @SIGKILL@.

KVM is currently a dependency for @snf-image@, meaning it is needed to spawn the helper VM. There is no restriction on the hypervisor used for the actual Ganeti instances. This is not a strict requirement; KVM could be replaced by @qemu@, doing full CPU virtualization without any kernel support for spawning the helper VM.

h3. snf-image-helper

This part runs inside the helper VM and undertakes customization of the VM being deployed using a number of hooks, or _[[Configuration Tasks|tasks]]_. The tasks run in an environment, specified by rules found in a virtual floppy, placed there by @snf-image@. @snf-image-helper@ uses @runparts@ to run tasks found under @/usr/lib/snf-image-helper/tasks@ by default.

The architecture is presented below:

h3. Graphical Representation

!snf-image_arch.png!

h3. Image Names

snf-image assumes all image files have the following format:
<pre><image_id>.<image_format></pre>

In order to create an instance with ganeti using an image with filename @debian_base-6.0-5-x86_64.extdump@, you need to specify the following OS parameters:
<pre>img_format=extdump
img_id=debian_base-6.0-5-x86_64</pre>

h2. Download

h3. Source

The latest source packages for snf-image (v0.9.1) can be found here:
* "@snf-image_0.9.1.orig.tar.gz@":https://code.grnet.gr/attachments/download/2609/snf-image_0.9.1.orig.tar.gz
* "@snf-image-helper_0.9.1.orig.tar.gz@":https://code.grnet.gr/attachments/download/2606/snf-image-helper_0.9.1.orig.tar.gz

h3. Packages (for debian squeeze)

The latest debian package for snf-image (v0.9.1) can be found here:
* "@snf-image@":https://code.grnet.gr/attachments/download/2612/snf-image_0.9.1-1_all.deb

Previous versions and source tarballs can be found here:
https://code.grnet.gr/projects/snf-image/files

You can also download the package from our @apt@ repo:

http://apt2.dev.grnet.gr

h3. Fixed snf-image-helper image

If you installed snf-image using the provided package, you can create the helper VM by launching `snf-image-update-helper' command. People who installed the program from source may use the fixed helper VM image provided below:

* "@snf_image_helper_image-0.9.1-1.tar.xz@":https://pithos.okeanos.grnet.gr/public/euharYruWl7s0C3KfdC2I4

h3. Sample Images

While developing snf-image, we created and tested a number of images. The following images are basic installations of some popular Linux distributions, that have been tested with snf-image and provided here for testing purposes:

* Debian Squeeze Base System ["diskdump":https://pithos.okeanos.grnet.gr/public/rjx2r] ["md5sum":https://pithos.okeanos.grnet.gr/public/lUkGY8Wb2dldZm58mR26s7] ["metadata":https://pithos.okeanos.grnet.gr/public/d9U3xAZeW58IoJC489OLc5]
* Debian Desktop ["diskdump":https://pithos.okeanos.grnet.gr/public/cqhm4] ["md5sum":https://pithos.okeanos.grnet.gr/public/oyso4CuAJdenmtfc7lDXP3] ["metadata":https://pithos.okeanos.grnet.gr/public/XA8X1dgDMUPUuwGwsKAwd4]
* CentOS 6.0 ["diskdump":https://pithos.okeanos.grnet.gr/public/8rxmc] ["md5sum":https://pithos.okeanos.grnet.gr/public/t0ChZ20QVhnsKwpulAcFo7] ["metadata":https://pithos.okeanos.grnet.gr/public/2fOzw5gPtNmmcxgNGPMgb4]
* Fedora Desktop 17 ["diskdump":https://pithos.okeanos.grnet.gr/public/7mosY2PmlVa8froaePOMT] ["md5sum":https://pithos.okeanos.grnet.gr/public/bveqK8Ppc1GeUMC2ObNl11] ["metadata":https://pithos.okeanos.grnet.gr/public/tOOQxCGkWsedYzh2axInY]
* Ubuntu Desktop 12.04 ["diskdump":https://pithos.okeanos.grnet.gr/public/max5g] ["md5sum":https://pithos.okeanos.grnet.gr/public/eIsgkntuFY7tOXxb500Lr5] ["metadata":https://pithos.okeanos.grnet.gr/public/0b5Xhv6YvkJ0OhCLx4gGX]
* Kubuntu Desktop 12.04 ["diskdump":https://pithos.okeanos.grnet.gr/public/p54vr] ["md5sum":https://pithos.okeanos.grnet.gr/public/kt2MPlurSGtj4nJYdQvsW6] ["metadata":https://pithos.okeanos.grnet.gr/public/pSisBRVqsgJ2vRBDH8vCD2]
* Ubuntu Desktop 12.10 ["diskdump":https://pithos.okeanos.grnet.gr/public/nBOFgsXPQUovbNteNP4Z61] ["md5sum":https://pithos.okeanos.grnet.gr/public/ul2bvJfi8zyosmmNmWqhC2] ["metadata":https://pithos.okeanos.grnet.gr/public/XJMgenFgi1iDNwxqaIgV34]
* Kubuntu Desktop 12.10 ["diskdump":https://pithos.okeanos.grnet.gr/public/V5VyiVLd4FHqhc0uB7KJj1] ["md5sum":https://pithos.okeanos.grnet.gr/public/URt4CefewQEiuLhvSzseG3] ["metadata":https://pithos.okeanos.grnet.gr/public/DEodlCBb0u3Pbq6ptBe5Z5]



After getting familiar with snf-image you can build your own Images ([[Image Format|more...]]), or build upon the ones listed above.

h2. Installation

Before installing snf-image be sure to have a working Ganeti installation in your cluster. The installation process should take place in *all* ganeti nodes. Here we will describe the installation in a single node. The process is identical for all nodes and should be repeated manually or automatically, e.g., with puppet.

h3. Installing snf-image using @apt@

Add the following lines in your @sources.list@ file:

<pre>
deb http://apt2.dev.grnet.gr stable/
deb-src http://apt2.dev.grnet.gr stable/
</pre>

and then run:

<pre>
# apt-get update
# apt-get install snf-image
# snf-image-update-helper
</pre>

The last command may take a while. If it exits without errors, you have installed snf-image successfully and you can move on to the configuration section.

h3. Installing snf-image using binary packages

# Download the snf-image debian package as described in the download section.
# Install the snf-image debian package:<pre>$ dpkg -i snf-image_0.9.1-1_all.deb</pre>
# If the dependencies are not met, install all the dependencies using @apt-get -f install@ (or install @snf-image@ with @apt-get@).
# Create the helper VM using the following command:<pre>$ snf-image-update-helper</pre>This command will automatically download all the packages needed to create the helper VM (including snf-image-helper).

h3. Installing snf-image from source

# Download the provided source package:<pre>$ wget https://code.grnet.gr/attachments/download/2609/snf-image_0.9.1.orig.tar.gz</pre>
# Untar, configure and compile the source:<pre>$ tar -xvf snf-image_0.9.orig.tar.gz
$ cd snf-image-0.9.1
$ ./autoget.sh
$ ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var
$ make</pre>
# Install snf-image:<pre>$ make install
$ install -Dm600 defaults /etc/default/snf-image</pre>
# Download the fixed [[wiki#Fixed-snf-image-helper-image|snf-image-helper appliance]]
# Extract it's content under @/var/lib/snf-image/helper/@:<pre>$ mkdir -p /var/lib/snf-image/helper
$ cd /var/lib/snf-image/helper
$ tar -xvf /place/where/you/stored/snf_image_helper_image-0.9.1-1.tar.xz</pre>

h2. Configuration

In this section, we assume that the image file you want to deploy resides under a local directory (e.g.: @/srv/myimages/@)
Once you have installed @snf-image@ in the Ganeti node, you need to overwrite the value of the corresponding option in @/etc/default/snf-image@:

<pre>
IMAGE_DIR = /srv/myimages/
</pre>

@IMAGE_DIR@ should point to the location where the image files are stored [default: @/var/lib/snf-image@].

h2. Sample Usage

h3. Download Image

Download a [[Wiki#Sample-Images|Sample Image]] and store it under @IMAGE_DIR@. Make sure you also have its corresponding metadata file.

h3. Spawn a @diskdump@ image

If you want to deploy an image of type @diskdump@, you need to provide the corresponding @img_properties@ as described in the [[Image_Format#OS-parameter-img_properties|Image Format]] section. If using a diskdump found in the [[Wiki#Sample-Images|Sample Images]] list, use the @img_properties@ described in the image's metadata file. For example:

<pre>gnt-instance add -o snf-image+default --os-parameters img_passwd=SamplePassw0rd,img_format=diskdump,img_id=debian_base-6.0-7-x86_64,img_properties='{"OSFAMILY":"linux"\,"ROOT_PARTITION":"1"}' -t plain --disk=0:size=10G --no-name-check --no-ip-check --no-nics test1</pre>

h3. Spawn an @extdump@/@ntfsdump@ image

To create a ganeti instance with snf-image using @debian_base-6.0-5-x86_64.extdump@ hosted under @IMAGE_DIR@, use a command like the one below:
<pre>gnt-instance add -o snf-image+default --os-parameters img_passwd=SamplePassw0rd,img_format=extdump,img_id=debian_base-6.0-5-x86_64 -t plain --disk=0:size=10G --no-name-check --no-ip-check --no-nics test1</pre>

h2. Advanced Usage

If you want to learn more and use the advanced features of snf-image please refer to following sections:

# [[Configuration Tasks|Image Configuration Tasks]]
# [[Image Format|Supported Image formats]]
# [[Image Store|Supported Image store locations]]
# [[PMI|Progress Monitor Interface]]

h2. Developers

If you are a developer or want to use the latest source code you can download the latest development version by cloning the snf-image git repository:
<pre>$ git clone https://code.grnet.gr/git/snf-image</pre>
The _master_ branch contains the latest development version
The _debian_ branch contains the _master_ plus the debian packaging directories.

For more information on how to configure, install or package from source, see the [[Developer|Developer's page]].

h2. Community & Support

Your help is very important. Any contributions and bug reports will be highly appreciated. You can contact the team at:

* Bug reports - feedback - support: synnefo@googlegroups.com