improve ganeti documentation
[mirror/dsa-wiki.git] / input / howto / install-ganeti.creole
1 == How To Install Ganeti Clusters and Instances ==
2
3 === suppositions ===
4
5 Suppose that there are two identical hosts: foo.debian.org and bar.debian.org.
6
7 They are running squeeze and have been integrated into Debian infrastructure.
8
9 They will serve as nodes in a ganeti cluster named foobar.debian.org.
10
11 They have a RAID1 array exposing three partitions: c0d0p1 for /, c0d0p2 for
12 swap and c0d0p3 for lvm volume groups to be used by ganeti via drbd.
13
14 They have two network interfaces: eth0 (public) and eth1 (private).
15
16 The public network is A.B.C.0/24 with gateway A.B.C.254.
17
18 The private network is E.F.G.0/24 with no gateway.
19
20 Suppose that the first instance to be hosted on foobar.debian.org is
21 qux.debian.org.
22
23 The following DNS records exist:
24
25 {{{
26     foobar.debian.org.                  IN A   A.B.C.1
27     foo.debian.org.                     IN A   A.B.C.2
28     bar.debian.org.                     IN A   A.B.C.3
29     qux.debian.org.                     IN A   A.B.C.4
30     foo.debprivate-hoster.debian.org.   IN A   E.F.G.2
31     bar.debprivate-hoster.debian.org.   IN A   E.F.G.3
32 }}}
33
34 === install required packages ===
35
36 On each node, install the required packages:
37
38 {{{
39     apt-get install fai-client ssed extlinux
40     apt-get install -t squeeze-backports drbd8-utils ganeti2 ganeti-instance-debootstrap ganeti-htools
41 }}}
42
43 === configure kernel modules ===
44
45 On each node, ensure that the required kernel modules are loaded at boot:
46
47 {{{
48     ainsl /etc/modules 'drbd minor_count=255 usermode_helper=/bin/true'
49     ainsl /etc/modules 'hmac'
50     ainsl /etc/modules 'tun'
51 }}}
52
53 === configure networking ===
54
55 On each node, ensure that br0 (not eth0) and eth1 are configured.
56
57 The bridge interface, br0, is used by the guest virtual machines to reach the
58 public network.
59
60 If the guest virtual machines need to access the private network, then br1
61 should be configure rather than eth1.
62
63 To prevent the link address changing due to startup/shutdown of virtual
64 machines, explicitly set the value.
65
66 {{{
67     # /etc/networking/interfaces for foo.debian.org
68
69     auto br0
70     iface br0 inet static
71       bridge_ports eth0
72       bridge_maxwait 0
73       bridge_fd 0
74       address A.B.C.2
75       netmask 255.255.255.0
76       gateway A.B.C.254
77       up ip link set addr $(cat /sys/class/net/$IFACE/address) dev $IFACE
78
79     auto eth1
80     iface eth1 inet static
81       address E.F.G.2
82       netmask 255.255.255.0
83 }}}
84
85 === configure lvm ===
86
87 On each node, configure lvm to ignore drbd devices and to prefer
88 {{{/dev/cciss}}} devices names over {{{/dev/block}}} device names
89 ([[http://code.google.com/p/ganeti/issues/detail?id=93|why?]]):
90
91 {{{
92     ssed -i \
93       -e 's#^\(\s*filter\s\).*#\1= [ "a|.*|", "r|/dev/drbd[0-9]+|" ]#'
94       -e 's#^\(\s*preferred_names\s\).*#\1= [ "^/dev/dm-*/", "^/dev/cciss/" ]#' \
95       /etc/lvm/lvm.conf
96     service lvm2 restart
97 }}}
98
99 === create lvm volume groups ===
100
101 On each node, create a volume group:
102
103 {{{
104     vgcreate vg_ganeti /dev/cciss/c0d0p3
105 }}}
106
107 === create kvmU symbolic links ===
108
109 On each node, create vmlinuz and initrd symlinks as expected by the kvm
110 hypervisor:
111
112 {{{
113     ln -s -T /boot/vmlinuz-2.6.32-5-amd64 /boot/vmlinuz-2.6-kvmU
114     ln -s -T /boot/initrd.img-2.6.32-5-amd64 /boot/initrd.img-2.6-kvmU
115 }}}
116
117 === exchange ssh keys ===
118
119 ipsum loren bacon puppet
120
121 === configure iptables (via ferm) ===
122
123 ipsum loren bacon puppet
124
125 === instantiate the cluster ===
126
127 On the master node (foo) only:
128
129 {{{
130     gnt-cluster init \
131       --master-netdev br0 \
132       --vg-name vg_ganeti \
133       --secondary-ip E.F.G.2 \
134       --enabled-hypervisors kvm \
135       --nic-parameters link=br0 \
136       --mac-prefix 00:16:37 \
137       --no-ssh-init \
138       --no-etc-hosts \
139       --hypervisor-parameters kvm:initrd_path=/boot/initrd.img-2.6-kvmU,kernel_path=/boot/vmlinuz-2.6-kvmU \
140       foobar.debian.org
141 }}}
142
143 Note the following:
144
145 * the master network device is set to br0, matching the public network bridge interface created above
146 * the volume group is set to vg_ganeti, matching the volume group created above
147 * the secondary IP address is set to the value of the master node's interface on the private network
148 * the nic parameters for instances is set to use br0 as default bridge
149 * the MAC prefix is registered in the dsa-kvm git repo
150
151 === add slave nodes ===
152
153 For each slave node (only bar for this example), on the master node (foo):
154
155 {{{
156     gnt-node add \
157       --secondary-ip E.F.G.3 \
158       --no-ssh-key-check \
159       --no-node-setup \
160       bar.debian.org
161 }}}
162
163 Note the following:
164
165 * the secondary IP address is set to the value of the slave node's interface on the private network
166
167 === verify cluster ===
168
169 On the master node (foo):
170
171 {{{
172     gnt-cluster verify
173 }}}
174
175 If everything has been configured correctly, no errors should be reported.
176
177 === create the 'dsa' variant ===
178
179 ipsum loren bacon deboostrap+dsa
180
181 ----
182
183 == How To Install Ganeti Instances ==
184
185 Suppose that qux.debian.org will be an instance (a virtual machine) hosted on
186 the foobar.debian.org ganeti cluster.
187
188 Before adding the instance, an LDAP entry must be created so that an A record
189 for the instance (A.B.C.4) exists.
190
191 === create the instance ===
192
193 On the master node (foo):
194
195 {{{
196     gnt-instance add \
197       --node foo:bar \
198       --disk-template drbd \
199       --os-size 4GiB \
200       --os-type debootstrap+dsa \
201       --hypervisor-parameters kvm:initrd_path=,kernel_path= \
202       --net 0:ip=A.B.C.4 \
203       qux.debian.org
204 }}}
205
206 Note the following:
207
208 * the primary and secondary nodes have been explicitly set
209 * the operating system type is 'debootstrap+dsa'
210 * the network interfarce 0 (eth1 on the system) is set to the instance's interface on the public network
211
212 ----
213
214 == Variations ==
215
216 If the instances require access to the private network, then there are two modifications necessary.
217
218 === re-configure networking ===
219
220 Ensure that br1 is configured (rather than eth1).
221
222 {{{
223     # /etc/networking/interfaces for foo.debian.org
224
225     auto br0
226     iface br0 inet static
227       bridge_ports eth0
228       bridge_maxwait 0
229       bridge_fd 0
230       address A.B.C.2
231       netmask 255.255.255.0
232       gateway A.B.C.254
233       up ip link set addr $(cat /sys/class/net/$IFACE/address) dev $IFACE
234
235     auto br1
236     iface br1 inet static
237       bridge_ports eth1
238       bridge_maxwait 0
239       bridge_fd 0
240       address E.F.G.2
241       netmask 255.255.255.0
242       up ip link set addr $(cat /sys/class/net/$IFACE/address) dev $IFACE
243 }}}
244
245 === create or update the instance  ===
246
247 When creating the instance, indicate both netwokrs:
248
249 {{{
250     gnt-instance add \
251       --node foo:bar \
252       --disk-template drbd \
253       --os-size 4GiB \
254       --os-type debootstrap+dsa \
255       --hypervisor-parameters kvm:initrd_path=,kernel_path= \
256       --net 0:ip=A.B.C.4,1:ip=E.F.G.4 \
257       qux.debian.org
258 }}}
259
260 Please note that the dsa bootscript will only configure eth1 (nic0).  If
261 specifying a second internface, the guest operating system must be updated
262 manually.
263
264 When updating an existing instance, add the interface:
265
266 {{{
267     gnt-instance shutdown qux.debian.org
268     gnt-instance modify \
269       --net add:ip=E.F.G.4 \
270       qux.debian.org
271     gnt-instance startup qux.debian.org
272 }}}
273
274 Please note that the hook scripts are run only at instance instantiation.  When
275 adding interfaces to an instance, the guest opearting system must be updated
276 manually.
277