Wiki

Version 62 (Constantinos Venetsanopoulos, 09/14/2012 03:18 pm)

1 21 Constantinos Venetsanopoulos
h2. snf-image
2 21 Constantinos Venetsanopoulos
3 21 Constantinos Venetsanopoulos
!snf-image-logo.png!
4 1 Constantinos Venetsanopoulos
5 10 Vangelis Koukis
h2. Introduction - Features
6 10 Vangelis Koukis
7 54 Constantinos Venetsanopoulos
snf-image is a "Ganeti":http://code.google.com/p/ganeti/ OS Definition, primarily used by "Synnefo":https://code.grnet.gr/projects/synnefo .
8 2 Constantinos Venetsanopoulos
9 30 Constantinos Venetsanopoulos
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.
10 1 Constantinos Venetsanopoulos
11 7 Vangelis Koukis
There are also additional hooks that can be enabled at image deployment. They allow for:
12 1 Constantinos Venetsanopoulos
13 7 Vangelis Koukis
 * changing the password of root or arbitrary users
14 7 Vangelis Koukis
 * injecting files at arbitrary locations inside the filesystem, e.g., SSH keys
15 7 Vangelis Koukis
 * setting a custom hostname
16 7 Vangelis Koukis
 * re-creating SSH host keys to ensure the image uses unique keys
17 1 Constantinos Venetsanopoulos
18 7 Vangelis Koukis
snf-image has been used successfully to deploy many major Linux distributions (Debian, Ubuntu/Kubuntu, CentOS, Fedora), as well as Windows 2008 R2.  
19 7 Vangelis Koukis
20 40 Constantinos Venetsanopoulos
The snf-image Ganeti OS Definition is released under [[Licence|GNU Generic Public Lisence version 2]].
21 35 Nikos Skalkotos
22 35 Nikos Skalkotos
h2. Ganeti OS Interface
23 35 Nikos Skalkotos
24 7 Vangelis Koukis
snf-image requires ganeti-os-interface v20 to operate.
25 7 Vangelis Koukis
It introduces the following OS parameters:
26 7 Vangelis Koukis
27 62 Constantinos Venetsanopoulos
 * @img_id@ (_required_ if @config_url@ is missing): the unique id of the image as known by the storage backend
28 62 Constantinos Venetsanopoulos
 * @img_format@ (_required_ if @config_url@ is missing): the image format type (see [[Image Format|here]])
29 62 Constantinos Venetsanopoulos
 * @img_passwd@ (_required_ if @config_url@ is missing): the passwd to be injected inside the image
