Statistics
| Branch: | Tag: | Revision:

root / docs / networks.rst @ a1d0bacb

History | View | Annotate | Download (19.5 kB)

1
.. _networks:
2

    
3
Network Service (part of Cyclades)
4
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5

    
6
Network setup overview
7
======================
8

    
9
Currently the Network Service is part of Cyclades and comes along with the
10
Cyclades software components.
11

    
12
Networking is deployment-specific and must be customized based on the specific
13
needs of the system administrator. However, to do so, the administrator needs
14
to understand how each level handles Virtual Networks, to be able to setup the
15
backend appropriately.
16

    
17
In the following sections we investigate in a top-down approach, the way
18
networks are defined from the Cyclades, Ganeti, and Backend persperctive. For
19
an introduction to the concepts of Cyclades networking and the exposed API see
20
:doc:`Cyclades networking design document <design/cyclades-networking>`.
21

    
22
Network @ Cyclades level
23
------------------------
24

    
25
Cyclades networks support a range of different options to cover the specific
26
needs of each deployment.
27

    
28
First of all, as far as visibility and accessibility is concerned, a network
29
can be either `public` or `private`. Public networks are created by the
30
administrator via the command line interface (`snf-manage network-create`) and
31
are visible to all end-users. On the other hand, private networks are created
32
by the end-user from the Web UI or the kamaki client and provide isolated Layer
33
2 connectivity to the end-user.
34

    
35
Both networks can have an IPv4 subnet or/and an IPv6 subnet along with the
36
corresponding gateway. When a virtual server is connected to a virtual network
37
it will be assigned an IP address from each of the subnets of the network. By
38
default the allocation pool of the network covers all IP addresses in the CIDR,
39
excluding the address for the subnet gateway. However, for IPv4 subnets,
40
allocation pools can be limited to specific ranges using the 'allocation-pool'
41
option of `snf-manage network-create` command. For example, the following
42
command will create a virtual network that will assign IPs only in the range
43
[192.168.2.10, 192.168.2.20] and [192.168.2.30, 192.168.2.40]:
44

    
45
.. code-block:: console
46

    
47
  snf-manage network-create --subnet=192.168.2.0 --gateway=192.168.2.1 --allocation-pool=192.168.2.10,192.168.2.20 --allocation-pool=192.168.2.30,192.168.2.40
48

    
49

    
50
By default, Cyclades will assign IP addresses to virtual servers by responding
51
to DHCP requests via the `nfdhcp` daemon. This functionality can be disabled by
52
using the `--dhcp=False` option during network creation.
53

    
54
A public network can also be marked as a floating IP pool with the
55
`--floating-ip-pool` option. Floating IPs, are IPv4 addresses that can be
56
dynamically by added and removed from running VMs. A user can reserve and
57
release a floating IP address that he can later add and remove it from running
58
VMs. Also the user can release a floating IP if it not used by any of his VMs.
59

    
60
Since private networks and floating IPs must be accesible to all virtual
61
servers that may be distributed accross different Ganeti backends, networks
62
must also be available to all Ganeti backends. Specially for private networks,
63
to avoid the overhead of creating the network to all backends, Cyclades create
64
these networks on demand, when an instance that lives in a backend tries to
65
connect to this network.
66

    
67
The administrator may also want to connect instances to force connection to
68
some networks (e.g. a public IPv6 network or a network that contains a special
69
metadata server). This can be achieved by setting the
70
`CYCLADES_FORCED_SERVER_NETWORKS` setting to the list of the selected networks.
71
Each member of the list may be a network UUID, a tuple of network UUIDs,
72
"SNF:ANY_PUBLIC_IPV4" [any public network with an IPv4 subnet defined],
73
"SNF:ANY_PUBLIC_IPV6 [any public network with only an IPV6 subnet defined], or
74
"SNF:ANY_PUBLIC" [any public network]. For this setting, no access control or
75
quota policy are enforced.  The server will get all IPv4/IPv6 addresses needed
76
to connect to the networks specified in CYCLADES_FORCED_SERVER_NETWORKS,
77
regardless of the state of the floating IP pool of the user, and without
78
allocating any floating IPs.
79

    
80
Also, the administrator can set the `CYCLADES_DEFAULT_SERVER_NETWORKS` setting,
81
which has the exact same format with `CYCLADES_FORCED_SERVER_NETWORKS` and
82
contains a list of networks to connect a newly created server to, if the user
83
has not specified them explicitly in the POST /server API call.  Access
84
control and quota policy are enforced, just as if the user had specified the
85
value of CYCLADES_DEFAULT_SERVER_NETWORKS in the content of the POST /call,
86
after processing of "SNF:\*" directives.
87

    
88
Another distinction between networks is their flavor. Flavor is a way to
89
abstract infrastructure specific options, that are used to ensure connectivity
90
and isolation to the VMs connected to the network. It is a set of options that
91
eventually will guide scripts to set up rules, while creating virtual
92
interfaces in the node level. Each of these flavors define attributes that will
93
be used at Ganeti level to create the physical network. These attributes are:
94

    
95
* ``mode``: Whether the network is in 'bridged' or 'routed' mode.
96
* ``link``: Bridge for 'bridged' networks and routing table for 'routed'
97
  networks. e.g. 'br100', 'rt200'
