Merge pull request #1126 from weaveworks/issues/1018-more-flexible-hostname-derivation

[proxy] More flexible container name -> hostname derivation

Closes #1018.
This commit is contained in:
Matthias Radestock committed 2015-07-14 17:31:53 +01:00
commit 7ae06ef00d
6 files changed
+86 -10

No files matched your search

+29
View File
@@ -130,6 +130,35 @@ automatically if it is running at the point when they are started -
see the [weaveDNS usage](weavedns.html#usage) section for an in-depth
explanation of the behaviour and how to control it.
Typically, the proxy will pass on container names as-is to [weaveDNS](weavedns.html)
for registration. However, there are situations in which the final container
name is out of the user's control (e.g. when using Docker orchestrators which
append control/namespacing identifiers to the original container names).
For those situations, the proxy provides two flags: `--hostname-match <regexp>`
and `--hostname-replacement <replacement>`. When launching a container, its name
is matched against regular expression `<regexp>`. Then, based on that match,
`<replacement>` will be used to generate a hostname, which will ultimately be
handed over to weaveDNS for registration.
For instance, if we launch the proxy using
`--hostname-match '^aws-[0-9]+-(.*)$'` and `--hostname-replacement 'my-app-$1'`
host1$ weave launch-router && weave launch-dns && weave launch-proxy --hostname-match '^aws-[0-9]+-(.*)$' --hostname-replacement 'my-app-$1'
host1$ eval "$(weave env)"
then, running a container named `aws-12798186823-foo` will lead to weaveDNS registering
hostname `my-app-foo` and not `aws-12798186823-foo`.
host1$ docker run -ti --name=aws-12798186823-foo ubuntu ping my-app-foo
PING my-app-foo.weave.local (10.32.0.2) 56(84) bytes of data.
64 bytes from my-app-foo.weave.local (10.32.0.2): icmp_seq=1 ttl=64 time=0.027 ms
64 bytes from my-app-foo.weave.local (10.32.0.2): icmp_seq=2 ttl=64 time=0.067 ms
Note how regexp substitution groups should be prepended with a dollar sign
(e.g. `$1`). For further details on the regular expression syntax please see
[Google's re2 documentation](https://github.com/google/re2/wiki/Syntax).
## <a name="tls"></a>Securing the docker communication with TLS
If you are