Wiki

Version 106 (Nikos Skalkotos, 03/12/2013 08:15 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 101 Nikos Skalkotos
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 101 Nikos Skalkotos
11 101 Nikos Skalkotos
snf-image supports KVM and Xen based ganeti clusters.
12 1 Constantinos Venetsanopoulos
13 7 Vangelis Koukis
There are also additional hooks that can be enabled at image deployment. They allow for:
14 1 Constantinos Venetsanopoulos
15 7 Vangelis Koukis
 * changing the password of root or arbitrary users
16 7 Vangelis Koukis
 * injecting files at arbitrary locations inside the filesystem, e.g., SSH keys
17 7 Vangelis Koukis
 * setting a custom hostname
18 7 Vangelis Koukis
 * re-creating SSH host keys to ensure the image uses unique keys
19 1 Constantinos Venetsanopoulos
20 72 Nikos Skalkotos
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.
21 7 Vangelis Koukis
22 40 Constantinos Venetsanopoulos
The snf-image Ganeti OS Definition is released under [[Licence|GNU Generic Public Lisence version 2]].
23 35 Nikos Skalkotos
24 35 Nikos Skalkotos
h2. Ganeti OS Interface
25 35 Nikos Skalkotos
26 7 Vangelis Koukis
snf-image requires ganeti-os-interface v20 to operate.
27 7 Vangelis Koukis
It introduces the following OS parameters:
28 7 Vangelis Koukis
29 69 Nikos Skalkotos
 * @img_id@ (_required if @config_url@ is missing_): the URI used to identify the image (see [[Image IDs and Storage Back Ends|here]])
30 63 Constantinos Venetsanopoulos
 * @img_format@ (_required if @config_url@ is missing_): the image format type (see [[Image Format|here]])
31 63 Constantinos Venetsanopoulos
 * @img_passwd@ (_required if @config_url@ is missing_): the passwd to be injected inside the image
32 8 Vangelis Koukis
 * @img_properties@ (_optional_): additional image properties used to customize the image ([[Image_Format#Image-Properties|details]])
33 1 Constantinos Venetsanopoulos
 * @img_personality@ (_optional_): files to be injected into the image filesystem ([[Personality OS Parameter|details]]).
34 62 Constantinos Venetsanopoulos
 * @config_url@ (_optional_): the url to download configuration data from
35 1 Constantinos Venetsanopoulos
36 1 Constantinos Venetsanopoulos
h2. Architecture
37 8 Vangelis Koukis
38 99 Nikos Skalkotos
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@).
39 8 Vangelis Koukis
40 95 Nikos Skalkotos
h3. snf-image
41 8 Vangelis Koukis
42 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.
43 8 Vangelis Koukis
44 102 Nikos Skalkotos
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@.
45 8 Vangelis Koukis
46 8 Vangelis Koukis
The @snf-image-helper@ component is spawned inside a specific hardware environment:
47 8 Vangelis Koukis
48 8 Vangelis Koukis
* The VM features a virtual floppy, containing an @ext2@ filesystem with all parameters needed for image customization.
49 8 Vangelis Koukis
* The hard disk of the VM being deployed is accessible as the first @virtio@ hard disk.
50 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.
51 8 Vangelis Koukis
* The helper VM is expected to output "SUCCESS" to its second serial port if image customization was successful inside the VM.
52 8 Vangelis Koukis
  In any other case, execution of the helper VM or @snf-image-helper@ has failed.
53 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@.
54 8 Vangelis Koukis
55 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.
56 8 Vangelis Koukis
57 8 Vangelis Koukis
h3. snf-image-helper
58 8 Vangelis Koukis
59 102 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 @snf-image@. @snf-image-helper@ uses @runparts@ to run tasks found under @/usr/lib/snf-image-helper/tasks@ by default.
60 3 Constantinos Venetsanopoulos
61 14 Vangelis Koukis
The architecture is presented below:
62 11 Constantinos Venetsanopoulos
63 12 Constantinos Venetsanopoulos
h3. Graphical Representation
64 11 Constantinos Venetsanopoulos
65 11 Constantinos Venetsanopoulos
!snf-image_arch.png!
66 11 Constantinos Venetsanopoulos
67 47 Nikos Skalkotos
h3. Image Names
68 47 Nikos Skalkotos
69 47 Nikos Skalkotos
snf-image assumes all image files have the following format:
70 47 Nikos Skalkotos
<pre><image_id>.<image_format></pre>
71 47 Nikos Skalkotos
72 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:
73 47 Nikos Skalkotos
<pre>img_format=extdump
74 47 Nikos Skalkotos
img_id=debian_base-6.0-5-x86_64</pre>
75 47 Nikos Skalkotos
76 1 Constantinos Venetsanopoulos
h2. Download
77 1 Constantinos Venetsanopoulos
78 79 Nikos Skalkotos
h3. Source
79 1 Constantinos Venetsanopoulos
80 106 Nikos Skalkotos
The latest source packages for snf-image (v0.8.1) can be found here:
81 106 Nikos Skalkotos
* "@snf-image_0.8.1.orig.tar.gz@":https://code.grnet.gr/attachments/download/2412/snf-image_0.8.1.orig.tar.gz
82 106 Nikos Skalkotos
* "@snf-image-helper_0.8.1.orig.tar.gz@":https://code.grnet.gr/attachments/download/2409/snf-image-helper_0.8.1.orig.tar.gz
83 79 Nikos Skalkotos
84 79 Nikos Skalkotos
h3. Packages (for debian squeeze)
85 79 Nikos Skalkotos
86 106 Nikos Skalkotos
The latest debian package for snf-image (v0.8.1) can be found here:
87 106 Nikos Skalkotos
* "@snf-image@":https://code.grnet.gr/attachments/download/2415/snf-image_0.8.1-1_all.deb
88 10 Vangelis Koukis
89 1 Constantinos Venetsanopoulos
Previous versions and source tarballs can be found here:
90 10 Vangelis Koukis
https://code.grnet.gr/projects/snf-image/files
91 1 Constantinos Venetsanopoulos
92 73 Nikos Skalkotos
You can also download the package from our @apt@ repo:
93 64 Constantinos Venetsanopoulos
94 83 Nikos Skalkotos
http://apt2.dev.grnet.gr
95 64 Constantinos Venetsanopoulos
96 80 Nikos Skalkotos
h3. Fixed snf-image-helper image
97 80 Nikos Skalkotos
98 102 Nikos Skalkotos
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:
99 80 Nikos Skalkotos
100 106 Nikos Skalkotos
* "@snf_image_helper_image-0.8.1-1.tar.xz@":https://pithos.okeanos.grnet.gr/public/g2tea
101 80 Nikos Skalkotos
102 41 Constantinos Venetsanopoulos
h3. Sample Images
103 41 Constantinos Venetsanopoulos
104 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:
105 41 Constantinos Venetsanopoulos
106 89 Nikos Skalkotos
* Debian Squeeze Base System ["diskdump":https://pithos.okeanos.grnet.gr/public/rjx2r] ["md5sum":https://pithos.okeanos.grnet.gr/public/ngx96] ["metadata":https://pithos.okeanos.grnet.gr/public/b5y5b]
107 89 Nikos Skalkotos
* Debian Desktop ["diskdump":https://pithos.okeanos.grnet.gr/public/cqhm4] ["md5sum":https://pithos.okeanos.grnet.gr/public/964nw] ["metadata":https://pithos.okeanos.grnet.gr/public/ja4e2]
108 90 Nikos Skalkotos
* CentOS 6.0 ["diskdump":https://pithos.okeanos.grnet.gr/public/8rxmc] ["md5sum":https://pithos.okeanos.grnet.gr/public/2am9n] ["metadata":https://pithos.okeanos.grnet.gr/public/gt758]
109 93 Nikos Skalkotos
* Fedora Desktop 17 ["diskdump":https://pithos.okeanos.grnet.gr/public/22y35] ["md5sum":https://pithos.okeanos.grnet.gr/public/g4qft] ["metadata":https://pithos.okeanos.grnet.gr/public/vd4gs]
110 92 Nikos Skalkotos
* Ubuntu Desktop 12.04 ["diskdump":https://pithos.okeanos.grnet.gr/public/max5g] ["md5sum":https://pithos.okeanos.grnet.gr/public/8xyzd] ["metadata":https://pithos.okeanos.grnet.gr/public/cvhnz]
111 91 Nikos Skalkotos
* Kubuntu Desktop 12.04 ["diskdump":https://pithos.okeanos.grnet.gr/public/p54vr] ["md5sum":https://pithos.okeanos.grnet.gr/public/4qyej] ["metadata":https://pithos.okeanos.grnet.gr/public/5nqtp]
112 41 Constantinos Venetsanopoulos
113 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.
114 33 Vangelis Koukis
115 1 Constantinos Venetsanopoulos
h2. Installation
116 1 Constantinos Venetsanopoulos
117 5 Constantinos Venetsanopoulos
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.
118 5 Constantinos Venetsanopoulos
119 104 Constantinos Venetsanopoulos
h3. Installing snf-image using @apt@
120 103 Constantinos Venetsanopoulos
121 104 Constantinos Venetsanopoulos
Add the following lines in your @sources.list@ file:
122 103 Constantinos Venetsanopoulos
123 104 Constantinos Venetsanopoulos
<pre>
124 1 Constantinos Venetsanopoulos
deb http://apt2.dev.grnet.gr stable/
125 103 Constantinos Venetsanopoulos
deb-src http://apt2.dev.grnet.gr stable/
126 104 Constantinos Venetsanopoulos
</pre>
127 103 Constantinos Venetsanopoulos
128 103 Constantinos Venetsanopoulos
and then run:
129 103 Constantinos Venetsanopoulos
130 105 Constantinos Venetsanopoulos
<pre>
131 103 Constantinos Venetsanopoulos
# apt-get update
132 103 Constantinos Venetsanopoulos
# apt-get install snf-image
133 103 Constantinos Venetsanopoulos
# snf-image-update-helper
134 105 Constantinos Venetsanopoulos
</pre>
135 103 Constantinos Venetsanopoulos
136 103 Constantinos Venetsanopoulos
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.
137 103 Constantinos Venetsanopoulos
138 81 Nikos Skalkotos
h3. Installing snf-image using binary packages
139 81 Nikos Skalkotos
140 94 Nikos Skalkotos
# Download the snf-image debian package as described in the download section.
141 94 Nikos Skalkotos
# Install the snf-image debian package:<pre>$ dpkg -i snf-image_0.8-1_all.deb</pre>
142 102 Nikos Skalkotos
# If the dependencies are not met, install all the dependencies using @apt-get -f install@ (or install @snf-image@ with @apt-get@).
143 1 Constantinos Venetsanopoulos
# 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).
144 81 Nikos Skalkotos
145 81 Nikos Skalkotos
h3. Installing snf-image from source
146 81 Nikos Skalkotos
147 106 Nikos Skalkotos
# Download the provided source package:<pre>$ wget https://code.grnet.gr/attachments/download/2412/snf-image_0.8.1.orig.tar.gz</pre>
148 106 Nikos Skalkotos
# Untar, configure and compile the source:<pre>$ tar -xvf snf-image_0.8.1.orig.tar.gz
149 106 Nikos Skalkotos
$ cd snf-image-0.8.1
150 81 Nikos Skalkotos
$ ./autoget.sh
151 81 Nikos Skalkotos
$ ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var
152 81 Nikos Skalkotos
$ make</pre>
153 102 Nikos Skalkotos
# Install snf-image:<pre>$ make install
154 85 Nikos Skalkotos
$ install -Dm600 defaults /etc/default/snf-image</pre>
155 81 Nikos Skalkotos
# Download the fixed snf-image-helper image
156 81 Nikos Skalkotos
# Extract it's content under @/var/lib/snf-image/helper/@:<pre>$ mkdir -p /var/lib/snf-image/helper
157 81 Nikos Skalkotos
$ cd /var/lib/snf-image/helper
158 106 Nikos Skalkotos
$ tar -xvf /place/where/you/stored/snf_image_helper_image-0.8.1-1.tar.xz</pre>
159 45 Nikos Skalkotos
160 45 Nikos Skalkotos
h2. Configuration
161 1 Constantinos Venetsanopoulos
162 45 Nikos Skalkotos
In this section, we assume that the image file you want to deploy resides under a local directory.
163 102 Nikos Skalkotos
Once you have installed snf-image in the Ganeti node, you may need to overwrite the value of the following variables in @/etc/default/snf-image@:
164 55 Constantinos Venetsanopoulos
# *IMAGE_DIR*: This should point to the location where the image files are stored [default: @/var/lib/snf-image@].
165 31 Vangelis Koukis
166 47 Nikos Skalkotos
h2. Sample Usage
167 1 Constantinos Venetsanopoulos
168 65 Constantinos Venetsanopoulos
h3. @diskdump@ images
169 65 Constantinos Venetsanopoulos
170 65 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:
171 65 Constantinos Venetsanopoulos
172 65 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>
173 65 Constantinos Venetsanopoulos
174 56 Constantinos Venetsanopoulos
h3. @extdump@/@ntfsdump@ images
175 1 Constantinos Venetsanopoulos
176 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:
177 56 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>
178 1 Constantinos Venetsanopoulos
179 65 Constantinos Venetsanopoulos
h2. Advanced Usage
180 1 Constantinos Venetsanopoulos
181 65 Constantinos Venetsanopoulos
If you want to learn more and use the advanced features of snf-image please refer to following sections:
182 1 Constantinos Venetsanopoulos
183 76 Nikos Skalkotos
# [[Configuration Tasks|Image Configuration Tasks]]
184 76 Nikos Skalkotos
# [[Image Format|Supported Image formats]]
185 76 Nikos Skalkotos
# [[Image Store|Supported Image store locations]]
186 76 Nikos Skalkotos
# [[PMI|Progress Monitor Interface]]
187 22 Constantinos Venetsanopoulos
188 13 Constantinos Venetsanopoulos
h2. Developers
189 46 Nikos Skalkotos
190 45 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:
191 18 Vangelis Koukis
<pre>$ git clone https://code.grnet.gr/git/snf-image</pre>
192 18 Vangelis Koukis
The _master_ branch contains the latest development version
193 18 Vangelis Koukis
The _debian_ branch contains the _master_ plus the debian packaging directories.
194 24 Constantinos Venetsanopoulos
195 27 Nikos Skalkotos
For more information on how to configure, install or package from source, see the [[Developer|Developer's page]].
196 19 Vangelis Koukis
197 1 Constantinos Venetsanopoulos
h2. Community & Support
198 13 Constantinos Venetsanopoulos
199 13 Constantinos Venetsanopoulos
Your help is very important. Any contributions and bug reports will be highly appreciated. You can contact the team at:
200 1 Constantinos Venetsanopoulos
201 75 Nikos Skalkotos
* Bug reports - feedback - support: synnefo@googlegroups.com