98
* ``mac_prefix``: A MAC prefix for the network. e.g. 'aa:00:05'
99
* ``tags``: A list of tags to be used at the Ganeti level.
100

    
101
To ensure L2 isolation, Synnefo supports two different mechanisms (see also Node
102
Level section):
103

    
104
* assigning one physical VLAN per network
105
* assigning one MAC prefix per network, so that every NIC attached to this
106
  network will have this prefix. Isolation is then achieved by filtering
107
  rules (via `ebtables`) based on a specific mask (ff:ff:f0:00:00:00, see Node
108
  Level section for more details).
109

    
110
Having this in mind and in order to prevent assignment of duplicate VLAN/MAC
111
prefix to different networks, Synnefo supports two types of Pools:
112

    
113
- Bridge Pool (corresponding to a number of VLANs bridged to those bridges)
114
- MAC prefix Pool
115

    
116
For Pool handling refer to the corresponding doc section. To use this pools,
117
set either `--link` or `--mac-prefix` to the reserved keyword `pool`.
118

    
119
Existing network flavors are the following:
120

    
121
==============   =======   ===============================   ======================  ==================
122
Flavor Name      Mode      Link                              MAC prefix              Tags
123
==============   =======   ===============================   ======================  ==================
124
IP_LESS_ROUTED   routed    ``snf-link-$network_id``          ``DEFAULT_MAC_PREFIX``  'ip-less-routed'
125
MAC_FILTERED     bridged   ``DEFAULT_MAC_FILTERED_BRIDGE``   'pool'                  'private'filtered'
126
PHYSICAL_VLAN    bridged   'pool'                            ``DEFAULT_MAC_PREFIX``  'physical-vlan'
127
CUSTOM           bridged   ``DEFAULT_BRIDGE``                ``DEFAULT_MAC_PREFIX``
128
==============   =======   ===============================   ======================  ==================
129

    
130
``DEFAULT_MAC_PREFIX``, ``DEFAULT_BRIDGE``,
131
``DEFAULT_MAC_FILTERED_BRIDGE`` are all configurable settings in
132
``/etc/synnefo/20-snf-cyclades-app-api.conf``. 'pool' is used to denote that a
133
link or MAC prefix will be allocated from the corresponding Pool. Finally,
134
most of these attributes, may be overridden when creating networks with
135
`snf-manage network-create command`.
136

    
137
The administrator is able to create any of the above flavors
138
and override their default values by explicitly passing mode, link, etc. using
139
the `snf-manage network-create` command.
140

    
141
The administrator can create networks of any flavor, but end-users is allowed
142
to create via API only networks with flavors that are set in the
143
`API_ENABLED_NETWORK_FLAVORS` setting.
144

    
145
Network @ Ganeti level
146
----------------------
147

    
148
Currently, stable Ganeti does not support IP Pool management. However, the
149
functionality has been merged in the official Ganeti master branch and will
150
appear on Ganeti 2.7.0. So, you can either checkout the Ganeti master branch
151
and build your packages, or clone our local repo
152
https://code.grnet.gr/git/ganeti-local and checkout the
153
`stable-2.6-ippool-hotplug-esi` branch. This is the Ganeti stable branch with
154
IP pool management, Hotplugging and ExtStorage Interface features merged on top
155
of it. The last two features are not a hard Synnefo requirement, but will
156
enable you to do neat things when you get experienced with Synnefo. They are
157
going to be pushed for review upstream sometime soon.
158

    
159
Any network created in Synnefo is also created in one (for public networks) or
160
all (for private networks) Ganeti backends. In Ganeti a network can have the
161
following options:
162

    
163
 - network (192.168.0.0/24, mandatory)
