Merge pull request #1135 from weaveworks/issues/1028-weave-dns-lookup
Implement `weave dns-lookup` Closes #1028.
This commit is contained in:
commit
3a22d2e6a1
5 files changed
+35
-11
No files matched your search
@@ -9,6 +9,7 @@ RUN apk add --update \
|
||||
iproute2 \
|
||||
util-linux \
|
||||
conntrack-tools \
|
||||
bind-tools \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
||||
WORKDIR /home/weave
|
||||
|
||||
+3
-10
@@ -296,13 +296,9 @@ returned. So now
|
||||
host2$ ping 10.2.1.132
|
||||
|
||||
will work, and, more interestingly, we can ping our `a1` application
|
||||
container, which is residing on `$HOST1`, after finding its IP
|
||||
address:
|
||||
container, which is residing on `$HOST1`:
|
||||
|
||||
host1$ weave ps a1
|
||||
a1 1e:88:d7:5b:77:68 10.2.1.2/24
|
||||
|
||||
host2$ ping 10.2.1.2
|
||||
host2$ ping $(weave dns-lookup a1)
|
||||
|
||||
Multiple subnet addresses can be exposed or hidden with a single
|
||||
invocation:
|
||||
@@ -337,11 +333,8 @@ explained [above](#host-network-integration), i.e.
|
||||
Then we add a NAT rule to route from the outside world to the
|
||||
destination container service.
|
||||
|
||||
host1$ weave ps a1
|
||||
a1 1e:88:d7:5b:77:68 10.2.1.2/24
|
||||
|
||||
host2$ iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 2211 \
|
||||
-j DNAT --to-destination 10.2.1.2:4422
|
||||
-j DNAT --to-destination $(weave dns-lookup a1):4422
|
||||
|
||||
Here we are assuming that the "outside world" is connecting to `$HOST2`
|
||||
via 'eth0'. We want TCP traffic to port 2211 on the external IPs to be
|
||||
|
||||
+9
-1
@@ -16,6 +16,7 @@ hosts.
|
||||
* [Load balancing](#load-balancing)
|
||||
* [Fault resilience](#fault-resilience)
|
||||
* [Adding and removing extra DNS entries](#add-remove)
|
||||
* [Resolve weaveDNS entries from host](#resolve-weavedns-entries-from-host)
|
||||
* [Hot-swapping service containers](#hot-swapping)
|
||||
* [Retaining DNS entries when containers stop](#retain-stopped)
|
||||
* [Configuring a custom TTL](#ttl)
|
||||
@@ -133,7 +134,6 @@ one of the `pingme` containers and re-run the ping tests, eventually
|
||||
[cache expiry time](#ttl)) we will only be hitting the address of the
|
||||
container that is still alive.
|
||||
|
||||
|
||||
## <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
|
||||
@@ -157,6 +157,14 @@ $ weave dns-remove 10.2.1.27 $C
|
||||
When queried about a name with multiple IPs, weaveDNS returns all IPs
|
||||
available in a random order.
|
||||
|
||||
## <a name="resolve-weavedns-entries-from-host"></a>Resolve weaveDNS entries from 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
|
||||
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#! /bin/bash
|
||||
|
||||
. ./config.sh
|
||||
|
||||
C1=10.2.0.78
|
||||
|
||||
start_suite "Cross host dns-lookup"
|
||||
|
||||
weave_on $HOST1 launch
|
||||
weave_on $HOST2 launch $HOST1
|
||||
|
||||
start_container $HOST1 $C1/24 --name c1
|
||||
|
||||
assert "weave_on $HOST2 dns-lookup c1" $C1
|
||||
|
||||
end_suite
|
||||
@@ -47,6 +47,7 @@ weave attach [<addr> ...] <container_id>
|
||||
weave detach [<addr> ...] <container_id>
|
||||
weave dns-add <ip_address> [<ip_address> ...] <container_id> [-h <fqdn>]
|
||||
weave dns-remove <ip_address> [<ip_address> ...] <container_id> [-h <fqdn>]
|
||||
weave dns-lookup <unqualified_name>
|
||||
weave expose [<addr> ...] [-h <fqdn>]
|
||||
weave hide [<addr> ...]
|
||||
weave ps [<container_id> ...]
|
||||
@@ -1334,6 +1335,11 @@ case "$COMMAND" in
|
||||
delete_dns_fqdn $CONTAINER "$3" $IP_ARGS
|
||||
fi
|
||||
;;
|
||||
dns-lookup)
|
||||
[ $# -eq 1 ] || usage
|
||||
docker_bridge_ip
|
||||
dig @$DOCKER_BRIDGE_IP +short $1
|
||||
;;
|
||||
expose)
|
||||
collect_cidr_args "$@"
|
||||
shift $CIDR_ARG_COUNT
|
||||
|
||||
Reference in new issue
Block a user