Update the documentation (part 2)
[snf-image] / docs / architecture.rst
1 Architecture
2 ============
3
4 snf-image is split in two components: The main program running on the Ganeti
5 host, with full root privilege (*snf-image* previously *snf-image-host*), and a
6 part running inside an unprivileged, helper VM (*snf-image-helper*).
7
8 snf-image
9 ^^^^^^^^^
10
11 This part implements the Ganeti OS interface. It extracts the Image onto the
12 Ganeti-provided block device, using streaming block I/O (dd with oflag=direct),
13 then passes control to snf-image-helper running inside a helper VM. The helper
14 VM is created using KVM, runs as an unprivileged user, nobody by default.
15
16 There is no restriction on the distribution running inside the helper VM, as
17 long as it executes the snf-image-helper component automatically upon bootup.
18 The snf-image-update-helper script is provided with snf-image to automate the
19 creation of a helper VM image based on Debian Stable, using multistrap.
20
21 The snf-image-helper component is spawned inside a specific hardware
22 environment:
23
24  * The VM features a virtual floppy, containing an ext2 filesystem with all
25    parameters needed for image customization.
26  * The hard disk of the VM being deployed is accessible as the first virtio
27    hard disk.
28  * All kernel/console output is redirected to the first virtual serial console,
29    and eventually finds its way into the OS definition log files that Ganeti
30    maintains.
31  * The helper VM is expected to output "SUCCESS" to its second serial port if
32    image customization was successful inside the VM.
33  * In any other case, execution of the helper VM or snf-image-helper has
34    failed.
35  * The helper VM is expected to shutdown automatically once it is done. Its
36    execution is time-limited; if it has not terminated after a number of
37    seconds, configurable via /etc/default/snf-image, it is sent a SIGTERM
38    and/or a SIGKILL.
39
40 KVM is currently a dependency for snf-image, meaning it is needed to spawn the
41 helper VM. There is no restriction on the hypervisor used for the actual Ganeti
42 instances. This is not a strict requirement; KVM could be replaced by qemu,
43 doing full CPU virtualization without any kernel support for spawning the
44 helper VM.
45
46 snf-image-helper
47 ^^^^^^^^^^^^^^^^
48
49 This part runs inside the helper VM and undertakes customization of the VM
50 being deployed using a number of hooks, or tasks. The tasks run in an
51 environment, specified by rules found in a virtual floppy, placed there by
52 *snf-image*. *snf-image-helper* uses runparts to run tasks found under
53 */usr/lib/snf-image-helper/tasks* by default
54
55 Graphical Representation
56 ^^^^^^^^^^^^^^^^^^^^^^^^
57
58 The architecture is presented below:
59
60 .. image:: /images/arch.png
61
62