164
 - gateway (192.168.0.1)
165
 - network6 (2001:648:2ffc:1201::/64)
166
 - gateway6 (2001:648:2ffc:1201::1)
167
 - mac_prefix (aa:00:01)
168
 - type (private, public)
169
 - tags
170

    
171
Networks in Ganeti cannot be used unless they are connected to a nodegroup in
172
order to define the connectivity mode and link. Synnefo, after creating a
173
network, connects it to all nodegroups of the Ganeti cluster(s) with the given
174
mode and link (defined in the network flavor).
175

    
176
Ganeti makes use of environment variables to inform scripts about each NIC's
177
setup. `kvm-vif-script` that comes with `snf-network` sets up the nfdhcpd lease and
178
applies any rules needed depending on the network's mode, link, mac_prefix and
179
tags.
180

    
181
Network @ Physical host level
182
-----------------------------
183

    
184
Currently, networking infrastructure must be pre-provisioned before creating
185
networks in Synnefo. According to which flavors you want to support, you should
186
have already setup all your physical hosts correspondingly. This means you
187
need:
188

    
189
 - one bridge for the ``CUSTOM`` flavor (br0, see Fig. 1)
190
 - one bridge for the ``MAC_FILTERED`` flavor (prv0, see Fig. 2)
191
 - a number of bridges and their corresponding VLANs (bridged to them) for
192
   the ``PHYSICAL_VLAN`` flavor (prv1..prv100, see Fig. 3)
193
 - a routing table for the ``IP_LESS_ROUTED`` flavor (snf_public, see Fig. 4)
194

    
195
Please refer to the following figures, which clarify each infrastructure setup
196
and how connectivity and isolation is achieved in every case for every type of
197
network.
198

    
199

    
200
FLAVORS
201
=======
202

    
203
As mentioned earlier supported flavors are:
204

    
205
 - CUSTOM
206
 - IP_LESS_ROUTED
207
 - MAC_FILTERED
208
 - PHYSICAL_VLAN
209

    
210
In the following sections we mention what configuration imposes each flavor from
211
Synnefo, Ganeti and Physical host perspective.
212

    
213

    
214

    
215
DEFAULT SCENARIO
216
----------------
217

    
218
In this case we will bridge all primary interfaces of the VMs on one bridge that must
219
be the same collition domain with the router. The router sould then forward packets
220
(if a public IPv4 Subnet is available) or do NAT in order to provide internet access to
221
the VMs.
222

    
223
To this end we will use the CUSTOM flavor and pre-provision in each Ganeti
224
node one bridge (e.g. ``br100``). If we assume that ``eth1`` is the physical interface
225
connected to the router, run:
226

    
227
.. image:: images/network-bridged.png
228
   :align: right
229
   :height: 550px
230
   :width: 500px
