banish ~~~bash

Just use indenting, which is much easier on the eye.
This commit is contained in:
Matthias Radestock committed 2016-03-29 10:30:51 +01:00
1 parent a1eb940c51
commit 3453972ac4
30 files changed
+61 -307

No files matched your search

-14
View File
@@ -15,12 +15,10 @@ configure Weave Net's IP allocator to manage multiple subnets.
Using [the netcat example](/site/using-weave/deploying-applications.md), configure multiple subsets:
~~~bash
host1$ weave launch --ipalloc-range 10.2.0.0/16 --ipalloc-default-subnet 10.2.1.0/24
host1$ eval $(weave env)
host2$ weave launch --ipalloc-range 10.2.0.0/16 --ipalloc-default-subnet 10.2.1.0/24 $HOST1
host2$ eval $(weave env)
~~~
This delegates the entire 10.2.0.0/16 subnet to Weave Net, and instructs
it to allocate from 10.2.1.0/24 within that, if a specific subnet is not
@@ -28,47 +26,35 @@ specified.
Next, launch the two netcat containers onto the default subnet:
~~~bash
host1$ docker run --name a1 -ti ubuntu
host2$ docker run --name a2 -ti ubuntu
~~~
And then to test the isolation, launch a few more containers onto a different subnet:
~~~bash
host1$ docker run -e WEAVE_CIDR=net:10.2.2.0/24 --name b1 -ti ubuntu
host2$ docker run -e WEAVE_CIDR=net:10.2.2.0.24 --name b2 -ti ubuntu
~~~
Ping each container to confirm that they can talk to each other, but not to the containers of our first subnet:
~~~bash
root@b1:/# ping -c 1 -q b2
PING b2.weave.local (10.2.2.128) 56(84) bytes of data.
--- b2.weave.local ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 1.338/1.338/1.338/0.000 ms
~~~
~~~bash
root@b1:/# ping -c 1 -q a1
PING a1.weave.local (10.2.1.2) 56(84) bytes of data.
--- a1.weave.local ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms
~~~
~~~bash
root@b1:/# ping -c 1 -q a2
PING a2.weave.local (10.2.1.130) 56(84) bytes of data.
--- a2.weave.local ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms
~~~
If required, a container can also be attached to multiple subnets when it is started using:
~~~bash
host1$ docker run -e WEAVE_CIDR="net:default net:10.2.2.0/24" -ti ubuntu
~~~
`net:default` is used to request the allocation of an address from the default subnet in addition to one from an explicitly specified range.
+1 -13
View File
@@ -63,9 +63,7 @@ To specify multiple peers, supply a list of addresses to which you want to conne
For example:
~~~bash
`host2$:weave launch` <ip address> <ip address>
~~~
host2$ weave launch <ip address> <ip address>
Peers can also be dynamically added. See [Adding Hosts Dynamically](/site/using-weave/finding-adding-hosts-dynamically.md) for more information.
@@ -77,44 +75,34 @@ With two containers running on separate hosts, test that both containers are abl
From the container started on `$HOST1`...
~~~bash
root@a1:/# ping -c 1 -q a2
PING a2.weave.local (10.40.0.2) 56(84) bytes of data.
--- a2.weave.local ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.341/0.341/0.341/0.000 ms
~~~
Similarly, in the container started on `$HOST2`...
~~~bash
root@a2:/# ping -c 1 -q a1
PING a1.weave.local (10.32.0.2) 56(84) bytes of data.
--- a1.weave.local ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.366/0.366/0.366/0.000 ms
~~~
###<a name="start-netcat"></a>Starting the Netcat Service
The `netcat` service can be started using the following commands:
~~~bash
root@a1:/# nc -lk -p 4422
~~~
and then connected to from the another container on `$HOST2` using:
~~~bash
root@a2:/# echo 'Hello, world.' | nc a1 4422
~~~
Weave Net supports *any* protocol, and it doesn't have to be over TCP/IP. For example, a netcat UDP service can also be run by using the following:
~~~bash
root@a1:/# nc -lu -p 5533
root@a2:/# echo 'Hello, world.' | nc -u a1 5533
~~~
**See Also**
@@ -8,11 +8,9 @@ When containers may not know the network to which they will be attached, Weave N
To illustrate...
~~~bash
host1$ C=$(docker run -e WEAVE_CIDR=none -dti ubuntu)
host1$ weave attach $C
10.2.1.3
~~~
where,
@@ -26,37 +24,29 @@ where,
A container can be detached from a subnet, by using the `weave detach` command:
~~~bash
host1$ weave detach $C
10.2.1.3
~~~
You can also detach a container from one network and then attach it to a different one:
~~~bash
host1$ weave detach net:default $C
10.2.1.3
host1$ weave attach net:10.2.2.0/24 $C
10.2.2.3
~~~
or, attach a container to multiple application networks, effectively sharing the same container between applications:
~~~bash
host1$ weave attach net:default
10.2.1.3
host1$ weave attach net:10.2.2.0/24
10.2.2.3
~~~
Finally, multiple addresses can be attached or detached using a single command:
~~~bash
host1$ weave attach net:default net:10.2.2.0/24 net:10.2.3.0/24 $C
10.2.1.3 10.2.2.3 10.2.3.1
host1$ weave detach net:default net:10.2.2.0/24 net:10.2.3.0/24 $C
10.2.1.3 10.2.2.3 10.2.3.1
~~~
>**Important!** Any addresses that were dynamically attached will not be re-attached if the container restarts.
@@ -20,9 +20,7 @@ To accomplish this, launch Weave Net onto the new host
without supplying any additional addresses. And then, from one
of the existing hosts run:
~~~bash
host# weave connect $NEW_HOST
~~~
Other hosts on the Weave network will automatically attempt
to establish connections to the new host as well.
@@ -31,9 +29,7 @@ Alternatively, you can also instruct a peer to forget a
particular host specified to it via `weave launch` or
`weave connect` by running:
~~~bash
host# weave forget $DECOMMISSIONED_HOST
~~~
This prevents the peer from trying to reconnect to that host
once connectivity to it is lost, and therefore can be used
@@ -43,9 +39,7 @@ from the network.
Hosts may also be bulk-replaced. All existing hosts
will be forgotten, and the new hosts will be added:
~~~bash
host# weave connect --replace $NEW_HOST1 $NEW_HOST2
~~~
For complete control over the peer topology, automatic
discovery can be disabled using the `--no-discovery`
@@ -58,11 +52,9 @@ A list of all hosts that a peer has been asked to connect
to with `weave launch` and `weave connect`
can be obtained using:
~~~bash
host# weave status targets
~~~
**See Also**
* [Enabling Multi-Cloud, Multi-Hop Networking and Routing](/site/using-weave/multi-cloud-multi-hop.md)
* [Stopping and Removing Peers](/site/ipam/stop-remove-peers-ipam.md)
* [Stopping and Removing Peers](/site/ipam/stop-remove-peers-ipam.md)
@@ -9,44 +9,34 @@ For example, returning to the [netcat example](/site/using-weave/deploying-appli
On `$HOST2` run:
~~~bash
host2$ weave expose
10.2.1.132
~~~
This command grants the host access to all of the application containers in the default subnet. An IP address is allocated by Weave Net especially for that purpose, and is returned after running `weave expose`.
Now you are able to ping the host:
~~~bash
host2$ ping 10.2.1.132
~~~
And you can also ping the `a1` netcat application container residing on `$HOST1`:
~~~bash
host2$ ping $(weave dns-lookup a1)
~~~
###Exposing Multiple Subnets
Multiple subnet addresses can be exposed or hidden using a single command:
~~~bash
host2$ weave expose net:default net:10.2.2.0/24
10.2.1.132 10.2.2.130
host2$ weave hide net:default net:10.2.2.0/24
10.2.1.132 10.2.2.130
~~~
###Adding Exposed Addresses to weavedns
Exposed addresses can also be added to `weavedns` by supplying fully qualified domain names:
~~~bash
host2$ weave expose -h exposed.weave.local
10.2.1.132
~~~
**See Also**
@@ -7,60 +7,46 @@ In some instances, you may need to run applications on the same container networ
To do this, you need to configure Weave's IP allocator to manage multiple subnets:
~~~bash
host1$ weave launch --ipalloc-range 10.2.0.0/16 --ipalloc-default-subnet 10.2.1.0/24
host1$ eval $(weave env)
host2$ weave launch --ipalloc-range 10.2.0.0/16 --ipalloc-default-subnet 10.2.1.0/24 $HOST1
host2$ eval $(weave env)
~~~
This delegates the entire 10.2.0.0/16 subnet to Weave Net, and instructs it to allocate from 10.2.1.0/24 within that if no specific subnet is specified.
Now you can launch two containers onto the default subnet:
~~~bash
host1$ docker run --name a1 -ti ubuntu
host2$ docker run --name a2 -ti ubuntu
~~~
And then launch several more containers onto a different subnet:
~~~bash
host1$ docker run -e WEAVE_CIDR=net:10.2.2.0/24 --name b1 -ti ubuntu
host2$ docker run -e WEAVE_CIDR=net:10.2.2.0.24 --name b2 -ti ubuntu
~~~
Ping the containers from each subnet to confirm that they can communicate with each other, but not to the containers of our first subnet:
~~~bash
root@b1:/# ping -c 1 -q b2
PING b2.weave.local (10.2.2.128) 56(84) bytes of data.
--- b2.weave.local ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 1.338/1.338/1.338/0.000 ms
~~~
~~~bash
root@b1:/# ping -c 1 -q a1
PING a1.weave.local (10.2.1.2) 56(84) bytes of data.
--- a1.weave.local ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms
~~~
~~~bash
root@b1:/# ping -c 1 -q a2
PING a2.weave.local (10.2.1.130) 56(84) bytes of data.
--- a2.weave.local ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms
~~~
###Attaching Containers to Multiple Subnets and Isolating Applications
A container can also be attached to multiple subnets by using the following command line arguments with `docker run`:
~~~bash
host1$ docker run -e WEAVE_CIDR="net:default net:10.2.2.0/24" -ti ubuntu
~~~
Where,
+14 -24
View File
@@ -5,10 +5,8 @@ layout: default
Containers are automatically allocated an IP address that is unique across the Weave network. You can see which address was allocated by running, [`weave ps`](/site/troubleshooting.md#weave-status):
~~~bash
host1$ weave ps a1
a7aee7233393 7a:44:d3:11:10:70 10.32.0.2/12
~~~
Weave Net detects when a container has exited and releases its allocated addresses so they can be re-used by the network.
@@ -23,37 +21,29 @@ For example, we can launch a couple of containers on `$HOST1` and
On `$HOST1`:
~~~bash
host1$ docker run -e WEAVE_CIDR=10.2.1.1/24 -ti ubuntu
root@7ca0f6ecf59f:/#
~~~
host1$ docker run -e WEAVE_CIDR=10.2.1.1/24 -ti ubuntu
root@7ca0f6ecf59f:/#
And `$HOST2`:
~~~bash
host2$ docker run -e WEAVE_CIDR=10.2.1.2/24 -ti ubuntu
root@04c4831fafd3:/#
~~~
host2$ docker run -e WEAVE_CIDR=10.2.1.2/24 -ti ubuntu
root@04c4831fafd3:/#
Then test that the container on `$HOST2` can be reached from the container on `$HOST1`:
~~~bash
root@7ca0f6ecf59f:/# ping -c 1 -q 10.2.1.2
PING 10.2.1.2 (10.2.1.2): 48 data bytes
--- 10.2.1.2 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max/stddev = 1.048/1.048/1.048/0.000 ms
~~~
root@7ca0f6ecf59f:/# ping -c 1 -q 10.2.1.2
PING 10.2.1.2 (10.2.1.2): 48 data bytes
--- 10.2.1.2 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max/stddev = 1.048/1.048/1.048/0.000 ms
And in the other direction...
~~~bash
root@04c4831fafd3:/# ping -c 1 -q 10.2.1.1
PING 10.2.1.1 (10.2.1.1): 48 data bytes
--- 10.2.1.1 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max/stddev = 1.034/1.034/1.034/0.000 ms
~~~
root@04c4831fafd3:/# ping -c 1 -q 10.2.1.1
PING 10.2.1.1 (10.2.1.1): 48 data bytes
--- 10.2.1.1 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max/stddev = 1.034/1.034/1.034/0.000 ms
The IP addresses and netmasks can be set to anything, but ensure they don’t conflict with any of the IP ranges in use on the hosts or with IP addresses used by any external services to which the hosts or containers may need to connect.
@@ -8,16 +8,12 @@ To connect containers across untrusted networks, Weave Net peers can be instruct
For example:
~~~bash
host1$ weave launch --password wfvAwt7sj
~~~
or
~~~bash
host1$ export WEAVE_PASSWORD=wfvAwt7sj
host1$ weave launch
~~~
>NOTE: The command line option takes precedence over the environment variable._
@@ -28,9 +24,7 @@ or
To guard against dictionary attacks, the password needs to be reasonably strong with at least 50 bits of entropy is recommended. An easy way to generate a random password that satisfies this requirement is:
~~~bash
< /dev/urandom tr -dc A-Za-z0-9 | head -c9 ; echo
~~~
The same password must be specified for all Weave Net peers, by default both control and data plane traffic will then use authenticated encryption.
-6
View File
@@ -13,25 +13,19 @@ you can expose the netcat service running on `HOST1` and make it accessible to t
First, expose the application network to `$HOST2`, as explained in [Integrating a Host Network with a Weave Net](/site/using-weave/host-network-integration.md):
~~~bash
host2$ weave expose
10.2.1.132
~~~
Then add a NAT rule that routes the traffic from the outside world to the destination container service.
~~~bash
host2$ iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 2211 \
-j DNAT --to-destination $(weave dns-lookup a1):4422
~~~
In this example, it is assumed that the "outside world" is connecting to `$HOST2` via 'eth0'. The TCP traffic to port 2211 on the external IPs will be routed to the 'nc' service running on port 4422 in the container a1.
With the above in place, you can connect to the 'nc' service from anywhere using:
~~~bash
echo 'Hello, world.' | nc $HOST2 2211
~~~
>**Note:** Due to the way routing is handled in the Linux kernel, this won't work when run *on* `$HOST2`.
+1 -21
View File
@@ -21,24 +21,18 @@ Turning back to the [netcat example](/site/using-weave/deploying-applications.md
To do this, expose the application network to `$HOST2`, as explained in [Host Network Integration](/site/using-weave/host-network-integration.md) by running:
~~~bash
host2$ weave expose
10.2.1.132
~~~
Then add a NAT rule to route from the outside world to the destination container service.
~~~bash
host2$ iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 2211 \
-j DNAT --to-destination $(weave dns-lookup a1):4422
~~~
Here it is assumed that the "outside world" is connecting to `$HOST2` via 'eth0'. The TCP traffic to port 2211 on the external IPs will be routed to the 'nc' service, running in the a1 container and listening on port 4422.
With the above in place, you are ready to connect to the 'nc' service from anywhere using:
~~~bash
echo 'Hello, world.' | nc $HOST2 2211
~~~
$ echo 'Hello, world.' | nc $HOST2 2211
>**Note:** Due to the way routing is handled in the Linux kernel, this won't work when run *on* `$HOST2`.
@@ -56,30 +50,22 @@ An additional caveat is that `$HOST3` can only be reached from `$HOST1`, which i
To satisfy this scenario, first [expose the application network to the host](/site/using-weave/host-network-integration.md) by running the following on `$HOST1`:
~~~bash
host1$ weave expose -h host1.weave.local
10.2.1.3
~~~
Then add a NAT rule, which routes from the above IP to the destination service.
~~~bash
host1$ iptables -t nat -A PREROUTING -p tcp -d 10.2.1.3 --dport 3322 \
-j DNAT --to-destination $HOST3:2211
~~~
This allows any application container to reach the service by connecting to 10.2.1.3:3322. So if `$HOST3` is running a
netcat service on port 2211:
~~~bash
host3$ nc -lk -p 2211
~~~
You can now connect to it from the application container running on `$HOST2` using:
~~~bash
root@a2:/# echo 'Hello, world.' | nc host1 3322
~~~
Note that you should be able to run this command from any application container.
@@ -101,23 +87,17 @@ Expanding on the [netcat example](/site/using-weave/deploying-applications.md),
Begin importing the service onto `$HOST2` by first exposing the application network:
~~~bash
host2$ weave expose
10.2.1.3
~~~
Then add a NAT rule which routes traffic from the `$HOST2` network (for example, anything that can connect to `$HOST2`) to the service endpoint on the Weave network:
~~~bash
host2$ iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 4433 \
-j DNAT --to-destination 10.2.1.3:3322
~~~
Now any host on the same network as `$HOST2` is able to access the service:
~~~bash
echo 'Hello, world.' | nc $HOST2 4433
~~~
###<a name="change-location"></a>Dynamically Changing Service Locations