Statistics
| Branch: | Revision:

root / README @ 549118f0

History | View | Annotate | Download (11.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
- ARCH:       Define the architecture of the image to use. Accepts either 'x86'
71
              or 'x86_64'.
72
- CUSTOMIZE_DIR: A directory containing customization script for the instance.
73
              (by default $sysconfdir/ganeti/instance-image/hooks) See
74
              "Customization of the instance" below.
75
- IMAGE_DEBUG: Enable verbose output for instance scripts.
76

    
77
Note that the settings file is important on the node that the instance is
78
installed on, not the cluster master. This is indeed not a very good model of
79
using this OS but currently the OS interface in ganeti is limiting.
80

    
81
Creation of Deployment Images
82
-----------------------------
83

    
84
There are three types that are supported for deploying images.
85

    
86
  * tarball
87
  * dump
88
  * qemu image
89

    
90
Tarball
91
~~~~~~~
92

    
93
Tarball based images are quite simply a tarball of a working system. An good
94
example use case for this is deploying a Gentoo instance using a stage4 tarball.
95
The only requirement is that the tarball is gzipped instead of bzip2 for speed.
96
If you wish use a kernel inside of the VM instead of externally, make sure that
97
a working kernel, grub config are install in the tarball. Enable the 'grub'
98
custom script to install the grub boot image during installation.
99

    
100
Qemu Images
101
~~~~~~~~~~~
102

    
103
NOTE: qemu images will create a partition of the exact same size as it was
104
originally created with. So if you create a 4GB image and created a new instance
105
of 10G it will create a partition that is only 4GB and leave the rest as "free".
106

    
107
To create a new qemu based disk image, you will need to able the ``CDINSTALL``
108
option and install the VM using the distro's provided installation medium. It is
109
not recommended to build images on systems outside of ganeti (such as libvirt)
110
as we have encountered issues with systems segfaulting.
111

    
112
Once the instance has been created, boot the instance and point it to the
113
install medium::
114

    
115
  gnt-instance start -H cdrom_image_path=path/to/iso/ubuntu-9.10.iso, \
116
    boot_order=cdrom instance-name
117

    
118
Once the base image has been installed, ensure you have the acpid package
119
installed so that ganeti can shutdown the VM properly. Once you are happy with
120
your base image, shutdown the VM, activate the disks,  and create the disk
121
image using qemu-img. Its recommended you use qcow2 with compression to reduce
122
the amount of disk space used::
123

    
124
 # activate disks
125
 gnt-instance activate-disks instance-name
126
 # create image
127
 qemu-img convert -c -f host_device /dev/drbd1 \
128
    -O qcow2 $IMAGE_DIR/ubuntu-9.10-x86_64.img
129

    
130
Note: Older versions of qemu-img may not support the ``host_device`` format so
131
use ``raw`` instead which should work in theory.
132

    
133
Dump
134
~~~~
135

    
136
The last, and most efficient type of disk image is creating filesystem dumps
137
using the dump command. The advantage with using dumps is that its much faster
138
to deploy using it, and it also has built-in compression. The disadvantage is
139
that you need to install grub manually which might be an issue on some operating
140
systems. We currently fully support grub 1 and have partial support with grub2.
141
After the new instance has booted, you will need to run ``update-grub`` and
142
reboot the VM to get the new settings. We currently cannot run ``update-grub``
143
during the install because of an upstream grub2 issue.
144

    
145
You will need to create images for both the boot and root partition (if you
146
include a boot partition).
147

    
148
Create a base image for an instance just like its described in Qemu Images. Make
149
sure the instance is shutdown and then issue the following commands (assuming
150
the activated disk is drbd1)::
151

    
152
  dump -0 -q -z9 -f ${IMAGE_DIR}/${IMAGE_NAME}-${ARCH}-boot.dump \
153
    /dev/mapper/drbdq-1
154

    
155
  dump -0 -q -z9 -f ${IMAGE_DIR}/${IMAGE_NAME}-${ARCH}-root.dump \
156
    /dev/mapper/drbdq-3
157

    
158
Partition Layout
159
~~~~~~~~~~~~~~~~
160

    
161
Currently the partition layout is locked into a specific way in order to make it
162
work more elegantly with ganeti. We might change this to be more flexible in the
163
future, however you *must* use the following layout otherwise ganeti will not
164
install the VM correctly. Currently the following partition layout is assumed:
165

    
166
With swap::
167
 /dev/$disk1    /boot
168
 /dev/$disk2    swap
169
 /dev/$disk3    /
170

    
171
Without swap::
172
 /dev/$disk1    /boot
173
 /dev/$disk2    /
174

    
175
NOTE: If you have kernel_path set, /boot will not be created and all partition
176
numbers will go up by one. For example:
177

    
178
With swap::
179
 /dev/$disk1    swap
180
 /dev/$disk2    /
181

    
182
Without swap::
183
 /dev/$disk1    /
184

    
185
Image Naming
186
~~~~~~~~~~~~
187

    
188
The naming convention that is used is the following:
189

    
190
tarball:    $IMAGE_NAME-$ARCH.tar.gz
191
dump:       $IMAGE_NAME-$ARCH-boot.dump
192
            $IMAGE_NAME-$ARCH-root.dump
193
qemu-img:   $IMAGE_NAME-$ARCH.img
194

    
195
Useful Scripts
196
~~~~~~~~~~~~~~
197

    
198
There are a set of useful scripts located in /usr/share/ganeti/os/image/tools
199
that you are welcome to use. These scripts are all intended to be run on the
200
master node::
201

    
202
  mount-disks $instance_name
203
  umount-disks $instance_name
204

    
205
This will mount or umount an instance to /tmp/${instance_name}_root
206

    
207
  ``make-dump $instance_name [ $IMAGE_DIR ]``
208

    
209
Create dump images for the given OS variant. You can override the default
210
$IMAGE_DIR setting by giving it as a second argument.
211

    
212
  ``make-qemu-img $instance_name [ $IMAGE_DIR ]``
213

    
214
Create an qemu image for the given OS variant.
215

    
216
Customization of the instance
217
-----------------------------
218

    
219
If run-parts is in the os create script, and the CUSTOMIZE_DIR (by default
220
$sysconfdir/ganeti/instance-image/hooks, /etc/ganeti/instance-image/hooks if you
221
configured the os with --sysconfdir=/etc) directory exists any executable whose
222
name matches the run-parts execution rules (quoting run-parts(8): the names must
223
consist entirely of upper and lower case letters, digits, underscores, and
224
hyphens) is executed to allow further personalization of the installation. The
225
following environment variables are passed, in addition to the ones ganeti
226
passes to the OS scripts:
227

    
228
TARGET:     directory in which the filesystem is mounted
229
BLOCKDEV:   ganeti block device
230
ROOT_DEV:   device in which the root (/) filesystem resides (the one mounted in
231
            TARGET)
232
BOOT_DEV:   device in which the boot (/boot) filesystem resides
233
IMAGE_TYPE: type of image being used (tarball, qemu, dump)
234

    
235
The scripts in CUSTOMIZE_DIR can exit with an error code to signal an error in
236
the instance creation, should they fail.
237

    
238
The scripts in CUSTOMIZE_DIR should not start any long-term processes or daemons
239
using this directory, otherwise the installation will fail because it won't be
240
able to umount the filesystem from the directory, and hand the instance back to
241
Ganeti.
242

    
243
Included Custom Scripts
244
-----------------------
245

    
246
This OS definition includes three optional customization scripts that are
247
disabled by default. They are not required but are useful.
248

    
249
Grub
250
~~~~
251

    
252
When enabled, this can setup three things:
253

    
254
- Install grub into the MBR
255
- Setup serial access to grub
256
- Add optional kernel boot parameters
257

    
258
In general, the MBR will only be installed if you're not using a qemu image
259
type, or the ``kernel_path`` parameter is empty or initiating an import.  There
260
is currently partial support for install a grub2 MBR (which Ubuntu Karmic and
261
newer requires).
262

    
263
If ``serial_console`` is ``True`` then this script will try to enable serial
264
support for grub.
265

    
266
Interfaces
267
~~~~~~~~~~
268

    
269
When enabled, it would try to setup networking for eth0 and enable DHCP. It
270
assumes you already have a DHCP client installed on the guest OS. This currently
271
supports the following operating systems:
272

    
273
- Redhat (CentOS/Fedora)
274
- Debian/Ubuntu
275
- Gentoo
276
- OpenSUSE
277

    
278
If you need to set a static ip for instances, you can do that by creating
279
several files in a manner described below.
280

    
281
Subnets:
282

    
283
Create a file in ``/etc/ganeti/instance-image/networks/subnets`` that has a
284
useful name such as ``vlan42``. This file will describe subnet routing
285
information such as the netmask and gateway. The following is an example:
286

    
287
  NETMASK=255.255.255.0
288
  GATEWAY=192.168.1.1
289

    
290
Instance:
291

    
292
Create a file in ``/etc/ganeti/instance-image/networks/instances`` and name it
293
the FQDN of the instance. The file will describe the IP address for the instance
294
and which subnet it resides on. For example, we could create a file named
295
``myinstance.osuosl.org`` and have the following in it:
296

    
297
  ADDRESS=192.168.1.100
298
  SUBNET=vlan42
299

    
300
SSH
301
~~~
302

    
303
When enabled, it will clear out any generated ssh keys that the image may have
304
so that each instance have *unique* host keys. Currently its disabled for
305
Debian/Ubuntu since the keys won't be regenerated via the init script. We plan
306
to fix this manually at some point in the future.
307

    
308
# vi: set tw=80 ft=rst :