231

    
232
.. code-block:: console
233

    
234
   # brctl addbr br100
235
   # brctl addif br100 eth1
236
   # ip link set br100 up
237

    
238
   # brctl show
239
   bridge name bridge id         STP enabled interfaces
240
   br100       8000.8a3c3ede3583 no          eth1
241

    
242

    
243

    
244
Then in Cyclades run:
245

    
246
.. code-block:: console
247

    
248
   # snf-manage network-create --subnet=5.6.7.0/27 --gateway=5.6.7.1 --subnet6=2001:648:2FFC:1322::/64 --gateway6=2001:648:2FFC:1322::1 --public --dhcp=True --flavor=CUSTOM --link=br100 ----name=default --backend-id=1
249

    
250
   # snf-manage network-list
251
   id    name     flavor   owner mac_prefix   dhcp    state         link  vms public IPv4 Subnet   IPv4 Gateway
252
   1     default  CUSTOM                      True    ACTIVE        br100     True   5.6.7.0/27    5.6.7.1
253

    
254
This will add a network in Synnefo DB and create a network in Ganeti backend by
255
issuing:
256

    
257
.. code-block:: console
258

    
259
   # gnt-network add --network=5.6.7.0/27 --gateway=5.6.7.1 --network6=2001:648:2FFC:1322::/64 --gateway6=2001:648:2FFC:1322::1 --network-type=public --tags=nfdhcpd snf-net-1
260

    
261
   # gnt-network connect snf-net-1 default bridged br100
262
   # gnt-network list snf-net-1
263
   Network   Subnet     Gateway NetworkType MacPrefix GroupList               Tags
264
   snf-net-1 5.6.7.0/27 5.6.7.1 public      None      default(bridged, br100) nfdhcpd
265

    
266

    
267
To enable NAT in a Internal Router if you do not have a public IP range available
268
but only a public routable IP (e.g 1.2.3.4):
269

    
270
.. code-block:: console
271

    
272
   # ip addr add 5.6.7.1/27 dev eth1
273
   # iptables -t nat -A POSTROUTING -o eth1 --to-source 1.2.3.4 -j SNAT
274

    
275
IP_LESS_ROUTED
276
--------------
277

    
278
.. image:: images/network-routed.png
279
   :align: right
280
   :height: 580px
281
   :width: 500px
282

    
283
To create a network with IP_LESS_ROUTED flavor run you have to pre-provision in
284
each Ganeti node one routing table (e.g. ``snf_public``) that will do all the
285
routing from/to the VMs' taps. Additionally you must enable ``Proxy-ARP``
286
support. All traffic will be on a single iterface (e.g. ``eth1``).
287

    
288
.. code-block:: console
289

    
290
   # echo 1 > /proc/sys/net/ipv4/conf/ip_fowarding
291
   # echo 10 snf_public >> /etc/iproute2/rt_tables
292
   # ip route add 5.6.7.0/27 dev eth1
293
   # ip route add 5.6.7.0/27 dev eth1 table snf_public
294
   # ip route add default via 5.6.7.1 dev eth1 table snf_public
295
   # ip rule add iif eth1 lookup snf_public
296
   # arptables -A OUTPUT -o eth1 --opcode 1 --mangle-ip-s 5.6.7.30  # last ip in Subnet
297

    
298
Then in Cyclades run:
299

    
300
.. code-block:: console
301

    
302
   # snf-manage network-create --subnet=5.6.7.0/27 --gateway=5.6.7.1 --subnet6=2001:648:2FFC:1322::/64 --gateway6=2001:648:2FFC:1322::1 --public --dhcp=True --flavor=IP_LESS_ROUTED --name=routed --backend-id=1
303

    
304
   # snf-manage network-list
305
   id    name     flavor         owner mac_prefix   dhcp    state   link      vms  public IPv4 Subnet   IPv4 Gateway
306
   2     routed   IP_LESS_ROUTED                    True    ACTIVE  snf_public     True   5.6.7.0/27    5.6.7.1
