From 6832ae20b017b183e8547406a40767b65850a2b3 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Tue, 14 Jul 2015 15:31:14 +0100 Subject: [PATCH 1/3] Implement `weave dns-lookup` --- prog/weaveexec/Dockerfile | 1 + weave | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/prog/weaveexec/Dockerfile b/prog/weaveexec/Dockerfile index c4cdb7a3..d704e75a 100644 --- a/prog/weaveexec/Dockerfile +++ b/prog/weaveexec/Dockerfile @@ -9,6 +9,7 @@ RUN apk add --update \ iproute2 \ util-linux \ conntrack-tools \ + bind-tools \ && rm -rf /var/cache/apk/* WORKDIR /home/weave diff --git a/weave b/weave index ad979a1d..0a4e3e70 100755 --- a/weave +++ b/weave @@ -47,6 +47,7 @@ weave attach [ ...] weave detach [ ...] weave dns-add [ ...] [-h ] weave dns-remove [ ...] [-h ] +weave dns-lookup weave expose [ ...] [-h ] weave hide [ ...] weave ps [ ...] @@ -1333,6 +1334,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 From 41834478d70d16082de439dd49b17118ad1d78d8 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Tue, 14 Jul 2015 15:32:24 +0100 Subject: [PATCH 2/3] Rework documentation to use `weave dns-lookup` --- site/features.md | 13 +++---------- site/weavedns.md | 10 +++++++++- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/site/features.md b/site/features.md index 0a5d297d..cc9d6126 100644 --- a/site/features.md +++ b/site/features.md @@ -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 diff --git a/site/weavedns.md b/site/weavedns.md index 1166b00e..5e9d261e 100644 --- a/site/weavedns.md +++ b/site/weavedns.md @@ -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. - ## 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. +## 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 + ## Hot-swapping service containers If you would like to deploy a new version of a service, keep the old From a3dc2d0482a774d672ea757cf34215875e76dbb1 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Tue, 14 Jul 2015 16:27:20 +0100 Subject: [PATCH 3/3] Smoketest dns-lookup --- test/250_dns_lookup_test.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 test/250_dns_lookup_test.sh diff --git a/test/250_dns_lookup_test.sh b/test/250_dns_lookup_test.sh new file mode 100755 index 00000000..aa7c283b --- /dev/null +++ b/test/250_dns_lookup_test.sh @@ -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