mv ipam tasks mv weavedns tasks mv image tasks/manage

This commit is contained in:
abuehrle committed 2017-07-20 15:31:36 -05:00
1 parent 16ce5eacbb
commit 1f1b22cee7
12 files changed

No files matched your search

+68
View File
@@ -0,0 +1,68 @@
---
title: Automatic Allocation Across Multiple Subnets
menu_order: 10
search_type: Documentation
---
IP subnets are used to define or restrict routing. By default, Weave Net
puts all containers into a subnet that spans the entire allocation
range, so that every Weave-attached container can communicate with every other
Weave-attached container.
If you want some [isolation](/site/using-weave/application-isolation.md), you
can choose to run containers on different subnets. To request the
allocation of an address from a particular subnet, set the
`WEAVE_CIDR` environment variable to `net:<subnet>` when creating the
container, for example:
host1$ docker run -e WEAVE_CIDR=net:10.2.7.0/24 -ti weaveworks/ubuntu
You can ask for multiple addresses in different subnets and add in
manually-assigned addresses (outside the automatic allocation range),
for instance:
host1$ docker run -e WEAVE_CIDR="net:10.2.7.0/24 net:10.2.8.0/24 ip:10.3.9.1/24" -ti weaveworks/ubuntu
>**Note:** The ".0" and ".-1" addresses in a subnet are not used, as required by
[RFC 1122](https://tools.ietf.org/html/rfc1122#page-29)).
When working with multiple subnets in this way, it is usually
desirable to constrain the default subnet - for example, the one chosen by the
allocator when no subnet is supplied - so that it does not overlap
with others. You can specify this by using `--ipalloc-default-subnet`:
host1$ weave launch --ipalloc-range 10.2.0.0/16 --ipalloc-default-subnet 10.2.3.0/24
`--ipalloc-range` should cover the entire range that you will ever use
for allocation, and `--ipalloc-default-subnet` is the subnet that will
be used when you don't explicitly specify one.
When specifying addresses, the default subnet can be denoted
symbolically using `net:default`.
### <a name="manual"></a>Mixing automatic and manual allocation
Containers can be started using a mixture of automatically-allocated
addresses and manually-chosen addresses in the same range. However, you may
find that the automatic allocator has already reserved a specific
address that you wanted.
To reserve a range for manual allocation in the same subnet as the
automatic allocator, you can specify an
`--ipalloc-range` that is smaller than `--ip-default-subnet`, For
example, if you launch weave with:
host1$ weave launch --ipalloc-range 10.9.0.0/17 --ipalloc-default-subnet 10.9.0.0/16
then you can run all containers in the 10.9.0.0/16 subnet, with
automatic allocation using the lower half, leaving the upper half free
for manual allocation.
**See Also**
* [Address Allocation with IP Address Management (IPAM)](/site/ipam.md)
* [Isolating Applications on a Weave Network](/site/using-weave/application-isolation.md)
* [Starting, Stopping and Removing Peers](/site/ipam/stop-remove-peers-ipam.md)
File renamed without changes.
+206
View File
@@ -0,0 +1,206 @@
---
title: Allocating IP Addresses
menu_order: 70
search_type: Documentation
---
Weave Net automatically assigns containers a unique IP address
across the network, and also releases that address when the container
exits. Unless you explicitly specify an address, this occurs for all
invocations of the
`attach`, `detach`, `expose`, and `hide` commands. Weave Net can also assign
addresses in multiple subnets.
The following automatic IP address management topics are discussed:
* [Initializing Peers on a Weave Network](#initialization)
* [`--ipalloc-init:consensus` and How Quorum is Achieved](#quorum)
* [Priming a Peer](#priming-a-peer)
* [Choosing an Allocation Range](#range)
### <a name="initialization"></a>Initializing Peers on a Weave Network
Three initialization strategies are available: seed, consensus and
observer. These options have different tradeoffs, so pick the one that
suits your deployment best.
#### <a name="seed"></a>Via Seed
Configuration via seed requires you to provide a list of _peer names_
(via the `--ipalloc-init seed=` parameter) amongst which the address
space will be shared initially. Normally weave derives a unique peer
name automatically at launch, but since you need to know them ahead of
time in this case you will need to name each peer explicitly via the
`--name` parameter.
> Peers in the weave network are identified by a 48-bit value
> formatted like an ethernet MAC address (e.g. 01:23:45:67:89:ab) -
> you can either specify the name fully, or substitute a single run of
> zero-octets using the `::` notation, similar to
> [IPv6 address representation](https://en.wikipedia.org/wiki/IPv6_address#Recommended_representation_as_text):
>
> * `00:00:00:00:00:01` can be written `::1`
> * `01:00:00:00:00:00` can be written `1::`
> * `01:00:00:00:00:01` can be written `1::1`
host1$ weave launch --name ::1 --ipalloc-init seed=::1,::2,::3
host2$ weave launch --name ::2 --ipalloc-init seed=::1,::2,::3
host3$ weave launch --name ::3 --ipalloc-init seed=::1,::2,::3
In this configuration each peer knows in advance how the address space
has been divided up, and will be able to perform allocations from the
outset even under conditions of partition - no consensus is required.
#### <a name="consensus"></a>Via One-off Consensus
Alternatively, you can let Weave Net determine the seed automatically
via a consensus algorithm. Since you don't need to provide it with a
list of peer names anymore, you can let Weave Net derive those
automatically for you as well.
However, in order for Weave Net to form a single consensus
reliably you must now instead tell each peer how many peers there are
in total either by listing them as target peers or using the
`--ipalloc-init consensus=` parameter.
Just once, when the first automatic IP address allocation is requested
in the whole network, Weave Net needs a majority of peers to be present in
order to avoid formation of isolated groups, which can lead to
inconsistency, for example, the same IP address being allocated to two
different containers.
Therefore, you must either supply the list of all peers in the network at `weave launch` or add the
`--ipalloc-init consensus=` flag to specify how many peers there will be.
To illustrate, suppose you have three hosts, accessible to each other
as `$HOST1`, `$HOST2` and `$HOST3`. You can start Weave Net on those three
hosts using these three commands:
host1$ weave launch $HOST2 $HOST3
host2$ weave launch $HOST1 $HOST3
host3$ weave launch $HOST1 $HOST2
Or, if it is not convenient to name all the other hosts at launch
time, you can pass the number of peers like this:
host1$ weave launch --ipalloc-init consensus=3
host2$ weave launch --ipalloc-init consensus=3 $HOST3
host3$ weave launch --ipalloc-init consensus=3 $HOST2
The consensus mechanism used to determine a majority transitions
through three states: 'deferred', 'waiting' and 'achieved':
* 'deferred' - no allocation requests or claims have been made yet;
consensus is deferred until then
* 'waiting' - an attempt to achieve consensus is ongoing, triggered by
an allocation or claim request; allocations will block. This state
persists until a quorum of peers are able to communicate amongst
themselves successfully
* 'achieved' - consensus achieved; allocations proceed normally
#### <a name="observer"></a>Via Observation
Finally, some (but never all) peers can be launched as observers
by specifying the `--ipalloc-init observer` option:
host4$ weave launch --ipalloc-init observer $HOST3
You do not need to specify an initial peer count or seed to such
peers. This can be useful to add peers to an existing fixed cluster
(for example in response to a scale-out event) without worrying about
adjusting initial peer counts accordingly.
#### <a name="quorum"></a> `--ipalloc-init consensus=` and How Quorum is Achieved
Normally it isn't a problem to over-estimate the value supplied to
`--ipalloc-init consensus=`, but if you supply a number that is too
small, then multiple independent groups may form.
Weave Net uses the estimate of the number of peers at initialization to
compute a majority or quorum number - specifically floor(n/2) + 1.
If the actual number of peers is less than half the number stated, then
they keep waiting for someone else to join in order to reach a quorum.
But if the actual number is more than twice the quorum
number, then you may end up with two sets of peers with each reaching a quorum and
initializing independent data structures. You'd have to be quite unlucky
for this to happen in practice, as they would have to go through the whole
agreement process without learning about each other, but it's
definitely possible.
The quorum number is only used once at start-up (specifically, the
first time someone tries to allocate or claim an IP address). Once
a set of peers is initialized, you can add more and they will join on
to the data structure used by the existing set.
The one issue to watch is if the earlier peers are restarted, you must restart
them using the current number of peers. If they use the smaller number
that was correct when they first started, then they could form an
independent set again.
To illustrate this last point, the following sequence of operations
is safe with respect to Weave Net's startup quorum:
host1$ weave launch
...time passes...
host2$ weave launch $HOST1
...time passes...
host3$ weave launch $HOST1 $HOST2
...time passes...
...host1 is rebooted...
host1$ weave launch $HOST2 $HOST3
### <a name="priming-a-peer"></a>Priming a Peer
Under certain circumstances (for example when adding new peers to an
existing network) it is desirable to ensure that a peer has
successfully joined and is ready to allocate IP addresses. An
administrative command is provided for this purpose:
host1$ weave prime
This operation will block until the peer on which it is run has joined
successfully.
### <a name="range"></a>Choosing an Allocation Range
By default, Weave Net allocates IP addresses in the 10.32.0.0/12
range. This can be overridden with the `--ipalloc-range` option:
host1$ weave launch --ipalloc-range 10.2.0.0/16
and must be the same on every host.
The range parameter is written in
[CIDR notation](http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) -
in this example "/16" means the first 16 bits of the address form the
network address and the allocator is to allocate container addresses
that all start 10.2. See [IP
addresses and routes](/site/how-it-works/ip-addresses.md) for more information.
Weave shares the IP address range across all peers, dynamically
according to their needs. If a group of peers becomes isolated from
the rest (a partition), they can continue to work with the address
ranges they had before isolation, and can subsequently be re-connected
to the rest of the network without any conflicts arising.
### <a name="persistence"></a>Data persistence
Key IPAM data is saved to disk, so that it is immediately available
when the peer restarts:
* The division of the IP allocation range amongst peers
* Allocation of addresses to containers on the local peer
A [data volume
container](https://docs.docker.com/engine/userguide/containers/dockervolumes/#creating-and-mounting-a-data-volume-container)
named `weavedb` is used to store this data.
**See Also**
* [Automatic Allocation Across Multiple Subnets](/site/ipam/allocation-multi-ipam.md)
* [Integrating Docker via the Network Plugin (Legacy)](/site/plugin.md)
File renamed without changes.
+61
View File
@@ -0,0 +1,61 @@
---
title: Starting, Stopping and Removing Peers
menu_order: 20
search_type: Documentation
---
You may wish to `weave stop` and re-launch to change some config or to
upgrade to a new version. Provided that the underlying protocol hasn't
changed, Weave Net picks up where it left off and learns from peers in
the network which address ranges it was previously using.
If, however, you run `weave reset` this removes the peer from the
network so if Weave Net is run again on that node it will start from
scratch.
For failed peers, the `weave rmpeer` command can be invoked to
permanently remove the ranges allocated to said peers. This allows
other peers to allocate IPs in the ranges previously owned by the
removed peers, and as such should be used with extreme caution: if the
removed peers had transferred some range of IP addresses to other
peers but this is not known to the whole network, or if some of them
later rejoin the Weave network, the same IP address may be allocated
twice.
Assume you had started the three peers in the
[overview example](/site/ipam.md), and then host3
caught fire, you can go to one of the other hosts and run:
host1$ weave rmpeer host3
524288 IPs taken over from host3
Weave Net takes all the IP address ranges owned by host3 and transfers
them to be owned by host1. The name "host3" is resolved via the
'nickname' feature of Weave Net, which defaults to the local host
name. Alternatively, you can supply a peer name as shown in `weave status`.
### <a name="caution-rmpeer"></a>Caution###
You cannot call `weave rmpeer` on more than one host. The address
space, which was owned by the stale peer cannot be left dangling, and
as a result it gets reassigned. In this instance, the address is
reassigned to the peer on which `weave rmpeer` was run. Therefore, if
you run `weave forget` and then `weave rmpeer` on more than one host
at a time, it results in duplicate IPs on more than one host.
Once the peers detect the inconsistency, they log the error and drop
the connection that supplied the inconsistent data. The rest of the
peers will carry on with their view of the world, but the network will
not function correctly.
Some peers may be able to communicate their claim to the others before
they run `rmpeer` (i.e. it's a race), so what you can expect is a few
cliques of peers that are still talking to each other, but repeatedly
dropping attempted connections with peers in other cliques.
**See Also**
* [Address Allocation with IP Address Management (IPAM)](/site/ipam.md)
* [Automatic Allocation Across Multiple Subnets](/site/ipam/allocation-multi-ipam.md)
* [Isolating Applications on a Weave Network](/site/using-weave/application-isolation.md)
+67
View File
@@ -0,0 +1,67 @@
---
title: Troubleshooting the IP Allocator
menu_order: 30
search_type: Documentation
---
The command
weave status
reports on the current status of the weave router and IP allocator:
```
...
Service: ipam
Status: awaiting consensus (quorum: 2, known: 0)
Range: 10.32.0.0-10.47.255.255
DefaultSubnet: 10.32.0.0/12
...
```
The first section covers the router; see the [troubleshooting
guide](/site/troubleshooting.md#weave-status) for full details.
The 'Service: ipam' section displays the consensus state as well as
the total allocation range and default subnet. Columns are as follows:
* 'Status' - allocator state
* 'idle' - no allocation requests or claims have been made yet;
consensus is deferred until then
* 'awaiting consensus' - an attempt to achieve consensus is
ongoing, triggered by an allocation or claim request;
allocations will block. This state persists until a quorum of
peers are able to communicate amongst themselves successfully.
* 'priming' - peer is an observer and is waiting to receive IPAM
data from seeding or consensus elsewhere in the network
* 'ready' - consensus achieved; allocations proceed normally
* 'waiting for IP range grant from peers' - peer has exhausted its
agreed portion of the range and is waiting to be granted some
more
* 'all IP ranges owned by unreachable peers' - peer has exhausted
its agreed portion of the range but cannot reach anyone to ask
for more
* 'Range' - total allocation range set by `--ipalloc-range`
* 'DefaultSubnet' - default subnet set by `--ipalloc-default-subnet`
Information regarding the division of the IP allocation range amongst
peers and their reachability can be obtained with
```
$ weave status ipam
00:00:00:00:00:01(one) 349526 IPs (33.3% of total)
00:00:00:00:00:02(two) 349525 IPs (33.3% of total)
00:00:00:00:00:03(three) 349525 IPs (33.3% of total) - unreachable!
```
Columns are as follows:
* Peer Name and Nickname
* Absolute quantity/percentage of allocation range managed by peer
* Indication of unreachability. This means that the peer is not
visible (directly or indirectly) to the peer on which `weave status
ipam` was run; whilst this could be a transient condition due to a
partition, it may be because the peer has failed and needs to be
removed administratively - see [Starting, Stopping and Removing
Peers](/site/ipam/stop-remove-peers-ipam.md) for more details.
+48
View File
@@ -0,0 +1,48 @@
---
title: How Weave Finds Containers
menu_order: 10
search_type: Documentation
---
The weaveDNS service running on every host acts as the nameserver for
containers on that host. It learns about hostnames for local containers
from the proxy and from the `weave attach` command.
If a hostname is in the `.weave.local` domain, then weaveDNS records the association of that
name with the container's Weave Net IP address(es) in its in-memory
database, and then broadcasts the association to other Weave Net peers in the
cluster.
When weaveDNS is queried for a name in the `.weave.local` domain, it
looks up the hostname in its memory database and responds with the IPs
of all containers for that hostname across the entire cluster.
When weaveDNS is queried for a name in a domain other than
`.weave.local`, it queries the host's configured nameserver, which is
the standard behaviour for Docker containers.
### Specifying a Different Docker Bridge Device
So that containers can connect to a stable and always routable IP
address, weaveDNS listens on port 53 to the Docker bridge device, which
is assumed to be `docker0`. Some configurations may use a different
Docker bridge device. To supply a different bridge device, use the
environment variable `DOCKER_BRIDGE`, e.g.,
```
$ sudo DOCKER_BRIDGE=someother weave launch
```
In the event that weaveDNS is launched in this way, it's important that
other calls to `weave` also specify the bridge device:
```
$ sudo DOCKER_BRIDGE=someother weave attach ...
```
**See Also**
* [Using WeaveDNS](/site/weavedns.md)
* [Load Balancing with weaveDNS](/site/weavedns/load-balance-fault-weavedns.md)
* [Managing Domain Entries](/site/weavedns/managing-domains-weavedns.md)
@@ -0,0 +1,59 @@
---
title: Load Balancing and Fault Resilience with weaveDNS
menu_order: 20
search_type: Documentation
---
It is permissible to register multiple containers with the same name:
weaveDNS returns all addresses, in a random order, for each request.
This provides a basic load balancing capability.
Expanding the [overview example](/site/weavedns.md), let us start an additional `pingme` container on a second host, and then run
some ping tests.
```
host2$ weave launch $HOST1
host2$ eval $(weave env)
host2$ docker run -dti --name=pingme weaveworks/ubuntu
root@ubuntu:/# ping -nq -c 1 pingme
PING pingme.weave.local (10.32.0.2) 56(84) bytes of data.
...
root@ubuntu:/# ping -nq -c 1 pingme
PING pingme.weave.local (10.40.0.1) 56(84) bytes of data.
...
root@ubuntu:/# ping -nq -c 1 pingme
PING pingme.weave.local (10.40.0.1) 56(84) bytes of data.
...
root@ubuntu:/# ping -nq -c 1 pingme
PING pingme.weave.local (10.32.0.2) 56(84) bytes of data.
...
```
Notice how the ping reaches different addresses.
However, due to
[RFC 3484 address selection](https://tools.ietf.org/html/rfc3484#section-6)
most DNS resolver libraries prefer certain addresses over others, to
the point where in some circumstances the same address is always
chosen. To avoid this behaviour, applications may want to perform
their own address selection, e.g. by choosing a random entry from the
result of
[`getaddrinfo()`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html).
## <a name="fault-resilience"></a>Fault Resilience
WeaveDNS removes the addresses of any container that dies. This offers
a simple way to implement redundancy. E.g. if in our example we stop
one of the `pingme` containers and re-run the ping tests, eventually
(within ~30s at most, since that is the weaveDNS
[cache expiry time](/site/weavedns/managing-entries-weavedns.md#ttl)) we will only be hitting the address of the
container that is still alive.
**See Also**
* [How Weave Finds Containers](/site/how-works-weavedns.md)
* [Managing Domains](/site/weavedns/managing-domains-weavedns.md)
* [Managing Domain Entries](/site/weavedns/managing-entries-weavedns.md)
@@ -0,0 +1,50 @@
---
title: Managing Domains
menu_order: 30
search_type: Documentation
---
The following topics are discussed:
* [Configuring the domain search path](#domain-search-path)
* [Using a different local domain](#local-domain)
## <a name="domain-search-path"></a>Configuring the domain search paths
If you don't supply a domain search path (with `--dns-search=`), Weave
Net (via the [proxy](/site/weave-docker-api.md) or via `weave attach`)
tells a container to look for "bare" hostnames, like `pingme`, in its
own domain (or in `weave.local` if it has no domain).
If you want to supply other entries for the domain search path,
e.g. if you want containers in different sub-domains to resolve
hostnames across all sub-domains plus some external domains, you need
*also* to supply the `weave.local` domain to retain the above
behaviour.
```
docker run -ti \
--dns-search=zone1.weave.local --dns-search=zone2.weave.local \
--dns-search=corp1.com --dns-search=corp2.com \
--dns-search=weave.local weaveworks/ubuntu
```
## <a name="local-domain"></a>Using a different local domain
By default, weaveDNS uses `weave.local.` as the domain for names on the
Weave network. In general users do not need to change this domain, but
you can force weaveDNS to use a different domain by launching it with
the `--dns-domain` argument. For example,
```
$ weave launch --dns-domain="mycompany.local."
```
The local domain should end with `local.`, since these names are
link-local as per [RFC6762](https://tools.ietf.org/html/rfc6762),
(though this is not strictly necessary).
* [How Weave Finds Containers](/site/how-works-weavedns.md)
* [Load Balancing and Fault Resilience with WeaveDNS](/site/weavedns/load-balance-fault-weavedns.md)
* [Managing Domain Entries](/site/weavedns/managing-entries-weavedns.md)
@@ -0,0 +1,83 @@
---
title: Managing Domain Entries
menu_order: 40
search_type: Documentation
---
The following topics are discussed:
* [Adding and removing extra DNS entries](#add-remove)
* [Resolving WeaveDNS entries from the Host](#resolve-weavedns-entries-from-host)
* [Hot-swapping Service Containers](#hot-swapping)
* [Configuring a Custom TTL](#ttl)
### <a name="add-remove"></a>Adding and Removing Extra DNS Entries
If you want to give the container a name in DNS *other* than its
hostname, you can register it using the `dns-add` command. For example:
```
$ C=$(docker run -ti weaveworks/ubuntu)
$ weave dns-add $C -h pingme2.weave.local
```
You can also use `dns-add` to add the container's configured hostname
and domain simply by omitting `-h <fqdn>`, or specify additional IP
addresses to be registered against the container's hostname e.g.
`weave dns-add 10.2.1.27 $C`.
The inverse operation can be carried out using the `dns-remove`
command:
```
$ weave dns-remove $C
```
By omitting the container name it is possible to add/remove DNS
records that associate names in the weaveDNS domain with IP addresses
that do not belong to containers, e.g. non-weave addresses of external
services:
```
$ weave dns-add 192.128.16.45 -h db.weave.local
```
Note that such records get removed when stopping the weave peer on
which they were added.
### <a name="resolve-weavedns-entries-from-host"></a>Resolving WeaveDNS Entries From the Host
You can resolve entries from any host running weaveDNS with `weave
dns-lookup`:
host1$ weave dns-lookup pingme
10.40.0.1
### <a name="hot-swapping"></a>Hot-swapping service containers
If you would like to deploy a new version of a service, keep the old
one running because it has active connections but make all new
requests go to the new version, then you can simply start the new
server container and then [remove](#add-remove) the entry for the old
server container. Later, when all connections to the old server have
terminated, stop the container as normal.
### <a name="ttl"></a>Configuring a custom TTL
By default, weaveDNS specifies a TTL of 30 seconds in responses to DNS
requests. However, you can force a different TTL value by launching
weave with the `--dns-ttl` argument:
```
$ weave launch --dns-ttl=10
```
This will shorten the lifespan of answers sent to clients, so you will
be effectively reducing the probability of them having stale
information, but you will also be increasing the number of request this
weaveDNS instance will receive.
**See Also**
* [How Weave Finds Containers](/site/weavedns/how-works-weavedns.md)
* [Load Balancing and Fault Resilience with WeaveDNS](/site/weavedns/load-balance-fault-weavedns.md)
* [Managing Domains](/site/weavedns/managing-domains-weavedns.md)
@@ -0,0 +1,54 @@
---
title: Troubleshooting and Present Limitations
menu_order: 50
search_type: Documentation
---
### <a name="troubleshooting"></a>Troubleshooting
The command:
weave status
reports on the current status of various Weave Net components, including
DNS:
```
...
Service: dns
Domain: weave.local.
Upstream: 8.8.8.8, 8.8.4.4
TTL: 1
Entries: 9
...
```
The first section covers the router; see the [troubleshooting
guide](/site/troubleshooting.md#weave-status) for more details.
The 'Service: dns' section is pertinent to weaveDNS, and includes:
* The local domain suffix which is being served
* The list of upstream servers used for resolving names not in the local domain
* The response ttl
* The total number of entries
You may also use `weave status dns` to obtain a [complete
dump](/site/troubleshooting.md#weave-status-dns) of all DNS registrations.
Information on the processing of queries, and the general operation of
weaveDNS, can be obtained from the container logs with
docker logs weave
### <a name="limitations"></a>Present Limitations
* The server will not know about restarted containers, but if you
re-attach a restarted container to the weave network, it will be
re-registered with weaveDNS.
* The server may give unreachable IPs as answers, since it doesn't
try to filter by reachability. If you use subnets, align your
hostnames with the subnets.