root / README @ e34560c8
History | View | Annotate | Download (12.6 kB)
1 |
ganeti-instance-image |
---|---|
2 |
===================== |
3 |
|
4 |
This is a guest OS definition for Ganeti (http://code.google.com/p/ganeti). It |
5 |
will install a Linux-based image using either a tarball, filesystem dump, or a |
6 |
qemu-img disk image file. This definition also allows for manual creation of an |
7 |
instance by simply setting only the disks up and allowing you to boot via the |
8 |
install cd manually. The goal of this instance is to allow fast and flexible |
9 |
installation of instances without the need for external tools such as |
10 |
debootstrap. |
11 |
|
12 |
Installation |
13 |
------------ |
14 |
|
15 |
In order to install this package from source, you need to determine what options |
16 |
ganeti itself has been configured with. If ganeti was built directly from |
17 |
source, then the only place it looks for OS definitions is ``/srv/ganeti/os``, |
18 |
and you need to install the OS under it:: |
19 |
|
20 |
./configure --prefix=/usr --localstatedir=/var \ |
21 |
--sysconfdir=/etc \ |
22 |
--with-os-dir=/srv/ganeti/os |
23 |
make && make install |
24 |
|
25 |
If ganeti was installed from a package, its default OS path should already |
26 |
include /usr/share/ganeti/os, so you can just run:: |
27 |
|
28 |
./configure -prefix=/usr --localstatedir=/var \ |
29 |
--sysconfdir=/etc |
30 |
make && make install |
31 |
|
32 |
Note that you need to repeat this procedure on all nodes of the cluster. |
33 |
|
34 |
The actual path that ganeti has been installed with can be determined by looking |
35 |
for a file named _autoconf.py under a ganeti directory in the python modules |
36 |
tree (e.g. ``/usr/lib/python2.4/site-packages/ganeti/_autoconf.py``). In this |
37 |
file, a variable named OS_SEARCH_PATH will list all the directories in which |
38 |
ganeti will look for OS definitions. |
39 |
|
40 |
Configuration of instance creation |
41 |
---------------------------------- |
42 |
|
43 |
The kind of instance created can be customized via a settings file. This file |
44 |
may or may not be installed by default, as the instance creation will work |
45 |
without it. The creation scripts will look for it in |
46 |
``$sysconfdir/default/ganeti-instance-image``, so if you have run configure with |
47 |
the parameter ``--sysconfdir=/etc``, the final filename will be |
48 |
``/etc/default/ganeti-instance-image``. |
49 |
|
50 |
The following settings will be examined in this file: |
51 |
|
52 |
- CDINSTALL: If 'yes' only setup disks for a cd based install or manual |
53 |
installation via other means. It will not deploy any images or |
54 |
create any partitions. (default: no) |
55 |
- SWAP: Create a swap partition (tarball only) (default: yes) |
56 |
- SWAP_SIZE: Manually set the default swap partition size in MB (default: size |
57 |
of instance memory) |
58 |
- FILESYSTEM: Set which filesystem to format the disks as. Currently only |
59 |
supports ext3 or ext4. (default: ext3) |
60 |
- KERNEL_ARGS: Add additional kernel boot parameters to an instance. This |
61 |
currently only works on booting a kernel from inside. |
62 |
- IMAGE_NAME: Name for the image to use. Generally they will have names similar |
63 |
to: centos-5.4, debian-5.0, etc. The naming is free form depending |
64 |
on what you name the file itself. |
65 |
- IMAGE_TYPE: Create instance by either using a gzipped tarball, file system |
66 |
dump, or an image created by qemu-img. Accepts either 'tarball', |
67 |
'dump', or 'qemu'. (default: dump). |
68 |
- IMAGE_DIR: Override default location for images. |
69 |
(default: ``$localstatedir/cache/ganeti-instance-image``) |
70 |
- NOMOUNT: Do not try to mount volume (typically used if it is not a linux |
71 |
partition). Accepts either 'yes' or 'no'. This option is useful |
72 |
for installing Windows images for example. (default: no) |
73 |
- OVERLAY: Overlay of files to be copied to the instance after OS |
74 |
installation. This is useful for situations where you want to copy |
75 |
instance specific configs such as resolv.conf. |
76 |
- ARCH: Define the architecture of the image to use. Accepts either 'x86' |
77 |
or 'x86_64'. |
78 |
- CUSTOMIZE_DIR: A directory containing customization script for the instance. |
79 |
(by default $sysconfdir/ganeti/instance-image/hooks) See |
80 |
"Customization of the instance" below. |
81 |
- IMAGE_DEBUG: Enable verbose output for instance scripts. Enable by either |
82 |
using "1" or "yes" (default: no ) |
83 |
|
84 |
Note that the settings file is important on the node that the instance is |
85 |
installed on, not the cluster master. This is indeed not a very good model of |
86 |
using this OS but currently the OS interface in ganeti is limiting. |
87 |
|
88 |
Creation of Deployment Images |
89 |
----------------------------- |
90 |
|
91 |
There are three types that are supported for deploying images. |
92 |
|
93 |
* tarball |
94 |
* dump |
95 |
* qemu image |
96 |
|
97 |
Tarball |
98 |
~~~~~~~ |
99 |
|
100 |
Tarball based images are quite simply a tarball of a working system. An good |
101 |
example use case for this is deploying a Gentoo instance using a stage4 tarball. |
102 |
The only requirement is that the tarball is gzipped instead of bzip2 for speed. |
103 |
If you wish use a kernel inside of the VM instead of externally, make sure that |
104 |
a working kernel, grub config are install in the tarball. Enable the 'grub' |
105 |
custom script to install the grub boot image during installation. |
106 |
|
107 |
Qemu Images |
108 |
~~~~~~~~~~~ |
109 |
|
110 |
NOTE: qemu images will create a partition of the exact same size as it was |
111 |
originally created with. So if you create a 4GB image and created a new instance |
112 |
of 10G it will create a partition that is only 4GB and leave the rest as "free". |
113 |
|
114 |
To create a new qemu based disk image, you will need to able the ``CDINSTALL`` |
115 |
option and install the VM using the distro's provided installation medium. It is |
116 |
not recommended to build images on systems outside of ganeti (such as libvirt) |
117 |
as we have encountered issues with systems segfaulting. |
118 |
|
119 |
Once the instance has been created, boot the instance and point it to the |
120 |
install medium:: |
121 |
|
122 |
gnt-instance start -H cdrom_image_path=path/to/iso/ubuntu-9.10.iso, \ |
123 |
boot_order=cdrom instance-name |
124 |
|
125 |
Once the base image has been installed, ensure you have the acpid package |
126 |
installed so that ganeti can shutdown the VM properly. Once you are happy with |
127 |
your base image, shutdown the VM, activate the disks, and create the disk |
128 |
image using qemu-img. Its recommended you use qcow2 with compression to reduce |
129 |
the amount of disk space used:: |
130 |
|
131 |
# activate disks |
132 |
gnt-instance activate-disks instance-name |
133 |
# create image |
134 |
qemu-img convert -c -f host_device /dev/drbd1 \ |
135 |
-O qcow2 $IMAGE_DIR/ubuntu-9.10-x86_64.img |
136 |
|
137 |
Note: Older versions of qemu-img may not support the ``host_device`` format so |
138 |
use ``raw`` instead which should work in theory. |
139 |
|
140 |
Dump |
141 |
~~~~ |
142 |
|
143 |
The last, and most efficient type of disk image is creating filesystem dumps |
144 |
using the dump command. The advantage with using dumps is that its much faster |
145 |
to deploy using it, and it also has built-in compression. The disadvantage is |
146 |
that you need to install grub manually which might be an issue on some operating |
147 |
systems. We currently fully support grub 1 and have partial support with grub2. |
148 |
After the new instance has booted, you will need to run ``update-grub`` and |
149 |
reboot the VM to get the new settings. We currently cannot run ``update-grub`` |
150 |
during the install because of an upstream grub2 issue. |
151 |
|
152 |
You will need to create images for both the boot and root partition (if you |
153 |
include a boot partition). |
154 |
|
155 |
Create a base image for an instance just like its described in Qemu Images. Make |
156 |
sure the instance is shutdown and then issue the following commands (assuming |
157 |
the activated disk is drbd1):: |
158 |
|
159 |
dump -0 -q -z9 -f ${IMAGE_DIR}/${IMAGE_NAME}-${ARCH}-boot.dump \ |
160 |
/dev/mapper/drbdq-1 |
161 |
|
162 |
dump -0 -q -z9 -f ${IMAGE_DIR}/${IMAGE_NAME}-${ARCH}-root.dump \ |
163 |
/dev/mapper/drbdq-3 |
164 |
|
165 |
Partition Layout |
166 |
~~~~~~~~~~~~~~~~ |
167 |
|
168 |
Currently the partition layout is locked into a specific way in order to make it |
169 |
work more elegantly with ganeti. We might change this to be more flexible in the |
170 |
future, however you *must* use the following layout otherwise ganeti will not |
171 |
install the VM correctly. Currently the following partition layout is assumed: |
172 |
|
173 |
With swap:: |
174 |
/dev/$disk1 /boot |
175 |
/dev/$disk2 swap |
176 |
/dev/$disk3 / |
177 |
|
178 |
Without swap:: |
179 |
/dev/$disk1 /boot |
180 |
/dev/$disk2 / |
181 |
|
182 |
NOTE: If you have kernel_path set, /boot will not be created and all partition |
183 |
numbers will go up by one. For example: |
184 |
|
185 |
With swap:: |
186 |
/dev/$disk1 swap |
187 |
/dev/$disk2 / |
188 |
|
189 |
Without swap:: |
190 |
/dev/$disk1 / |
191 |
|
192 |
Image Naming |
193 |
~~~~~~~~~~~~ |
194 |
|
195 |
The naming convention that is used is the following: |
196 |
|
197 |
tarball: $IMAGE_NAME-$ARCH.tar.gz |
198 |
dump: $IMAGE_NAME-$ARCH-boot.dump |
199 |
$IMAGE_NAME-$ARCH-root.dump |
200 |
qemu-img: $IMAGE_NAME-$ARCH.img |
201 |
|
202 |
Useful Scripts |
203 |
~~~~~~~~~~~~~~ |
204 |
|
205 |
There are a set of useful scripts located in /usr/share/ganeti/os/image/tools |
206 |
that you are welcome to use. These scripts are all intended to be run on the |
207 |
master node:: |
208 |
|
209 |
mount-disks $instance_name |
210 |
umount-disks $instance_name |
211 |
|
212 |
This will mount or umount an instance to /tmp/${instance_name}_root |
213 |
|
214 |
``make-dump $instance_name [ $IMAGE_DIR ]`` |
215 |
|
216 |
Create dump images for the given OS variant. You can override the default |
217 |
$IMAGE_DIR setting by giving it as a second argument. |
218 |
|
219 |
``make-qemu-img $instance_name [ $IMAGE_DIR ]`` |
220 |
|
221 |
Create an qemu image for the given OS variant. |
222 |
|
223 |
Customization of the instance |
224 |
----------------------------- |
225 |
|
226 |
If run-parts is in the os create script, and the CUSTOMIZE_DIR (by default |
227 |
$sysconfdir/ganeti/instance-image/hooks, /etc/ganeti/instance-image/hooks if you |
228 |
configured the os with --sysconfdir=/etc) directory exists any executable whose |
229 |
name matches the run-parts execution rules (quoting run-parts(8): the names must |
230 |
consist entirely of upper and lower case letters, digits, underscores, and |
231 |
hyphens) is executed to allow further personalization of the installation. The |
232 |
following environment variables are passed, in addition to the ones ganeti |
233 |
passes to the OS scripts: |
234 |
|
235 |
TARGET: directory in which the filesystem is mounted |
236 |
BLOCKDEV: ganeti block device |
237 |
ROOT_DEV: device in which the root (/) filesystem resides (the one mounted in |
238 |
TARGET) |
239 |
BOOT_DEV: device in which the boot (/boot) filesystem resides |
240 |
IMAGE_TYPE: type of image being used (tarball, qemu, dump) |
241 |
|
242 |
The scripts in CUSTOMIZE_DIR can exit with an error code to signal an error in |
243 |
the instance creation, should they fail. |
244 |
|
245 |
The scripts in CUSTOMIZE_DIR should not start any long-term processes or daemons |
246 |
using this directory, otherwise the installation will fail because it won't be |
247 |
able to umount the filesystem from the directory, and hand the instance back to |
248 |
Ganeti. |
249 |
|
250 |
Included Custom Scripts |
251 |
----------------------- |
252 |
|
253 |
This OS definition includes three optional customization scripts that are |
254 |
disabled by default. They are not required but are useful. |
255 |
|
256 |
Grub |
257 |
~~~~ |
258 |
|
259 |
When enabled, this can setup three things: |
260 |
|
261 |
- Install grub into the MBR |
262 |
- Setup serial access to grub |
263 |
- Add optional kernel boot parameters |
264 |
|
265 |
In general, the MBR will only be installed if you're not using a qemu image |
266 |
type, or the ``kernel_path`` parameter is empty or initiating an import. There |
267 |
is currently partial support for install a grub2 MBR (which Ubuntu Karmic and |
268 |
newer requires). |
269 |
|
270 |
If ``serial_console`` is ``True`` then this script will try to enable serial |
271 |
support for grub. |
272 |
|
273 |
Interfaces |
274 |
~~~~~~~~~~ |
275 |
|
276 |
When enabled, it would try to setup networking for eth0 and enable DHCP. It |
277 |
assumes you already have a DHCP client installed on the guest OS. This currently |
278 |
supports the following operating systems: |
279 |
|
280 |
- Redhat (CentOS/Fedora) |
281 |
- Debian/Ubuntu |
282 |
- Gentoo |
283 |
- OpenSUSE |
284 |
|
285 |
If you need to set a static ip for instances, you can do that by creating |
286 |
several files in a manner described below. |
287 |
|
288 |
Subnets: |
289 |
|
290 |
Create a file in ``/etc/ganeti/instance-image/networks/subnets`` that has a |
291 |
useful name such as ``vlan42``. This file will describe subnet routing |
292 |
information such as the netmask and gateway. The following is an example: |
293 |
|
294 |
NETMASK=255.255.255.0 |
295 |
GATEWAY=192.168.1.1 |
296 |
|
297 |
Instance: |
298 |
|
299 |
Create a file in ``/etc/ganeti/instance-image/networks/instances`` and name it |
300 |
the FQDN of the instance. The file will describe the IP address for the instance |
301 |
and which subnet it resides on. For example, we could create a file named |
302 |
``myinstance.osuosl.org`` and have the following in it: |
303 |
|
304 |
ADDRESS=192.168.1.100 |
305 |
SUBNET=vlan42 |
306 |
|
307 |
SSH |
308 |
~~~ |
309 |
|
310 |
When enabled, it will clear out any generated ssh keys that the image may have |
311 |
so that each instance have *unique* host keys. Currently its disabled for |
312 |
Debian/Ubuntu since the keys won't be regenerated via the init script. We plan |
313 |
to fix this manually at some point in the future. |
314 |
|
315 |
Overlays |
316 |
~~~~~~~~ |
317 |
|
318 |
When enabled it will copy a directory of files recursively into the instance. |
319 |
This is quite useful for site specific configurations such as resolv.conf. |
320 |
Create a directory in ``/etc/ganeit/instance-image/overlays/`` and copy files as |
321 |
needed into it. Treat the directory as the root of the filesystem. Set |
322 |
``OVERLAY`` for the variant as the name of the directory. This directory needs |
323 |
to exist on all nodes in order to work. |
324 |
|
325 |
# vi: set tw=80 ft=rst : |