30 8 Vangelis Koukis
 * @img_properties@ (_optional_): additional image properties used to customize the image ([[Image_Format#Image-Properties|details]])
31 1 Constantinos Venetsanopoulos
 * @img_personality@ (_optional_): files to be injected into the image filesystem ([[Personality OS Parameter|details]]).
32 62 Constantinos Venetsanopoulos
 * @config_url@ (_optional_): the url to download configuration data from
33 1 Constantinos Venetsanopoulos
34 1 Constantinos Venetsanopoulos
h2. Architecture
35 8 Vangelis Koukis
36 8 Vangelis Koukis
snf-image is split in two components: A part running on the Ganeti host, with full root privilege (@snf-image-host@), and a part running inside an unprivileged, helper VM (@snf-image-helper@).
37 8 Vangelis Koukis
38 8 Vangelis Koukis
h3. snf-image-host
39 8 Vangelis Koukis
40 8 Vangelis Koukis
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.
41 8 Vangelis Koukis
42 8 Vangelis Koukis
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-host@ to automate the creation of a helper VM image based on Debian Stable, using @debootstrap@.
43 8 Vangelis Koukis
44 8 Vangelis Koukis
The @snf-image-helper@ component is spawned inside a specific hardware environment:
45 8 Vangelis Koukis
46 8 Vangelis Koukis
* The VM features a virtual floppy, containing an @ext2@ filesystem with all parameters needed for image customization.
47 8 Vangelis Koukis
* The hard disk of the VM being deployed is accessible as the first @virtio@ hard disk.
48 40 Constantinos Venetsanopoulos
* 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.
49 8 Vangelis Koukis
* The helper VM is expected to output "SUCCESS" to its second serial port if image customization was successful inside the VM.
50 8 Vangelis Koukis
  In any other case, execution of the helper VM or @snf-image-helper@ has failed.
51 8 Vangelis Koukis
* 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@.
52 8 Vangelis Koukis
53 8 Vangelis Koukis
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.
54 8 Vangelis Koukis
55 8 Vangelis Koukis
h3. snf-image-helper
56 8 Vangelis Koukis
57 43 Nikos Skalkotos
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 the @snf-image-host@ component. @snf-image-helper@ uses @runparts@ to run tasks found under @/usr/lib/snf-image-helper/tasks@ by default.
58 3 Constantinos Venetsanopoulos
59 14 Vangelis Koukis
The architecture is presented below:
60 11 Constantinos Venetsanopoulos
61 12 Constantinos Venetsanopoulos
h3. Graphical Representation
62 11 Constantinos Venetsanopoulos
63 11 Constantinos Venetsanopoulos
!snf-image_arch.png!
64 11 Constantinos Venetsanopoulos
65 47 Nikos Skalkotos
h3. Image Names
66 47 Nikos Skalkotos
67 47 Nikos Skalkotos
snf-image assumes all image files have the following format:
68 47 Nikos Skalkotos
<pre><image_id>.<image_format></pre>
69 47 Nikos Skalkotos
70 47 Nikos Skalkotos
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:
71 47 Nikos Skalkotos
<pre>img_format=extdump
72 47 Nikos Skalkotos
img_id=debian_base-6.0-5-x86_64</pre>
73 47 Nikos Skalkotos
74 1 Constantinos Venetsanopoulos
h2. Download
75 1 Constantinos Venetsanopoulos
76 41 Constantinos Venetsanopoulos
h3. Packages
77 41 Constantinos Venetsanopoulos
78 53 Constantinos Venetsanopoulos
Download the latest debian packages (v0.4):
79 59 Constantinos Venetsanopoulos
* "@snf-image-host@":https://code.grnet.gr/attachments/download/1416/snf-image-host_0.4.2-1_all.deb
80 59 Constantinos Venetsanopoulos
* "@snf-image-helper@":https://code.grnet.gr/attachments/download/1410/snf-image-helper_0.4.2-1_all.deb
81 10 Vangelis Koukis
82 25 Constantinos Venetsanopoulos
Previous versions and source tarballs can be found here:
83 10 Vangelis Koukis
https://code.grnet.gr/projects/snf-image/files
84 1 Constantinos Venetsanopoulos
85 41 Constantinos Venetsanopoulos
h3. Sample Images
86 41 Constantinos Venetsanopoulos
87 41 Constantinos Venetsanopoulos
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:
88 41 Constantinos Venetsanopoulos
89 61 Nikos Skalkotos
* Debian Squeeze Base System ["diskdump":https://pithos.okeanos.grnet.gr/public/grv9n] ["md5sum":https://pithos.okeanos.grnet.gr/public/vdwf3] ["metadata":https://pithos.okeanos.grnet.gr/public/zt6mc]
90 60 Nikos Skalkotos
* Debian Desktop ["diskdump":https://pithos.okeanos.grnet.gr/public/n8dh4] ["md5sum":https://pithos.okeanos.grnet.gr/public/byvsw] ["metadata":https://pithos.okeanos.grnet.gr/public/cu92b]
91 61 Nikos Skalkotos
* CentOS 6.0 ["diskdump":https://pithos.okeanos.grnet.gr/public/mw8vg] ["md5sum":https://pithos.okeanos.grnet.gr/public/85k8d] ["metadata":https://pithos.okeanos.grnet.gr/public/cm6tz]
92 60 Nikos Skalkotos
* Fedora Desktop 17 ["diskdump":https://pithos.okeanos.grnet.gr/public/wf6c7] ["md5sum":https://pithos.okeanos.grnet.gr/public/j76kv] ["metadata":https://pithos.okeanos.grnet.gr/public/yss35]
93 60 Nikos Skalkotos
* Ubuntu Desktop 12.04 ["diskdump":https://pithos.okeanos.grnet.gr/public/vjkyy] ["md5sum":https://pithos.okeanos.grnet.gr/public/z4wgs] ["metadata":https://pithos.okeanos.grnet.gr/public/mejnd]
94 60 Nikos Skalkotos
* Kubuntu Desktop 12.04 ["diskdump":https://pithos.okeanos.grnet.gr/public/8xd6f] ["md5sum":https://pithos.okeanos.grnet.gr/public/cvkzx] ["metadata":https://pithos.okeanos.grnet.gr/public/wpwh6]
95 41 Constantinos Venetsanopoulos
96 41 Constantinos Venetsanopoulos
After getting familiar with snf-image you can build your own Images ([[Image Format|more...]]), or build upon the ones listed above.
97 33 Vangelis Koukis
98 1 Constantinos Venetsanopoulos
h2. Installation
99 1 Constantinos Venetsanopoulos
100 9 Vangelis Koukis
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.
101 5 Constantinos Venetsanopoulos
102 5 Constantinos Venetsanopoulos
# Download the snf-image-host debian package as described in the download section.
103 5 Constantinos Venetsanopoulos
# Install the snf-image-host debian package:
104 5 Constantinos Venetsanopoulos
<pre>
105 5 Constantinos Venetsanopoulos
 # dpkg -i snf-image-host_version.deb
106 5 Constantinos Venetsanopoulos
</pre>
107 55 Constantinos Venetsanopoulos
# If the dependencies are not met, install all the dependencies using @apt-get install@ (or install @snf-image-host@ with @apt-get@).
108 5 Constantinos Venetsanopoulos
# Download the snf-image-helper debian package as described in the download section and store it in a handy location.
109 16 Constantinos Venetsanopoulos
# *Do NOT install the snf-image-helper debian package* in the Ganeti node (the @deb@ file should be present in all nodes, but NOT installed in any node).
110 5 Constantinos Venetsanopoulos
# Configure the package, as described in the next section, before you can start using the new OS Definition.
111 5 Constantinos Venetsanopoulos
112 45 Nikos Skalkotos
h2. Configuration
113 45 Nikos Skalkotos
114 1 Constantinos Venetsanopoulos
Once you have installed snf-image-host in the Ganeti node, you may need to overwrite the value of some of the following variables in @/etc/default/snf-image@:
115 45 Nikos Skalkotos
# *IMAGE_DIR*: This should point to the location where the image files are stored [default: @/var/lib/snf-image@].
116 45 Nikos Skalkotos
# *HELPER_DIR*: This should point to a directory which will host all helper VM files [default: @/var/lib/snf-image/helper@]. This directory should be able to host 700MB.
117 1 Constantinos Venetsanopoulos
# *HELPER_PKG*: This should point to the snf-image-helper debian package [default: @/var/lib/snf-image/helper/snf-image-helper_version.deb@].
118 45 Nikos Skalkotos
119 47 Nikos Skalkotos
After all variables are properly set, execute @snf-image-update-helper@ command to populate @HELPER_DIR@ with the needed files: <pre>$ /usr/bin/snf-image-update-helper</pre>
120 55 Constantinos Venetsanopoulos
The above will create the helper VM, install the snf-image-helper package inside it and store all the above under @HELPER_DIR@. If no errors are displayed, you are ready to use the snf-image OS Definition.
121 31 Vangelis Koukis
122 47 Nikos Skalkotos
h2. Sample Usage
123 1 Constantinos Venetsanopoulos
124 56 Constantinos Venetsanopoulos
h3. @extdump@/@ntfsdump@ images
125 56 Constantinos Venetsanopoulos
126 56 Constantinos Venetsanopoulos
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:
127 1 Constantinos Venetsanopoulos
<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>
128 1 Constantinos Venetsanopoulos
129 56 Constantinos Venetsanopoulos
h3. @diskdump@ images
130 56 Constantinos Venetsanopoulos
131 58 Constantinos Venetsanopoulos
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 Sample Images list, use the @img_properties@ described in the image's metadata file. For example:
132 56 Constantinos Venetsanopoulos
133 57 Constantinos Venetsanopoulos
<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>
134 23 Constantinos Venetsanopoulos
135 22 Constantinos Venetsanopoulos
h2. Developers
136 13 Constantinos Venetsanopoulos
137 46 Nikos Skalkotos
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:
138 45 Nikos Skalkotos
<pre>$ git clone https://code.grnet.gr/git/snf-image</pre>
139 18 Vangelis Koukis
The _master_ branch contains the latest development version
140 18 Vangelis Koukis
The _debian_ branch contains the _master_ plus the debian packaging directories.
141 18 Vangelis Koukis
142 24 Constantinos Venetsanopoulos
For more information on how to configure, install or package from source, see the [[Developer|Developer's page]].
143 27 Nikos Skalkotos
For more information on the image format used in snf-image, see [[Image Format]].
144 19 Vangelis Koukis
145 1 Constantinos Venetsanopoulos
h2. Community & Support
146 13 Constantinos Venetsanopoulos
147 13 Constantinos Venetsanopoulos
Your help is very important. Any contributions and bug reports will be highly appreciated. You can contact the team at:
148 1 Constantinos Venetsanopoulos
149 9 Vangelis Koukis
* Bug reports - feedback - support: synnefo@lists.grnet.gr