307

    
308

    
309
This will add a network in Synnefo DB and create a network in Ganeti backend by
310
issuing:
311

    
312
.. code-block:: console
313

    
314
   # gnt-network add --network=5.6.7.0/27 --gateway=5.6.7.1 --network6=2001:648:2FFC:1322::/64 --gateway6=2001:648:2FFC:1322::1  --network-type=public  --tags=nfdhcpd,ip-less-routed  snf-net-2
315

    
316
   # gnt-network connect snf-net-2 default bridged br100
317
   # gnt-network list snf-net-2
318
   Network      Subnet            Gateway        NetworkType MacPrefix GroupList                   Tags
319
   dimara-net-1 62.217.123.128/27 62.217.123.129 public      None      default(routed, snf_public) nfdhcpd,ip-less-routed
320

    
321

    
322

    
323

    
324
MAC_FILTERED
325
------------
326

    
327

    
328
To create a network with MAC_FILTERED flavor you have to pre-provision in each Ganeti
329
node one bridge (e.g. ``prv0``) that will be bridged with one interface (e.g. ``eth2``)
330
across the whole cluster.
331

    
332
.. image:: images/network-mac.png
333
   :align: right
334
   :height: 500px
335
   :width: 500px
336

    
337
.. code-block:: console
338

    
339
   # brctl addbr prv0
340
   # brctl addif prv0 eth2
341
   # ip link set prv0 up
342

    
343
   # brctl show
344
   bridge name bridge id         STP enabled interfaces
345
   prv0        8000.8a3c3ede3583 no          eth2
346

    
347

    
348

    
349
Then in Cyclades first create a pool for MAC prefixes by running:
350

    
351
.. code-block:: console
352

    
353
   # snf-manage pool-create --type=mac-prefix --base=aa:00:0 --size=65536
354

    
355
and the create the network:
356

    
357
.. code-block:: console
358

    
359
   # snf-manage network-create --subnet=192.168.1.0/24 --gateway=192.168.1.0/24 --dhcp=True --flavor=MAC_FILTERED --link=prv0 --name=mac --backend-id=1
360
   # snf-manage network-list
361
   id    name     flavor       owner mac_prefix   dhcp    state         link  vms public IPv4 Subnet    IPv4 Gateway
362
   3     mac      MAC_FILTERED       aa:00:01     True    ACTIVE        prv0      False  192.168.1.0/24 192.168.1.1
363

    
364
Edit the synnefo setting `DEFAULT_MAC_FILTERED_BRIDGE` to `prv0`.
365

    
366
This will add a network in Synnefo DB and create a network in Ganeti backend by
367
issuing:
368

    
369
.. code-block:: console
370

    
371
   # gnt-network add --network=192.168.1.0/24  --gateway=192.168.1.1  --network-type=private  --tags=nfdhcpd,private-filtered snf-net-3
372

    
373
   # gnt-network connect snf-net-3 default bridged prv0
374
   # gnt-network list snf-net-3
375
   Network   Subnet         Gateway     NetworkType MacPrefix GroupList               Tags
376
   snf-net-3 192.168.1.0/24 192.168.1.1 private     aa:00:01  default(bridged, prv0) nfdhcpd,private-filtered
377

    
378

    
379

    
380

    
381

    
382

    
383
PHYSICAL_VLAN
384
-------------
385

    
386

    
387
To create a network with PHYSICAL_VALN flavor you have to pre-provision in each Ganeti
388
node a range of bridges (e.g. ``prv1..20``) that will be bridged with the corresponding VLANs (e.g. ``401..420``)
389
across the whole cluster. To this end if we assume that ``eth3`` is the interface to use, run:
390

    
391
.. image:: images/network-vlan.png
392
   :align: right
393
   :height: 480px
394
   :width: 500px
395

    
396

    
397
.. code-block:: console
398

    
399
   # for i in {1..20}; do
400
      br=prv$i ; vlanid=$((400+i)) ; vlan=eth3.$vlanid
401
      brctl addbr $br ; ip link set $br up
402
      vconfig add eth0 vlanid ; ip link set vlan up
403
      brctl addif $br $vlan
404
   done
405
   # brctl show
406
   bridge name     bridge id               STP enabled     interfaces
407
   prv1            8000.8a3c3ede3583       no              eth3.401
408
   prv2            8000.8a3c3ede3583       no              eth3.402
409
   ...
410

    
411

    
412
Then in Cyclades first create a pool for bridges by running:
413

    
414
.. code-block:: console
415

    
416
   # snf-manage pool-create --type=bridge --base=prv --size=20
417

    
418
and the create the network:
419

    
420
.. code-block:: console
421

    
422
   # snf-manage network-create --subnet=192.168.1.0/24  --gateway=192.168.1.0/24  --dhcp=True --flavor=PHYSICAL_VLAN  --name=vlan  --backend-id=1
423

    
424
   # snf-manage network-list
425
   id    name     flavor       owner mac_prefix   dhcp    state         link  vms public IPv4 Subnet    IPv4 Gateway
426
   4     vlan     PHYSICAL_VLAN                   True    ACTIVE        prv1      False  192.168.1.0/24 192.168.1.1
427

    
428
This will add a network in Synnefo DB and create a network in Ganeti backend by
429
issuing:
430

    
431
.. code-block:: console
432

    
433
   # gnt-network add --network=192.168.1.0/24 --gateway=192.168.1.1 --network-type=private --tags=nfdhcpd,physica-vlan snf-net-4
434

    
435
   # gnt-network connect snf-net-4 default bridged prv1
436
   # gnt-network list snf-net-4
437
   Network   Subnet         Gateway     NetworkType MacPrefix GroupList               Tags
438
   snf-net-4 192.168.1.0/24 192.168.1.1 private     None      default(bridged, prv1)  nfdhcpd,physical-vlan
439

    
440

    
441

    
442
ADVANCED SCENARIO
443
-----------------
444

    
445
To create a network with CUSTOM flavor you have to pass your self mode, link,
446
mac prefix, tags for the network. You are not allowed to use the existing pools
447
(only MAC_FILTERED, PHYSICAL_VLAN use them) so link and mac prefix uniqueness
448
cannot be guaranteed.
449

    
450
Lets assume a bridge ``br200`` that serves a VPN network to GRNET already exists
451
on Ganeti nodes and we want to create for a certain user a private network so
452
that he can access the VPN. Then we run in Cyclades:
453

    
454
.. code-block:: console
455

    
456
   # snf-manage network-create --subnet=192.168.1.0/24 --gateway=192.168.1.0/24 --dhcp=True --flavor=CUSTOM --mode=bridged --link=br200 --mac-prefix=bb:00:44 --owner=user@grnet.gr --tags=nfdhcpd,vpn --name=vpn --backend-id=1
457

    
458
   # snf-manage network-list
459
   id    name     flavor       owner              mac_prefix   dhcp    state         link  vms public IPv4 Subnet    IPv4 Gateway
460
   5     vpn      CUSTOM       user@grnet.gr      bb:00:44     True    ACTIVE        br200     False  192.168.1.0/24 192.168.1.1
461

    
462
This will add a network in Synnefo DB and create a network in Ganeti backend by
463
issuing:
464

    
465
.. code-block:: console
466

    
467
   # gnt-network add --network=192.168.1.0/24 --gateway=192.168.1.1 --network-type=private --tags=nfdhcpd snf-net-5
468

    
469
   # gnt-network connect snf-net-5 default bridged br200
470
   # gnt-network list snf-net-5
471
   Network   Subnet         Gateway     NetworkType MacPrefix GroupList               Tags
472
   snf-net-5 192.168.1.0/24 192.168.1.1 private     bb:00:55  default(bridged, br200) nfdhcpd,private-filtered
473

    
474